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