I've been following the excellent guides to create debian packages to install an application executable
https://wiki.debian.org/Packaging/Intro?action=show&redirect=IntroDebianPackaging
and using dh-systemd to install a systemd service
https://bunn.cc/2017/debian-packaging-with-systemd/
however, I would like to combine the two to create a package to install a service and install the binary which gets run by the service.
The first tutorial has the application files in the directory above the /debian folder and a make file to build and install the application, whereas the systemd tutorial has the service file in the debian folder. It is not clear to me how to create a control file which installs both service file and dependant binary.
I'd be grateful if someone could advise how to do this or provide some useful reference material.
I've tried reading https://wiki.debian.org/Teams/pkg-systemd/Packaging but this doesn't explain much.
Is this a realistic expectation, or should services and applications be packaged separately?
Thanks
Best Answer
Services and applications should be packaged together; at least, services should be packaged with the binaries implementing the service they manage.
In most cases, installing systemd units is transparent. If the main build installs units into the expected target directories (
/lib/systemd/system
), they will be picked up and enabled automatically. If the package ships units indebian
, they will be installed in the right place and also enabled automatically. All this is handled bydh_systemd_enable
anddh_systemd_start
, which used to be shipped indh-systemd
but are now part ofdebhelper
, and included in the defaultdh
sequences.So, if you take your existing application package, and add a service file in
debian
, you should find it “just works” (assuming you’re usingdh
).