--- modules-update.orig 2004-09-11 09:46:45.536205480 -0500 +++ modules-update 2004-09-11 09:46:55.741654016 -0500 @@ -110,105 +110,150 @@ fi -echo "${HEADER}" > "${TMPFILE}" -cat <> "${TMPFILE}" +# this section generates ${CFGFILE} if needed +# first find out if there is a newer file in ${MODDIR}/* +# so we know if this step is necesary +newerfiles="$( + for cfg in "${MODDIR}"/* "${CONF}" + do + if [ "${cfg}" -nt "${CFGFILE}" ] + then + echo "${cfg}" + fi + done +)" + +if [ -n "${newerfiles}" ] || $FORCE +then + echo "Generating ${CFGFILE}" + echo "${HEADER}" > "${TMPFILE}" + cat <> "${TMPFILE}" # # Please do not edit this file directly. If you want to change or add # anything please take a look at the files in ${MODDIR} and read # the manpage for modules-update. # EOF -if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "true" ] -then - sed -e "s:the files in ${MODDIR}:${CFGFILE}:" \ - "${TMPFILE}" > "${TMPFILE2}" - - if [ -f "${CFGFILE3}" ] - then - sed -e "s:the files in ${MODDIR}:${CFGFILE3}:" \ - "${TMPFILE}" > "${TMPFILE4}" - 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 + + 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 >> "${TMPFILE}" + echo "### modules-update: end processing ${cfg}" >> "${TMPFILE}" + echo >> "${TMPFILE}" + done + + mv -f "${TMPFILE}" "${CFGFILE}" 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 - - echo "### modules-update: start processing ${cfg}" >> "${TMPFILE}" - - if [ -x ${cfg} ] +# this section generates ${CFGFILE2} if CFGFILE is newer + +if [ "${CFGFILE}" -nt "${CFGFILE2}" ] || $FORCE +then + + if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "true" ] then - # $cfg can be executable; nice touch, Wichert! :) - "${cfg}" >> "${TMPFILE}" - else - cat "${cfg}" >> "${TMPFILE}" + echo "Generating ${CFGFILE2}" + echo "${HEADER}" > "${TMPFILE2}" + cat <> "${TMPFILE2}" +# +# Please do not edit this file directly. If you want to change or add +# anything please take a look at ${CFGFILE} and read +# the manpage for modules-update. +# +EOF + # Make sure that generate-modprobe.conf can handle --assume-kernel + # if we were called with it. + if [[ -n ${ASSUME_KV} ]] && ! grep -qe --assume-kernel \ + /sbin/generate-modprobe.conf + then + eerror "Error: modules-update called with --assume-kernel flag, but" + eerror "generate-modprobe.conf doesn't understand it. You need to" + eerror "install >=module-init-tools-3.0-r2" + exit 3 + fi + if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ + >> "${TMPFILE2}" 2> /dev/null + then + mv -f "${TMPFILE2}" "${CFGFILE2}" + else + ewarn "Warning: could not generate ${CFGFILE2}!" + rm -f "${TMPFILE2}" + fi fi - - echo >> "${TMPFILE}" - echo "### modules-update: end processing ${cfg}" >> "${TMPFILE}" - echo >> "${TMPFILE}" -done +fi -mv -f "${TMPFILE}" "${CFGFILE}" -if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "true" ] +if [ "${CFGFILE3}" -nt "${CFGFILE4}" ] || $FORCE then - # Make sure that generate-modprobe.conf can handle --assume-kernel - # if we were called with it. - if [[ -n ${ASSUME_KV} ]] && ! grep -qe --assume-kernel \ - /sbin/generate-modprobe.conf - then - eerror "Error: modules-update called with --assume-kernel flag, but" - eerror "generate-modprobe.conf doesn't understand it. You need to" - eerror "install >=module-init-tools-3.0-r2" - exit 3 - fi - if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ - >> "${TMPFILE2}" 2> /dev/null - then - mv -f "${TMPFILE2}" "${CFGFILE2}" - else - ewarn "Warning: could not generate ${CFGFILE2}!" - rm -f "${TMPFILE2}" - fi - if [ -f "${CFGFILE3}" ] + if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "true" ] then - gawk '$0 !~ /^[[:space:]]*include/ { print $0 }' "${CFGFILE3}" \ - > "${TMPFILE3}" - - export TESTING_MODPROBE_CONF="${TMPFILE3}" - if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ - >> "${TMPFILE4}" 2> /dev/null + if [ -f "${CFGFILE3}" ] then - mv -f "${TMPFILE4}" "${CFGFILE4}" - - echo >> "${CFGFILE4}" - echo "include /etc/modprobe.conf" >> "${CFGFILE4}" - else - ewarn "Warning: could not generate ${CFGFILE4}!" - rm -f "${TMPFILE4}" + echo "Generating ${CFGFILE4}" + + echo "${HEADER}" > "${TMPFILE4}" + cat <> "${TMPFILE4}" +# +# Please do not edit this file directly. If you want to change or add +# anything please take a look at ${CFGFILE3} and read +# the manpage for modules-update. +# +EOF + + gawk '$0 !~ /^[[:space:]]*include/ { print $0 }' "${CFGFILE3}" \ + > "${TMPFILE3}" + + export TESTING_MODPROBE_CONF="${TMPFILE3}" + if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ + >> "${TMPFILE4}" 2> /dev/null + then + echo >> "${TMPFILE4}" + echo "include /etc/modprobe.conf" >> "${TMPFILE4}" + + mv -f "${TMPFILE4}" "${CFGFILE4}" + else + ewarn "Warning: could not generate ${CFGFILE4}!" + rm -f "${TMPFILE4}" + fi + rm -f "${TMPFILE3}" fi - rm -f "${TMPFILE3}" fi fi # We also call depmod here to stop insmod from complaining that modules.conf # is more recent then modules.dep # -if [ -d "`depdir`" -a -f /proc/modules ] + +if [ "${CFGFILE2}" -nt /lib/modules/${KV}/modules.dep ] || $FORCE then - if [ -f /usr/src/linux/System.map ]; then - depmod -a -F /usr/src/linux/System.map ${KV} - else - depmod -a ${KV} + if [ -d "`depdir`" -a -f /proc/modules ] + then + echo "Generating /lib/modules/${KV}/modules.dep" + if [ -f /usr/src/linux/System.map ]; then + depmod -a -F /usr/src/linux/System.map ${KV} + else + depmod -a ${KV} + fi fi fi - # vim:ts=4