Magellan Linux

Contents of /tags/grubby-8_5/new-kernel-pkg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1731 - (show annotations) (download)
Sat Feb 18 00:59:46 2012 UTC (12 years, 2 months ago) by niro
File size: 21995 byte(s)
tagged 'grubby-8_5'
1 #!/bin/bash
2 # $Id$
3 #
4 # new-kernel-pkg
5 # Invoked upon installation or removal of a kernel package, the following
6 # tasks are/can be done here:
7 # creation/removal of initrd
8 # run of depmod/removal of depmod generated files
9 # addition/removal of kernel images from grub/lilo configuration (via grubby)
10 #
11 # Copyright 2002-2008 Red Hat, Inc. All rights reserved.
12 # modified for Magellan-Linux by Niels Rogalla <niro@magellan-linux.de>
13 #
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #
27
28 PATH=/sbin:/bin:$PATH
29
30 lilo=/sbin/lilo
31
32 # some defaults that are sane for most arches
33 kernelName=kernel
34
35 if [ -x ./grubby ]
36 then
37 grubby=./grubby
38 else
39 grubby=/sbin/grubby
40 fi
41
42 [ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby
43 [ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot
44
45 cfgGrub2=""
46 cfgGrub2Efi=""
47 cfgGrub=""
48 cfgLilo=""
49 cfgExtlinux=""
50 cfguBoot=""
51 runLilo=""
52 grubConfig=""
53 grub2Config=""
54 grub2EfiConfig=""
55 extlinuxConfig=""
56
57 ARCH=$(uname -m)
58
59 if [[ ${ARCH} = ia64 ]]
60 then
61 liloConfig=/boot/efi/EFI/redhat/elilo.conf
62 bootPrefix=/boot/efi/EFI/redhat
63 liloFlag=elilo
64 isx86=""
65 elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
66 then
67 liloConfig=/etc/yaboot.conf
68 bootPrefix=/boot
69 lilo=/sbin/ybin
70 liloFlag=yaboot
71 runLilo="yes"
72 isx86=""
73 elif [[ ${ARCH} = sparc ]] || [[ ${ARCH} = sparc64 ]]
74 then
75 liloConfig=/etc/silo.conf
76 bootPrefix=/boot
77 liloFlag=silo
78 lilo=/sbin/silo
79 isx86=""
80 elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
81 then
82 liloConfig=/etc/zipl.conf
83 bootPrefix=/boot
84 liloFlag=zipl
85 lilo=/sbin/zipl
86 runLilo="yes"
87 isx86=""
88 elif [[ ${ARCH} = armv7l ]]
89 then
90 liloConfig=""
91 bootPrefix=/boot
92 ubootDir=${UBOOT_DIR:-"/boot/uboot"}
93 ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
94 ubootKList=${UBOOT_KLIST:-"klist.txt"}
95 ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
96 ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}
97 ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}
98 mounted=""
99 liloFlag=""
100 isx86=""
101 else
102 # this leaves i?86 and x86_64
103 liloConfig=/etc/lilo.conf
104 grubConfig=/boot/grub/grub.conf
105 grub2Config=/boot/grub/grub.cfg
106 grub2EfiConfig=/boot/grub/grub-efi.cfg
107 extlinuxConfig=/boot/extlinux/extlinux.conf
108 bootPrefix=/boot
109 liloFlag=lilo
110 isx86="yes"
111 fi
112
113 mode=""
114 version=""
115 initrd=""
116 dracut=""
117 dracuthostonly=""
118 initrdfile=""
119 moddep=""
120 verbose=""
121 makedefault=""
122 package=""
123 mbkernel="${HYPERVISOR}"
124 mbargs="${HYPERVISOR_ARGS}"
125 adddracutargs=""
126 addplymouthinitrd=""
127
128 usage()
129 {
130 echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
131 echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
132 echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2
133 echo " [--banner=<banner>] [--multiboot=multiboot]" >&2
134 echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
135 echo " [--add-plymouth-initrd]" >&2
136 echo " [--host-only]" >&2
137 echo " <--install | --remove | --update> <kernel-version>" >&2
138 echo " (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2
139 exit 1
140 }
141
142 install()
143 {
144 # XXX kernel should be able to be specified also (or work right on ia64)
145 if [ ! -f ${bootPrefix}/${kernelName}-${version} ]
146 then
147 [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
148 return
149 fi
150
151 INITRD=""
152 if [ -f ${initrdfile} ]
153 then
154 [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
155 INITRD="--initrd ${initrdfile}"
156
157 if [[ -n ${addplymouthinitrd} ]]
158 then
159 INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
160 fi
161 fi
162
163 # FIXME: is this a good heuristic to find out if we're on iSeries?
164 if [ -d /proc/iSeries ]
165 then
166 [[ -n ${verbose} ]] && echo "On an iSeries, just making img file"
167 if [[ -z ${initrdfile} ]]
168 then
169 [[ -n ${verbose} ]] && echo "No initrd, just adding system map"
170 /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version}
171 else
172 /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version}
173 /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null
174 rm ${bootPrefix}/vmlinux.sm-${version}
175 fi
176 return
177 fi
178
179 # get the root filesystem to use
180 rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)
181
182 if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
183 then
184 [[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf"
185 cfgLilo=""
186 fi
187
188 if [[ -n ${cfgGrub} ]]
189 then
190 [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
191
192 if [[ -n ${banner} ]]
193 then
194 title="${banner} (${version})"
195 elif [ -f /etc/mageversion ]
196 then
197 title="Magellan Linux $(< /etc/mageversion) (${version})"
198 else
199 title="Magellan Linux (${version})"
200 fi
201 ${grubby} --grub -c ${grubConfig} \
202 --add-kernel=${bootPrefix}/${kernelName}-${version} \
203 ${INITRD} --copy-default ${makedefault} --title "${title}" \
204 ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
205 --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
206 else
207 [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
208 fi
209 if [[ -n ${cfgGrub2} ]]
210 then
211 [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
212
213 if [[ -n ${banner} ]]
214 then
215 title="${banner} (${version})"
216 elif [ -f /etc/mageversion ]
217 then
218 title="Magellan Linux $(< /etc/mageversion) (${version})"
219 else
220 title="Magellan Linux (${version})"
221 fi
222 ${grubby} --grub2 -c ${grub2Config} \
223 --add-kernel=${bootPrefix}/${kernelName}-${version} \
224 ${INITRD} --copy-default ${makedefault} --title "${title}" \
225 ${mbkernel:+--add-multiboot="${mbkernel}"} \
226 ${mbargs:+--mbargs="${mbargs}"} \
227 --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
228 else
229 [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
230 fi
231 if [[ -n ${cfgGrub2Efi} ]]
232 then
233 [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
234
235 if [[ -n ${banner} ]]
236 then
237 title="${banner} (${version})"
238 elif [ -f /etc/mageversion ]
239 then
240 title="Magellan Linux $(< /etc/mageversion) (${version})"
241 else
242 title="Magellan Linux (${version})"
243 fi
244 ${grubby} --grub2 -c ${grub2EfiConfig} \
245 --add-kernel=${bootPrefix}/${kernelName}-${version} \
246 ${INITRD} --copy-default ${makedefault} --title "${title}" \
247 ${mbkernel:+--add-multiboot="${mbkernel}"} \
248 ${mbargs:+--mbargs="${mbargs}"} \
249 --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
250 else
251 [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI"
252 fi
253
254 if [[ -n ${cfgLilo} ]]
255 then
256 [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
257
258 ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \
259 --copy-default ${makedefault} --title ${version} \
260 ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
261 --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \
262 --${liloFlag}
263
264 if [[ -n ${runLilo} ]]
265 then
266 [[ -n ${verbose} ]] && echo "running ${lilo}"
267 if [ ! -x ${lilo} ]
268 then
269 [[ -n ${verbose} ]] && echo "${lilo} does not exist"
270 else
271 ${lilo} > /dev/null
272 fi
273 fi
274 else
275 [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
276 fi
277
278 if [[ -n ${cfgExtlinux} ]]
279 then
280 [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
281
282 if [[ -n ${banner} ]]
283 then
284 title="${banner} (${version})"
285 elif [ -f /etc/mageversion ]
286 then
287 title="Magellan Linux $(< /etc/mageversion) (${version})"
288 else
289 title="Magellan Linux (${version})"
290 fi
291 ${grubby} --extlinux -c ${extlinuxConfig} \
292 --add-kernel=${bootPrefix}/${kernelName}-${version} \
293 ${INITRD} --copy-default ${makedefault} --title "${title}" \
294 ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
295 --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
296 else
297 [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
298 fi
299 }
300
301 remove()
302 {
303 # FIXME: is this a good heuristic to find out if we're on iSeries?
304 if [ -d /proc/iSeries ]
305 then
306 [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
307 rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null
308 return
309 fi
310
311 if [[ -n ${cfgGrub} ]]
312 then
313 [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
314 ${grubby} --grub -c ${grubConfig} \
315 --remove-kernel=${bootPrefix}/${kernelName}-${version}
316 else
317 [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
318 fi
319 if [[ -n ${cfgGrub2} ]]
320 then
321 [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"
322 ${grubby} --grub2 -c ${grub2Config} \
323 --remove-kernel=${bootPrefix}/${kernelName}-${version}
324 else
325 [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
326 fi
327 if [[ -n ${cfgGrub2Efi} ]]
328 then
329 [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"
330 ${grubby} --grub2 -c ${grub2EfiConfig} \
331 --remove-kernel=${bootPrefix}/${kernelName}-${version}
332 else
333 [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"
334 fi
335
336 if [[ -n ${cfgLilo} ]]
337 then
338 [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
339 ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag}
340
341 if [[ -n ${runLilo} ]]
342 then
343 [[ -n ${verbose} ]] && echo "running ${lilo}"
344 if [ ! -x ${lilo} ]
345 then
346 [[ -n ${verbose} ]] && echo "${lilo} does not exist"
347 else
348 ${lilo} > /dev/null
349 fi
350 fi
351 else
352 [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
353 fi
354
355 if [[ -n ${cfguBoot} ]]
356 then
357 [[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..."
358
359 if [ -f ${ubootDir}/${ubootKList} ]
360 then
361 tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
362 curversion=$(tail -n1 ${ubootDir}/${ubootKList})
363 sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList}
364 newversion=$(tail -n1 ${tmpKList})
365 if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
366 then
367 if [[ ${curversion} != ${newversion} ]]
368 then
369 cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage}
370 if [ $? -ne 0 ]
371 then
372 [[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit
373 fi
374 cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd}
375 if [ $? -ne 0 ]
376 then
377 [[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit
378 fi
379 fi
380
381 [[ -n ${verbose} ]] && echo "removing uImage-${version}"
382 if [ -f ${ubootDir}/uImage-${version} ]
383 then
384 rm -f ${ubootDir}/uImage-${version}
385 else
386 [[ -n ${verbose} ]] && echo "uImage-${version} did not exist!"
387 fi
388
389 [[ -n ${verbose} ]] && echo "removing uInitrd-${version}"
390 if [ -f ${ubootDir}/uInitrd-${version} ]
391 then
392 rm -f ${ubootDir}/uInitrd-${version}
393 else
394 [[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!"
395 fi
396
397 mv ${tmpKList} ${ubootDir}/${ubootKList}
398 else
399 [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
400 [ -f ${tmpKList} ] && rm -f ${tmpKList}
401 fi
402 else
403 [[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!"
404 fi
405 else
406 [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
407 fi
408
409 if [[ -n ${cfgExtlinux} ]]
410 then
411 [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}"
412 ${grubby} --extlinux -c ${extlinuxConfig} \
413 --remove-kernel=${bootPrefix}/${kernelName}-${version}
414 else
415 [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
416 fi
417 }
418
419 update()
420 {
421 if [ ! -f ${bootPrefix}/${kernelName}-${version} ]
422 then
423 [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
424 return
425 fi
426
427 INITRD=""
428 if [ -f ${initrdfile} ]
429 then
430 [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
431 INITRD="--initrd ${initrdfile}"
432
433 if [[ -n ${addplymouthinitrd} ]]
434 then
435 INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
436 fi
437 fi
438
439 if [[ -n ${cfgGrub} ]]
440 then
441 [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
442 ${grubby} --grub -c ${grubConfig} \
443 --update-kernel=${bootPrefix}/${kernelName}-${version} \
444 ${INITRD} \
445 ${kernargs:+--args="${kernargs}"} \
446 ${removeargs:+--remove-args="${removeargs}"}
447 else
448 [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
449 fi
450
451 if [[ -n ${cfgGrub2} ]]
452 then
453 [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
454 ${grubby} --grub2 -c ${grub2Config} \
455 --update-kernel=${bootPrefix}/${kernelName}-${version} \
456 ${INITRD} \
457 ${kernargs:+--args="${kernargs}"} \
458 ${removeargs:+--remove-args="${removeargs}"}
459 else
460 [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
461 fi
462
463 if [[ -n ${cfgGrub2Efi} ]]
464 then
465 [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
466 ${grubby} --grub2 -c ${grub2EfiConfig} \
467 --update-kernel=${bootPrefix}/${kernelName}-${version} \
468 ${INITRD} \
469 ${kernargs:+--args="${kernargs}"} \
470 ${removeargs:+--remove-args="${removeargs}"}
471 else
472 [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
473 fi
474
475 if [[ -n ${cfgLilo} ]]
476 then
477 [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
478 ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \
479 ${INITRD} \
480 ${kernargs:+--args="${kernargs}"} \
481 ${removeargs:+--remove-args="${removeargs}"} \
482 --${liloFlag}
483
484 if [[ -n ${runLilo} ]]
485 then
486 [[ -n ${verbose} ]] && echo "running ${lilo}"
487 if [ ! -x ${lilo} ]
488 then
489 [[ -n ${verbose} ]] && echo "${lilo} does not exist"
490 else
491 ${lilo} > /dev/null
492 fi
493 fi
494 else
495 [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
496 fi
497
498 if [[ -n ${cfguBoot} ]]
499 then
500 [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
501
502 [[ -n ${verbose} ]] && echo "creating uImage-${version}"
503 mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \
504 -n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version}
505
506 [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
507 mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
508 -n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version}
509
510 if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ]
511 then
512 cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage}
513 if [ $? -ne 0 ]
514 then
515 [[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit
516 fi
517 cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd}
518 if [ $? -ne 0 ]
519 then
520 [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
521 fi
522 echo ${version} >> ${ubootDir}/${ubootKList}
523 else
524 [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
525 fi
526 else
527 [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
528 fi
529
530 if [[ -n ${cfgExtlinux} ]]
531 then
532 [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
533 ${grubby} --extlinux -c ${extlinuxConfig} \
534 --update-kernel=${bootPrefix}/${kernelName}-${version} \
535 ${INITRD} \
536 ${kernargs:+--args="${kernargs}"} \
537 ${removeargs:+--remove-args="${removeargs}"}
538 else
539 [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
540 fi
541 }
542
543 mkinitrd()
544 {
545 if [[ -n ${dracut} ]]
546 then
547 tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
548 else
549 tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}"
550 fi
551 [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
552 ${tool}
553 rc=$?
554 if [ ${rc} != 0 ]
555 then
556 echo "mkinitrd failed" >&2
557 exit 1
558 fi
559 }
560
561 rminitrd()
562 {
563 [[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}"
564 [ -f ${initrdfile} ] && rm -f ${initrdfile}
565 }
566
567 doDepmod()
568 {
569 [[ -n ${verbose} ]] && echo "running depmod for ${version}"
570 depmod -ae -F /boot/System.map-${version} ${version}
571 }
572
573 doRmmoddep()
574 {
575 [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
576 [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*
577 }
578
579
580 while [ $# -gt 0 ]
581 do
582 case $1 in
583 --mkinitrd)
584 initrd="make"
585 ;;
586
587 --rminitrd)
588 initrd="remove"
589 ;;
590
591 --dracut)
592 dracut=--dracut
593 ;;
594
595 --host-only)
596 dracuthostonly=-H
597 ;;
598
599 --initrdfile*)
600 if echo $1 | grep '=' >/dev/null
601 then
602 initrdfile=$(echo $1 | sed 's/^--initrdfile=//')
603 else
604 initrdfile=$2
605 shift
606 fi
607 ;;
608
609 --kernel-args*)
610 if echo $1 | grep '=' >/dev/null
611 then
612 kernargs=$(echo $1 | sed 's/^--kernel-args=//')
613 else
614 kernargs=$2
615 shift
616 fi
617 ;;
618
619 --remove-args*)
620 if echo $1 | grep '=' >/dev/null
621 then
622 removeargs=$(echo $1 | sed 's/^--remove-args=//')
623 else
624 removeargs=$2
625 shift
626 fi
627 ;;
628
629 --banner*)
630 if echo $1 | grep '=' >/dev/null
631 then
632 banner=$(echo $1 | sed 's/^--banner=//')
633 else
634 banner=$2
635 shift
636 fi
637 ;;
638
639 --multiboot*)
640 if echo $1 |grep '=' >/dev/null
641 then
642 mbkernel=$(echo $1 | sed 's/^--multiboot=//')
643 else
644 # can't really support having an optional second arg here
645 # sorry!
646 mbkernel="/boot/xen.gz"
647 fi
648 ;;
649
650 --mbargs*)
651 if echo $1 |grep '=' >/dev/null
652 then
653 mbargs=$(echo $1 | sed 's/^--mbargs=//')
654 else
655 mbargs="$2"
656 shift
657 fi
658 ;;
659
660 --depmod)
661 moddep="make"
662 ;;
663
664 --rmmoddep)
665 moddep="remove"
666 ;;
667
668 --make-default)
669 makedefault="--make-default"
670 ;;
671
672 --package)
673 if echo $1 | grep '=' >/dev/null
674 then
675 package=$(echo $1 | sed 's/^--package=//')
676 else
677 package=$2
678 shift
679 fi
680 ;;
681
682 --add-dracut-args)
683 adddracutargs=--add-dracut-args
684 ;;
685
686 --add-plymouth-initrd)
687 addplymouthinitrd=--add-plymouth-initrd
688 ;;
689
690 -v)
691 verbose=-v
692 ;;
693
694 *)
695 if [[ -z ${mode} ]]
696 then
697 mode=$1
698 elif [[ -z ${version} ]]
699 then
700 version=$1
701 else
702 usage
703 fi
704 ;;
705 esac
706
707 shift
708 done
709
710 # make sure the mode is valid
711 if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]]
712 then
713 usage
714 fi
715
716 if [[ -z ${version} ]]
717 then
718 usage
719 fi
720
721 if [ "${mode}" != "--install" -a "${makedefault}" ]
722 then
723 usage
724 fi
725
726 kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)
727
728 # kernel image for 2.4 is kernel
729 if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
730 then
731 if [[ ${kernelmajor} = 2.4 ]]
732 then
733 kernelName=kernel
734 fi
735 fi
736
737 # set the initrd file based on arch; ia64 is the only currently known oddball
738 if [[ -z ${initrdfile} ]]
739 then
740 INITRD_NAME_PREFIX="initrd"
741 if [[ -n ${dracut} ]]
742 then
743 INITRD_NAME_PREFIX="initramfs"
744 fi
745
746 if [[ $(uname -m) = ia64 ]]
747 then
748 initrdfile="/boot/efi/EFI/redhat/${INITRD_NAME_PREFIX}-${version}.img"
749 else
750 initrdfile="/boot/${INITRD_NAME_PREFIX}-${version}.img"
751 fi
752 fi
753 [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
754
755 # add dracut i18n, keyboard and plymouth kernel args if requested
756 if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
757 then
758 [ -r /etc/conf.d/keymap ] && . /etc/conf.d/keymap
759 [ -r /etc/conf.d/consolefont ] && . /etc/conf.d/consolefont
760
761 if [[ -n ${KEYMAP} ]]
762 then
763 kernargs="${kernargs} KEYTABLE=${KEYMAP}"
764 fi
765
766 if [[ -n ${CONSOLEFONT} ]]
767 then
768 kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
769 fi
770 fi
771
772 # set this as the default if we have the package and it matches
773 if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&
774 [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]
775 then
776 makedefault="--make-default"
777 [[ -n ${verbose} ]] && echo "making it the default based on config"
778 fi
779
780 if [[ ${moddep} = make ]]
781 then
782 doDepmod
783 elif [[ ${moddep} = remove ]]
784 then
785 doRmmoddep
786 fi
787
788 if [[ ${initrd} = make ]]
789 then
790 mkinitrd
791 elif [[ ${initrd} = remove ]]
792 then
793 rminitrd
794 fi
795
796 if [ ! -x ${grubby} ]
797 then
798 [[ -n ${verbose} ]] && echo "${grubby} does not exist"
799 exit 0
800 fi
801
802 [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
803 [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
804 [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
805 [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
806 [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
807
808 # if we have a uBoot directory, check if it is mounted.
809 # if not, mount it. Then check if a boot script exists.
810 if [[ -n ${ubootDir} ]]
811 then
812 mountEntry=$(mount | grep ${ubootDir})
813 if [[ -z ${mountEntry} ]]
814 then
815 mount ${ubootDevice} ${ubootDir}
816 mounted=1
817 fi
818 [ -f ${ubootScript} ] && cfguBoot=1
819 fi
820
821 # if we have a lilo config on an x86 box, see if the default boot loader
822 # is lilo to determine if it should be run
823 if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]]
824 then
825 runLilo=$(${grubby} --bootloader-probe | grep lilo)
826 fi
827
828 if [[ ${mode} = --install ]]
829 then
830 install
831 elif [[ ${mode} = --remove ]]
832 then
833 remove
834 elif [[ ${mode} = --update ]]
835 then
836 update
837 fi
838
839 exit 0

Properties

Name Value
svn:executable *