Accepting request 76799 from home:vuntz:branches:multimedia:libs

bnc#707703: call setup-pulseaudio in %post

OBS-URL: https://build.opensuse.org/request/show/76799
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/pulseaudio?expand=0&rev=68
This commit is contained in:
Takashi Iwai 2011-07-22 16:27:43 +00:00 committed by Git OBS Bridge
parent d847de43d0
commit 9b92918303
4 changed files with 103 additions and 37 deletions

View File

@ -1,3 +1,28 @@
-------------------------------------------------------------------
Fri Jul 22 17:23:07 CEST 2011 - vuntz@opensuse.org
- Automatically configure the system for pulseaudio in %post:
+ Note that this change will forcefully enable PulseAudio on
systems where it had manually been disabled with
"setup-pulseaudio --disable" but without adding
PULSEAUDIO_ENABLE="no" to /etc/sysconfig/sound.
+ Install sysconfig.sound-pulseaudio template, and use fillup in
%post to merge it in /etc/sysconfig/sound. Add %fillup_prereq
PreReq for this.
+ This defines the PULSEAUDIO_ENABLE variable that can be set to
"yes", "no", "custom" (which means that the user has manually
changed the configuration). Set to "yes" by default.
+ Add --auto option setup-pulseaudio: this automatically
enables (resp. disables) pulseaudio if PULSEAUDIO_ENABLE is set
to "yes" (resp. "no"). It does nothing if PULSEAUDIO_ENABLE is
set to "custom".
+ Call "setup-pulseaudio --auto" in %post.
+ This fixes bnc#707703.
- Remove call to /sbin/SuSEconfig in setup-pulseaudio: it should
not be needed.
- Use sed instead of perl in setup-pulseaudio: this avoids leaving
empty lines when removing a line from the configuration.
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Mar 21 14:51:21 CET 2011 - tiwai@suse.de Mon Mar 21 14:51:21 CET 2011 - tiwai@suse.de

View File

@ -28,6 +28,7 @@ Group: System/Sound Daemons
Source: %{name}-%{version}.tar.bz2 Source: %{name}-%{version}.tar.bz2
Source1: default.pa-for-gdm Source1: default.pa-for-gdm
Source2: setup-pulseaudio Source2: setup-pulseaudio
Source3: sysconfig.sound-pulseaudio
Source99: baselibs.conf Source99: baselibs.conf
Patch0: disabled-start.diff Patch0: disabled-start.diff
# PATCH-FIX-UPSTREAM bnc666350-fix-incorrect-check-of-return-value.patch sreeves@novell.com -- fix to correctly report realtime status # PATCH-FIX-UPSTREAM bnc666350-fix-incorrect-check-of-return-value.patch sreeves@novell.com -- fix to correctly report realtime status
@ -58,6 +59,7 @@ BuildRequires: tcpd-devel
BuildRequires: translation-update-upstream BuildRequires: translation-update-upstream
BuildRequires: update-desktop-files BuildRequires: update-desktop-files
BuildRequires: xorg-x11-devel BuildRequires: xorg-x11-devel
PreReq: %fillup_prereq
PreReq: pwdutils PreReq: pwdutils
Recommends: alsa-plugins-pulse Recommends: alsa-plugins-pulse
Recommends: %{name}-lang Recommends: %{name}-lang
@ -273,6 +275,8 @@ rm -rf $RPM_BUILD_ROOT%{_libdir}/*.a
%find_lang %{name} %find_lang %{name}
install %SOURCE2 $RPM_BUILD_ROOT%{_bindir} install %SOURCE2 $RPM_BUILD_ROOT%{_bindir}
chmod 755 $RPM_BUILD_ROOT%{_bindir}/setup-pulseaudio chmod 755 $RPM_BUILD_ROOT%{_bindir}/setup-pulseaudio
install -d $RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates
install -m 0644 %SOURCE3 %{buildroot}%{_localstatedir}/adm/fillup-templates
mkdir -p $RPM_BUILD_ROOT/etc/profile.d mkdir -p $RPM_BUILD_ROOT/etc/profile.d
touch $RPM_BUILD_ROOT/etc/profile.d/pulseaudio.sh touch $RPM_BUILD_ROOT/etc/profile.d/pulseaudio.sh
touch $RPM_BUILD_ROOT/etc/profile.d/pulseaudio.csh touch $RPM_BUILD_ROOT/etc/profile.d/pulseaudio.csh
@ -301,7 +305,11 @@ groupadd -r pulse-access &>/dev/null || :
%postun -n libpulse-browse0 -p /sbin/ldconfig %postun -n libpulse-browse0 -p /sbin/ldconfig
%post -p /sbin/ldconfig %post
/sbin/ldconfig
%{fillup_only -an sound}
# Update the /etc/profile.d/pulseaudio.* files
setup-pulseaudio --auto > /dev/null
%postun -p /sbin/ldconfig %postun -p /sbin/ldconfig
@ -318,6 +326,7 @@ groupadd -r pulse-access &>/dev/null || :
# created by setup-pulseaudio script # created by setup-pulseaudio script
%ghost /etc/profile.d/pulseaudio.sh %ghost /etc/profile.d/pulseaudio.sh
%ghost /etc/profile.d/pulseaudio.csh %ghost /etc/profile.d/pulseaudio.csh
%{_localstatedir}/adm/fillup-templates/sysconfig.sound-pulseaudio
%dir %{_libdir}/pulse-%{drvver}/ %dir %{_libdir}/pulse-%{drvver}/
%dir %{_libdir}/pulse-%{drvver}/modules/ %dir %{_libdir}/pulse-%{drvver}/modules/
%{_libdir}/libpulsecore-%{drvver}.so %{_libdir}/libpulsecore-%{drvver}.so

View File

@ -3,11 +3,12 @@
LIST_OF_OSS_APPS="aumix sox" LIST_OF_OSS_APPS="aumix sox"
show_help() { show_help() {
echo "setup-pulseaudio [ --enable | --disable | --status ]" echo "setup-pulseaudio [ --enable | --disable | --auto | --status ]"
echo "" echo ""
echo "Modifies configuration files of some applications for PulseAudio" echo "Modifies configuration files of some applications for PulseAudio"
echo " --enable Enables PulseAudio" echo " --enable Enables PulseAudio"
echo " --disable Disables PulseAudio" echo " --disable Disables PulseAudio"
echo " --auto Automatically enables/disables PulseAudio based on configuration"
echo " --status Shows activation state (disabled or enabled) for PulseAudio" echo " --status Shows activation state (disabled or enabled) for PulseAudio"
echo "" echo ""
echo "You need to be root for this command to succeed" echo "You need to be root for this command to succeed"
@ -98,7 +99,7 @@ enable_speechd() {
echo "Enabling PulseAudio for speech dispatcher..." echo "Enabling PulseAudio for speech dispatcher..."
if test -f /etc/speech-dispatcher/speechd.conf; then if test -f /etc/speech-dispatcher/speechd.conf; then
if grep -q 'AudioOutputMethod' /etc/speech-dispatcher/speechd.conf; then if grep -q 'AudioOutputMethod' /etc/speech-dispatcher/speechd.conf; then
perl -pi -e "s|^.*AudioOutputMethod .*|AudioOutputMethod \"pulse\"|g;" /etc/speech-dispatcher/speechd.conf sed -i -e "s|^.*AudioOutputMethod .*|AudioOutputMethod \"pulse\"|g" /etc/speech-dispatcher/speechd.conf
else else
echo "AudioOutputMethod \"pulse\"" >> /etc/speech-dispatcher/speechd.conf echo "AudioOutputMethod \"pulse\"" >> /etc/speech-dispatcher/speechd.conf
fi fi
@ -158,7 +159,7 @@ EOF
enable_autospawn() { enable_autospawn() {
echo "Enabling PulseAudio autospawn..." echo "Enabling PulseAudio autospawn..."
if grep -q ^autospawn /etc/pulse/client.conf; then if grep -q ^autospawn /etc/pulse/client.conf; then
perl -pi -e "s|^autospawn.*|autospawn = yes|g;" /etc/pulse/client.conf sed -i -e "s|^autospawn.*|autospawn = yes|g" /etc/pulse/client.conf
else else
echo "autospawn = yes" >> /etc/pulse/client.conf echo "autospawn = yes" >> /etc/pulse/client.conf
fi fi
@ -177,7 +178,7 @@ disable_phonon() {
disable_libao() { disable_libao() {
if test -f /etc/libao.conf; then if test -f /etc/libao.conf; then
echo "Disabling PulseAudio for libao..." echo "Disabling PulseAudio for libao..."
perl -pi -e "s|default_driver=pulse||g;" /etc/libao.conf sed -i -e "/default_driver=pulse/d" /etc/libao.conf
fi fi
} }
@ -193,7 +194,7 @@ disable_speechd() {
echo "Disabling PulseAudio for speech dispatcher..." echo "Disabling PulseAudio for speech dispatcher..."
if test -f /etc/speech-dispatcher/speechd.conf; then if test -f /etc/speech-dispatcher/speechd.conf; then
if grep -q 'AudioOutputMethod' /etc/speech-dispatcher/speechd.conf; then if grep -q 'AudioOutputMethod' /etc/speech-dispatcher/speechd.conf; then
perl -pi -e "s|^.*AudioOutputMethod .*|#AudioOutputMethod \"pulse\"|g;" /etc/speech-dispatcher/speechd.conf sed -i -e "s|^.*AudioOutputMethod .*|#AudioOutputMethod \"pulse\"|g" /etc/speech-dispatcher/speechd.conf
fi fi
fi fi
} }
@ -206,7 +207,7 @@ disable_openal() {
disable_oss() { disable_oss() {
for app in $LIST_OF_OSS_APPS; do for app in $LIST_OF_OSS_APPS; do
perl -pi -e "s|alias $app='padsp $app'||g;" $PROFNAME sed -i -e "/alias $app='padsp $app'/d" $PROFNAME
done done
} }
@ -217,7 +218,7 @@ disable_sdl() {
disable_timidity() { disable_timidity() {
echo "Disabling PulseAudio for Timidity..." echo "Disabling PulseAudio for Timidity..."
perl -pi -e "s|alias timidity='timidity -Oe'||g;" $PROFNAME sed -i -e "/alias timidity='timidity -Oe'/d" $PROFNAME
} }
disable_xine() { disable_xine() {
@ -238,44 +239,66 @@ disable_festival() {
disable_autospawn() { disable_autospawn() {
echo "Disabling PulseAudio autospawn..." echo "Disabling PulseAudio autospawn..."
if grep -q ^autospawn /etc/pulse/client.conf; then if grep -q ^autospawn /etc/pulse/client.conf; then
perl -pi -e "s|^autospawn.*|autospawn = no|g;" /etc/pulse/client.conf sed -i -e "s|^autospawn.*|autospawn = no|g" /etc/pulse/client.conf
else else
echo "autospawn = no" >> /etc/pulse/client.conf echo "autospawn = no" >> /etc/pulse/client.conf
fi fi
} }
enable_all() {
enable_alsa
enable_libao
enable_mplayer
enable_openal
enable_oss
enable_sdl
enable_timidity
enable_xine
enable_festival
enable_autospawn
enable_phonon
enable_speechd
}
disable_all() {
disable_alsa
disable_libao
disable_mplayer
disable_openal
disable_oss
disable_sdl
disable_timidity
disable_xine
disable_festival
disable_autospawn
disable_phonon
disable_speechd
}
case $1 in case $1 in
--enable) --enable)
check_root || exit check_root || exit
ENABLE=1 ENABLE=1
enable_alsa enable_all
enable_libao
enable_mplayer
enable_openal
enable_oss
enable_sdl
enable_timidity
enable_xine
enable_festival
enable_autospawn
enable_phonon
enable_speechd
;; ;;
--disable) --disable)
check_root || exit check_root || exit
ENABLE=0 ENABLE=0
disable_alsa disable_all
disable_libao ;;
disable_mplayer --auto)
disable_openal check_root || exit
disable_oss if [ -f /etc/sysconfig/sound ]; then
disable_sdl . /etc/sysconfig/sound
disable_timidity fi
disable_xine if [ "x$PULSEAUDIO_ENABLE" = "xyes" ]; then
disable_festival enable_all
disable_autospawn elif [ "x$PULSEAUDIO_ENABLE" = "xcustom" ]; then
disable_phonon echo "Custom configuration detected, doing nothing."
disable_speechd else
disable_all
fi
exit
;; ;;
--status) --status)
if [ -f /etc/sysconfig/sound ]; then if [ -f /etc/sysconfig/sound ]; then
@ -283,6 +306,8 @@ case $1 in
fi fi
if [ "x$PULSEAUDIO_ENABLE" = "xyes" ]; then if [ "x$PULSEAUDIO_ENABLE" = "xyes" ]; then
echo "enabled" echo "enabled"
elif [ "x$PULSEAUDIO_ENABLE" = "xcustom" ]; then
echo "custom configured"
else else
echo "disabled" echo "disabled"
fi fi
@ -296,9 +321,9 @@ esac
# Now, update /etc/sysconfig/sound with the PA status # Now, update /etc/sysconfig/sound with the PA status
if grep -q PULSEAUDIO_ENABLE /etc/sysconfig/sound; then if grep -q PULSEAUDIO_ENABLE /etc/sysconfig/sound; then
if [ "x$ENABLE" = "x1" ]; then if [ "x$ENABLE" = "x1" ]; then
perl -pi -e "s|PULSEAUDIO_ENABLE=\"no\"|PULSEAUDIO_ENABLE=\"yes\"|g;" /etc/sysconfig/sound sed -i -e "s|PULSEAUDIO_ENABLE=\"no\"|PULSEAUDIO_ENABLE=\"yes\"|g" /etc/sysconfig/sound
else else
perl -pi -e "s|PULSEAUDIO_ENABLE=\"yes\"|PULSEAUDIO_ENABLE=\"no\"|g;" /etc/sysconfig/sound sed -i -e "s|PULSEAUDIO_ENABLE=\"yes\"|PULSEAUDIO_ENABLE=\"no\"|g" /etc/sysconfig/sound
fi fi
else else
if [ "x$ENABLE" = "x1" ]; then if [ "x$ENABLE" = "x1" ]; then
@ -307,5 +332,3 @@ else
echo "PULSEAUDIO_ENABLE=\"no\"" >> /etc/sysconfig/sound echo "PULSEAUDIO_ENABLE=\"no\"" >> /etc/sysconfig/sound
fi fi
fi fi
/sbin/SuSEconfig

View File

@ -0,0 +1,9 @@
## Path: Hardware/Soundcard/PulseAudio
## Description: PulseAudio configuration
## Type: list(yes,no,custom)
#
# Enable or disable PulseAudio system. Can be set to "custom" to not have
# scripts automatically change sound-related configuration for PulseAudio.
#
PULSEAUDIO_ENABLE="yes"