Skip to content

Building a .tar.gz or .deb package with CPack fails

Created by: mkoval

I am trying to build a .deb package of libbarrett using CPack. I followed the instructions in the README and tried running make package with the CONFIG_PACKAGE and CONFIG_DEBIAN flags.

This is the entire sequence of commands I ran:

mkdir build && cd build
cmake -DNON_REALTIME:bool=1 -DCONFIG_PACKAGE:bool=1 -DCONFIG_DEBIAN:bool=1 \
      -DINSTALL_EXAMPLES:bool=0 -DINSTALL_SANDBOX:bool=0 ..
make && make package

The make command succeeds. The make package command does produce a .deb package, also prints a bunch of warnings:

[100%] Built target barrett
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: libbarrett
CPack: - Install project: libbarrett
Traceback (most recent call last):
>>> Source: /home/prdemo/libbarrett_source/config
>>> Destination: /etc/barrett
  File "/home/prdemo/libbarrett_source/programs/install_config_files", line 180, in <module>
    main()
  File "/home/prdemo/libbarrett_source/programs/install_config_files", line 59, in main
    os.mkdir(backupDir)
OSError: [Errno 13] Permission denied: '/etc/barrett/BACKUP-20150327-0'
chown: invalid group: `prdemo:prdemo'
/sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Permission denied
CPack: Create package
CPack: - package: /home/prdemo/libbarrett_source/build/libbarrett-1.2.3_x86_64.deb generated.

Installing the resulting .deb package with dpkg -i libbarrett-1.2.3_x86_64.deb fails with a similar error message:

Selecting previously unselected package libbarrett-dev.
(Reading database ... 303290 files and directories currently installed.)
Unpacking libbarrett-dev (from libbarrett-1.2.3_x86_64.deb) ...
Setting up libbarrett-dev (1.2.3) ...
Current user is = prdemo
Changing owner of examples directory located: /home/prdemo/libbarrett_examples to prdemo
chown: invalid group: `prdemo:prdemo'
dpkg: error processing libbarrett-dev (--install):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 libbarrett-dev

It seems incorrect to chown files in the Debian package based on who is running the build. Also, the current logic in CMakeLists.txt assumes that there exists a group with the same name as the the current user. This is not true in our case and causes the chown: invalid group: prdemo:prdemo error.

More importantly, am I following the right process to build a package?