Comment 3 for bug 2027613

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

#1 current situation

## Jammy

override_dh_installsystemd:
        dh_installsystemd --no-enable --no-start

Leading to
root@j:~# grep -C 5 landscape-client.service /var/lib/dpkg/info/landscape-client.p*
/var/lib/dpkg/info/landscape-client.postinst- # Migrate old sysvinit config to systemd
/var/lib/dpkg/info/landscape-client.postinst- DEFAULTS=/etc/default/landscape-client
/var/lib/dpkg/info/landscape-client.postinst- if [ -f $DEFAULTS ]; then
/var/lib/dpkg/info/landscape-client.postinst- RUN=$(. $DEFAULTS; echo $RUN)
/var/lib/dpkg/info/landscape-client.postinst- if [ "$RUN" = "1" ]; then
/var/lib/dpkg/info/landscape-client.postinst: systemctl enable landscape-client.service
/var/lib/dpkg/info/landscape-client.postinst- fi
/var/lib/dpkg/info/landscape-client.postinst- rm -f $DEFAULTS
/var/lib/dpkg/info/landscape-client.postinst- fi
/var/lib/dpkg/info/landscape-client.postinst- ;;
/var/lib/dpkg/info/landscape-client.postinst-
--
/var/lib/dpkg/info/landscape-client.postinst-fi
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst-# End automatically added section
/var/lib/dpkg/info/landscape-client.postinst-# Automatically added by dh_installsystemd/13.6ubuntu1
/var/lib/dpkg/info/landscape-client.postinst-if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
/var/lib/dpkg/info/landscape-client.postinst: if deb-systemd-helper debian-installed 'landscape-client.service'; then
/var/lib/dpkg/info/landscape-client.postinst- # This will only remove masks created by d-s-h on package removal.
/var/lib/dpkg/info/landscape-client.postinst: deb-systemd-helper unmask 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst: if deb-systemd-helper --quiet was-enabled 'landscape-client.service'; then
/var/lib/dpkg/info/landscape-client.postinst- # Create new symlinks, if any.
/var/lib/dpkg/info/landscape-client.postinst: deb-systemd-helper enable 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postinst- fi
/var/lib/dpkg/info/landscape-client.postinst- fi
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst- # Update the statefile to add new symlinks (if any), which need to be cleaned
/var/lib/dpkg/info/landscape-client.postinst- # up on purge. Also remove old symlinks.
/var/lib/dpkg/info/landscape-client.postinst: deb-systemd-helper update-state 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postinst-fi
/var/lib/dpkg/info/landscape-client.postinst-# End automatically added section
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst-exit 0
--
/var/lib/dpkg/info/landscape-client.postrm-fi
/var/lib/dpkg/info/landscape-client.postrm-# End automatically added section
/var/lib/dpkg/info/landscape-client.postrm-# Automatically added by dh_installsystemd/13.6ubuntu1
/var/lib/dpkg/info/landscape-client.postrm-if [ "$1" = "remove" ]; then
/var/lib/dpkg/info/landscape-client.postrm- if [ -x "/usr/bin/deb-systemd-helper" ]; then
/var/lib/dpkg/info/landscape-client.postrm: deb-systemd-helper mask 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postrm- fi
/var/lib/dpkg/info/landscape-client.postrm-fi
/var/lib/dpkg/info/landscape-client.postrm-
/var/lib/dpkg/info/landscape-client.postrm-if [ "$1" = "purge" ]; then
/var/lib/dpkg/info/landscape-client.postrm- if [ -x "/usr/bin/deb-systemd-helper" ]; then
/var/lib/dpkg/info/landscape-client.postrm: deb-systemd-helper purge 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postrm: deb-systemd-helper unmask 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postrm- fi
/var/lib/dpkg/info/landscape-client.postrm-fi
/var/lib/dpkg/info/landscape-client.postrm-# End automatically added section
/var/lib/dpkg/info/landscape-client.postrm-# Automatically added by dh_installdebconf/13.6ubuntu1
/var/lib/dpkg/info/landscape-client.postrm-if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
--
/var/lib/dpkg/info/landscape-client.preinst-#!/bin/sh
/var/lib/dpkg/info/landscape-client.preinst-set -e
/var/lib/dpkg/info/landscape-client.preinst-# Automatically added by dh_installsystemd/13.6ubuntu1
/var/lib/dpkg/info/landscape-client.preinst-if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = upgrade ] && [ -d /run/systemd/system ] ; then
/var/lib/dpkg/info/landscape-client.preinst: deb-systemd-invoke stop 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.preinst-fi
/var/lib/dpkg/info/landscape-client.preinst-# End automatically added section

Simplified that means:
1. postinst: carry over being enabled if it was enabled in systemd
   (can that be dropped, that transition is dond isn't it? Would simplify and reduce edge cases)
2. postinst: only enable it if it was enabled before
3. postrm: masking & unmasking & purging for different conditions
4. preinst: stop the service

This 4. is what you try to fix AFAIU

## Mantic

override_dh_installsystemd:
        dh_installsystemd --no-enable --no-start --no-stop-on-upgrade

root@m:~# grep -C 5 landscape-client.service /var/lib/dpkg/info/landscape-client.p*
/var/lib/dpkg/info/landscape-client.postinst- # Migrate old sysvinit config to systemd
/var/lib/dpkg/info/landscape-client.postinst- DEFAULTS=/etc/default/landscape-client
/var/lib/dpkg/info/landscape-client.postinst- if [ -f $DEFAULTS ]; then
/var/lib/dpkg/info/landscape-client.postinst- RUN=$(. $DEFAULTS; echo $RUN)
/var/lib/dpkg/info/landscape-client.postinst- if [ "$RUN" = "1" ]; then
/var/lib/dpkg/info/landscape-client.postinst: systemctl enable landscape-client.service
/var/lib/dpkg/info/landscape-client.postinst- fi
/var/lib/dpkg/info/landscape-client.postinst- rm -f $DEFAULTS
/var/lib/dpkg/info/landscape-client.postinst- fi
/var/lib/dpkg/info/landscape-client.postinst- ;;
/var/lib/dpkg/info/landscape-client.postinst-
--
/var/lib/dpkg/info/landscape-client.postinst-fi
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst-# End automatically added section
/var/lib/dpkg/info/landscape-client.postinst-# Automatically added by dh_installsystemd/13.11.4ubuntu3
/var/lib/dpkg/info/landscape-client.postinst-if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
/var/lib/dpkg/info/landscape-client.postinst: if deb-systemd-helper debian-installed 'landscape-client.service'; then
/var/lib/dpkg/info/landscape-client.postinst- # The following line should be removed in trixie or trixie+1
/var/lib/dpkg/info/landscape-client.postinst: deb-systemd-helper unmask 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst: if deb-systemd-helper --quiet was-enabled 'landscape-client.service'; then
/var/lib/dpkg/info/landscape-client.postinst- # Create new symlinks, if any.
/var/lib/dpkg/info/landscape-client.postinst: deb-systemd-helper enable 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postinst- fi
/var/lib/dpkg/info/landscape-client.postinst- fi
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst- # Update the statefile to add new symlinks (if any), which need to be cleaned
/var/lib/dpkg/info/landscape-client.postinst- # up on purge. Also remove old symlinks.
/var/lib/dpkg/info/landscape-client.postinst: deb-systemd-helper update-state 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postinst-fi
/var/lib/dpkg/info/landscape-client.postinst-# End automatically added section
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst-
/var/lib/dpkg/info/landscape-client.postinst-exit 0
--
/var/lib/dpkg/info/landscape-client.postrm-fi
/var/lib/dpkg/info/landscape-client.postrm-# End automatically added section
/var/lib/dpkg/info/landscape-client.postrm-# Automatically added by dh_installsystemd/13.11.4ubuntu3
/var/lib/dpkg/info/landscape-client.postrm-if [ "$1" = "purge" ]; then
/var/lib/dpkg/info/landscape-client.postrm- if [ -x "/usr/bin/deb-systemd-helper" ]; then
/var/lib/dpkg/info/landscape-client.postrm: deb-systemd-helper purge 'landscape-client.service' >/dev/null || true
/var/lib/dpkg/info/landscape-client.postrm- fi
/var/lib/dpkg/info/landscape-client.postrm-fi
/var/lib/dpkg/info/landscape-client.postrm-# End automatically added section
/var/lib/dpkg/info/landscape-client.postrm-# Automatically added by dh_installdebconf/13.11.4ubuntu3
/var/lib/dpkg/info/landscape-client.postrm-if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then

Simplified that means:
1. postinst: carry over being enabled if it was enabled in systemd
   (can that be dropped, that transition is dond isn't it? Would simplify and reduce edge cases)
2. postinst: only enable it if it was enabled before
3. postrm: purging for different conditions

So the stop you wanted to remove is gone (and the umask/mask, but that is ok) and all is good right?
You have fixed what you wanted to fix, but I believe it is still not sufficient (by knowing the problem from other cases).