cpack generates RPMs with %files entries that conf

2019-02-16 22:07发布

Recently, I need to ensure that our software can be packaged using cpack for RHEL 7 and its free rebuilds (e.g. CentOS 7). Nevertheless, I have been having an issue that didn't exist for RHEL 6.x and its free rebuilds: the RPMs that cpack generates all have in its %files section system directory entries like the following:

%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

which shouldn't be declared by the package.

AFAIK, this requirement has been in the RPM spec for years but only in the recent versions of RPM (i.e. newer than 4.8.0) it is enforced. Since RHEL 7 bundles with RPM 4.11.1, so what cpack generates now conflict with filesystem-3.2-18.el7.x86_64 with errors like below during a 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
[...]

I have tried to use a small cmake module consisting of the following:

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")

and include it right before the CMakeLists.txt's include(CPack). But the generated RPM still contains these system directories :(

As a temporary get-around, I have been using a hint given in File conflict for installing a package with "Filesystem", i.e. using the rpmrebuild utility to remove these system directory entries in the %files section. Obviously, this is not a fix at all.

Anyone has found a better way?

标签: cmake rpm cpack
1条回答
倾城 Initia
2楼-- · 2019-02-16 23:02

I couldn't afford to wait. So, looking at the latest cmake 3.0.0 release, there is a variable CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST that the new release supports with sensible defaults

[Edit] Upon reviewing the doc of 2.8.12, the pair is supported by that older version too.

Since cmake source comes with CMakeLists.txt files and can generate packages OOTB, including RPM (although I need to tune the settings to fit RHEL's package naming convention, but that's not hard to do), so I simply went ahead first bootstrapped cmake-3.0.0 with cmake 2.8.11, rpmrebuild -pe to fix the resulting cmake 3.0.0 RPM, yum install it, and then use it to do a 2nd bootstrap. Now everything is fine. Problem solved.

My parting thought is that kitware should make its documentation better written. The way a lot of variables is described is dense and even confusing - lacking example is a glaring deficiency.

Furthermore, kitware should eat its own dogfood: provide instructions to build cmake with cmake, not with autotools x-(

查看更多
登录 后发表回答