[Pkg-alsa-devel] [Debian ALSA CVS] debian/alsa-utils/debian (changelog postrm)

David B Harris dbharris-guest@quantz.debian.org
Fri, 27 Feb 2004 00:50:30 +0100


    Date: Friday, February 27, 2004 @ 00:50:30
  Author: dbharris-guest
    Path: /cvsroot/pkg-alsa/debian/alsa-utils/debian

Modified: changelog postrm

Add abort-{upgrade,install} support so that /var/lib/alsa/asound.state is moved back to /etc/ on a failed upgrade.


-----------+
 changelog |    4 +++-
 postrm    |   30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)


Index: debian/alsa-utils/debian/changelog
diff -u debian/alsa-utils/debian/changelog:1.9 debian/alsa-utils/debian/changelog:1.10
--- debian/alsa-utils/debian/changelog:1.9	Fri Feb 27 00:30:33 2004
+++ debian/alsa-utils/debian/changelog	Fri Feb 27 00:50:29 2004
@@ -12,9 +12,11 @@
     - debian/postinst: If /etc/asound.state exists, copy it to /var/lib/alsa.
       alsa-base will require a versioned Depends: on this package so that
       restarting ALSA in its postinst will get the state from the right place.
+    - debian/postrm: Add abort-{upgrade,install} support so that
+      /var/lib/alsa/asound.state is moved back to /etc/ on a failed upgrade.
   * Unreleased.
 
- -- David B. Harris <dbharris@debian.org>  Thu, 26 Feb 2004 18:29:43 -0500
+ -- David B. Harris <dbharris@debian.org>  Thu, 26 Feb 2004 18:49:59 -0500
 
 alsa-utils (1.0.2-1) unstable; urgency=low
 
Index: debian/alsa-utils/debian/postrm
diff -u debian/alsa-utils/debian/postrm:1.1 debian/alsa-utils/debian/postrm:1.2
--- debian/alsa-utils/debian/postrm:1.1	Mon Feb  9 00:14:34 2004
+++ debian/alsa-utils/debian/postrm	Fri Feb 27 00:50:29 2004
@@ -4,4 +4,34 @@
   rm -f /etc/alsa/0.9/asound.conf
 fi
 
+if [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-install" ]; then
+    if [ "$#" -ge "2" ]; then
+	OLDVERSION="$2"
+	if dpkg --compare-versions "$OLDVERSION" '<<' '1.0.2-2'; then
+	    if [ -f /var/lib/alsa/asound.state ]; then
+		if [ -f /etc/asound.state ]; then
+		    if ! cmp /var/lib/alsa/asound.state /etc/asound.state; then
+			# /var/lib/alsa/asound.state and /etc/asound.state both exist,
+			# but differ.
+			echo "Warning, /var/lib/alsa/sound.state and /etc/asound.state both exist."
+			echo "Removing /var/lib/alsa/asound.conf. You may wish to run 'alsactl store'"
+			# We do need to remove this file, otherwise we'll have yet
+			# another maintainer script failure [the only reason we're here
+			# is because the upgrade was aborted]
+			rm -f /var/lib/alsa/asound.state
+		    else
+			# /var/lib/alsa/asound.state and /etc/asound.state both exist,
+			# but they're identical - remove /var/lib/alsa/asound.state
+			rm -f /var/lib/alsa/asound.state
+		    fi
+		else
+		    # /var/lib/alsa/asound.state exists, and /etc/asound.state doesn't.
+		    # Put asound.state back in /etc
+		    mv /var/lib/alsa/asound.state /etc/asound.state
+		fi
+	    fi
+	fi
+    fi
+fi
+
 #DEBHELPER#