CPack将系统目录添加到生成的RPM

时间:2016-10-17 22:37:47

标签: cmake rpm yum cpack

我有一个CMake项目,我使用CPack为我的CentOS YUM存储库生成RPM。但是,当我尝试安装生成的RPM时,出现此错误:

file /usr from install of clstrd-0.1.0-1.x86_64 conflicts with file from package filesystem-3.2-20.el7.x86_64
file /usr/bin from install of clstrd-0.1.0-1.x86_64 conflicts with file from package filesystem-3.2-20.el7.x86_64
file /usr/lib from install of clstrd-0.1.0-1.x86_64 conflicts with file from package filesystem-3.2-20.el7.x86_64

进一步检查RPM的内容,我发现它包含这些文件和目录:

$ rpm -qlp clstrd-0.1.0-Linux.rpm
/usr
/usr/bin
/usr/bin/clstrd
/usr/lib
/usr/lib/libclstrd.a

我的问题是:如何强制CMake从RPM中排除/usr/usr/bin等常见目录?不应该自动完成吗?

我试过CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION没有运气。

修改:以下是我CMakeLists.txt

的相关部分
# Targets
add_library(clstrd_lib ${SOURCE_FILES})
...
add_executable(clstrd main.cpp)
target_link_libraries(clstrd clstrd_lib)
...
# Installation configuration.
install(TARGETS clstrd_lib clstrd
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin)

# CPack configuration.
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyAwesomePackage")
set(CPACK_PACKAGE_VENDOR "MyAwesomeVendor")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
set(CPACK_PACKAGE_EXECUTABLES "clstrd", "MyAwesomeExecutable")
set(CPACK_RPM_PACKAGE_AUTOREQPROV " no")
set(CPACK_RPM_PACKAGE_REQUIRES, "libpqxx, gtest, gflags, root,     root-netx, xrootd-client-libs")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION, "/usr /usr/bin /usr/lib")
set(CPACK_SOURCE_GENERATOR "RPM")
include(CPack)

2 个答案:

答案 0 :(得分:2)

这似乎是cmake 2.8.9中的一个错误,已在cmake 2.8.12中修复:

https://public.kitware.com/Bug/view.php?id=13609

答案 1 :(得分:0)

您可以尝试一下,

list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/lib")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/lib/systemd")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/lib/systemd/system")

在带有cmake 2.8.12.2的CentOS7上测试确定。