how to debug CPack creation

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

how to debug CPack creation

Илья Шипицин
hi,

we use cmake/cpack for mangling systemd scripts


what happens:

(*) deb installs files to /usr/libexec
(*) cmake sets location as /usr/local/libexec

as a result: it does not work (systemd cannot find executable)


I enabled "set(CPACK_DEBIAN_PACKAGE_DEBUG ON)", but it did not provide me a clue.


any idea how to debug that?

CPackDeb Debug: Found dependency: libc6 (>= 2.15), libreadline7 (>= 6.0), libssl1.1 (>= 1.1.0), zlib1g (>= 1:1.1.4) from output shlibs:Depends=libc6 (>= 2.15), libreadline7 (>= 6.0), libssl1.1 (>= 1.1.0), zlib1g (>= 1:1.1.4)
CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY          = '/home/ilia/softethervpn/build/_CPack_Packages/Linux/DEB'
CPackDeb:Debug: CPACK_TOPLEVEL_TAG                = 'Linux'
CPackDeb:Debug: CPACK_TEMPORARY_DIRECTORY         = '/home/ilia/softethervpn/build/_CPack_Packages/Linux/DEB/softether-5.1.9660-Linux/vpnserver'
CPackDeb:Debug: CPACK_OUTPUT_FILE_NAME            = 'softether-vpnserver_5.1.9660-1_amd64.deb'
CPackDeb:Debug: CPACK_OUTPUT_FILE_PATH            = '/home/ilia/softethervpn/build/softether-vpnserver_5.1.9660-1_amd64.deb'
CPackDeb:Debug: CPACK_PACKAGE_FILE_NAME           = 'softether-5.1.9660-Linux'
CPackDeb:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY   = 'softether 5.1.9660'
CPackDeb:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = '/home/ilia/softethervpn/build/_CPack_Packages/Linux/DEB/softether-vpnserver_5.1.9660-1_amd64.deb'
CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION = ''
CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_SOURCE       = ''
CPack: - package: /home/ilia/softethervpn/build/softether-vpnbridge_5.1.9660-1_amd64.deb generated.
CPack: - package: /home/ilia/softethervpn/build/softether-vpnclient_5.1.9660-1_amd64.deb generated.
CPack: - package: /home/ilia/softethervpn/build/softether-vpncmd_5.1.9660-1_amd64.deb generated.
CPack: - package: /home/ilia/softethervpn/build/softether-vpnserver_5.1.9660-1_amd64.deb generated.
make: Leaving directory '/home/ilia/softethervpn/tmp'


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how to debug CPack creation

Eric Noulard


Le sam. 20 oct. 2018 à 10:15, Илья Шипицин <[hidden email]> a écrit :
hi,

we use cmake/cpack for mangling systemd scripts


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.
The installation prefix of CPack is controlled by the  https://cmake.org/cmake/help/latest/variable/CPACK_PACKAGING_INSTALL_PREFIX.html variable.
Each CPack generator has a default value for that (if you don't specify it).

How do run cpack?
Do you do "make package" or do you run 
cpack -G DEB

Which version of cmake/cpack are you using?


as a result: it does not work (systemd cannot find executable)


I enabled "set(CPACK_DEBIAN_PACKAGE_DEBUG ON)", but it did not provide me a clue.

DEB generator is not as verbose as I thought.

Do you generate RPM as well? RPM is more verbose and leaves you log file in 
_CPack_Packages/<yoursystem>/RPM/

Is the RPM containing what you expect?
 
--
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how to debug CPack creation

Илья Шипицин


сб, 20 окт. 2018 г. в 13:30, Eric Noulard <[hidden email]>:


Le sam. 20 oct. 2018 à 10:15, Илья Шипицин <[hidden email]> a écrit :
hi,

we use cmake/cpack for mangling systemd scripts


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.
 
The installation prefix of CPack is controlled by the  https://cmake.org/cmake/help/latest/variable/CPACK_PACKAGING_INSTALL_PREFIX.html variable.
Each CPack generator has a default value for that (if you don't specify it).

How do run cpack?
Do you do "make package" or do you run 

I run:

./configure
make -C tmp package
 
cpack -G DEB

Which version of cmake/cpack are you using?

3.9.6
 


as a result: it does not work (systemd cannot find executable)


I enabled "set(CPACK_DEBIAN_PACKAGE_DEBUG ON)", but it did not provide me a clue.

DEB generator is not as verbose as I thought.

Do you generate RPM as well? RPM is more verbose and leaves you log file in 
_CPack_Packages/<yoursystem>/RPM/

Is the RPM containing what you expect?


I did not check it yet.
 
 
--
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how to debug CPack creation

Илья Шипицин
just in case, I tried 3.12.3
the same issue

сб, 20 окт. 2018 г. в 13:53, Илья Шипицин <[hidden email]>:


сб, 20 окт. 2018 г. в 13:30, Eric Noulard <[hidden email]>:


Le sam. 20 oct. 2018 à 10:15, Илья Шипицин <[hidden email]> a écrit :
hi,

we use cmake/cpack for mangling systemd scripts


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.
 
The installation prefix of CPack is controlled by the  https://cmake.org/cmake/help/latest/variable/CPACK_PACKAGING_INSTALL_PREFIX.html variable.
Each CPack generator has a default value for that (if you don't specify it).

How do run cpack?
Do you do "make package" or do you run 

I run:

./configure
make -C tmp package
 
cpack -G DEB

Which version of cmake/cpack are you using?

3.9.6
 


as a result: it does not work (systemd cannot find executable)


I enabled "set(CPACK_DEBIAN_PACKAGE_DEBUG ON)", but it did not provide me a clue.

DEB generator is not as verbose as I thought.

Do you generate RPM as well? RPM is more verbose and leaves you log file in 
_CPack_Packages/<yoursystem>/RPM/

Is the RPM containing what you expect?


I did not check it yet.
 
 
--
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how to debug CPack creation

Eric Noulard
In reply to this post by Илья Шипицин


Le sam. 20 oct. 2018 à 10:54, Илья Шипицин <[hidden email]> a écrit :


сб, 20 окт. 2018 г. в 13:30, Eric Noulard <[hidden email]>:


Le sam. 20 oct. 2018 à 10:15, Илья Шипицин <[hidden email]> a écrit :
hi,

we use cmake/cpack for mangling systemd scripts


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

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how to debug CPack creation

Eric Noulard

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?

 
Now I think I get it.
IN vpnserver CMakeLists.txt you do:

install_systemd_service("vpnserver" "${CMAKE_SOURCE_DIR}/systemd/softether-vpnserver.service" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver")

So at this point (during CMake config step) "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver"
is /usr/local/softether/vpnserver/vpnserver

In your install_systemd_service CMake macro wrapper you do:

macro(install_systemd_service component file_path binary_path)
    get_filename_component(file_name ${file_path} NAME)
    get_filename_component(binary_directory ${binary_path} DIRECTORY)

    file(READ ${file_path} FILE_CONTENT)
    string(REPLACE "[DIRECTORY]" ${binary_directory} FILE_CONTENT ${FILE_CONTENT})
    string(REPLACE "[BINARY]" ${binary_path} FILE_CONTENT ${FILE_CONTENT})
    file(WRITE ${CMAKE_SOURCE_DIR}/tmp/systemd/${file_name} ${FILE_CONTENT})
...

So you generate a systemd service file which contains /usr/local prefix because this is the one which
is know during "CMake configuration step".

You cannot do that this way with .deb or .rpm because you don't know the "actual" prefix that will be in the package
because it is controlby CPACK_PACKAGING_INSTALL_PREFIX  "at CPack time", i.e. when CPack runs.

It's even worse because .deb or .rpm may be relocated see e.g.:

When you want to install script that should know where things get installed you have 3 options:

1) Assume the binary executable is installed in the path
    thus call the executable as-is "vpnserver" without absolute path

2) Put a pre- or post- install script that will compute the appropriate path 
   **during package installation** when you are sure what the real path will be.
   Have a look at CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA in https://cmake.org/cmake/help/latest/cpack_gen/deb.html
   
3) Ensure that you generate package with 
   CMAKE_INSTALL_PREFIX == CPACK_PACKAGING_INSTALL_PREFIX
   This is ok but will break if the installation of the package is relocated.

1) may be ok.
2) need a little work but is the more robust
3) may be enough but prevent relocatable install

-- 
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how to debug CPack creation

Илья Шипицин


сб, 20 окт. 2018 г. в 18:31, Eric Noulard <[hidden email]>:

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?

 
Now I think I get it.
IN vpnserver CMakeLists.txt you do:

install_systemd_service("vpnserver" "${CMAKE_SOURCE_DIR}/systemd/softether-vpnserver.service" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver")

So at this point (during CMake config step) "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver"
is /usr/local/softether/vpnserver/vpnserver

In your install_systemd_service CMake macro wrapper you do:

macro(install_systemd_service component file_path binary_path)
    get_filename_component(file_name ${file_path} NAME)
    get_filename_component(binary_directory ${binary_path} DIRECTORY)

    file(READ ${file_path} FILE_CONTENT)
    string(REPLACE "[DIRECTORY]" ${binary_directory} FILE_CONTENT ${FILE_CONTENT})
    string(REPLACE "[BINARY]" ${binary_path} FILE_CONTENT ${FILE_CONTENT})
    file(WRITE ${CMAKE_SOURCE_DIR}/tmp/systemd/${file_name} ${FILE_CONTENT})
...

So you generate a systemd service file which contains /usr/local prefix because this is the one which
is know during "CMake configuration step".

You cannot do that this way with .deb or .rpm because you don't know the "actual" prefix that will be in the package
because it is controlby CPACK_PACKAGING_INSTALL_PREFIX  "at CPack time", i.e. when CPack runs.

It's even worse because .deb or .rpm may be relocated see e.g.:

When you want to install script that should know where things get installed you have 3 options:

1) Assume the binary executable is installed in the path
    thus call the executable as-is "vpnserver" without absolute path

2) Put a pre- or post- install script that will compute the appropriate path 
   **during package installation** when you are sure what the real path will be.
   Have a look at CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA in https://cmake.org/cmake/help/latest/cpack_gen/deb.html
   
3) Ensure that you generate package with 
   CMAKE_INSTALL_PREFIX == CPACK_PACKAGING_INSTALL_PREFIX
   This is ok but will break if the installation of the package is relocated.

this is good.
is there a way to install shared libs to system location ? (in order to avoid ld manipulation)

 

1) may be ok.
2) need a little work but is the more robust
3) may be enough but prevent relocatable install

-- 
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how to debug CPack creation

Craig Scott-3


On Sun, Oct 21, 2018 at 3:41 AM Илья Шипицин <[hidden email]> wrote:


сб, 20 окт. 2018 г. в 18:31, Eric Noulard <[hidden email]>:

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?

 
Now I think I get it.
IN vpnserver CMakeLists.txt you do:

install_systemd_service("vpnserver" "${CMAKE_SOURCE_DIR}/systemd/softether-vpnserver.service" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver")

So at this point (during CMake config step) "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver"
is /usr/local/softether/vpnserver/vpnserver

In your install_systemd_service CMake macro wrapper you do:

macro(install_systemd_service component file_path binary_path)
    get_filename_component(file_name ${file_path} NAME)
    get_filename_component(binary_directory ${binary_path} DIRECTORY)

    file(READ ${file_path} FILE_CONTENT)
    string(REPLACE "[DIRECTORY]" ${binary_directory} FILE_CONTENT ${FILE_CONTENT})
    string(REPLACE "[BINARY]" ${binary_path} FILE_CONTENT ${FILE_CONTENT})
    file(WRITE ${CMAKE_SOURCE_DIR}/tmp/systemd/${file_name} ${FILE_CONTENT})
...

So you generate a systemd service file which contains /usr/local prefix because this is the one which
is know during "CMake configuration step".

You cannot do that this way with .deb or .rpm because you don't know the "actual" prefix that will be in the package
because it is controlby CPACK_PACKAGING_INSTALL_PREFIX  "at CPack time", i.e. when CPack runs.

It's even worse because .deb or .rpm may be relocated see e.g.:

When you want to install script that should know where things get installed you have 3 options:

1) Assume the binary executable is installed in the path
    thus call the executable as-is "vpnserver" without absolute path

2) Put a pre- or post- install script that will compute the appropriate path 
   **during package installation** when you are sure what the real path will be.
   Have a look at CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA in https://cmake.org/cmake/help/latest/cpack_gen/deb.html
   
3) Ensure that you generate package with 
   CMAKE_INSTALL_PREFIX == CPACK_PACKAGING_INSTALL_PREFIX
   This is ok but will break if the installation of the package is relocated.

this is good.
is there a way to install shared libs to system location ? (in order to avoid ld manipulation)

If your app isn't part of the Linux distribution itself, you shouldn't install it to /usr. You should be looking to install to somewhere like /opt instead (or maybe /usr/local, but /opt is generally better). You should be able to use RPATH to avoid needing to mess with the library search path - search the CMake docs for INSTALL_RPATH, it has pretty good support for RPATH these days. Just be sure to use relative RPATHs (i.e. start each path with $ORIGIN for Linux) to ensure your package remains relocatable.


--
Craig Scott
Melbourne, Australia


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how to debug CPack creation

Илья Шипицин
In reply to this post by Eric Noulard
Eric, thank you for your review.
I still wonder why is it so complicated (my expectation was "ok, since I use both cmake and cpack, they should work together")

(it is based on your suggestions)

сб, 20 окт. 2018 г. в 17:59, Eric Noulard <[hidden email]>:


Le sam. 20 oct. 2018 à 10:54, Илья Шипицин <[hidden email]> a écrit :


сб, 20 окт. 2018 г. в 13:30, Eric Noulard <[hidden email]>:


Le sam. 20 oct. 2018 à 10:15, Илья Шипицин <[hidden email]> a écrit :
hi,

we use cmake/cpack for mangling systemd scripts


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

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how to debug CPack creation

Eric Noulard


Le mar. 23 oct. 2018 à 08:07, Илья Шипицин <[hidden email]> a écrit :
Eric, thank you for your review.
I still wonder why is it so complicated (my expectation was "ok, since I use both cmake and cpack, they should work together")

The main reason is that CPack was first design as a standalone tool that can be used without CMake.
I guess that some project may still be using that way.
CMake has a "simple" way to generate CPackConfig.cmake file that drives the CPack run but you can generate those files
by other mean and still be using CPack, without CMake.

 

I made comment on this commit, basically don't generate *any* file in source tree it's a [relatively] bad habit.
If a file is an artefact of the build then it belongs to build tree.

As a matter of fact you CI build tree seems to <source_tree>/tmp (from your configure script) but if ever this is changing it'll break the build
use CMAKE_BINARY_DIR.

I think it should work now but your CI will show you if it's ok.

Now concerning your CMAKE_INSTALL_PREFIX if your CI is producing ready to use .deb / .rpm etc... package then
you'd better use "/opt" as a prefix as suggested by Craig.




сб, 20 окт. 2018 г. в 17:59, Eric Noulard <[hidden email]>:


Le sam. 20 oct. 2018 à 10:54, Илья Шипицин <[hidden email]> a écrit :


сб, 20 окт. 2018 г. в 13:30, Eric Noulard <[hidden email]>:


Le sam. 20 oct. 2018 à 10:15, Илья Шипицин <[hidden email]> a écrit :
hi,

we use cmake/cpack for mangling systemd scripts


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


--
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake