%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/lib/dpkg/info/
Upload File :
Create Path :
Current File : /var/lib/dpkg/info/alsa-base.postinst

#!/bin/sh

set -e

MYNAME="$0"

# $* message
warn() { echo "${MYNAME}: Warning: $*" >&2 ; }

# $* message
report_error() { echo "${MYNAME}: Error: $*" >&2 ; }

# Move a conffile without triggering a dpkg question
mv_conffile() {
    OLDCONFFILE="$1"
    NEWCONFFILE="$2"

    if [ -e "$OLDCONFFILE" ]; then
        echo "Preserving user changes to $NEWCONFFILE"
        mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
        mv -f "$OLDCONFFILE" "$NEWCONFFILE"
    elif [ -e "$OLDCONFFILE".dpkg-bak ]; then
        rm -f "$OLDCONFFILE".dpkg-bak
    fi
}

case "$1" in
configure|reconfigure)
	if dpkg --compare-versions "$2" lt "1.0.23+dfsg-1ubuntu4"; then
		mv_conffile /etc/modprobe.d/alsa-base \
			    /etc/modprobe.d/alsa-base.conf
		mv_conffile /etc/modprobe.d/blacklist-modem \
			    /etc/modprobe.d/blacklist-modem.conf
	fi
	# Decide which conf file to read
	conf_file=""
	if [ -f /etc/default/alsa ] ; then
		conf_file=/etc/default/alsa
	elif [ -f /usr/share/alsa-base/alsa.default ] ; then
		conf_file=/usr/share/alsa-base/alsa.default
	else
		report_error "No configuration file found"
		exit 1
	fi
	# Read variables from conf file
	force_unload_modules_before_suspend="$( 
		. "$conf_file" >/dev/null 2>&1
		echo "$force_unload_modules_before_suspend"
	)"
	# Write new conf file
	cat /usr/share/alsa-base/alsa.default | sed \
		-e "s/force_unload_modules_before_suspend=.*/force_unload_modules_before_suspend=\"${force_unload_modules_before_suspend}\"/" \
		> /etc/default/alsa
	# Set up apm symlinks
	[ -f /etc/apm/scripts.d/alsa ] || warn "/etc/apm/scripts.d/alsa is absent"
	# $1: file to check
	already_linked_to_alsa()
	{
		[ "$1" ] || return 1
		[ -L "$1" ] || return 1
		[ "$(basename "$(readlink "$1")")" = alsa ] || return 1
		return 0
	}
	ALREADY_LINKED=no
	for F in /etc/apm/suspend.d/??alsa ; do
		already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
	done
	[ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/suspend.d/80alsa
	ALREADY_LINKED=no
	for F in /etc/apm/resume.d/??alsa ; do
		already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
	done
	[ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/resume.d/20alsa
	;;
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 1
	;;
esac



Zerion Mini Shell 1.0