[Pkg-ganeti-devel] [ganeti] 14/29: Maintainer script overhaul for 2.10

Apollon Oikonomopoulos apoikos at moszumanska.debian.org
Fri Mar 7 10:15:05 UTC 2014


This is an automated email from the git hooks/post-receive script.

apoikos pushed a commit to branch master
in repository ganeti.

commit 9f71a1c430a95028e330dfadf6392783cf981f33
Author: Apollon Oikonomopoulos <apoikos at debian.org>
Date:   Thu Feb 27 16:18:19 2014 +0200

    Maintainer script overhaul for 2.10
    
     • postinst: handle symlink creation and service restarts
       The version symlinks are created if appropriate.
    
     • postinst: manage service restarts: the service is only restarted if
       the symlinks changed or the running version was updated.
    
     • postrm: remove symlinks on remove/purge.
---
 debian/ganeti.postinst.in | 32 ++++++++++++++++++++++++++++++++
 debian/ganeti.postrm.in   |  3 +++
 debian/rules              |  7 +++++--
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/debian/ganeti.postinst.in b/debian/ganeti.postinst.in
index df39e7d..78002fc 100644
--- a/debian/ganeti.postinst.in
+++ b/debian/ganeti.postinst.in
@@ -41,6 +41,38 @@ case "$1" in
 		find /var/log/ganeti -user gnt-mond -exec chown root:root {} \;
 		deluser --system gnt-mond || true
 	fi
+
+	update_symlinks=0
+	# Handle symlinks...
+	# ... if we are upgrading from pre-2.10 versions
+	if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.10.0; then
+		update_symlinks=1
+
+	# ... or if we are not part of a cluster
+	elif ! /usr/lib/ganeti/@VER@/usr/lib/ganeti/daemon-util check-config; then
+		update_symlinks=1
+
+	# ... or if something is broken
+	elif [ ! -e /etc/ganeti/lib -o ! -e /etc/ganeti/share ]; then
+		update_symlinks=1
+	fi
+
+	if [ "$update_symlinks" = 1 ]; then
+		for target in lib share; do
+			if [ "$(readlink /etc/ganeti/${target})" != "/usr/${target}/ganeti/@VER@" ]; then
+				echo "Updating /etc/ganeti/${target}"
+				ln -snf /usr/${target}/ganeti/@VER@ /etc/ganeti/${target}
+			fi
+		done
+	fi
+
+	# Restart the service if we have either updated the symlinks, or
+	# shipped the same minor version
+	if [ "$update_symlinks" = 1 -o "${2%.*}" = "@VER@" ]; then
+		if [ -x "/etc/init.d/ganeti" ]; then
+			invoke-rc.d ganeti restart || true
+		fi
+	fi
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
diff --git a/debian/ganeti.postrm.in b/debian/ganeti.postrm.in
index d882c32..9237a17 100644
--- a/debian/ganeti.postrm.in
+++ b/debian/ganeti.postrm.in
@@ -20,9 +20,12 @@ set -e
 
 case "$1" in
     purge)
+	rm -f /etc/ganeti/share /etc/ganeti/lib
+
 	#GANETI_USERS#
     ;;
     remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+	rm -f /etc/ganeti/share /etc/ganeti/lib
     ;;
 
     *)
diff --git a/debian/rules b/debian/rules
index 9891fb9..d6c77f9 100755
--- a/debian/rules
+++ b/debian/rules
@@ -56,8 +56,11 @@ override_dh_auto_build:
 	dh_auto_build
 	mv doc/html doc/html.orig
 	$(MAKE) doc/html
+
+	# Generate postinst and postrm scripts
 	$(CURDIR)/debian/genscript.py postinst "$(CURDIR)" | \
-		sed -f "$(CURDIR)/autotools/replace_vars.sed" >"$(CURDIR)/debian/ganeti.postinst"
+		sed -f "$(CURDIR)/autotools/replace_vars.sed" \
+		    -e "s#@VER@#$(VER)#g" >"$(CURDIR)/debian/ganeti.postinst"
 	$(CURDIR)/debian/genscript.py postrm "$(CURDIR)" >"$(CURDIR)/debian/ganeti.postrm"
 
 # Add missing bits to ganeti and python-ganeti-rapi. We do not use
@@ -85,7 +88,7 @@ override_dh_python2:
 	dh_python2 -pganeti-$(VER) usr/share/ganeti/$(VER)
 
 override_dh_installinit:
-	dh_installinit --error-handler=true -i -- defaults 20 80
+	dh_installinit --error-handler=true --no-restart-on-upgrade -i -- defaults 20 80
 
 override_dh_compress:
 	dh_compress

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ganeti/ganeti.git



More information about the Pkg-ganeti-devel mailing list