Contents of /tags/grubby-8_5/new-kernel-pkg
Parent Directory | Revision Log
Revision 1691 -
(show annotations)
(download)
Fri Feb 17 23:10:15 2012 UTC (12 years, 7 months ago) by niro
Original Path: trunk/grubby/new-kernel-pkg
File size: 17422 byte(s)
Fri Feb 17 23:10:15 2012 UTC (12 years, 7 months ago) by niro
Original Path: trunk/grubby/new-kernel-pkg
File size: 17422 byte(s)
Add uboot support for ARM (#712199)
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 | cfgGrub="" |
46 | cfgLilo="" |
47 | cfguBoot="" |
48 | runLilo="" |
49 | grubConfig="" |
50 | |
51 | ARCH=$(uname -m) |
52 | |
53 | if [[ ${ARCH} = ia64 ]] |
54 | then |
55 | liloConfig=/boot/efi/EFI/redhat/elilo.conf |
56 | bootPrefix=/boot/efi/EFI/redhat |
57 | liloFlag=elilo |
58 | isx86="" |
59 | elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
60 | then |
61 | liloConfig=/etc/yaboot.conf |
62 | bootPrefix=/boot |
63 | lilo=/sbin/ybin |
64 | liloFlag=yaboot |
65 | runLilo="yes" |
66 | isx86="" |
67 | elif [[ ${ARCH} = sparc ]] || [[ ${ARCH} = sparc64 ]] |
68 | then |
69 | liloConfig=/etc/silo.conf |
70 | bootPrefix=/boot |
71 | liloFlag=silo |
72 | lilo=/sbin/silo |
73 | isx86="" |
74 | elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]] |
75 | then |
76 | liloConfig=/etc/zipl.conf |
77 | bootPrefix=/boot |
78 | liloFlag=zipl |
79 | lilo=/sbin/zipl |
80 | runLilo="yes" |
81 | isx86="" |
82 | elif [[ ${ARCH} = armv7l ]] |
83 | then |
84 | liloConfig="" |
85 | bootPrefix=/boot |
86 | ubootDir=${UBOOT_DIR:-"/boot/uboot"} |
87 | ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} |
88 | ubootKList=${UBOOT_KLIST:-"klist.txt"} |
89 | ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} |
90 | ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} |
91 | ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} |
92 | mounted="" |
93 | liloFlag="" |
94 | isx86="" |
95 | else |
96 | # this leaves i?86 and x86_64 |
97 | liloConfig=/etc/lilo.conf |
98 | grubConfig=/boot/grub/grub.conf |
99 | bootPrefix=/boot |
100 | liloFlag=lilo |
101 | isx86="yes" |
102 | fi |
103 | |
104 | mode="" |
105 | version="" |
106 | initrd="" |
107 | dracut="" |
108 | dracuthostonly="" |
109 | initrdfile="" |
110 | moddep="" |
111 | verbose="" |
112 | makedefault="" |
113 | package="" |
114 | mbkernel="" |
115 | mbargs="" |
116 | adddracutargs="" |
117 | addplymouthinitrd="" |
118 | |
119 | usage() |
120 | { |
121 | echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2 |
122 | echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2 |
123 | echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2 |
124 | echo " [--banner=<banner>] [--multiboot=multiboot]" >&2 |
125 | echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2 |
126 | echo " [--add-plymouth-initrd]" >&2 |
127 | echo " [--host-only]" >&2 |
128 | echo " <--install | --remove | --update> <kernel-version>" >&2 |
129 | echo " (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2 |
130 | exit 1 |
131 | } |
132 | |
133 | run_grub2() |
134 | { |
135 | if [ -d /boot/grub -a -x /sbin/grub-mkconfig ] |
136 | then |
137 | cp /boot/grub/grub.cfg /boot/grub/grub.cfg.old |
138 | /sbin/grub-mkconfig -o /boot/grub/grub.cfg |
139 | fi |
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 | # Run grub2's configuration update in parallel, if it is installed |
180 | run_grub2 |
181 | |
182 | # get the root filesystem to use |
183 | rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab) |
184 | |
185 | if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]] |
186 | then |
187 | [[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf" |
188 | cfgLilo="" |
189 | fi |
190 | |
191 | if [[ -n ${cfgGrub} ]] |
192 | then |
193 | [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}" |
194 | |
195 | if [[ -n ${banner} ]] |
196 | then |
197 | title="${banner} (${version})" |
198 | elif [ -f /etc/mageversion ] |
199 | then |
200 | title="Magellan Linux $(< /etc/mageversion) (${version})" |
201 | else |
202 | title="Magellan Linux (${version})" |
203 | fi |
204 | ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \ |
205 | ${INITRD} --copy-default ${makedefault} --title "${title}" \ |
206 | ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
207 | --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
208 | else |
209 | [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
210 | fi |
211 | |
212 | if [[ -n ${cfgLilo} ]] |
213 | then |
214 | [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}" |
215 | |
216 | ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \ |
217 | --copy-default ${makedefault} --title ${version} \ |
218 | ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
219 | --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \ |
220 | --${liloFlag} |
221 | |
222 | if [[ -n ${runLilo} ]] |
223 | then |
224 | [[ -n ${verbose} ]] && echo "running ${lilo}" |
225 | if [ ! -x ${lilo} ] |
226 | then |
227 | [[ -n ${verbose} ]] && echo "${lilo} does not exist" |
228 | else |
229 | ${lilo} > /dev/null |
230 | fi |
231 | fi |
232 | else |
233 | [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
234 | fi |
235 | } |
236 | |
237 | remove() |
238 | { |
239 | # FIXME: is this a good heuristic to find out if we're on iSeries? |
240 | if [ -d /proc/iSeries ] |
241 | then |
242 | [[ -n ${verbose} ]] && echo "On an iSeries, remove img file" |
243 | rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null |
244 | return |
245 | fi |
246 | |
247 | # Run grub2's configuration update in parallel, if it is installed |
248 | run_grub2 |
249 | |
250 | if [[ -n ${cfgGrub} ]] |
251 | then |
252 | [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
253 | ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} |
254 | else |
255 | [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
256 | fi |
257 | |
258 | if [[ -n ${cfgLilo} ]] |
259 | then |
260 | [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}" |
261 | ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag} |
262 | |
263 | if [[ -n ${runLilo} ]] |
264 | then |
265 | [[ -n ${verbose} ]] && echo "running ${lilo}" |
266 | if [ ! -x ${lilo} ] |
267 | then |
268 | [[ -n ${verbose} ]] && echo "${lilo} does not exist" |
269 | else |
270 | ${lilo} > /dev/null |
271 | fi |
272 | fi |
273 | else |
274 | [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
275 | fi |
276 | |
277 | if [[ -n ${cfguBoot} ]] |
278 | then |
279 | [[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..." |
280 | |
281 | if [ -f ${ubootDir}/${ubootKList} ] |
282 | then |
283 | tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) |
284 | curversion=$(tail -n1 ${ubootDir}/${ubootKList}) |
285 | sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
286 | newversion=$(tail -n1 ${tmpKList}) |
287 | if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] |
288 | then |
289 | if [[ ${curversion} != ${newversion} ]] |
290 | then |
291 | cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage} |
292 | if [ $? -ne 0 ] |
293 | then |
294 | [[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit |
295 | fi |
296 | cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd} |
297 | if [ $? -ne 0 ] |
298 | then |
299 | [[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit |
300 | fi |
301 | fi |
302 | |
303 | [[ -n ${verbose} ]] && echo "removing uImage-${version}" |
304 | if [ -f ${ubootDir}/uImage-${version} ] |
305 | then |
306 | rm -f ${ubootDir}/uImage-${version} |
307 | else |
308 | [[ -n ${verbose} ]] && echo "uImage-${version} did not exist!" |
309 | fi |
310 | |
311 | [[ -n ${verbose} ]] && echo "removing uInitrd-${version}" |
312 | if [ -f ${ubootDir}/uInitrd-${version} ] |
313 | then |
314 | rm -f ${ubootDir}/uInitrd-${version} |
315 | else |
316 | [[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!" |
317 | fi |
318 | |
319 | mv ${tmpKList} ${ubootDir}/${ubootKList} |
320 | else |
321 | [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!" |
322 | [ -f ${tmpKList} ] && rm -f ${tmpKList} |
323 | fi |
324 | else |
325 | [[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!" |
326 | fi |
327 | else |
328 | [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
329 | fi |
330 | } |
331 | |
332 | update() |
333 | { |
334 | if [ ! -f ${bootPrefix}/${kernelName}-${version} ] |
335 | then |
336 | [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
337 | return |
338 | fi |
339 | |
340 | INITRD="" |
341 | if [ -f ${initrdfile} ] |
342 | then |
343 | [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" |
344 | INITRD="--initrd ${initrdfile}" |
345 | |
346 | if [[ -n ${addplymouthinitrd} ]] |
347 | then |
348 | INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img" |
349 | fi |
350 | fi |
351 | |
352 | # Run grub2's configuration update in parallel, if it is installed |
353 | run_grub2 |
354 | |
355 | if [[ -n ${cfgGrub} ]] |
356 | then |
357 | [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
358 | ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
359 | ${INITRD} \ |
360 | ${kernargs:+--args="${kernargs}"} \ |
361 | ${removeargs:+--remove-args="${removeargs}"} |
362 | else |
363 | [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
364 | fi |
365 | |
366 | if [[ -n ${cfgLilo} ]] |
367 | then |
368 | [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" |
369 | ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
370 | ${INITRD} \ |
371 | ${kernargs:+--args="${kernargs}"} \ |
372 | ${removeargs:+--remove-args="${removeargs}"} \ |
373 | --${liloFlag} |
374 | |
375 | if [[ -n ${runLilo} ]] |
376 | then |
377 | [[ -n ${verbose} ]] && echo "running ${lilo}" |
378 | if [ ! -x ${lilo} ] |
379 | then |
380 | [[ -n ${verbose} ]] && echo "${lilo} does not exist" |
381 | else |
382 | ${lilo} > /dev/null |
383 | fi |
384 | fi |
385 | else |
386 | [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
387 | fi |
388 | |
389 | if [[ -n ${cfguBoot} ]] |
390 | then |
391 | [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
392 | |
393 | [[ -n ${verbose} ]] && echo "creating uImage-${version}" |
394 | mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \ |
395 | -n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
396 | |
397 | [[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
398 | mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ |
399 | -n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version} |
400 | |
401 | if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ] |
402 | then |
403 | cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage} |
404 | if [ $? -ne 0 ] |
405 | then |
406 | [[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit |
407 | fi |
408 | cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd} |
409 | if [ $? -ne 0 ] |
410 | then |
411 | [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit |
412 | fi |
413 | echo ${version} >> ${ubootDir}/${ubootKList} |
414 | else |
415 | [[ -n ${verbose} ]] && echo "cannot make ${version} the default" |
416 | fi |
417 | else |
418 | [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" |
419 | fi |
420 | } |
421 | |
422 | mkinitrd() |
423 | { |
424 | if [[ -n ${dracut} ]] |
425 | then |
426 | tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
427 | else |
428 | tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}" |
429 | fi |
430 | [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
431 | ${tool} |
432 | rc=$? |
433 | if [ ${rc} != 0 ] |
434 | then |
435 | echo "mkinitrd failed" >&2 |
436 | exit 1 |
437 | fi |
438 | } |
439 | |
440 | rminitrd() |
441 | { |
442 | [[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}" |
443 | [ -f ${initrdfile} ] && rm -f ${initrdfile} |
444 | } |
445 | |
446 | doDepmod() |
447 | { |
448 | [[ -n ${verbose} ]] && echo "running depmod for ${version}" |
449 | depmod -ae -F /boot/System.map-${version} ${version} |
450 | } |
451 | |
452 | doRmmoddep() |
453 | { |
454 | [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}" |
455 | [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.* |
456 | } |
457 | |
458 | |
459 | while [ $# -gt 0 ] |
460 | do |
461 | case $1 in |
462 | --mkinitrd) |
463 | initrd="make" |
464 | ;; |
465 | |
466 | --rminitrd) |
467 | initrd="remove" |
468 | ;; |
469 | |
470 | --dracut) |
471 | dracut=--dracut |
472 | ;; |
473 | |
474 | --host-only) |
475 | dracuthostonly=-H |
476 | ;; |
477 | |
478 | --initrdfile*) |
479 | if echo $1 | grep '=' >/dev/null |
480 | then |
481 | initrdfile=$(echo $1 | sed 's/^--initrdfile=//') |
482 | else |
483 | initrdfile=$2 |
484 | shift |
485 | fi |
486 | ;; |
487 | |
488 | --kernel-args*) |
489 | if echo $1 | grep '=' >/dev/null |
490 | then |
491 | kernargs=$(echo $1 | sed 's/^--kernel-args=//') |
492 | else |
493 | kernargs=$2 |
494 | shift |
495 | fi |
496 | ;; |
497 | |
498 | --remove-args*) |
499 | if echo $1 | grep '=' >/dev/null |
500 | then |
501 | removeargs=$(echo $1 | sed 's/^--remove-args=//') |
502 | else |
503 | removeargs=$2 |
504 | shift |
505 | fi |
506 | ;; |
507 | |
508 | --banner*) |
509 | if echo $1 | grep '=' >/dev/null |
510 | then |
511 | banner=$(echo $1 | sed 's/^--banner=//') |
512 | else |
513 | banner=$2 |
514 | shift |
515 | fi |
516 | ;; |
517 | |
518 | --multiboot*) |
519 | if echo $1 |grep '=' >/dev/null |
520 | then |
521 | mbkernel=$(echo $1 | sed 's/^--multiboot=//') |
522 | else |
523 | # can't really support having an optional second arg here |
524 | # sorry! |
525 | mbkernel="/boot/xen.gz" |
526 | fi |
527 | ;; |
528 | |
529 | --mbargs*) |
530 | if echo $1 |grep '=' >/dev/null |
531 | then |
532 | mbargs=$(echo $1 | sed 's/^--mbargs=//') |
533 | else |
534 | mbargs="$2" |
535 | shift |
536 | fi |
537 | ;; |
538 | |
539 | --depmod) |
540 | moddep="make" |
541 | ;; |
542 | |
543 | --rmmoddep) |
544 | moddep="remove" |
545 | ;; |
546 | |
547 | --make-default) |
548 | makedefault="--make-default" |
549 | ;; |
550 | |
551 | --package) |
552 | if echo $1 | grep '=' >/dev/null |
553 | then |
554 | package=$(echo $1 | sed 's/^--package=//') |
555 | else |
556 | package=$2 |
557 | shift |
558 | fi |
559 | ;; |
560 | |
561 | --add-dracut-args) |
562 | adddracutargs=--add-dracut-args |
563 | ;; |
564 | |
565 | --add-plymouth-initrd) |
566 | addplymouthinitrd=--add-plymouth-initrd |
567 | ;; |
568 | |
569 | -v) |
570 | verbose=-v |
571 | ;; |
572 | |
573 | *) |
574 | if [[ -z ${mode} ]] |
575 | then |
576 | mode=$1 |
577 | elif [[ -z ${version} ]] |
578 | then |
579 | version=$1 |
580 | else |
581 | usage |
582 | fi |
583 | ;; |
584 | esac |
585 | |
586 | shift |
587 | done |
588 | |
589 | # make sure the mode is valid |
590 | if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]] |
591 | then |
592 | usage |
593 | fi |
594 | |
595 | if [[ -z ${version} ]] |
596 | then |
597 | usage |
598 | fi |
599 | |
600 | if [ "${mode}" != "--install" -a "${makedefault}" ] |
601 | then |
602 | usage |
603 | fi |
604 | |
605 | kernelmajor=$(echo ${kernel} | cut -d . -f 1,2) |
606 | |
607 | # kernel image for 2.4 is kernel |
608 | if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
609 | then |
610 | if [[ ${kernelmajor} = 2.4 ]] |
611 | then |
612 | kernelName=kernel |
613 | fi |
614 | fi |
615 | |
616 | # set the initrd file based on arch; ia64 is the only currently known oddball |
617 | if [[ -z ${initrdfile} ]] |
618 | then |
619 | INITRD_NAME_PREFIX="initrd" |
620 | if [[ -n ${dracut} ]] |
621 | then |
622 | INITRD_NAME_PREFIX="initramfs" |
623 | fi |
624 | |
625 | if [[ $(uname -m) = ia64 ]] |
626 | then |
627 | initrdfile="/boot/efi/EFI/redhat/${INITRD_NAME_PREFIX}-${version}.img" |
628 | else |
629 | initrdfile="/boot/${INITRD_NAME_PREFIX}-${version}.img" |
630 | fi |
631 | fi |
632 | [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}" |
633 | |
634 | # add dracut i18n, keyboard and plymouth kernel args if requested |
635 | if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]] |
636 | then |
637 | [ -r /etc/conf.d/keymap ] && . /etc/conf.d/keymap |
638 | [ -r /etc/conf.d/consolefont ] && . /etc/conf.d/consolefont |
639 | |
640 | if [[ -n ${KEYMAP} ]] |
641 | then |
642 | kernargs="${kernargs} KEYTABLE=${KEYMAP}" |
643 | fi |
644 | |
645 | if [[ -n ${CONSOLEFONT} ]] |
646 | then |
647 | kernargs="${kernargs} SYSFONT=${CONSOLEFONT}" |
648 | fi |
649 | fi |
650 | |
651 | # set this as the default if we have the package and it matches |
652 | if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && |
653 | [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]] |
654 | then |
655 | makedefault="--make-default" |
656 | [[ -n ${verbose} ]] && echo "making it the default based on config" |
657 | fi |
658 | |
659 | if [[ ${moddep} = make ]] |
660 | then |
661 | doDepmod |
662 | elif [[ ${moddep} = remove ]] |
663 | then |
664 | doRmmoddep |
665 | fi |
666 | |
667 | if [[ ${initrd} = make ]] |
668 | then |
669 | mkinitrd |
670 | elif [[ ${initrd} = remove ]] |
671 | then |
672 | rminitrd |
673 | fi |
674 | |
675 | if [ ! -x ${grubby} ] |
676 | then |
677 | [[ -n ${verbose} ]] && echo "${grubby} does not exist" |
678 | exit 0 |
679 | fi |
680 | |
681 | [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
682 | [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
683 | |
684 | # if we have a uBoot directory, check if it is mounted. |
685 | # if not, mount it. Then check if a boot script exists. |
686 | if [[ -n ${ubootDir} ]] |
687 | then |
688 | mountEntry=$(mount | grep ${ubootDir}) |
689 | if [[ -z ${mountEntry} ]] |
690 | then |
691 | mount ${ubootDevice} ${ubootDir} |
692 | mounted=1 |
693 | fi |
694 | [ -f ${ubootScript} ] && cfguBoot=1 |
695 | fi |
696 | |
697 | # if we have a lilo config on an x86 box, see if the default boot loader |
698 | # is lilo to determine if it should be run |
699 | if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]] |
700 | then |
701 | runLilo=$(${grubby} --bootloader-probe | grep lilo) |
702 | fi |
703 | |
704 | if [[ ${mode} = --install ]] |
705 | then |
706 | install |
707 | elif [[ ${mode} = --remove ]] |
708 | then |
709 | remove |
710 | elif [[ ${mode} = --update ]] |
711 | then |
712 | update |
713 | fi |
714 | |
715 | exit 0 |
Properties
Name | Value |
---|---|
svn:executable | * |