Package: libvirt
Version: 1.0.6-1
Severity: normal
Tags: patch
User: pkg-systemd-maintain...@lists.alioth.debian.org
Usertags: systemd-units
X-Debbugs-CC: pkg-systemd-maintain...@lists.alioth.debian.org


Hi,

Thanks for shipping service files with libvirt.

The attached patch simplifies/unifies the packaging by removing the
systemd-specific bits from debian/libvirt-bin.postinst and using
dh-systemd instead.

This makes the packaging simpler and more correct: your service files
will get enabled and started properly (even if installed on sysvinit and
later switching to systemd).

Therefore, please apply the patch for your next upload. Thanks!

I also attached a diff of the control.tar.gz from 1.0.6-1 (OLD) to
1.0.6-1 with systemd (NEW).

-- 
Best regards,
Michael
>From aa97de9385b8707318304528c8710e6ec38f7523 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <mich...@stapelberg.de>
Date: Wed, 26 Jun 2013 19:47:34 +0200
Subject: [PATCH] switch to dh-systemd for proper systemd maintscripts

---
 debian/control              |    1 +
 debian/libvirt-bin.postinst |    6 ------
 debian/rules                |    2 ++
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/debian/control b/debian/control
index fb43596..2f5ed38 100644
--- a/debian/control
+++ b/debian/control
@@ -5,6 +5,7 @@ Maintainer: Debian Libvirt Maintainers <pkg-libvirt-maintain...@lists.alioth.deb
 Uploaders: Guido Günther <a...@sigxcpu.org>, Laurent Léonard <laur...@open-minds.org>
 Build-Depends: cdbs (>= 0.4.90~),
  debhelper (>= 7),
+ dh-systemd (>= 1.3),
  libxml2-dev,
  libncurses5-dev,
  libreadline-dev,
diff --git a/debian/libvirt-bin.postinst b/debian/libvirt-bin.postinst
index 3ad45c9..3c21454 100644
--- a/debian/libvirt-bin.postinst
+++ b/debian/libvirt-bin.postinst
@@ -104,12 +104,6 @@ case "$1" in
 	    sleep 1
 	fi
 
-	# enable libvirt-{bin,guests} for systemd
-	if [ -x /bin/systemctl ] && [ -d /sys/fs/cgroup/systemd ]; then
-            systemctl enable libvirt-bin.service
-            systemctl enable libvirt-guests.service
-	fi
-
 	if dpkg --compare-versions "$2" lt "0.6.1-2"; then
 	    if [ -e /etc/rc2.d/S20libvirt-bin ] && \
 	       [ -e /etc/rc3.d/S20libvirt-bin ] && \
diff --git a/debian/rules b/debian/rules
index c1fa1f1..984ce5b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -116,9 +116,11 @@ binary-install/libvirt-bin::
 	    debian/libvirt-bin.libvirt-guests.init
 	cp tools/libvirt-guests.sysconf \
 	    debian/libvirt-bin.libvirt-guests.default
+	dh_systemd_enable
 	dh_installinit --name=libvirt-guests --no-restart-on-upgrade -- defaults 29 71
 	-mv debian/libvirt-bin/lib/systemd/system/libvirtd.service \
 	    debian/libvirt-bin/lib/systemd/system/libvirt-bin.service
+	dh_systemd_start
 	rm debian/libvirt-bin/usr/lib/libvirt/connection-driver/*.la
 
 	for l in $(LOGROTATE); do \
-- 
1.7.10.4

diff -ur OLD/control NEW/control
--- OLD/control	2013-06-12 15:08:24.000000000 +0200
+++ NEW/control	2013-06-26 19:55:01.000000000 +0200
@@ -3,8 +3,8 @@
 Version: 1.0.6-1
 Architecture: amd64
 Maintainer: Debian Libvirt Maintainers <pkg-libvirt-maintain...@lists.alioth.debian.org>
-Installed-Size: 8299
-Depends: libaudit0 (>= 1.7.13), libavahi-client3 (>= 0.6.16), libavahi-common3 (>= 0.6.16), libblkid1 (>= 2.17.2), libc6 (>= 2.17), libcap-ng0, libdbus-1-3 (>= 1.0.2), libdevmapper1.02.1 (>= 2:1.02.20), libgcrypt11 (>= 1.4.5), libgnutls26 (>= 2.12.17-0), libnetcf1 (>= 1:0.2.2), libnl-3-200 (>= 3.2.7), libnl-route-3-200 (>= 3.2.7), libnuma1, libparted0debian1 (>= 2.2-1), libpcap0.8 (>= 1.0.0), libpciaccess0, libreadline6 (>= 6.0), libsasl2-2 (>= 2.1.24), libudev0 (>= 0.140), libvirt0 (= 1.0.6-1), libxenstore3.0 (>= 3.2.0), libxml2 (>= 2.7.4), libyajl2 (>= 2.0.4), adduser, logrotate, gettext-base
+Installed-Size: 8110
+Depends: libaudit0 (>= 1.7.13), libavahi-client3 (>= 0.6.16), libavahi-common3 (>= 0.6.16), libblkid1 (>= 2.17.2), libc6 (>= 2.17), libcap-ng0, libdbus-1-3 (>= 1.0.2), libdevmapper1.02.1 (>= 2:1.02.20), libgcrypt11 (>= 1.4.5), libgnutls26 (>= 2.12.17-0), libnetcf1 (>= 1:0.2.2), libnl-3-200 (>= 3.2.7), libnl-route-3-200 (>= 3.2.7), libnuma1, libparted0debian1 (>= 2.2-1), libpcap0.8 (>= 1.0.0), libpciaccess0, libreadline6 (>= 6.0), libsasl2-2 (>= 2.1.24), libudev0 (>= 0.140), libvirt0 (= 1.0.6-1), libxenstore3.0 (>= 3.2.0), libxml2 (>= 2.7.4), libyajl2 (>= 2.0.4), init-system-helpers (>= 1.3), adduser, logrotate, gettext-base
 Recommends: netcat-openbsd, bridge-utils, dnsmasq-base (>= 2.46-1), iptables (>= 1.4.10), qemu-kvm | qemu (>= 0.9.1), libxml2-utils, gawk, ebtables, dmidecode, iproute, parted, pm-utils
 Suggests: policykit-1, radvd, auditd, systemtap
 Enhances: qemu, qemu-kvm, xen
diff -ur OLD/postinst NEW/postinst
--- OLD/postinst	2013-06-12 15:08:04.000000000 +0200
+++ NEW/postinst	2013-06-26 19:54:54.000000000 +0200
@@ -104,12 +104,6 @@
 	    sleep 1
 	fi
 
-	# enable libvirt-{bin,guests} for systemd
-	if [ -x /bin/systemctl ] && [ -d /sys/fs/cgroup/systemd ]; then
-            systemctl enable libvirt-bin.service
-            systemctl enable libvirt-guests.service
-	fi
-
 	if dpkg --compare-versions "$2" lt "0.6.1-2"; then
 	    if [ -e /etc/rc2.d/S20libvirt-bin ] && \
 	       [ -e /etc/rc3.d/S20libvirt-bin ] && \
@@ -147,12 +141,23 @@
 	invoke-rc.d libvirt-bin start || exit $?
 fi
 # End automatically added section
+# Automatically added by dh_systemd_enable
+if [ -x "/usr/bin/deb-systemd-helper" ]; then
+	deb-systemd-helper enable virtlockd.service virtlockd.socket libvirtd.service libvirt-guests.service >/dev/null || true
+fi
+# End automatically added section
 # Automatically added by dh_installinit
 if [ -x "/etc/init.d/libvirt-guests" ]; then
 	update-rc.d libvirt-guests defaults 29 71 >/dev/null
 	invoke-rc.d libvirt-guests start || exit $?
 fi
 # End automatically added section
+# Automatically added by dh_systemd_start
+if [ -d /run/systemd/system ]; then
+	systemctl --system daemon-reload >/dev/null || true
+	deb-systemd-invoke start virtlockd.service virtlockd.socket >/dev/null || true
+fi
+# End automatically added section
 
 
 exit 0
diff -ur OLD/postrm NEW/postrm
--- OLD/postrm	2013-06-12 15:08:04.000000000 +0200
+++ NEW/postrm	2013-06-26 19:54:54.000000000 +0200
@@ -47,6 +47,11 @@
 # dh_installdeb will replace this with shell code automatically
 # generated by other debhelper scripts.
 
+# Automatically added by dh_systemd_start
+if [ -d /run/systemd/system ]; then
+	systemctl --system daemon-reload >/dev/null || true
+fi
+# End automatically added section
 # Automatically added by dh_installinit
 if [ "$1" = "purge" ] ; then
 	update-rc.d libvirt-guests remove >/dev/null
@@ -59,6 +64,19 @@
 	systemctl --system daemon-reload >/dev/null || true
 fi
 # End automatically added section
+# Automatically added by dh_systemd_enable
+if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
+	if [ -x "/usr/bin/deb-systemd-helper" ]; then
+		if [ "$1" = "purge" ]; then
+			export _DEB_SYSTEMD_HELPER_PURGE=1
+		else
+			# To explicitly clean the environment.
+			export _DEB_SYSTEMD_HELPER_PURGE=0
+		fi
+		deb-systemd-helper disable virtlockd.service virtlockd.socket libvirtd.service libvirt-guests.service >/dev/null
+	fi
+fi
+# End automatically added section
 # Automatically added by dh_installinit
 if [ "$1" = "purge" ] ; then
 	update-rc.d libvirt-bin remove >/dev/null
diff -ur OLD/prerm NEW/prerm
--- OLD/prerm	2013-06-12 15:08:04.000000000 +0200
+++ NEW/prerm	2013-06-26 19:54:54.000000000 +0200
@@ -1,5 +1,10 @@
 #!/bin/sh
 set -e
+# Automatically added by dh_systemd_start
+if [ -d /run/systemd/system ]; then
+	deb-systemd-invoke stop virtlockd.service virtlockd.socket >/dev/null
+fi
+# End automatically added section
 # Automatically added by dh_installinit
 if [ -x "/etc/init.d/libvirt-guests" ] && [ "$1" = remove ]; then
 	invoke-rc.d libvirt-guests stop || exit $?

Reply via email to