[CMake] how to debug CPack creation

Eric Noulard eric.noulard at gmail.com
Sat Oct 20 08:59:27 EDT 2018


Le sam. 20 oct. 2018 à 10:54, Илья Шипицин <chipitsine at gmail.com> a écrit :

>
>
> сб, 20 окт. 2018 г. в 13:30, Eric Noulard <eric.noulard at gmail.com>:
>
>>
>>
>> Le sam. 20 oct. 2018 à 10:15, Илья Шипицин <chipitsine at gmail.com> a
>> écrit :
>>
>>> hi,
>>>
>>> we use cmake/cpack for mangling systemd scripts
>>>
>>>
>>> https://github.com/SoftEtherVPN/SoftEtherVPN/blob/master/src/vpnserver/CMakeLists.txt#L26
>>>
>>> what happens:
>>>
>>> (*) deb installs files to /usr/libexec
>>> (*) cmake sets location as /usr/local/libexec
>>>
>>
>> It looks like your get default "/usr/local" prefix from somewhere.
>>
>
> exactly.
>

So I I understand it well (correct me if I'm wrong) when you do:

1) make install
    You get all installed files prefixed by /usr/local
    which is the expected behaviour unless you configure
CMAKE_INSTALL_PREFIX
    or you use
    DESTDIR=/your/prefix make install

2) deb created by CPack get "/usr" prefix instead
   which is the expected behaviour unless you specify an alternate value
using
   CPACK_PACKAGING_INSTALL_PREFIX

    go to your build tree and try:
    cpack -G DEB -D  CPACK_PACKAGING_INSTALL_PREFIX=/opt

    and you'll see that the .deb will have /opt prefix.

The question is what do expect as a prefix?
/usr/local
/usr
something else ??

The rules are the following when using install rule.
1) if your DESTINATION is a relative path then it will be prefix with
   CMAKE_INSTALL_PREFIX when doing make install
   CPACK_PACKAGING_INSTALL_PREFIX when building package with CPack

2) if your DESTINATION is "absolute" like /etc/whatever/confdir
    It'll get install there when doing make install (whatever the value of
CMAKE_INSTALL_PREFIX)

    With CPack, it depends on the generator.
   Some generators (like DEB a,nd RPM) try to catch "absolute" install file
and handle them
   as config file. RPM generator is more verbose about it see below.

Is the RPM containing what you expect?
>>
>
> I did not check it yet.
>

I tried using:
$  cpack -G RPM

and you get expected warning about the mix of absolute and relative install
path:
CPack: Create package using RPM
CPack: Install projects
CPack: - Install project: SoftEtherVPN
CPack: -   Install component: vpnserver
CPack: -   Install component: vpnclient
CPack: -   Install component: vpnbridge
CPack: -   Install component: vpncmd
CPack: Create package
CMake Warning (dev) at
/home/enoulard/local/share/cmake-3.12/Modules/Internal/CPack/CPackRPM.cmake:135
(message):
  CPackRPM:Warning: Path /lib/systemd/system/softether-vpnbridge.service is
  not on one of the relocatable paths! Package will be partially
relocatable.
Call Stack (most recent call first):

/home/enoulard/local/share/cmake-3.12/Modules/Internal/CPack/CPackRPM.cmake:1001
(cpack_rpm_prepare_relocation_paths)

/home/enoulard/local/share/cmake-3.12/Modules/Internal/CPack/CPackRPM.cmake:1870
(cpack_rpm_generate_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

[...]

CPack: - package: []/build/softether-vpnbridge-5.1.9660-1.x86_64.rpm
generated.
CPack: - package: []/build/softether-vpnclient-5.1.9660-1.x86_64.rpm
generated.
CPack: - package: []/build/softether-vpncmd-5.1.9660-1.x86_64.rpm generated.
CPack: - package: []/build/softether-vpnserver-5.1.9660-1.x86_64.rpm
generated.

And the content is:
$ rpm -qpl softether-vpnserver-5.1.9660-1.x86_64.rpm
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/softether-vpnserver.service
/usr/libexec
/usr/libexec/softether
/usr/libexec/softether/vpnserver
/usr/libexec/softether/vpnserver/hamcore.se2
/usr/libexec/softether/vpnserver/vpnserver
/usr/local
/usr/local/bin
/usr/local/bin/vpnserver

the content of the .deb is similar:
$ dpkg-deb -c softether-vpnserver_5.1.9660_amd64.deb
drwxr-xr-x root/root         0 2018-10-20 14:45 ./lib/
drwxr-xr-x root/root         0 2018-10-20 14:45 ./lib/systemd/
drwxr-xr-x root/root         0 2018-10-20 14:45 ./lib/systemd/system/
-rw-r--r-- root/root       700 2018-10-20 14:45
./lib/systemd/system/softether-vpnserver.service
drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/
drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/libexec/
drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/libexec/softether/
drwxr-xr-x root/root         0 2018-10-20 14:45
./usr/libexec/softether/vpnserver/
-rw-r--r-- root/root   1770716 2018-10-20 14:45
./usr/libexec/softether/vpnserver/hamcore.se2
-rwxr-xr-x root/root   2088960 2018-10-20 14:45
./usr/libexec/softether/vpnserver/vpnserver
drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/local/
drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/local/bin/
-rwxr-xr-x root/root        72 2018-10-20 14:45 ./usr/local/bin/vpnserver

The main question is, what filesystem layout do you expect for those files?

-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181020/11254fea/attachment.html>


More information about the CMake mailing list