/usr/lib/.build-id & RPM relocation
Moving from RHEL7 to RHEL8 I note that RPM now include entries in /usr/lib/.build-id (see https://unix.stackexchange.com/questions/411727/what-is-the-purpose-of-usr-lib-build-id-dir and https://fedoraproject.org/wiki/Releases/FeatureBuildId for reference).
In integration tests I install RPMs using a fake DB and relocating them as in:
rpmdb --initdb --dbpath "$WSDIR"/rpmdb
rpm --relocate /opt/foo="$WSDIR"/opt/foo --dbpath "$WSDIR"/rpmdb -i foobar.rpm --nodeps
The new path mean I must instead use:
rpm --relocate /opt/foo="$WSDIR"/opt/foo --relocate /usr/lib="$WSDIR"/usr/lib --dbpath "$WSDIR"/rpmdb -i foobar.rpm --nodeps
With cmake, it is not possible to make /usr/lib relocatable unless I explicitly install a dummy file myself. For example:
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/VERSION DESTINATION "/usr/lib" COMPONENT core RENAME "/usr/lib/.dummy/.foobar.core.dummy")
set(CPACK_RPM_CORE_RELOCATION_PATHS "/usr/lib")
Otherwise adding the relocation path is silently ignored.
I suggest the following:
-
On platforms using /usr/lib/.build-id it should be possible to add a relocation for /usr/lib or at least /usr/lib/.build-id without installing an additional file.
-
For variables that are used by cmake an error or warning should be issued if the requested operation cannot be performed. If I add:
set(CPACK_RPM_CORE_RELOCATION_PATHS "/IDONOTEXIST")
There should be some message like "relocation ignored: no files installed to /IDONOTEXIST"
Also consider:
- Find a way to disable inclusion of /usr/lib/.build-id in RPMBuild There isn't one by design - see https://bugzilla.redhat.com/show_bug.cgi?id=1724153 but perhaps it could/should be made optional upstream. While this is outside the scope of cmake itself, the cmake maintainers may have useful opinions and a louder voice.