Index: modules-update =================================================================== RCS file: /var/cvsroot/gentoo-src/rc-scripts/sbin/modules-update,v retrieving revision 1.12 diff -u -r1.12 modules-update --- modules-update 4 Feb 2005 06:29:39 -0000 1.12 +++ modules-update 10 Feb 2005 02:06:22 -0000 @@ -20,6 +20,7 @@ TMPFILE="${CFGFILE}.$$" CFGFILE2="/etc/modprobe.conf" TMPFILE2="${CFGFILE2}.$$" +TMPFILE2B="${CFGFILE2}B.$$" CFGFILE3="/etc/modules.devfs" TMPFILE3="${CFGFILE3}.$$" CFGFILE4="/etc/modprobe.devfs" @@ -54,6 +55,9 @@ KERNEL_2_6=false fi +# Check if $CONF is valid +[[ ! -r ${CONF} ]] && CONF= + set -e # Reset the sorting order since we depend on it @@ -110,27 +114,41 @@ fi fi -for cfg in "${MODDIR}"/* "${CONF}" ; do - [[ -d ${cfg} ]] && continue - - [[ ! -r ${cfg} ]] && continue - - # Skip backup and RCS files; fixes bug 20597 (07 May 2004 agriffis) - [[ ${cfg} == *~ || ${cfg} == *.bak || ${cfg} == *,v ]] && continue +generate_config() { + local cfg= + local conf="$1" + local moddir="$2" + local tmpfile="$3" + local do_mprobe="$4" + + for cfg in "${moddir}"/* "${conf}" ; do + [[ -d ${cfg} ]] && continue + + [[ ! -r ${cfg} ]] && continue + + # Skip backup and RCS files; fixes bug 20597 (07 May 2004 agriffis) + [[ ${cfg} == *~ || ${cfg} == *.bak || ${cfg} == *,v ]] && continue + + [[ ${do_mprobe} -eq 1 && -e "/etc/modprobe.d/${x##*/}" ]] && continue + + echo "### modules-update: start processing ${cfg}" >> "${tmpfile}" + + if [[ -x ${cfg} ]] ; then + # $cfg can be executable; nice touch, Wichert! :) + "${cfg}" >> "${tmpfile}" + else + cat "${cfg}" >> "${tmpfile}" + fi - echo "### modules-update: start processing ${cfg}" >> "${TMPFILE}" + echo >> "${tmpfile}" + echo "### modules-update: end processing ${cfg}" >> "${tmpfile}" + echo >> "${tmpfile}" + done - if [[ -x ${cfg} ]] ; then - # $cfg can be executable; nice touch, Wichert! :) - "${cfg}" >> "${TMPFILE}" - else - cat "${cfg}" >> "${TMPFILE}" - fi + return 0 +} - echo >> "${TMPFILE}" - echo "### modules-update: end processing ${cfg}" >> "${TMPFILE}" - echo >> "${TMPFILE}" -done +generate_config "${CONF}" "${MODDIR}" "${TMPFILE}" 0 mv -f "${TMPFILE}" "${CFGFILE}" @@ -150,8 +168,31 @@ then mv -f "${TMPFILE2}" "${CFGFILE2}" else - ewarn "Warning: could not generate ${CFGFILE2}!" + + # + # If we made it here, it means either generate-modprobe.conf + # bombed on us, or the user doesn't have modutils installed. + # If the latter is true, then we should generate modprobe.conf + # ourselves with any old files laying around in /etc/modules.d. + # rm -f "${TMPFILE2}" + if type -p modprobe.old > /dev/null ; then + ewarn "Warning: could not generate ${CFGFILE2}!" + else + rm -f "${CFGFILE}" + echo "${FULLHEADER/modules.d/modprobe.d}" > "${TMPFILE2B}" + generate_config "${CONF}" "${MODDIR}" "${TMPFILE2}" 1 + export TESTING_MODPROBE_CONF="${TMPFILE2}" + if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ + >> "${TMPFILE2B}" 2> /dev/null + then + mv -f "${TMPFILE2B}" "${CFGFILE2}" + else + ewarn "Warning: could not generate ${CFGFILE2}!" + rm -f "${TMPFILE2B}" + fi + rm -f "${TMPFILE2}" + fi fi if [[ -f ${CFGFILE3} ]] ; then