--- /sbin/functions.sh.orig 2004-11-10 09:43:57.000000000 -0600 +++ /sbin/functions.sh 2004-11-16 07:56:32.621812680 -0600 @@ -562,6 +562,32 @@ echo "${mylist}" } +# finds if any of the dependency files is newer than the target file +# +# int dependencyChanged(char * target, char ** dependencies) +# +# return 0 if any dependency is newer than target +# +# EXAMPLE: if dependencyChanged a.out *.o ; then ... +# +dependencyChanged() { + local x= + local target="$1" + shift + + for x in "$@" + do + [ "${x}" -nt "${target}" ] && return 0 + + if [ -d "${x}" ] + then + dependencyChanged "${target}" "${x}"/* && return 0 + fi + done + + return 1 +} + # void save_options(char *option, char *optstring) # # save the settings ("optstring") for "option" --- /sbin/modules-update.orig 2004-11-10 09:43:57.000000000 -0600 +++ /sbin/modules-update 2004-11-16 08:03:56.077397184 -0600 @@ -94,121 +94,164 @@ exit 2 fi -if [ -e "${CFGFILE}" ] +# this section generates ${CFGFILE} if needed +if $FORCE || dependencyChanged ${CFGFILE} "${MODDIR}" "${CONF}" then - cp -f "${CFGFILE}" "${CFGFILE}".old -fi -if ${KERNEL_2_5}; then - if [ -e "${CFGFILE2}" ] - then - cp -f "${CFGFILE2}" "${CFGFILE2}".old - fi - if [ -e "${CFGFILE4}" ] - then - cp -f "${CFGFILE4}" "${CFGFILE4}".old - fi -fi - - -echo "${HEADER}" > "${TMPFILE}" -cat <> "${TMPFILE}" + ebegin "Updating ${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 -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 + for cfg in "${MODDIR}"/* "${CONF}" + do + [ -d "${cfg}" ] && continue - echo "### modules-update: start processing ${cfg}" >> "${TMPFILE}" + [ ! -r "${cfg}" ] && continue - if [ -x ${cfg} ] + # 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 + + # back up the current file + if [ -e "${CFGFILE}" ] then - # $cfg can be executable; nice touch, Wichert! :) - "${cfg}" >> "${TMPFILE}" - else - cat "${cfg}" >> "${TMPFILE}" + cp -f "${CFGFILE}" "${CFGFILE}".old fi - echo >> "${TMPFILE}" - echo "### modules-update: end processing ${cfg}" >> "${TMPFILE}" - echo >> "${TMPFILE}" -done + mv -f "${TMPFILE}" "${CFGFILE}" + + eend "$?" +fi + -mv -f "${TMPFILE}" "${CFGFILE}" -if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "true" ] +# this section generates ${CFGFILE2} if CFGFILE is newer + +if [ "${CFGFILE}" -nt "${CFGFILE2}" ] || $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}" + ebegin "Updating ${CFGFILE2}" - export TESTING_MODPROBE_CONF="${TMPFILE3}" + 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}} \ - >> "${TMPFILE4}" 2> /dev/null + >> "${TMPFILE2}" 2> /dev/null then - mv -f "${TMPFILE4}" "${CFGFILE4}" - - echo >> "${CFGFILE4}" - echo "include /etc/modprobe.conf" >> "${CFGFILE4}" + # back up the current file + if [ -e "${CFGFILE2}" ] + then + cp -f "${CFGFILE2}" "${CFGFILE2}".old + fi + mv -f "${TMPFILE2}" "${CFGFILE2}" else - ewarn "Warning: could not generate ${CFGFILE4}!" - rm -f "${TMPFILE4}" + ewarn "Warning: could not generate ${CFGFILE2}!" + rm -f "${TMPFILE2}" + fi + + eend "$?" + fi +fi + + +if [ "${CFGFILE3}" -nt "${CFGFILE4}" ] || $FORCE +then + + if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "true" ] + then + if [ -f "${CFGFILE3}" ] + then + ebegin "Updating ${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}" + + # backup the current file + if [ -e "${CFGFILE4}" ] + then + cp -f "${CFGFILE4}" "${CFGFILE4}".old + fi + + mv -f "${TMPFILE4}" "${CFGFILE4}" + else + ewarn "Warning: could not generate ${CFGFILE4}!" + rm -f "${TMPFILE4}" + fi + rm -f "${TMPFILE3}" + + eend "$?" 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 + ebegin "Updating /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 + eend "$?" fi fi - # vim:ts=4 --- /etc/init.d/modules.orig 2004-11-16 08:13:44.672917064 -0600 +++ /etc/init.d/modules 2004-11-16 08:14:35.325216744 -0600 @@ -81,11 +81,11 @@ return 1 fi - if [ -z "${CDBOOT}" ] && touch /etc/modules.conf 2> /dev/null + if [ -z "${CDBOOT}" ] 2> /dev/null then - ebegin "Calculating module dependencies" + #ebegin "Calculating module dependencies" /sbin/modules-update &>/dev/null - eend $? "Failed to calculate module dependencies" + #eend $? "Failed to calculate module dependencies" fi if [ -f /etc/modules.autoload -a ! -L /etc/modules.autoload ]