Magellan Linux

Annotation of /trunk/grubby/new-kernel-pkg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1749 - (hide annotations) (download)
Sat Feb 18 01:09:18 2012 UTC (12 years, 8 months ago) by niro
File size: 21989 byte(s)
Fix hard coded paths so kernel's "make install" will DTRT.


1 niro 532 #!/bin/bash
2 niro 924 # $Id$
3 niro 532 #
4 niro 923 # new-kernel-pkg
5 niro 532 # 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 niro 923 # Copyright 2002-2008 Red Hat, Inc. All rights reserved.
12 niro 532 # modified for Magellan-Linux by Niels Rogalla <niro@magellan-linux.de>
13     #
14 niro 923 # 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 niro 532
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 niro 924 if [ -x ./grubby ]
36     then
37     grubby=./grubby
38 niro 532 else
39 niro 924 grubby=/sbin/grubby
40 niro 532 fi
41    
42 niro 925 [ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby
43 niro 1691 [ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot
44 niro 532
45 niro 1697 cfgGrub2=""
46     cfgGrub2Efi=""
47 niro 532 cfgGrub=""
48     cfgLilo=""
49 niro 1716 cfgExtlinux=""
50 niro 1691 cfguBoot=""
51 niro 532 runLilo=""
52     grubConfig=""
53 niro 1702 grub2Config=""
54     grub2EfiConfig=""
55 niro 1716 extlinuxConfig=""
56 niro 532
57     ARCH=$(uname -m)
58    
59 niro 924 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 niro 1691 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 niro 532 else
102 niro 924 # this leaves i?86 and x86_64
103     liloConfig=/etc/lilo.conf
104     grubConfig=/boot/grub/grub.conf
105 niro 1697 grub2Config=/boot/grub/grub.cfg
106     grub2EfiConfig=/boot/grub/grub-efi.cfg
107 niro 1716 extlinuxConfig=/boot/extlinux/extlinux.conf
108 niro 924 bootPrefix=/boot
109     liloFlag=lilo
110     isx86="yes"
111 niro 532 fi
112    
113     mode=""
114     version=""
115     initrd=""
116 niro 1334 dracut=""
117     dracuthostonly=""
118 niro 532 initrdfile=""
119     moddep=""
120     verbose=""
121     makedefault=""
122     package=""
123 niro 1706 mbkernel="${HYPERVISOR}"
124     mbargs="${HYPERVISOR_ARGS}"
125 niro 1334 adddracutargs=""
126     addplymouthinitrd=""
127 niro 532
128 niro 924 usage()
129     {
130 niro 1334 echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
131 niro 924 echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
132 niro 1305 echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2
133 niro 924 echo " [--banner=<banner>] [--multiboot=multiboot]" >&2
134 niro 1334 echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
135     echo " [--add-plymouth-initrd]" >&2
136     echo " [--host-only]" >&2
137 niro 924 echo " <--install | --remove | --update> <kernel-version>" >&2
138     echo " (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2
139     exit 1
140 niro 532 }
141    
142 niro 924 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 niro 923
151 niro 924 INITRD=""
152     if [ -f ${initrdfile} ]
153     then
154     [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
155     INITRD="--initrd ${initrdfile}"
156 niro 1334
157     if [[ -n ${addplymouthinitrd} ]]
158     then
159     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
160     fi
161 niro 924 fi
162 niro 532
163 niro 924 # 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 niro 532 fi
178    
179 niro 924 # get the root filesystem to use
180     rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)
181 niro 532
182 niro 924 if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
183     then
184     [[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf"
185     cfgLilo=""
186     fi
187 niro 532
188 niro 924 if [[ -n ${cfgGrub} ]]
189     then
190     [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
191 niro 532
192 niro 924 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 niro 1710 ${grubby} --grub -c ${grubConfig} \
202     --add-kernel=${bootPrefix}/${kernelName}-${version} \
203 niro 924 ${INITRD} --copy-default ${makedefault} --title "${title}" \
204     ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
205     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
206 niro 532 else
207 niro 1697 [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
208 niro 532 fi
209 niro 1697 if [[ -n ${cfgGrub2} ]]
210     then
211     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
212 niro 532
213 niro 1697 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 niro 1702 ${grubby} --grub2 -c ${grub2Config} \
223 niro 1697 --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 niro 1702 ${grubby} --grub2 -c ${grub2EfiConfig} \
245 niro 1697 --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 niro 924 if [[ -n ${cfgLilo} ]]
255     then
256     [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
257 niro 532
258 niro 924 ${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 niro 532
264 niro 924 if [[ -n ${runLilo} ]]
265     then
266     [[ -n ${verbose} ]] && echo "running ${lilo}"
267 niro 1305 if [ ! -x ${lilo} ]
268 niro 924 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 niro 532 fi
277 niro 1716
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 niro 532 }
300    
301 niro 924 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 niro 532
311 niro 924 if [[ -n ${cfgGrub} ]]
312     then
313     [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
314 niro 1710 ${grubby} --grub -c ${grubConfig} \
315     --remove-kernel=${bootPrefix}/${kernelName}-${version}
316 niro 924 else
317 niro 1697 [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
318 niro 924 fi
319 niro 1697 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 niro 532
336 niro 924 if [[ -n ${cfgLilo} ]]
337     then
338     [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
339 niro 1305 ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag}
340 niro 532
341 niro 924 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 niro 532 fi
354 niro 1691
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 niro 1716
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 niro 532 }
418    
419 niro 924 update()
420     {
421 niro 1305 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 niro 1334
433     if [[ -n ${addplymouthinitrd} ]]
434     then
435     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
436     fi
437 niro 1305 fi
438    
439 niro 924 if [[ -n ${cfgGrub} ]]
440     then
441     [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
442 niro 1710 ${grubby} --grub -c ${grubConfig} \
443     --update-kernel=${bootPrefix}/${kernelName}-${version} \
444 niro 1305 ${INITRD} \
445 niro 924 ${kernargs:+--args="${kernargs}"} \
446     ${removeargs:+--remove-args="${removeargs}"}
447     else
448     [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
449     fi
450 niro 923
451 niro 1697 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 niro 924 if [[ -n ${cfgLilo} ]]
476     then
477     [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
478     ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \
479 niro 1305 ${INITRD} \
480 niro 924 ${kernargs:+--args="${kernargs}"} \
481     ${removeargs:+--remove-args="${removeargs}"} \
482     --${liloFlag}
483 niro 923
484 niro 924 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 niro 923 fi
497 niro 1691
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 niro 1716
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 niro 923 }
542    
543 niro 924 mkinitrd()
544     {
545 niro 1334 if [[ -n ${dracut} ]]
546     then
547 niro 1728 tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
548 niro 1334 else
549 niro 1749 tool="mkinitrd --allow-missing -f ${initrdfile} ${version}"
550 niro 1334 fi
551 niro 924 [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
552 niro 1334 ${tool}
553 niro 924 rc=$?
554     if [ ${rc} != 0 ]
555     then
556     echo "mkinitrd failed" >&2
557     exit 1
558     fi
559 niro 532 }
560    
561 niro 924 rminitrd()
562     {
563     [[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}"
564     [ -f ${initrdfile} ] && rm -f ${initrdfile}
565 niro 532 }
566    
567 niro 924 doDepmod()
568     {
569     [[ -n ${verbose} ]] && echo "running depmod for ${version}"
570     depmod -ae -F /boot/System.map-${version} ${version}
571 niro 532 }
572    
573 niro 924 doRmmoddep()
574     {
575     [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
576     [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*
577 niro 532 }
578    
579    
580 niro 924 while [ $# -gt 0 ]
581     do
582     case $1 in
583     --mkinitrd)
584     initrd="make"
585     ;;
586 niro 532
587 niro 924 --rminitrd)
588     initrd="remove"
589     ;;
590 niro 532
591 niro 1334 --dracut)
592     dracut=--dracut
593     ;;
594    
595     --host-only)
596     dracuthostonly=-H
597     ;;
598    
599 niro 924 --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 niro 532
609 niro 924 --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 niro 532
619 niro 924 --remove-args*)
620     if echo $1 | grep '=' >/dev/null
621     then
622 niro 1305 removeargs=$(echo $1 | sed 's/^--remove-args=//')
623 niro 924 else
624     removeargs=$2
625     shift
626     fi
627     ;;
628 niro 923
629 niro 924 --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 niro 532
639 niro 924 --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 niro 532
650 niro 924 --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 niro 532
660 niro 924 --depmod)
661     moddep="make"
662     ;;
663 niro 532
664 niro 924 --rmmoddep)
665     moddep="remove"
666     ;;
667 niro 532
668 niro 924 --make-default)
669     makedefault="--make-default"
670     ;;
671 niro 532
672 niro 924 --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 niro 532
682 niro 1334 --add-dracut-args)
683     adddracutargs=--add-dracut-args
684     ;;
685    
686     --add-plymouth-initrd)
687     addplymouthinitrd=--add-plymouth-initrd
688     ;;
689    
690 niro 924 -v)
691     verbose=-v
692     ;;
693 niro 532
694 niro 924 *)
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 niro 532
707 niro 924 shift
708 niro 532 done
709    
710     # make sure the mode is valid
711 niro 924 if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]]
712     then
713     usage
714 niro 532 fi
715    
716 niro 924 if [[ -z ${version} ]]
717     then
718     usage
719 niro 532 fi
720    
721 niro 924 if [ "${mode}" != "--install" -a "${makedefault}" ]
722     then
723     usage
724 niro 532 fi
725    
726 niro 924 kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)
727 niro 532
728 niro 1305 # kernel image for 2.4 is kernel
729 niro 924 if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
730     then
731     if [[ ${kernelmajor} = 2.4 ]]
732     then
733     kernelName=kernel
734     fi
735 niro 532 fi
736    
737     # set the initrd file based on arch; ia64 is the only currently known oddball
738 niro 924 if [[ -z ${initrdfile} ]]
739     then
740     INITRD_NAME_PREFIX="initrd"
741 niro 1334 if [[ -n ${dracut} ]]
742     then
743     INITRD_NAME_PREFIX="initramfs"
744     fi
745 niro 923
746 niro 924 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 niro 532 fi
753 niro 924 [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
754 niro 532
755 niro 1334 # 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 niro 532 # set this as the default if we have the package and it matches
773 niro 924 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 niro 532 fi
779    
780 niro 924 if [[ ${moddep} = make ]]
781     then
782     doDepmod
783     elif [[ ${moddep} = remove ]]
784     then
785     doRmmoddep
786 niro 532 fi
787    
788 niro 924 if [[ ${initrd} = make ]]
789     then
790     mkinitrd
791     elif [[ ${initrd} = remove ]]
792     then
793     rminitrd
794 niro 532 fi
795    
796 niro 924 if [ ! -x ${grubby} ]
797     then
798     [[ -n ${verbose} ]] && echo "${grubby} does not exist"
799     exit 0
800 niro 532 fi
801    
802 niro 924 [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
803 niro 1697 [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
804     [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
805 niro 924 [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
806 niro 1716 [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
807 niro 532
808 niro 1691 # 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 niro 532 # 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 niro 924 if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]]
824     then
825     runLilo=$(${grubby} --bootloader-probe | grep lilo)
826 niro 532 fi
827    
828 niro 924 if [[ ${mode} = --install ]]
829     then
830     install
831     elif [[ ${mode} = --remove ]]
832     then
833     remove
834     elif [[ ${mode} = --update ]]
835     then
836     update
837 niro 532 fi
838    
839     exit 0

Properties

Name Value
svn:executable *