/[baselayout]/trunk/sbin/modules-update
Gentoo

Diff of /trunk/sbin/modules-update

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1747 Revision 1748
35# the manpage for modules-update(8). 35# the manpage for modules-update(8).
36# 36#
37" 37"
38 38
39source /sbin/functions.sh 39source /sbin/functions.sh
40esyslog() { :; }
40 41
41# Parse command-line 42# Parse command-line
43VERBOSE=0
44DEBUG=0
42FORCE=false 45FORCE="false"
43ASSUME_KV= 46ASSUME_KV=
44while [[ -n $1 ]] ; do 47while [[ -n $1 ]] ; do
45 case "$1" in 48 case "$1" in
46 force) 49 -f|--force|force)
47 FORCE="true" 50 FORCE="true"
48 ;; 51 ;;
49 --assume-kernel=*) 52 --assume-kernel=*)
50 ASSUME_KV=${1#*=} 53 ASSUME_KV=${1#*=}
54 ;;
55 -v|--verbose)
56 ((++VERBOSE))
57 ;;
58 -d|--debug)
59 DEBUG=1
60 ;;
61 -V|--version)
62 cat /etc/gentoo-release
63 exit 0
64 ;;
65 -h|--help)
66 cat <<-EOF
67 Usage: modules-update [options]
68
69 Options:
70 --assume-kernel=KV Assume the kernel is at least version KV
71 -f, --force Force execution in face of bad things
72 -v, --verbose Be a bit more verbose in what we do
73 -d, --debug Helpful debug output
74 -V, --version Dump version info
75 -h, --help This help screen, duh
76 EOF
77 exit 0
51 ;; 78 ;;
52 *) 79 *)
53 eerror "Error: I don't understand $1" 80 eerror "Error: I don't understand $1"
54 exit 1 81 exit 1
55 ;; 82 ;;
56 esac 83 esac
57 shift 84 shift
58done 85done
86
87[[ ${DEBUG} == "1" ]] && set -x
59 88
60# Set kernel version, either from --assume-kernel or uname -r 89# Set kernel version, either from --assume-kernel or uname -r
61KV=${ASSUME_KV:-$(uname -r)} 90KV=${ASSUME_KV:-$(uname -r)}
62if [[ $(KV_to_int ${KV}) -ge "$(KV_to_int 2.5.48)" ]] ; then 91if [[ $(KV_to_int ${KV}) -ge "$(KV_to_int 2.5.48)" ]] ; then
63 KERNEL_2_6="true" 92 KERNEL_2_6="true"
166 fi 195 fi
167 196
168 ebegin "Updating ${CFGFILE2}" 197 ebegin "Updating ${CFGFILE2}"
169 echo "${FULLHEADER/modules.d/modprobe.d}" > "${TMPFILE2}" 198 echo "${FULLHEADER/modules.d/modprobe.d}" > "${TMPFILE2}"
170 if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ 199 if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \
171 >> "${TMPFILE2}" 2>/dev/null ; then 200 >> "${TMPFILE2}" 2> "${TMPFILE2}.err" ; then
172 [[ -e ${CFGFILE2} ]] && mv -f "${CFGFILE2}" "${CFGFILE2}.old" 201 [[ -e ${CFGFILE2} ]] && mv -f "${CFGFILE2}" "${CFGFILE2}.old"
173 mv -f "${TMPFILE2}" "${CFGFILE2}" 202 mv -f "${TMPFILE2}" "${CFGFILE2}"
174 eend 0 203 eend 0
175 else 204 else
176 # 205 #
179 # If the latter is true, then we should generate modprobe.conf 208 # If the latter is true, then we should generate modprobe.conf
180 # ourselves with any old files laying around in /etc/modules.d. 209 # ourselves with any old files laying around in /etc/modules.d.
181 # 210 #
182 rm -f "${TMPFILE2}" 211 rm -f "${TMPFILE2}"
183 if type -p modprobe.old > /dev/null ; then 212 if type -p modprobe.old > /dev/null ; then
213 [[ ${VERBOSE} -gt 0 ]] && cat "${TMPFILE2}.err"
184 eend 1 "Warning: could not generate ${CFGFILE2}!" 214 eend 1 "Warning: could not generate ${CFGFILE2}!"
185 else 215 else
186 echo "${FULLHEADER/modules.d/modprobe.d}" > "${TMPFILE2B}" 216 echo "${FULLHEADER/modules.d/modprobe.d}" > "${TMPFILE2B}"
187 generate_config "${CONF}" "${MODDIR}" "${TMPFILE2}" 1 217 generate_config "${CONF}" "${MODDIR}" "${TMPFILE2}" 1
188 export TESTING_MODPROBE_CONF="${TMPFILE2}" 218 export TESTING_MODPROBE_CONF="${TMPFILE2}"
189 if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ 219 if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \
190 >> "${TMPFILE2B}" 2> /dev/null ; then 220 >> "${TMPFILE2B}" 2> "${TMPFILE2B}.err" ; then
191 [[ -e ${CFGFILE2} ]] && mv -f "${CFGFILE2}" "${CFGFILE2}.old" 221 [[ -e ${CFGFILE2} ]] && mv -f "${CFGFILE2}" "${CFGFILE2}.old"
192 mv -f "${TMPFILE2B}" "${CFGFILE2}" 222 mv -f "${TMPFILE2B}" "${CFGFILE2}"
193 eend 0 223 eend 0
194 else 224 else
225 [[ ${VERBOSE} -gt 0 ]] && cat "${TMPFILE2B}.err"
195 eend 1 "Warning: could not generate ${CFGFILE2}!" 226 eend 1 "Warning: could not generate ${CFGFILE2}!"
196 rm -f "${TMPFILE2B}" 227 rm -f "${TMPFILE2B}"
197 fi 228 fi
198 rm -f "${TMPFILE2}" 229 rm -f "${TMPFILE2}" "${TMPFILE2B}.err"
199 fi 230 fi
231 rm -f "${TMPFILE2}.err"
200 fi 232 fi
201 233
202 if [[ -f ${CFGFILE3} ]] ; then 234 if [[ -f ${CFGFILE3} ]] ; then
203 ebegin "Updating ${CFGFILE4}" 235 ebegin "Updating ${CFGFILE4}"
204 gawk '$0 !~ /^[[:space:]]*include/ { print $0 }' "${CFGFILE3}" \ 236 gawk '$0 !~ /^[[:space:]]*include/ { print $0 }' "${CFGFILE3}" \
205 > "${TMPFILE3}" 237 > "${TMPFILE3}"
206 238
207 echo "${FULLHEADER/modules.d/modprobe.d}" > "${TMPFILE4}" 239 echo "${FULLHEADER/modules.d/modprobe.d}" > "${TMPFILE4}"
208 export TESTING_MODPROBE_CONF="${TMPFILE3}" 240 export TESTING_MODPROBE_CONF="${TMPFILE3}"
209 if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ 241 if /sbin/generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \
210 >> "${TMPFILE4}" 2> /dev/null ; then 242 >> "${TMPFILE4}" 2> "${TMPFILE4}.err" ; then
211 [[ -e ${CFGFILE4} ]] && mv -f "${CFGFILE4}" "${CFGFILE4}.old" 243 [[ -e ${CFGFILE4} ]] && mv -f "${CFGFILE4}" "${CFGFILE4}.old"
212 mv -f "${TMPFILE4}" "${CFGFILE4}" 244 mv -f "${TMPFILE4}" "${CFGFILE4}"
213 245
214 echo >> "${CFGFILE4}" 246 echo >> "${CFGFILE4}"
215 echo "include /etc/modprobe.conf" >> "${CFGFILE4}" 247 echo "include /etc/modprobe.conf" >> "${CFGFILE4}"
216 eend 0 248 eend 0
217 else 249 else
250 [[ ${VERBOSE} -gt 0 ]] && cat "${TMPFILE4}.err"
218 eend 1 "Warning: could not generate ${CFGFILE4}!" 251 eend 1 "Warning: could not generate ${CFGFILE4}!"
219 rm -f "${TMPFILE4}" 252 rm -f "${TMPFILE4}"
220 fi 253 fi
221 rm -f "${TMPFILE3}" 254 rm -f "${TMPFILE3}" "${TMPFILE4}.err"
222 fi 255 fi
223 fi 256 fi
224fi 257fi
225 258
226# We also call depmod here to stop insmod from complaining that modules.conf 259# We also call depmod here to stop insmod from complaining that modules.conf

Legend:
Removed from v.1747  
changed lines
  Added in v.1748

  ViewVC Help
Powered by ViewVC 1.1.20