CPack/RPM: Issue with CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX variable
There seems to be an issue with the CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
variable not working as intended.
With the following code:
cmake_minimum_required(VERSION 3.21)
project(cpack_example)
install(FILES foo.h
DESTINATION lib
COMPONENT FOO
)
install(FILES bar.h
DESTINATION bin
COMPONENT BAR
)
set(CPACK_RPM_PACKAGE_RELOCATABLE ON)
set(CPACK_PACKAGE_NAME Example)
set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/package)
set(CPACK_GENERATOR RPM)
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_FOO_PACKAGE_PREFIX "/usr")
set(CPACK_RPM_BAR_PACKAGE_PREFIX "/etc")
include(CPack)
cpack_add_component(FOO
DISPLAY_NAME FOO
REQUIRED
)
cpack_add_component(BAR
DISPLAY_NAME BAR
REQUIRED
)
The packaging gives the following output:
❯ cmake --build . --target package
[0/1] Run CPack packaging tool...
CPack: Create package using RPM
CPack: Install projects
CPack: - Install project: cpack_example []
CPack: - Install component: BAR
CPack: - Install component: FOO
CPack: Create package
-- alien found, we may be on a Debian based distro.
CMake Warning (dev) at /home/lmalka/bin/cmake-3.21.1-linux-x86_64/share/cmake-3.21/Modules/Internal/CPack/CPackRPM.cmake:190 (message):
CPackRPM:Warning: Path /usr/bin/bar.h is not on one of the relocatable
paths! Package will be partially relocatable.
Call Stack (most recent call first):
/home/lmalka/bin/cmake-3.21.1-linux-x86_64/share/cmake-3.21/Modules/Internal/CPack/CPackRPM.cmake:1058 (cpack_rpm_prepare_relocation_paths)
/home/lmalka/bin/cmake-3.21.1-linux-x86_64/share/cmake-3.21/Modules/Internal/CPack/CPackRPM.cmake:1958 (cpack_rpm_generate_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CPackRPM: Will use GENERATED spec file: /home/lmalka/dev/tests/cpack_example/build/package/_CPack_Packages/Linux/RPM/SPECS/example-BAR.spec
-- alien found, we may be on a Debian based distro.
CPackRPM: Will use GENERATED spec file: /home/lmalka/dev/tests/cpack_example/build/package/_CPack_Packages/Linux/RPM/SPECS/example-FOO.spec
CPack: - package: /home/lmalka/dev/tests/cpack_example/build/package/Example-0.1.1-Linux-BAR.rpm generated.
CPack: - package: /home/lmalka/dev/tests/cpack_example/build/package/Example-0.1.1-Linux-FOO.rpm generated.
Installing the FOO
package works as intended and copies the foo.h file to /usr/lib
, but installing the BAR
package does nothing.
Here are some information about the generated .rpm
files:
❯ rpm -qi package/Example-0.1.1-Linux-FOO.rpm
Name : example-FOO
Version : 0.1.1
Release : 1
Architecture: x86_64
Install Date: (not installed)
Group : unknown
Size : 0
License : unknown
Signature : (none)
Source RPM : example-FOO-0.1.1-1.src.rpm
Build Date : Tue 14 Sep 2021 10:42:23 AM CEST
Build Host : lmalka-mint
Relocations : /usr
Vendor : Humanity
Summary : cpack_example built using CMake
Description :
DESCRIPTION
===========
This is an installer created using CPack (https://cmake.org). No additional installation instructions provided.
❯ rpm -qi package/Example-0.1.1-Linux-BAR.rpm
Name : example-BAR
Version : 0.1.1
Release : 1
Architecture: x86_64
Install Date: (not installed)
Group : unknown
Size : 0
License : unknown
Signature : (none)
Source RPM : example-BAR-0.1.1-1.src.rpm
Build Date : Tue 14 Sep 2021 10:42:23 AM CEST
Build Host : lmalka-mint
Relocations : (not relocatable)
Vendor : Humanity
Summary : cpack_example built using CMake
Description :
DESCRIPTION
===========
This is an installer created using CPack (https://cmake.org). No additional installation instructions provided.
If I understand the documentation correctly, the BAR
package should have /opt
in its relocations paths, which is not the case.
Edited by Brad King