[pve-devel] [RFC manager 15/15] postinst: use autogenerated DEBHELPER parts for systemd stuff

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Mar 6 12:11:22 CET 2018


this is unfortunately not as easy.

the patch as is has the following issues:
- it's missing the DEBHELPER stanza in prerm/preinst
- compat level is 9, so dh_systemd_start defaults to stopping in prerm
  and (only!) starting in postinst

we could switch to compat 10 (and disable --parallel until the build is
fixed), or tell dh_systemd_start to --restart-after-upgrade, but

- on first install it would start the services
- on upgrades it would try-restart them

which is a change of behaviour compared to the current
reload-or-restart. there is no way to tell dh_systemd_start to
reload-or-restart, AFAICT (might be worth an upstream bug report?)

we definitely want reload for pvedaemon, pveproxy and spiceproxy, so
this patch IMHO needs to wait for reload support in dh_systemd_start

On Wed, Jan 24, 2018 at 02:12:40PM +0100, Thomas Lamprecht wrote:
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  debian/postinst | 45 ++-------------------------------------------
>  debian/postrm   | 34 +---------------------------------
>  debian/rules    |  7 ++++++-
>  3 files changed, 9 insertions(+), 77 deletions(-)
> 
> diff --git a/debian/postinst b/debian/postinst
> index 42e0f085..11762027 100755
> --- a/debian/postinst
> +++ b/debian/postinst
> @@ -49,49 +49,6 @@ case "$1" in
>  	echo '|/usr/bin/pvemailforward' >/root/.forward
>      fi
>  
> -    systemctl --system daemon-reload >/dev/null || true
> -
> -    # same as dh_systemd_enable (code copied)
> -
> -    for timer in pvesr; do
> -	deb-systemd-helper unmask $timer.timer >/dev/null || true
> -
> -	# was-enabled defaults to true, so new installations run enable.
> -	if deb-systemd-helper --quiet was-enabled $timer.timer; then
> -	    # Enables the unit on first installation, creates new
> -	    # symlinks on upgrades if the unit file has changed.
> -	    deb-systemd-helper enable $timer.timer >/dev/null || true
> -	else
> -	    # Update the statefile to add new symlinks (if any), which need to be
> -	    # cleaned up on purge. Also remove old symlinks.
> -	    deb-systemd-helper update-state $timer.timer >/dev/null || true
> -	fi
> -    done
> -
> -    for service in pvedaemon pveproxy spiceproxy pvestatd pvebanner pvenetcommit pve-guests; do
> -	deb-systemd-helper unmask $service.service >/dev/null || true
> -
> -	# was-enabled defaults to true, so new installations run enable.
> -	if deb-systemd-helper --quiet was-enabled $service.service; then
> -	    # Enables the unit on first installation, creates new
> -	    # symlinks on upgrades if the unit file has changed.
> -	    deb-systemd-helper enable $service.service >/dev/null || true
> -	else
> -	    # Update the statefile to add new symlinks (if any), which need to be
> -	    # cleaned up on purge. Also remove old symlinks.
> -	    deb-systemd-helper update-state $service.service >/dev/null || true
> -	fi
> -    done
> -
> -    if test ! -e /proxmox_install_mode; then
> -
> -	for service in pvedaemon pveproxy spiceproxy pvestatd; do
> -	    deb-systemd-invoke reload-or-restart $service
> -	done
> -
> -	deb-systemd-invoke start pvesr.timer >/dev/null || true
> -    fi
> -
>      if test -z "$2"; then
>        : # no old version, nothing to do
>      else
> @@ -111,4 +68,6 @@ case "$1" in
>       exit 0;;
>  esac
>  
> +#DEBHELPER#
> +
>  exit 0
> diff --git a/debian/postrm b/debian/postrm
> index 5cc18ca4..e4d53294 100755
> --- a/debian/postrm
> +++ b/debian/postrm
> @@ -19,36 +19,4 @@ case "$1" in
>      ;;
>  esac
>  
> -# same as dh_systemd_enable (code copied)
> -systemctl --system daemon-reload >/dev/null || true
> -
> -PVESERVICES="pvedaemon pveproxy spiceproxy pvestatd pvebanner pvenetcommit pve-guests"
> -PVETIMERS="pvesr"
> -
> -if [ "$1" = "remove" ]; then
> -    for timer in ${PVETIMERS}; do
> -	if [ -x "/usr/bin/deb-systemd-helper" ]; then
> -	    deb-systemd-helper mask $timer.timer >/dev/null
> -	fi
> -    done
> -    for service in ${PVESERVICES}; do
> -	if [ -x "/usr/bin/deb-systemd-helper" ]; then
> -	    deb-systemd-helper mask $service.service >/dev/null
> -	fi
> -    done
> -fi
> -
> -if [ "$1" = purge ]; then
> -    for timer in ${PVETIMERS}; do
> -	if [ -x "/usr/bin/deb-systemd-helper" ]; then
> -	    deb-systemd-helper purge $timer.timer >/dev/null
> -	    deb-systemd-helper unmask $timer.timer >/dev/null
> -	fi
> -    done
> -    for service in ${PVESERVICES}; do
> -	if [ -x "/usr/bin/deb-systemd-helper" ]; then
> -	    deb-systemd-helper purge $service.service >/dev/null
> -	    deb-systemd-helper unmask $service.service >/dev/null
> -	fi
> -    done
> -fi
> +#DEBHELPER#
> diff --git a/debian/rules b/debian/rules
> index f2c2cb77..188f216b 100755
> --- a/debian/rules
> +++ b/debian/rules
> @@ -10,4 +10,9 @@ override_dh_fixperms:
>  	dh_fixperms -Xpvemailforward -Xvar/log/pveproxy
>  
>  %:
> -	dh $@
> +	dh $@ --with=systemd
> +
> +override_dh_systemd_start:
> +	dh_systemd_start pve-daily-update.timer pvesr.timer
> +	dh_systemd_start pvedaemon pveproxy spiceproxy pvestatd
> +	dh_systemd_start --remaining-packages
> -- 
> 2.14.2
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list