debian systemd package-management – Debian Package with Combined Systemd Service and Executed Binary

debianpackage-managementsystemd

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 in debian, they will be installed in the right place and also enabled automatically. All this is handled by dh_systemd_enable and dh_systemd_start, which used to be shipped in dh-systemd but are now part of debhelper, and included in the default dh 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 using dh).

Related Question