1 http://bugs.gentoo.org/149426
3 keep from blowing up when people have duplicate aliases ... the grep
4 ends up including new lines and with certain formed comments, hits an
7 for example, the following inputs illustrates the problem:
8 ----------------------------------------------
9 # Old nvidia support ...
10 alias char-major-195 NVdriver
11 alias /dev/nvidiactl char-major-195
12 alias char-major-195 nvidia
13 alias /dev/nvidiactl char-major-195
14 # To enable Side Band Adressing: NVreg_EnableAGPSBA=1
15 #options nvidia NVreg_EnableAGPSBA=1 NVreg_EnableAGPFW=1
16 #options nvidia NVreg_SoftEDIDs=0 NVreg_Mobile=3
17 ----------------------------------------------
20 ----------------------------------------------
22 fixes from Martin Väth
24 --- generate-modprobe.conf
25 +++ generate-modprobe.conf
27 # Resolve (possibly recursive) alias: args filename alias
30 - RA_RESOLVE=`grep "^alias[ ][ ]*$2[ ]" -- $1 | awk '{ print $3 }'`
31 + if [ 0$3 -gt 99 ]; then
32 + echo "Infinite recursion detected; aborting after $3 tries (alias '$2')" 1>&2
36 + _RA_RESOLVE=`grep "^alias[ ][ ]*$2[ ]" -- $1 | awk '{ print $3 }'`
37 + RA_RESOLVE=`echo "$_RA_RESOLVE" | head -n 1`
38 + if [ x"$_RA_RESOLVE" != x"$RA_RESOLVE" ]; then
39 + echo "Invalid dupliate alias found for '$2' (results: `echo $_RA_RESOLVE`)" 1>&2
42 if [ x"$RA_RESOLVE" = x ]; then
47 - (resolve_alias $1 "$RA_RESOLVE")
48 + (resolve_alias $1 "$RA_RESOLVE" $(($3 + 1)))
51 # Parse alias: args filename modulename aliasto.
54 - PA_ALIAS=`resolve_alias $1 $3`
55 + PA_ALIAS=`resolve_alias $1 $3` || exit 1
56 NAME=`echo $2|sed -e 's/\(block\|char\)-major-\([0-9]\+\)$/\1-major-\2-*/'`
58 echo "alias $NAME $PA_ALIAS"
60 parse_options $MODULE `grab_noninstall_options $REST`
61 INSTALL_OPTIONS=`grab_install_options $REST`
62 INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE"
63 - eval install_$MODNAME=\"/sbin/modprobe $INSTALL_OPTIONS --ignore-install `resolve_alias $MODPROBECONF $MODULE`\"
64 + INSTALL_ALIAS=`resolve_alias $MODPROBECONF "$MODULE"` || exit 1
65 + eval install_$MODNAME=\"/sbin/modprobe $INSTALL_OPTIONS --ignore-install $INSTALL_ALIAS\"
68 parse_options $MODULE "$REST"