File: alsa-base.postinst

package info (click to toggle)
alsa-driver 1.0.13-5etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 20,108 kB
  • ctags: 50,477
  • sloc: ansic: 319,881; sh: 32,930; makefile: 2,015; python: 1,527; perl: 1,316; xml: 896; awk: 66
file content (139 lines) | stat: -rw-r--r-- 4,385 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/sh

set -e

MYNAME="$0"

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

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

devfs_is_active()
{
	test -e /dev/.devfsd
}

kernel_is_2_6_or_above()
{
	case "$(uname -r)" in
		1.*|2.[012345]*) return 1 ;;
		*) return 0 ;;
	esac
}

udev_is_active()
{
	test -e /dev/.udev.tdb || test -d /dev/.udevdb || return 1
	kernel_is_2_6_or_above || return 1
	return 0
}

case "$1" in
configure|reconfigure)
	# Remove old obsolete configuration files
	# (Keep this until etch)
	if [ -d /etc/sound ]; then 
		rmdir /etc/sound 2> /dev/null || :
	fi
	rm -f \
		/etc/apm/event.d/alsa \
		/etc/apm/event.d/alsa.dpkg-old \
		/etc/default/alsa.debconf-backup \
		/etc/devfs/conf.d/alsa \
		/etc/discover.conf.d/10alsa \
		/etc/discover.conf.d/10alsa.dpkg-old \
		/etc/alsa/alsa-base.conf \
		/etc/alsa/modutils/0.5 \
		/etc/alsa/modutils/0.9 \
		/etc/alsa/modutils/1.0 \
		/etc/alsa/modutils/0.5.debconf-backup \
		/etc/alsa/modutils/0.9.debconf-backup \
		/etc/alsa/modutils/1.0.debconf-backup \
		/etc/alsa/modprobe-post-install.d/alsa-base \
		/etc/alsa/modprobe-post-install.d/alsa-base.dpkg-old \
		/etc/modutils/alsa \
		/etc/modutils/alsa-path \
		/etc/modprobe.d/alsa
	# Delete hotplug blacklist backup file since hotplug doesn't ignore
	# it as it should (#299205)
	rm -f \
		/etc/hotplug/blacklist.d/alsa-base.dpkg-old
	# Delete obsolete rc symlinks to alsa init.d script
	# (update-rc.d produces an unnecessary warning message on stderr (see #164471) so print the error message only if its error status is nonzero)
	STDERR="$(update-rc.d -f alsa remove 2>&1 >/dev/null)" || echo "Warning: 'update-rc.d -f alsa remove' reported: '$STDERR'." >&2
	# Update modutils config
	[ "$(which update-modules 2>/dev/null)" ] && update-modules >/dev/null || :
	# 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
	# Run snddevices if required
	# We ignore #309581 "Creating devices not using MAKEDEV violates policy 10.6"
	make_snddevices() { /usr/share/alsa-base/snddevices --no-wipe --owner=root.audio "$@" >/dev/null ; }
	if devfs_is_active ; then
		# devfs /dev/
		# Run update-devfsd because we have eliminated the devfsd configuration file
		[ "$(which update-devfsd 2>/dev/null)" ] && update-devfsd
	else
		if ! udev_is_active || [ "$WRITE_ON_UDEV" ] ; then
			# static /dev/ or udev-controlled /dev/ that we should write on
			[ -d /dev/snd ] || make_snddevices
		else
			# udev-controlled /dev/ which we shouldn't overwrite
			if [ -d /dev/.static/dev ] && [ -e /proc/mounts ] && grep -qE '^[^ ]+ /dev/\.static/dev' /proc/mounts ; then
				[ -d /dev/.static/dev/snd ] || make_snddevices --dev-dir=/dev/.static/dev > /dev/null
			elif [ -d /.dev ] && [ -e /proc/mounts ] && grep -qE '^[^ ]+ /\.dev' /proc/mounts ; then
				[ -d /.dev/snd ] || make_snddevices --dev-dir=/.dev > /dev/null
			fi
		fi
	fi
	# 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

#DEBHELPER#