Systemd service in package is restarted on upgrade

544 views Asked by At

I use debhelper with python setuptools in order to build my packages. I recently updated the compatibility level 9 to 11 in order to use the systemd timers.

From that moment every time I upgrade the package the service contained is restarted. I tried to build with the following rules:

#! /usr/bin/make -f

#export DH_VERBOSE = 1
export PYBUILD_NAME=my_pkg
export DH_ALWAYS_EXCLUDE=CVS:.svn:.git:.vscode*
export PYBUILD_INTERPRETERS=python3

%:
    dh $@ --with python3 --buildsystem=pybuild

override_dh_installinit:
        dh_installinit --no-stop-on-upgrade --no-restart-on-upgrade --no-restart-after-upgrade --no-start

override_dh_systemd_enable:
        dh_systemd_enable --name=my_pkg

override_dh_systemd_start:
        dh_systemd_start --no-stop-on-upgrade --no-restart-on-upgrade --no-restart-after-upgrade --no-start
        python3 setup.py clean --all

According to the documentation those tags should do what I look for but probably there is something I'm missing:

dh_systemd_start

dh_installinit

Every time I update it the service contained is restarted. The service is running the update itself so when is restarted the update is left uncompleted.

1

There are 1 answers

0
IK428 On

As expected I was looking in the wrong direction. The correct option to use is: dh_installsystemd

change the rule file into:

#! /usr/bin/make -f

#export DH_VERBOSE = 1
export PYBUILD_NAME=my_pkg
export DH_ALWAYS_EXCLUDE=CVS:.svn:.git:.vscode*
export PYBUILD_INTERPRETERS=python3

%:
    dh $@ --with python3 --buildsystem=pybuild

override_dh_systemd_enable:
        dh_systemd_enable --name=my_pkg

override_dh_installsystemd:
        dh_installsystemd --no-restart-after-upgrade

override_dh_systemd_start:
        python3 setup.py clean --all

I hope this will help someone else in the same situation.