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?