【发布时间】:2014-07-27 16:49:01
【问题描述】:
最近,我需要确保我们的软件可以使用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 的 include(CPack) 之前。但是生成的 RPM 仍然包含这些系统目录 :(
作为临时解决办法,我一直在使用File conflict for installing a package with "Filesystem" 中给出的提示,即使用rpmrebuild 实用程序删除%files 部分中的这些系统目录条目。显然,这根本不是解决办法。
有人找到更好的方法了吗?
【问题讨论】:
-
对于它的价值,如果你想支持早于 2.8.12 的 cmake,最后一个解决方法(使用 %ignore)有效,你只需要在每个 %ignore 之后放置一个换行符字符串。