Subject: alsa-utils: alsa-restore.service uses /run wiich is tmpfs

From: GT <[email-masked]>
Date: Thu, 17 Aug 2017 21:22:26 +0200

Package: alsa-utils
Version: 1.1.3-1
Severity: normal

Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?
modified  values with alsamixer are not restored at boot
   * What exactly did you do (or not do) that was effective (or
     ineffective)?
use alsamixer
reboot
   * What was the outcome of this action?
cursors are not well restored
   * What outcome did you expect instead?
same values than before the boot

i modify to  use /var/lib/alsa

cat /lib/systemd/system/alsa-restore.service
#
# Note that two different ALSA card state management schemes exist and they
# can be switched using a file exist check - /etc/alsa/state-daemon.conf .
#

[Unit]
Description=Save/Restore Sound Card State
Documentation=man:alsactl(1)
ConditionPathExists=!/etc/alsa/state-daemon.conf
ConditionPathExistsGlob=/dev/snd/control*
After=alsa-state.service

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=-/usr/sbin/alsactl -E HOME=/var/lib/alsa restore
ExecStop=-/usr/sbin/alsactl -E HOME=/var/lib/alsa store

-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-3-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages alsa-utils depends on:
ii  kmod              24-1
ii  libasound2        1.1.3-5
ii  libc6             2.24-12
ii  libfftw3-single3  3.3.6p2-1
ii  libncursesw5      6.0+20170715-2
ii  libsamplerate0    0.1.8-8+b2
ii  libtinfo5         6.0+20170715-2
ii  lsb-base          9.20161125
ii  whiptail          0.52.20-1+b1

alsa-utils recommends no packages.

alsa-utils suggests no packages.

-- Configuration Files:
/etc/init.d/alsa-utils changed:
[ -x /usr/sbin/alsactl ] || exit 0
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MYNAME=/etc/init.d/alsa-utils
ALSACTLHOME=/run/alsa
[ -d "$ALSACTLHOME" ] || mkdir -p "$ALSACTLHOME"
. /lib/lsb/init-functions
. /usr/share/alsa/utils.sh
log_action_end_msg_and_exit()
{
	log_action_end_msg "$1" ${2:+"$2"}
	exit $1
}
executable()
{
	# If which is not available then we must be running before
	# /usr is mounted on a system that has which in /usr/bin/.
	# Conclude that $1 is not executable.
	[ -x /bin/which ] || [ -x /usr/bin/which ] || return 1
	which "$1" >/dev/null 2>&1
}
executable amixer || { echo "${MYNAME}: Error: No amixer program available." >&2 ; exit 1 ; }
restore_levels()
{
	[ -f /var/lib/alsa/asound.state ] || return 1
	CARD="$1"
	[ "$1" = all ] && CARD=""
	# Assume that if alsactl prints a message on stderr
	# then it failed somehow.  This works around the fact
	# that alsactl doesn't return nonzero status when it
	# can't restore settings for the card
	touch /home/guy/alsa-utils-ok.txt
	if MSG="$(alsactl -E HOME="$ALSACTLHOME" restore $CARD 2>&1 >/dev/null)" && [ ! "$MSG" ] ; then
		return 0
	else
		# Retry with the "force" option.  This restores more levels
		# but it results in much longer error messages.
		alsactl -F restore $CARD >/dev/null 2>&1
		log_action_cont_msg "warning: 'alsactl -E HOME="$ALSACTLHOME" restore${CARD:+ $CARD}' failed with error message '$MSG'"
		return 1
	fi
}
store_levels()
{
	CARD="$1"
	[ "$1" = all ] && CARD=""
	if MSG="$(alsactl -E HOME="$ALSACTLHOME" store $CARD 2>&1)" ; then
		sleep 1
		return 0
	else
		log_action_cont_msg "warning: 'alsactl store${CARD:+ $CARD}' failed with error message '$MSG'"
		return 1
	fi
}
mute_and_zero_levels_on_card()
{
	CARDOPT="-c $1"
	for CTL in \
		Master \
		PCM \
		Synth \
		CD \
		Line \
		Mic \
		"PCM,1" \
		Wave \
		Music \
		AC97 \
		"Master Digital" \
		DAC \
		"DAC,0" \
		"DAC,1" \
		Headphone \
		Speaker \
		Playback
	do
		mute_and_zero_level "$CTL"
	done
	return 0
}
mute_and_zero_levels()
{
	TTZML_RETURNSTATUS=0
	case "$1" in
	  all)
		for CARD in $(echo_card_indices) ; do
			mute_and_zero_levels_on_card "$CARD" || TTZML_RETURNSTATUS=1
		done
		;;
	  *)
		mute_and_zero_levels_on_card "$1" || TTZML_RETURNSTATUS=1
		;;
	esac
	return $TTZML_RETURNSTATUS
}
card_OK()
{
	[ "$1" ] || bugout
	if [ "$1" = all ] ; then
		[ -d /proc/asound ]
		return $?
	else
		[ -d "/proc/asound/card$1" ] || [ -d "/proc/asound/$1" ]
		return $?
	fi
}
case "$1" in
  start)
	EXITSTATUS=0
	TARGET_CARD="$2"
	case "$TARGET_CARD" in
	  ""|all) TARGET_CARD=all ; log_action_begin_msg "Setting up ALSA" ;;
	  *) log_action_begin_msg "Setting up ALSA card ${TARGET_CARD}" ;;
	esac
	card_OK "$TARGET_CARD" || log_action_end_msg_and_exit "$( [ ! "$2" ] ; echo $? ; )" "none loaded"
	preinit_levels "$TARGET_CARD" || EXITSTATUS=1
	if ! restore_levels "$TARGET_CARD" ; then
		sanify_levels "$TARGET_CARD" || EXITSTATUS=1
		restore_levels "$TARGET_CARD" >/dev/null 2>&1 || :
	fi
	log_action_end_msg_and_exit "$EXITSTATUS"
	;;
  stop)
	EXITSTATUS=0
	TARGET_CARD="$2"
	case "$TARGET_CARD" in
	  ""|all) TARGET_CARD=all ; log_action_begin_msg "Shutting down ALSA" ;;
	  *) log_action_begin_msg "Shutting down ALSA card ${TARGET_CARD}" ;;
	esac
	card_OK "$TARGET_CARD" || log_action_end_msg_and_exit "$( [ ! "$2" ] ; echo $? ; )" "none loaded"
	store_levels "$TARGET_CARD" || EXITSTATUS=1
	#mute_and_zero_levels "$TARGET_CARD" || EXITSTATUS=1
	log_action_end_msg_and_exit "$EXITSTATUS"
	;;
  restart|force-reload)
	EXITSTATUS=0
	$0 stop || EXITSTATUS=1
	$0 start || EXITSTATUS=1
	exit $EXITSTATUS
	;;
  reset)
	TARGET_CARD="$2"
	case "$TARGET_CARD" in
	  ""|all) TARGET_CARD=all ; log_action_begin_msg "Resetting ALSA" ;;
	  *) log_action_begin_msg "Resetting ALSA card ${TARGET_CARD}" ;;
	esac
	card_OK "$TARGET_CARD" || log_action_end_msg_and_exit "$( [ ! "$2" ] ; echo $? ; )" "none loaded"
	preinit_levels "$TARGET_CARD"
	sanify_levels "$TARGET_CARD"
	log_action_end_msg_and_exit "$?"
	;;
  *)
	echo "Usage: $MYNAME {start [CARD]|stop [CARD]|restart [CARD]|reset [CARD]}" >&2
	exit 3
	;;
esac

-- no debconf information