I'm trying to package a mono application to run as a systemd service.

I've followed the instructions here: https://wiki.debian.org/Teams/pkg-systemd/Packaging

I've added dh-systemd (>= 1.5) to my debian control file build depends.

I've added --with=systemd to my rules file as follows:

    dh $@ --with=cli --with=systemd

I've added my service file to my debian folder called mypackage.service with the following contents:

Description=My Service Description

ExecStart=/usr/bin/mono /usr/lib/mypackage/myservice.exe


However building gives the following lintian warnings and errors:

Now running lintian...
E: mypackage: postrm-does-not-call-updaterc.d-for-init.d-script     etc/init.d/mypackage
W: mypackage: init.d-script-not-marked-as-conffile etc/init.d/mypackage
E: mypackage: init.d-script-not-included-in-package etc/init.d/mypackage

This is confusing me for several reasons

  1. These warning are about init.d which is the old system which is replaced by systemd, are these errors and warnings just wrong, does debuild think I'm using init.d because I've configured my package wrong?
  2. I was under the impression that the --with=systemd would create these scripts for me.


The generated postrm file is as follows:

set -e
# Automatically added by dh_systemd_start
if [ -d /run/systemd/system ]; then
    systemctl --system daemon-reload >/dev/null || true
# End automatically added section
# Automatically added by dh_systemd_enable
if [ "$1" = "remove" ]; then
    if [ -x "/usr/bin/deb-systemd-helper" ]; then
        deb-systemd-helper mask mypackage.service >/dev/null

if [ "$1" = "purge" ]; then
     if [ -x "/usr/bin/deb-systemd-helper" ]; then
        deb-systemd-helper purge mypackage.service >/dev/null
        deb-systemd-helper unmask mypackage.service >/dev/null
# End automatically added section

the generated prerm file is as follows:

set -e
# Automatically added by dh_systemd_start
if [ -d /run/systemd/system ]; then
    deb-systemd-invoke stop mypackage.service >/dev/null
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/mypackage" ] || [ -e "/etc/init/mypackage.conf" ]; then
    invoke-rc.d mypackage stop || exit $?
# End automatically added section

The package actually installs fine and the service starts correctly. The lintian errors are worrying, and I'd like to get to the bottom of them.

  • What does your postrm script contain? Does it have the debhelper boilerplate?
    – muru
    Mar 15, 2016 at 2:36
  • where is it? what is it? the instructions don't say to create one, and the linked example doesn't have one. So either it's autogenerated by dh-systemd or doesn't exist
    – trampster
    Mar 15, 2016 at 2:50
  • 2
    See debian.org/doc/debian-policy/ch-maintainerscripts.html and wiki.debian.org/MaintainerScripts. If you don't know what these are, debhelper (aka dh) should be generating appropriate ones. Run dpkg-deb --control on the generated deb file, and look in the newly-created DEBIAN directory for postinst, postrm files.
    – muru
    Mar 15, 2016 at 2:54
  • OK will do the instructions say "After rebuilding, your package will have additional code in the postinst, prerm and postrm maintainer scripts." given then these are auto generated I have little chance to stuff them up.
    – trampster
    Mar 15, 2016 at 2:59
  • Updated question with postrm and prerm generated scripts
    – trampster
    Mar 15, 2016 at 3:12

2 Answers 2


I ran into this issue as well. This is what I've come up with:

You'll want to override the dh_installinit and dh_systemd_start, this is an example from my network bridge service:

#!/usr/bin/make -f


    dh $@ --with systemd

    dh_systemd_enable -popenstack --name=openstack openstack.service
    dh_installinit -popenstack --no-start --noscripts
    dh_systemd_start -popenstack --no-restart-on-upgrade

    echo "Not running dh_systemd_start"

The full source of my package can be found here: https://github.com/Ubuntu-Solutions-Engineering/openstack-deb/tree/master/debian

I also used https://github.com/lxc/lxd-pkg-ubuntu/blob/dpm-xenial/debian/rules as a reference.

Hopefully this will get you going as it did take me a little while to figure this out.


When not including SysV or Upstart init scripts, instruct dh_installinit to not modify the postinst/postrm/prerm scripts. dh_systemd will handle it.

    dh_installinit --noscripts

This applies to debhelper compatibility level < 10 and with 10 even though dh_systemd has been merged into debhelper.

According to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800043 debhelper compatibility level 11 >= this will have this fixed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .