Cpack generates RPMs with% file files that contradict the RPM specification. How to fix?

Recently, I need to ensure that our software can be packaged with cpack for RHEL 7 and its free rebuilds (like CentOS 7). However, I had a problem that did not exist for RHEL 6.x and its free changes: the RPMs that cpack generate all have the following elements in their %files system directories:

 %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 should not be declared as a package.

AFAIK, this requirement has been used in the RPM specification for many years, but only in the latest RPM versions (i.e. newer than 4.8.0) does it apply. Since RHEL 7 communicates with RPM 4.11.1, now that cpack creates a conflict with filesystem-3.2-18.el7.x86_64 with errors, as shown below during 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 tried using 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 enable it immediately before CMakeLists.txt include(CPack) . But the generated RPM still contains these system directories :(

As a temporary transition, I used the file conflict hint to install the package with the file system , that is, using the rpmrebuild utility to delete these system directory entries in the %files section. Obviously, this is not a problem at all.

Has anyone found a better way?

+6
source share
1 answer

I could not wait. So, looking at the latest version of cmake 3.0.0, there is a variable CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST , which the new version supports with reasonable default values

[Edit] When viewing document 2.8.12, the pair is supported by this older version.

Since the cmake source comes with CMakeLists.txt files and can generate OOTB packages, including RPMs (although I need to configure the settings to match the RHEL package naming convention, it’s not difficult to do this), so I just went ahead, download cmake-3.0.0 using cmake 2.8.11 , rpmrebuild -pe , to fix the resulting cmake 3.0.0 RPM, install yum and then use it to execute the second bootstrap. Now everything is all right. The problem is resolved.

My parting thought is that kitware should make its documentation better written. The way many variables are described is dense and even confusing β€” a missing example β€” a blatant flaw.

In addition, kitware should eat its own dogfood: provide instructions for creating cmake with cmake, not using autotools x - (

+7
source

Source: https://habr.com/ru/post/972923/


All Articles