alsactl: Move systemd unit start-up from basic.target to sound.target

Ensures soundcard is ready before restoring state.

sound.target added to systemd in v18:
https://cgit.freedesktop.org/systemd/systemd/commit/?id=88dfa2938af

Simplify dependencies:
 - After=alsa-state.service is not needed because both units test for
   @daemonswitch@ with opposite outcomes.

 - After=sysinit.target is automatically added by systemd.

First proposed by Tom Yan.

Signed-off-by: Chris Mayo <aklhfex@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Chris Mayo 2017-09-26 19:36:12 +01:00 committed by Takashi Iwai
parent dbd4fc84f8
commit f72a296d23
5 changed files with 10 additions and 5 deletions

View file

@ -10,6 +10,9 @@ the develop package additionally to link with this library.
alsaconf requires dialog or whiptail program to run properly. alsaconf requires dialog or whiptail program to run properly.
If systemd (minimum version 18) is installed it will be used to run
alsactl to store and restore settings.
Installation Installation
------------ ------------

View file

@ -29,8 +29,8 @@ systemdsystemunit_DATA = \
install-data-hook: install-data-hook:
$(MKDIR_P) -m 0755 \ $(MKDIR_P) -m 0755 \
$(DESTDIR)$(systemdsystemunitdir)/basic.target.wants $(DESTDIR)$(systemdsystemunitdir)/sound.target.wants
( cd $(DESTDIR)$(systemdsystemunitdir)/basic.target.wants && \ ( cd $(DESTDIR)$(systemdsystemunitdir)/sound.target.wants && \
rm -f alsa-state.service alsa-restore.service && \ rm -f alsa-state.service alsa-restore.service && \
$(LN_S) ../alsa-state.service alsa-state.service && \ $(LN_S) ../alsa-state.service alsa-state.service && \
$(LN_S) ../alsa-restore.service alsa-restore.service) $(LN_S) ../alsa-restore.service alsa-restore.service)

View file

@ -7,7 +7,6 @@
Description=Save/Restore Sound Card State Description=Save/Restore Sound Card State
ConditionPathExists=!@daemonswitch@ ConditionPathExists=!@daemonswitch@
ConditionPathExistsGlob=/dev/snd/control* ConditionPathExistsGlob=/dev/snd/control*
After=alsa-state.service
[Service] [Service]
Type=oneshot Type=oneshot

View file

@ -6,7 +6,6 @@
[Unit] [Unit]
Description=Manage Sound Card State (restore and store) Description=Manage Sound Card State (restore and store)
ConditionPathExists=@daemonswitch@ ConditionPathExists=@daemonswitch@
After=sysinit.target
[Service] [Service]
Type=simple Type=simple

View file

@ -383,13 +383,17 @@ SAVE_UTIL_VERSION
AC_SUBST(LIBRT) AC_SUBST(LIBRT)
dnl Check for systemd dnl Check for systemd
PKG_CHECK_MODULES(SYSTEMD, [systemd >= 18],
[have_min_systemd="yes"],
[have_min_systemd="no"])
AC_ARG_WITH([systemdsystemunitdir], AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]), AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
[], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)]) [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
if test "x$with_systemdsystemunitdir" != xno; then if test "x$with_systemdsystemunitdir" != xno; then
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir]) AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
fi fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ]) AM_CONDITIONAL(HAVE_SYSTEMD, [test "$have_min_systemd" = "yes" \
-a -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
AC_ARG_WITH([asound-state-dir], AC_ARG_WITH([asound-state-dir],
AS_HELP_STRING([--with-asound-state-dir=DIR], [Directory to place asound.state file in]), AS_HELP_STRING([--with-asound-state-dir=DIR], [Directory to place asound.state file in]),