[Pkg-libvirt-commits] [Git][libvirt-team/libvirt][debian/latest] Replace manual maintscript code with dh_installsystemd
Andrea Bolognani (@abologna)
gitlab at salsa.debian.org
Mon Dec 19 15:36:15 GMT 2022
Andrea Bolognani pushed to branch debian/latest at Libvirt Packaging Team / libvirt
Commits:
4d6db567 by Michael Biebl at 2022-12-19T15:14:51+00:00
Replace manual maintscript code with dh_installsystemd
Since #994204 has long been fixed, remove all manual maintscript code
dealing with systemd units. This not only removes a good chunk of
maintscript code but also ensures, that changes in dh_installsystemd,
like the improved mask handling, are applied automatically.
Closes: #1021956
- - - - -
4 changed files:
- debian/libvirt-daemon-system.postinst
- debian/libvirt-daemon-system.postrm
- − debian/libvirt-daemon-system.prerm
- debian/rules
Changes:
=====================================
debian/libvirt-daemon-system.postinst
=====================================
@@ -107,52 +107,6 @@ add_statoverrides()
fi
}
-systemd_daemon_reload() {
- if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- fi
-}
-
-systemd_unit_enable() {
- for unit in "$@"; do
- deb-systemd-helper unmask "$unit" >/dev/null || true
- # was-enabled defaults to true, so new installations run enable.
- if deb-systemd-helper --quiet was-enabled "$unit"; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable "$unit" >/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 "$unit" >/dev/null || true
- fi
- done
-}
-
-systemd_unit_start() {
- if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
- deb-systemd-invoke start "$@" >/dev/null || true
- fi
-}
-
-systemd_unit_restart() {
- if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
- deb-systemd-invoke restart "$@" >/dev/null || true
- fi
-}
-
-systemd_unit_reload() {
- if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
- for unit in "$@"; do
- if systemctl is-active -q "$unit"; then
- deb-systemd-invoke reload "$unit" >/dev/null || true
- else
- deb-systemd-invoke start "$unit" >/dev/null || true
- fi
- done
- fi
-}
-
case "$1" in
configure)
add_users_groups
@@ -185,19 +139,6 @@ case "$1" in
install -m 0644 /dev/null "$local_abstraction"
fi
done
-
- systemd_daemon_reload
- systemd_unit_enable virtlockd.service virtlockd.socket virtlockd-admin.socket
- systemd_unit_enable virtlogd.service virtlogd.socket virtlogd-admin.socket
- systemd_unit_enable libvirtd.service libvirtd.socket libvirtd-admin.socket libvirtd-ro.socket
- systemd_unit_enable libvirt-guests.service
- systemd_unit_start virtlogd.socket virtlogd-admin.socket
- systemd_unit_reload virtlogd.service
- systemd_unit_start virtlockd.socket virtlockd-admin.socket
- systemd_unit_reload virtlockd.service
- systemd_unit_start libvirtd.socket libvirtd-admin.socket libvirtd-ro.socket
- systemd_unit_restart libvirtd.service
- systemd_unit_start libvirt-guests.service
;;
abort-upgrade|abort-remove|abort-deconfigure)
=====================================
debian/libvirt-daemon-system.postrm
=====================================
@@ -45,25 +45,6 @@ abort_conffile_transfer() {
rm -f "$conffile.dpkg-disappear"
}
-systemd_daemon_reload() {
- if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- fi
-}
-
-systemd_unit_disable() {
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper mask "$@" >/dev/null || true
- fi
-}
-
-systemd_unit_delete() {
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper purge "$@" >/dev/null || true
- deb-systemd-helper unmask "$@" >/dev/null || true
- fi
-}
-
NWFILTERS="
allow-arp
allow-dhcp
@@ -86,21 +67,7 @@ NWFILTERS="
"
case "$1" in
- remove)
- systemd_daemon_reload
- systemd_unit_disable libvirt-guests.service
- systemd_unit_disable libvirtd.service libvirtd.socket libvirtd-admin.socket libvirtd-ro.socket
- systemd_unit_disable virtlogd.service virtlogd.socket virtlogd-admin.socket
- systemd_unit_disable virtlockd.service virtlockd.socket virtlockd-admin.socket
- ;;
-
purge)
- systemd_daemon_reload
- systemd_unit_delete libvirt-guests.service
- systemd_unit_delete libvirtd.service libvirtd.socket libvirtd-admin.socket libvirtd-ro.socket
- systemd_unit_delete virtlogd.service virtlogd.socket virtlogd-admin.socket
- systemd_unit_delete virtlockd.service virtlockd.socket virtlockd-admin.socket
-
if getent group libvirt >/dev/null; then
delgroup libvirt >/dev/null || true
fi
@@ -166,7 +133,7 @@ case "$1" in
done
;;
- upgrade|failed-upgrade|disappear)
+ remove|upgrade|failed-upgrade|disappear)
;;
*)
=====================================
debian/libvirt-daemon-system.prerm deleted
=====================================
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-set -e
-
-# summary of how this script can be called:
-# * <prerm> `remove`
-# * <old-prerm> `upgrade` <new-version>
-# * <new-prerm> `failed-upgrade` <old-version <new-version>
-# * <prerm> `deconfigure` `in-favour` <new-package> <new-version>
-# * <prerm> `remove` `in-favour` <new-package> <new-version>
-# for details, see https://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-systemd_unit_stop() {
- if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
- deb-systemd-invoke stop "$@" >/dev/null || true
- fi
-}
-
-case "$1" in
- remove)
- systemd_unit_stop libvirt-guests.service
- systemd_unit_stop libvirtd.service libvirtd.socket libvirtd-admin.socket libvirtd-ro.socket
- systemd_unit_stop virtlogd.service virtlogd.socket virtlogd-admin.socket
- systemd_unit_stop virtlockd.service virtlockd.socket virtlockd-admin.socket
- ;;
-
- upgrade|failed-upgrade|deconfigure)
- ;;
-
- *)
- echo "prerm called with unknown argument \`$1'" >&2
- exit 1
- ;;
-esac
-
-#DEBHELPER#
-
-exit 0
=====================================
debian/rules
=====================================
@@ -144,6 +144,20 @@ DEB_CONFIGURE_EXTRA_ARGS := \
-Dwireshark_dissector=enabled \
$(NULL)
+# Those have to stay up through upgrades to avoid interruptions
+LIBVIRT_UNITS = \
+ virtlogd.service \
+ virtlockd.service \
+ libvirt-guests.service \
+ libvirtd.socket \
+ libvirtd-ro.socket \
+ libvirtd-admin.socket \
+ virtlogd.socket \
+ virtlogd-admin.socket \
+ virtlockd.socket \
+ virtlockd-admin.socket \
+ $(NULL)
+
APPARMOR_ABSTRACTIONS = \
libvirt-lxc \
libvirt-qemu \
@@ -293,12 +307,9 @@ override_dh_installinit:
dh_installinit -p libvirt-daemon-system --name=libvirtd --no-scripts
dh_installinit -p libvirt-daemon-system --name=libvirt-guests --no-scripts
-# We handle starting, stopping and restarting systemd units ourselves.
-# See the various systemd_*() functions in maintainer scripts for details.
-# The implementation is based on the code that would be generated by
-# dh_installsystemd, but it's been tailored to fit libvirt's specifics
-# such as the requirement to reload rather than restart virtlogd on upgrade
override_dh_installsystemd:
+ dh_installsystemd -p libvirt-daemon-system --no-also libvirtd.service
+ dh_installsystemd -p libvirt-daemon-system --no-stop-on-upgrade $(LIBVIRT_UNITS)
override_dh_installdocs:
dh_installdocs -plibvirt-doc --doc-main-package libvirt-doc
View it on GitLab: https://salsa.debian.org/libvirt-team/libvirt/-/commit/4d6db5671782b92f9d3a0b695dd2cc8bd9c496a6
--
View it on GitLab: https://salsa.debian.org/libvirt-team/libvirt/-/commit/4d6db5671782b92f9d3a0b695dd2cc8bd9c496a6
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-libvirt-commits/attachments/20221219/be7b794c/attachment-0001.htm>
More information about the Pkg-libvirt-commits
mailing list