[Pkg-alsa-devel] [Debian ALSA CVS] debian/alsa-driver/debian (3 files)

Thomas Hood jdthood-guest@haydn.debian.org
Thu, 02 Sep 2004 05:40:33 -0600


    Date: Thursday, September 2, 2004 @ 05:40:33
  Author: jdthood-guest
    Path: /cvsroot/pkg-alsa/debian/alsa-driver/debian

Modified: alsa-base.conf alsa-base.postinst changelog

Fix up alsa-base.postinst; update changelog accordingly; fix error in alsa-base.conf comment


--------------------+
 alsa-base.conf     |    2 -
 alsa-base.postinst |   74 ++++++++++++++++++++++++++++-----------------------
 changelog          |   15 ++++++++++
 3 files changed, 58 insertions(+), 33 deletions(-)


Index: debian/alsa-driver/debian/alsa-base.conf
diff -u debian/alsa-driver/debian/alsa-base.conf:1.7 debian/alsa-driver/debian/alsa-base.conf:1.8
--- debian/alsa-driver/debian/alsa-base.conf:1.7	Thu Sep  2 04:49:00 2004
+++ debian/alsa-driver/debian/alsa-base.conf	Thu Sep  2 05:40:33 2004
@@ -1,7 +1,7 @@
 # Configuration file for alsa-base.
 
 # alsactl_store_on_shutdown is used to determine when "alsactl store" will
-# be executed. If the setting is 'autosave always' then the command will
+# be executed. If the setting is 'always autosave' then the command will
 # be executed on shutdown (if the setting of the runlevels_save variable
 # permits this). If the setting is 'autosave once at next shutdown' then
 # the command will be executed on the next shutdown and never again (if
Index: debian/alsa-driver/debian/alsa-base.postinst
diff -u debian/alsa-driver/debian/alsa-base.postinst:1.39 debian/alsa-driver/debian/alsa-base.postinst:1.40
--- debian/alsa-driver/debian/alsa-base.postinst:1.39	Tue Aug 31 21:16:41 2004
+++ debian/alsa-driver/debian/alsa-base.postinst	Thu Sep  2 05:40:33 2004
@@ -1,38 +1,51 @@
 #!/bin/sh
 
 set -e
-		
-if [ "$1" = "configure" ]; then
-    filename=""
-    if [ ! -f /etc/default/alsa ]; then
-	if [ -f /etc/alsa/alsa-base.conf ]; then
-	    filename="/etc/alsa/alsa-base.conf"
-	elif [ -f /etc/alsa-base.conf ]; then
-	    filename="/etc/alsa-base.conf"
-	fi
-	if [ -n "$filename" ]; then
-	    printf "Note: Moving $filename to /etc/default/alsa\n"
-	    mv $filename /etc/default/alsa
-	fi
-    fi
-fi
 
 . /usr/share/debconf/confmodule
 db_version 2.0
-
+		
 case "$1" in
-    configure)
+    configure|reconfigure)
+	# Ensure that there is a conf file to work on
 	if [ ! -f /etc/default/alsa ]; then
-	    cp /usr/share/alsa-base/alsa-base.conf /etc/default/alsa
-	else
-	    db_get alsa-base/alsactl_store_on_shutdown
-	    alsactl_store_on_shutdown="$RET"
-	    sed -e "s/alsactl_store_on_shutdown=.*/alsactl_store_on_shutdown=\"$alsactl_store_on_shutdown\"/" /etc/default/alsa > /etc/default/alsa.tmp
-	    mv /etc/default/alsa /etc/default/alsa.debconf-backup
-	    mv /etc/default/alsa.tmp /etc/default/alsa
+	    old_conf_filename=""
+	    if [ -f /etc/alsa/alsa-base.conf ]; then
+		old_conf_filename="/etc/alsa/alsa-base.conf"
+	    elif [ -f /etc/alsa-base.conf ]; then
+		old_conf_filename="/etc/alsa-base.conf"
+	    fi
+	    if [ "$old_conf_filename" ]; then
+		echo "Moving old configuration file $old_conf_filename to /etc/default/alsa"
+		cat "$old_conf_filename" > /etc/default/alsa
+		rm -f "$old_conf_filename"
+	    fi
+	fi
+	if [ ! -f /etc/default/alsa ]; then
+	    cat /usr/share/alsa-base/alsa-base.conf > /etc/default/alsa
 	fi
-	if [ ! -c /dev/audio -a ! -c /dev/dsp -a ! -c /dev/amixer ] || [ -h /dev/snd -o ! -d /dev/snd ]; then
-	    if [ ! -e /dev/.devfsd -a ! -e /dev/.udev.tdb ]; then
+	# Update conf file from debconf database
+	# (This is kosher so long as the debconf values were initialized from
+	# the conf file; thus administrator settings are preserved.)
+	db_get alsa-base/alsactl_store_on_shutdown
+	case "$RET" in
+		"autosave always") alsactl_store_on_shutdown="always autosave" ;;
+		*) alsactl_store_on_shutdown="$RET" ;;
+	esac
+	sed -e "s/alsactl_store_on_shutdown=.*/alsactl_store_on_shutdown=\"${alsactl_store_on_shutdown}\"/" /etc/default/alsa > /etc/default/alsa.tmp
+	rm -f /etc/default/alsa.dpkg-old
+	mv -f /etc/default/alsa /etc/default/alsa.dpkg-old
+	mv -f /etc/default/alsa.tmp /etc/default/alsa
+	# Ensure asound.state exists unless user has chosen "never autosave" 
+	if [ "$alsactl_store_on_shutdown" != "never autosave" ] ; then
+	    [ -f /var/lib/alsa/asound.state ] || alsactl store >/dev/null 2>&1 || :
+	fi
+	# Run snddevices if required
+	if \
+	    { [ ! -c /dev/audio ] && [ ! -c /dev/dsp ] && [ ! -c /dev/amixer ] ; } \
+	    || { [ -L /dev/snd ] || [ ! -d /dev/snd ] ; }
+	then
+	    if [ ! -e /dev/.devfsd ] && [ ! -e /dev/.udev.tdb ]; then
 		/usr/share/alsa-base/snddevices > /dev/null
 	    fi
 	fi
@@ -41,17 +54,14 @@
 	fi
 	;;
     abort-upgrade|abort-remove|abort-deconfigure)
+	# We don't have to do anything because we didn't do anything in prerm
 	exit 0
 	;;
     *)
-	echo "postinst called with unknown argument \`$1'" >&2;
-	exit 0;
+	echo "postinst called with unknown argument \`$1'" >&2
+	exit 1
 	;;
 esac
-
-if [ -z "$alsactl_store_on_shutdown" -o "$alsactl_store_on_shutdown" = 'autosave always' -o "$alsactl_store_on_shutdown" = 'always autosave' ]; then
-    alsactl store >/dev/null 2>&1 || true
-fi
 
 #DEBHELPER#
 
Index: debian/alsa-driver/debian/changelog
diff -u debian/alsa-driver/debian/changelog:1.266 debian/alsa-driver/debian/changelog:1.267
--- debian/alsa-driver/debian/changelog:1.266	Thu Sep  2 04:49:00 2004
+++ debian/alsa-driver/debian/changelog	Thu Sep  2 05:40:33 2004
@@ -43,6 +43,21 @@
       + Don't pad '...' with spaces (as per policy 9.4)
     - /etc/default/alsa
       + Try to improve comments some more
+    - alsa-base.postinst
+      + Clean up, add comments
+      + Run confmodule at the beginning since it restarts the script
+      + Eliminate use of test's -a and -o options
+      + exit 1 on illegal argument
+      + Use '.dpkg-old' as backup-file extension
+      + Only initialize asound.state if it doesn't already
+        exits (Closes: #188595)
+      + Update from debconf database even if conf file is
+        initialized from /usr/share/alsa-base/alsa-base.conf
+        (Closes: #269212)
+      + Use cat instead of cp in order to handle the case
+        where people have replaced conf files by symlinks
+      + Always use -f option with mv and rm
+      + Replace 'autosave always' by 'always autosave'
   * Unreleased.
 
  -- Steve Kowalik <stevenk@debian.org>  Wed,  1 Sep 2004 13:07:24 +1000