diff options
author | Thomas Hood <jdthood@yahoo.co.uk> | 2004-09-24 09:58:20 +0000 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2004-09-24 09:58:20 +0000 |
commit | dba1bfa750e8ebd87cf41063e46b5e24aac05e3c (patch) | |
tree | fe5b08adf9802ae77b680306593e8bfffed120e1 /alsaconf | |
parent | 7de47ff37bb053d3f747a91893f6c194a8516608 (diff) | |
download | alsa-utils-dba1bfa750e8ebd87cf41063e46b5e24aac05e3c.tar.gz |
Refrain from creating /etc/modprobe.conf if it does not already exist
Patch for alsaconf which makes it refrain from creating
/etc/modprobe.conf if the latter does not already exist.
Creating an empty /etc/modprobe.conf is bad because if it
exists then modprobe uses _only_ this file -- it does not
use /etc/modprobe.d/.
Additionally, this patch makes alsaconf set the cleanup
trap before it creates temporary files rather than after.
Signed-off-by: Thomas Hood <jdthood@yahoo.co.uk>
Diffstat (limited to 'alsaconf')
-rw-r--r-- | alsaconf/alsaconf.in | 82 |
1 files changed, 32 insertions, 50 deletions
diff --git a/alsaconf/alsaconf.in b/alsaconf/alsaconf.in index 3823553..b062a6a 100644 --- a/alsaconf/alsaconf.in +++ b/alsaconf/alsaconf.in @@ -170,9 +170,6 @@ elif [ "$kernel" = "new" ]; then if [ -d /etc/modprobe.d ]; then cfgout="/etc/modprobe.d/sound" fi - if [ ! -r /etc/modprobe.conf ]; then - touch /etc/modprobe.conf - fi cfgfile="/etc/modprobe.conf" elif [ "$distribution" = "debian" ]; then cfgfile="/etc/modutils/alsa-base" @@ -372,12 +369,24 @@ if [ -d /proc/asound ]; then fi +cleanup () { + killall -9 aplay arecord >/dev/null 2>&1 + /sbin/modprobe -r isapnp >/dev/null 2>&1 + /sbin/modprobe -r isa-pnp >/dev/null 2>&1 + rm -f "$TMP" "$addcfg" "$FOUND" "$DUMP" +} +trap cleanup 0 TMP=`mktemp -q /tmp/alsaconf.XXXXXX` if [ $? -ne 0 ]; then echo "$0: Can't create temp file, exiting..." exit 1 fi +addcfg=`mktemp -q /tmp/alsaconf.XXXXXX` +if [ $? -ne 0 ]; then + echo "$0: Can't create temp file, exiting..." + exit 1 +fi FOUND=`mktemp -q /tmp/alsaconf.XXXXXX` if [ $? -ne 0 ]; then echo "$0: Can't create temp file, exiting..." @@ -388,13 +397,6 @@ if [ $? -ne 0 ]; then echo "$0: Can't create temp file, exiting..." exit 1 fi -cleanup () { - killall -9 aplay arecord >/dev/null 2>&1 - /sbin/modprobe -r isapnp >/dev/null 2>&1 - /sbin/modprobe -r isa-pnp >/dev/null 2>&1 - rm -f "$TMP" "$FOUND" "$DUMP" -} -trap cleanup 0 # convert ISA PnP id number to string 'ABC' convert_isapnp_id () { @@ -553,20 +555,6 @@ find_device_name () { } # -# make a backup of old config -backup_old_config () { - if cmp -s $1 $2; then - return - fi - if cp -f $1 $1.old; then - cp -f $2 $1 - else - echo "ERROR! $1 could not be saved." - exit 1 - fi -} - -# # configure and try test sound # ac_config_card () { @@ -575,14 +563,14 @@ ac_config_card () { CARD_OPTS="${*:2}" if [ -n "$cfgout" ]; then - addcfg="$cfgout" + $DIALOG --yesno " +Configuring $CARD_DRIVER +Do you want to modify ${cfgout} (and ${cfgfile} if present)?" 8 50 || acex 0 else - addcfg="$cfgfile" - fi - # Configuration done - $DIALOG --yesno " + $DIALOG --yesno " Configuring $CARD_DRIVER -Do you want to modify ${addcfg}?" 8 50 || acex 0 +Do you want to modify ${cfgfile}?" 8 50 || acex 0 + fi clear # Copy conf.modules and make changes. @@ -599,20 +587,12 @@ Do you want to modify ${addcfg}?" 8 50 || acex 0 SOUND_CORE="snd" fi - if [ "$distribution" = "redhat" -o "$distribution" = "fedora" ] ; then - remove_ac_block < $cfgfile | remove_sndconfig_block | uniq > $TMP - else - remove_ac_block < $cfgfile | remove_y2_block | uniq > $TMP - fi - - if [ -n "$cfgout" ]; then - rm -f "$cfgout" - touch "$cfgout" - addcfg="$cfgout" - else - addcfg="$TMP" - echo "$ACB -# --- ALSACONF verion $version ---" >> $addcfg + if [ -r $cfgfile ] ; then + if [ "$distribution" = "redhat" -o "$distribution" = "fedora" ] ; then + remove_ac_block < $cfgfile | remove_sndconfig_block | uniq > $TMP + else + remove_ac_block < $cfgfile | remove_y2_block | uniq > $TMP + fi fi if [ -z "$have_alias" -a "$kernel" = "new" ]; then @@ -637,15 +617,17 @@ alias sound-slot-0 $CARD_DRIVER" >> $addcfg if [ -n "$CARD_OPTS" ]; then echo "options $CARD_DRIVER $CARD_OPTS" >> $addcfg fi - if [ -z "$cfgout" ]; then - echo "$ACE -" >> $addcfg - fi if [ -n "$cfgout" ]; then - backup_old_config $cfgfile $TMP + [ ! -r "$cfgfile" ] || cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile" + cmp -s "$addcfg" "$cfgout" || cat "$addcfg" > "$cfgout" else - backup_old_config $cfgfile $addcfg + echo "$ACB +# --- ALSACONF verion $version ---" >> $TMP + cat "$addcfg" >> "$TMP" + echo "$ACE +" >> $TMP + cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile" fi /sbin/depmod -a 2>/dev/null |