最近,我需要确保我们的软件可以打包使用cpack
RHEL 7 及其免费重建(例如 CentOS 7)。尽管如此,我一直遇到 RHEL 6.x 及其免费重建不存在的问题:cpack
生成所有的 RPM 在其%files
部分系统目录条目中具有如下所示:
%dir %attr(0755, root, root) "/"
%dir %attr(0755, root, root) "/usr"
%dir %attr(0755, root, root) "/usr/bin"
%dir %attr(0755, root, root) "/usr/share"
%dir %attr(0755, root, root) "/usr/share/applications"
%dir %attr(0755, root, root) "/usr/share/doc"
%dir %attr(0755, root, root) "/usr/share/icons"
%dir %attr(0755, root, root) "/usr/share/icons/hicolor"
%dir %attr(0755, root, root) "/usr/share/icons/hicolor/scalable"
%dir %attr(0755, root, root) "/usr/share/icons/hicolor/scalable/apps"enter code here
不应由包声明。
AFAIK,这个要求多年来一直在 RPM 规范中,但只有在最新版本的 RPM(即比 4.8.0 更新)中才被强制执行。由于 RHEL 7 与 RPM 4.11.1 捆绑在一起,因此现在生成的内容与以下错误cpack
发生冲突:filesystem-3.2-18.el7.x86_64
yum install ...
file / from install of tunesviwer-1.4-2.noarch conflicts with file from package filesystem-3.2-18.el7.x86_64
file /usr/bin from install of tunesviewer-1.4-2.noarch conflicts with file from package filesystem-3.2-18.el7.x86_64
[...]
我尝试使用一个cmake
包含以下内容的小模块:
set(CPACK_RPM_SPEC_MORE_DEFINE "%define ignore \#")
set(CPACK_RPM_USER_FILELIST "%ignore /" "%ignore /usr" "%ignore /usr/bin" "%ignore /usr/share" "%ignore /usr/share/applications" "%ignore /usr/share/doc" "%ignore/usr/share/icons" "%ignore /usr/share/icons/hicolor" "%ignore /usr/share/icons/hicolor/scalable" "%ignore /usr/share/icons/hicolor/scalable/apps")
并将其包含在CMakeLists.txt
's之前include(CPack)
。但是生成的 RPM 仍然包含这些系统目录 :(
作为一种临时解决方法,我一直在使用文件冲突中给出的提示来安装带有 "Filesystem" 的包,即使用该rpmrebuild
实用程序删除该部分中的这些系统目录条目%files
。显然,这根本不是解决办法。
有人找到更好的方法吗?