Annotation of /trunk/grubby/new-kernel-pkg
Parent Directory | Revision Log
Revision 2996 -
(hide annotations)
(download)
Thu Jun 30 10:39:38 2016 UTC (8 years, 2 months ago) by niro
File size: 27028 byte(s)
Thu Jun 30 10:39:38 2016 UTC (8 years, 2 months ago) by niro
File size: 27028 byte(s)
ppc64le sync grub.cfg changes to disk (#1212114)
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 | niro | 1778 | read_os_release() |
29 | { | ||
30 | local NAME | ||
31 | local ID | ||
32 | local Version | ||
33 | local Version_ID | ||
34 | local PRETTY_NAME | ||
35 | local ANSI_COLOR | ||
36 | local CPE_NAME | ||
37 | |||
38 | if [[ -f /etc/os-release ]] | ||
39 | then | ||
40 | source /etc/os-release | ||
41 | |||
42 | case $1 in | ||
43 | name) echo "${NAME}" ;; | ||
44 | id) echo "${ID}" ;; | ||
45 | version) echo "${Version}" ;; | ||
46 | version_id) echo "${Version_ID}" ;; | ||
47 | pretty_name) echo "${PRETTY_NAME}" ;; | ||
48 | ansi_color) echo "${ANSI_COLOR}" ;; | ||
49 | cpe_name) echo "${CPE_NAME}" ;; | ||
50 | esac | ||
51 | fi | ||
52 | } | ||
53 | |||
54 | niro | 532 | PATH=/sbin:/bin:$PATH |
55 | |||
56 | lilo=/sbin/lilo | ||
57 | |||
58 | # some defaults that are sane for most arches | ||
59 | kernelName=kernel | ||
60 | |||
61 | niro | 924 | if [ -x ./grubby ] |
62 | then | ||
63 | grubby=./grubby | ||
64 | niro | 532 | else |
65 | niro | 924 | grubby=/sbin/grubby |
66 | niro | 532 | fi |
67 | |||
68 | niro | 925 | [ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby |
69 | niro | 1691 | [ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot |
70 | niro | 532 | |
71 | niro | 1697 | cfgGrub2="" |
72 | cfgGrub2Efi="" | ||
73 | niro | 532 | cfgGrub="" |
74 | cfgLilo="" | ||
75 | niro | 1716 | cfgExtlinux="" |
76 | niro | 1691 | cfguBoot="" |
77 | niro | 532 | runLilo="" |
78 | grubConfig="" | ||
79 | niro | 1702 | grub2Config="" |
80 | grub2EfiConfig="" | ||
81 | niro | 1716 | extlinuxConfig="" |
82 | niro | 2961 | ubootScript="/boot/boot.scr" |
83 | niro | 532 | |
84 | ARCH=$(uname -m) | ||
85 | |||
86 | niro | 924 | if [[ ${ARCH} = ia64 ]] |
87 | then | ||
88 | liloConfig=/boot/efi/EFI/redhat/elilo.conf | ||
89 | bootPrefix=/boot/efi/EFI/redhat | ||
90 | liloFlag=elilo | ||
91 | isx86="" | ||
92 | elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] | ||
93 | then | ||
94 | liloConfig=/etc/yaboot.conf | ||
95 | niro | 1803 | grub2Config=/boot/grub/grub.cfg |
96 | niro | 924 | bootPrefix=/boot |
97 | lilo=/sbin/ybin | ||
98 | liloFlag=yaboot | ||
99 | runLilo="yes" | ||
100 | isx86="" | ||
101 | elif [[ ${ARCH} = sparc ]] || [[ ${ARCH} = sparc64 ]] | ||
102 | then | ||
103 | liloConfig=/etc/silo.conf | ||
104 | bootPrefix=/boot | ||
105 | liloFlag=silo | ||
106 | lilo=/sbin/silo | ||
107 | isx86="" | ||
108 | elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]] | ||
109 | then | ||
110 | liloConfig=/etc/zipl.conf | ||
111 | bootPrefix=/boot | ||
112 | liloFlag=zipl | ||
113 | lilo=/sbin/zipl | ||
114 | runLilo="yes" | ||
115 | isx86="" | ||
116 | niro | 1848 | elif [[ ${ARCH} =~ armv[5|7].*l ]] |
117 | niro | 1691 | then |
118 | liloConfig="" | ||
119 | bootPrefix=/boot | ||
120 | niro | 2259 | extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null) |
121 | niro | 1847 | ubootDir=${UBOOT_DIR:-"/boot"} |
122 | niro | 1691 | ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} |
123 | ubootKList=${UBOOT_KLIST:-"klist.txt"} | ||
124 | ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} | ||
125 | ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} | ||
126 | ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} | ||
127 | niro | 1937 | ubootAddress=${UBOOT_IMGADDR:-"0x00008000"} |
128 | niro | 1691 | mounted="" |
129 | liloFlag="" | ||
130 | isx86="" | ||
131 | niro | 532 | else |
132 | niro | 924 | # this leaves i?86 and x86_64 |
133 | liloConfig=/etc/lilo.conf | ||
134 | grubConfig=/boot/grub/grub.conf | ||
135 | niro | 1697 | grub2Config=/boot/grub/grub.cfg |
136 | grub2EfiConfig=/boot/grub/grub-efi.cfg | ||
137 | niro | 1716 | extlinuxConfig=/boot/extlinux/extlinux.conf |
138 | niro | 924 | bootPrefix=/boot |
139 | liloFlag=lilo | ||
140 | isx86="yes" | ||
141 | niro | 532 | fi |
142 | |||
143 | mode="" | ||
144 | version="" | ||
145 | initrd="" | ||
146 | niro | 1334 | dracut="" |
147 | dracuthostonly="" | ||
148 | niro | 532 | initrdfile="" |
149 | niro | 2685 | devtreefile="" |
150 | niro | 532 | moddep="" |
151 | verbose="" | ||
152 | makedefault="" | ||
153 | package="" | ||
154 | niro | 1706 | mbkernel="${HYPERVISOR}" |
155 | mbargs="${HYPERVISOR_ARGS}" | ||
156 | niro | 1334 | adddracutargs="" |
157 | addplymouthinitrd="" | ||
158 | niro | 2993 | DEBUGARG="systemd.log_level=debug systemd.log_target=kmsg" |
159 | niro | 532 | |
160 | niro | 924 | usage() |
161 | { | ||
162 | niro | 1334 | echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2 |
163 | niro | 924 | echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2 |
164 | niro | 1305 | echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2 |
165 | niro | 924 | echo " [--banner=<banner>] [--multiboot=multiboot]" >&2 |
166 | niro | 1334 | echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2 |
167 | echo " [--add-plymouth-initrd]" >&2 | ||
168 | niro | 2972 | echo " [--host-only] [--devtree=<devicetree.dtb>] [--devtreedir=</devicetree/path/>]" >&2 |
169 | niro | 924 | echo " <--install | --remove | --update> <kernel-version>" >&2 |
170 | echo " (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2 | ||
171 | exit 1 | ||
172 | niro | 532 | } |
173 | |||
174 | niro | 2961 | rungrubby() |
175 | { | ||
176 | if [[ $1 == --debug ]] | ||
177 | then | ||
178 | [[ ${MAKEDEBUG} != yes ]] && return 0 | ||
179 | [[ -n ${verbose} ]] && echo "- First, making a debug entry." | ||
180 | niro | 2990 | if [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]] |
181 | then | ||
182 | declare -x debugtitle="_with_debugging" | ||
183 | else | ||
184 | declare -x debugtitle=" with debugging" | ||
185 | fi | ||
186 | niro | 2961 | declare -x debugargs="${DEBUGARG}" |
187 | shift | ||
188 | else | ||
189 | [[ -n ${verbose} ] && echo "- Making a normal entry." | ||
190 | fi | ||
191 | $(eval $grubby $@) | ||
192 | export -n debugargs | ||
193 | export -n debugtitle | ||
194 | unset debugargs | ||
195 | unset debugtitle | ||
196 | } | ||
197 | |||
198 | set_title() | ||
199 | { | ||
200 | if [[ -n ${banner} ]] | ||
201 | then | ||
202 | if [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]] | ||
203 | then | ||
204 | title=$(echo ${banner} | sed 's/ /_/g') | ||
205 | else | ||
206 | title="${banner} [ ${version} ]" | ||
207 | fi | ||
208 | elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]] | ||
209 | then | ||
210 | title=$(echo ${version} | sed 's/ /_/g') | ||
211 | elif [ -f /etc/os-release ] | ||
212 | then | ||
213 | title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" | ||
214 | elif [ -f /etc/mageversion ] | ||
215 | then | ||
216 | title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" | ||
217 | else | ||
218 | title="Magellan Linux [ ${version} ]" | ||
219 | fi | ||
220 | } | ||
221 | |||
222 | niro | 924 | install() |
223 | { | ||
224 | # XXX kernel should be able to be specified also (or work right on ia64) | ||
225 | niro | 2241 | if [ ! -f ${kernelImage} ] |
226 | niro | 924 | then |
227 | [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" | ||
228 | return | ||
229 | fi | ||
230 | niro | 923 | |
231 | niro | 924 | INITRD="" |
232 | if [ -f ${initrdfile} ] | ||
233 | then | ||
234 | [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" | ||
235 | INITRD="--initrd ${initrdfile}" | ||
236 | niro | 1334 | |
237 | if [[ -n ${addplymouthinitrd} ]] | ||
238 | then | ||
239 | INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img" | ||
240 | fi | ||
241 | niro | 924 | fi |
242 | niro | 532 | |
243 | niro | 2685 | DEVTREE="" |
244 | niro | 2972 | if [[ -n ${devtreefile} ]] && [ -f ${devtreefile} ] |
245 | niro | 2685 | then |
246 | [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby" | ||
247 | DEVTREE="--devtree ${devtreefile}" | ||
248 | fi | ||
249 | |||
250 | niro | 2972 | DEVTREEDIR="" |
251 | if [[ -n ${devtreedir} ]] && [ -d ${devtreedir} ] | ||
252 | then | ||
253 | [ -n ${verbose} ] && echo "found ${devtreedir} and using it with grubby" | ||
254 | DEVTREEDIR="--devtreedir ${devtreedir}" | ||
255 | fi | ||
256 | |||
257 | niro | 924 | # FIXME: is this a good heuristic to find out if we're on iSeries? |
258 | if [ -d /proc/iSeries ] | ||
259 | then | ||
260 | [[ -n ${verbose} ]] && echo "On an iSeries, just making img file" | ||
261 | if [[ -z ${initrdfile} ]] | ||
262 | then | ||
263 | [[ -n ${verbose} ]] && echo "No initrd, just adding system map" | ||
264 | niro | 2241 | /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinitrd-${version} |
265 | niro | 924 | else |
266 | niro | 2241 | /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinux.sm-${version} |
267 | niro | 924 | /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null |
268 | rm ${bootPrefix}/vmlinux.sm-${version} | ||
269 | fi | ||
270 | return | ||
271 | niro | 532 | fi |
272 | |||
273 | niro | 924 | # get the root filesystem to use |
274 | niro | 2238 | rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab 2>/dev/null) |
275 | niro | 2237 | if [[ -z $rootdevice ]] |
276 | then | ||
277 | rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline) | ||
278 | fi | ||
279 | niro | 532 | |
280 | niro | 924 | if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]] |
281 | then | ||
282 | [[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf" | ||
283 | cfgLilo="" | ||
284 | fi | ||
285 | niro | 532 | |
286 | niro | 2961 | set_title |
287 | niro | 2239 | |
288 | niro | 924 | if [[ -n ${cfgGrub} ]] |
289 | then | ||
290 | [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}" | ||
291 | niro | 532 | |
292 | niro | 2961 | ARGS="--grub -c ${grubConfig} --add-kernel=${kernelImage} ${INITRD} \ |
293 | ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \ | ||
294 | ${mbargs:+--mbargs=\"${mbargs}\"} \ | ||
295 | --title=\"${title}\${debugtitle}\" --copy-default \ | ||
296 | --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \ | ||
297 | --remove-kernel=\"TITLE=${title}\${debugtitle}\"" | ||
298 | rungrubby --debug ${ARGS} | ||
299 | rungrubby ${ARGS} ${makedefault} | ||
300 | niro | 532 | else |
301 | niro | 1697 | [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
302 | niro | 532 | fi |
303 | niro | 1697 | if [[ -n ${cfgGrub2} ]] |
304 | then | ||
305 | [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}" | ||
306 | niro | 532 | |
307 | niro | 2961 | ARGS="--grub2 -c ${grub2Config} --add-kernel=${kernelImage} ${INITRD} \ |
308 | --copy-default --title \"${title}\${debugtitle}\" \ | ||
309 | ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \ | ||
310 | ${mbargs:+--mbargs=\"${mbargs}\"} \ | ||
311 | --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \ | ||
312 | --remove-kernel=\"TITLE=${title}\${debugtitle}\"" | ||
313 | rungrubby --debug ${ARGS} | ||
314 | rungrubby ${ARGS} ${makedefault} | ||
315 | niro | 1697 | else |
316 | [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" | ||
317 | fi | ||
318 | if [[ -n ${cfgGrub2Efi} ]] | ||
319 | then | ||
320 | [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}" | ||
321 | |||
322 | niro | 2961 | ARGS="--grub2 -c ${grub2EfiConfig} --efi \ |
323 | --add-kernel=${kernelImage} ${DEVTREE} ${INITRD} \ | ||
324 | --copy-default --title \"${title}\${debugtitle}\" \ | ||
325 | ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \ | ||
326 | ${mbargs:+--mbargs=\"${mbargs}\"} \ | ||
327 | --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \ | ||
328 | --remove-kernel=\"TITLE=${title}\${debugtitle}\"" | ||
329 | rungrubby --debug ${ARGS} | ||
330 | rungrubby ${ARGS} ${makedefault} | ||
331 | niro | 1697 | else |
332 | [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI" | ||
333 | fi | ||
334 | |||
335 | niro | 924 | if [[ -n ${cfgLilo} ]] |
336 | then | ||
337 | [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}" | ||
338 | niro | 532 | |
339 | niro | 2961 | ARGS="--${liloFlag} --add-kernel=${kernelImage} ${INITRD} \ |
340 | --copy-default --title \"${title}\${debugtitle}\" \ | ||
341 | ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \ | ||
342 | ${mbargs:+--mbargs=\"${mbargs}\"} \ | ||
343 | --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \ | ||
344 | --remove-kernel=\"TITLE=${version}\"" | ||
345 | rungrubby --debug ${ARGS} | ||
346 | rungrubby ${ARGS} ${makedefault} | ||
347 | niro | 532 | |
348 | niro | 924 | if [[ -n ${runLilo} ]] |
349 | then | ||
350 | [[ -n ${verbose} ]] && echo "running ${lilo}" | ||
351 | niro | 1305 | if [ ! -x ${lilo} ] |
352 | niro | 924 | 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 | niro | 532 | fi |
361 | niro | 1716 | |
362 | if [[ -n ${cfgExtlinux} ]] | ||
363 | then | ||
364 | [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}" | ||
365 | |||
366 | niro | 2961 | ARGS="--extlinux -c ${extlinuxConfig} --add-kernel=${kernelImage} \ |
367 | niro | 2972 | ${DEVTREEDIR} ${DEVTREE} \ |
368 | ${INITRD} --copy-default --title \"${title}\${debugtitle}\" \ | ||
369 | niro | 2961 | ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \ |
370 | ${mbargs:+--mbargs=\"${mbargs}\"} \ | ||
371 | --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \ | ||
372 | --remove-kernel=\"TITLE=${title}\${debugtitle}\"" | ||
373 | rungrubby --debug ${ARGS} | ||
374 | rungrubby ${ARGS} ${makedefault} | ||
375 | niro | 1716 | else |
376 | [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" | ||
377 | fi | ||
378 | niro | 532 | } |
379 | |||
380 | niro | 924 | remove() |
381 | { | ||
382 | # FIXME: is this a good heuristic to find out if we're on iSeries? | ||
383 | if [ -d /proc/iSeries ] | ||
384 | then | ||
385 | [[ -n ${verbose} ]] && echo "On an iSeries, remove img file" | ||
386 | niro | 2241 | rm -f ${kernelImage}.img 2>/dev/null |
387 | niro | 924 | return |
388 | fi | ||
389 | niro | 532 | |
390 | niro | 924 | if [[ -n ${cfgGrub} ]] |
391 | then | ||
392 | [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" | ||
393 | niro | 1710 | ${grubby} --grub -c ${grubConfig} \ |
394 | niro | 2241 | --remove-kernel=${kernelImage} |
395 | niro | 924 | else |
396 | niro | 1697 | [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
397 | niro | 924 | fi |
398 | niro | 1697 | if [[ -n ${cfgGrub2} ]] |
399 | then | ||
400 | [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}" | ||
401 | ${grubby} --grub2 -c ${grub2Config} \ | ||
402 | niro | 2241 | --remove-kernel=${kernelImage} |
403 | niro | 1697 | else |
404 | [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" | ||
405 | fi | ||
406 | if [[ -n ${cfgGrub2Efi} ]] | ||
407 | then | ||
408 | [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}" | ||
409 | niro | 2051 | ${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
410 | niro | 2241 | --remove-kernel=${kernelImage} |
411 | niro | 1697 | else |
412 | [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI" | ||
413 | fi | ||
414 | niro | 532 | |
415 | niro | 924 | if [[ -n ${cfgLilo} ]] |
416 | then | ||
417 | [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}" | ||
418 | niro | 2241 | ${grubby} --remove-kernel=${kernelImage} --${liloFlag} |
419 | niro | 532 | |
420 | niro | 924 | if [[ -n ${runLilo} ]] |
421 | then | ||
422 | [[ -n ${verbose} ]] && echo "running ${lilo}" | ||
423 | if [ ! -x ${lilo} ] | ||
424 | then | ||
425 | [[ -n ${verbose} ]] && echo "${lilo} does not exist" | ||
426 | else | ||
427 | ${lilo} > /dev/null | ||
428 | fi | ||
429 | fi | ||
430 | else | ||
431 | [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" | ||
432 | niro | 532 | fi |
433 | niro | 1691 | |
434 | if [[ -n ${cfguBoot} ]] | ||
435 | then | ||
436 | [[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..." | ||
437 | |||
438 | if [ -f ${ubootDir}/${ubootKList} ] | ||
439 | then | ||
440 | tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) | ||
441 | curversion=$(tail -n1 ${ubootDir}/${ubootKList}) | ||
442 | niro | 1847 | sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
443 | niro | 1691 | newversion=$(tail -n1 ${tmpKList}) |
444 | if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] | ||
445 | then | ||
446 | if [[ ${curversion} != ${newversion} ]] | ||
447 | then | ||
448 | cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage} | ||
449 | if [ $? -ne 0 ] | ||
450 | then | ||
451 | [[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit | ||
452 | fi | ||
453 | cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd} | ||
454 | if [ $? -ne 0 ] | ||
455 | then | ||
456 | [[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit | ||
457 | fi | ||
458 | fi | ||
459 | |||
460 | [[ -n ${verbose} ]] && echo "removing uImage-${version}" | ||
461 | if [ -f ${ubootDir}/uImage-${version} ] | ||
462 | then | ||
463 | rm -f ${ubootDir}/uImage-${version} | ||
464 | else | ||
465 | [[ -n ${verbose} ]] && echo "uImage-${version} did not exist!" | ||
466 | fi | ||
467 | |||
468 | [[ -n ${verbose} ]] && echo "removing uInitrd-${version}" | ||
469 | if [ -f ${ubootDir}/uInitrd-${version} ] | ||
470 | then | ||
471 | rm -f ${ubootDir}/uInitrd-${version} | ||
472 | else | ||
473 | [[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!" | ||
474 | fi | ||
475 | |||
476 | mv ${tmpKList} ${ubootDir}/${ubootKList} | ||
477 | niro | 2248 | [ -x /sbin/a-b-c ] && /sbin/a-b-c |
478 | niro | 1691 | else |
479 | [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!" | ||
480 | [ -f ${tmpKList} ] && rm -f ${tmpKList} | ||
481 | fi | ||
482 | else | ||
483 | niro | 1752 | [[ -n ${verbose} ]] && echo "No previous kernel version. U-Boot images not removed!" |
484 | niro | 1691 | fi |
485 | else | ||
486 | [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" | ||
487 | fi | ||
488 | niro | 1716 | |
489 | if [[ -n ${cfgExtlinux} ]] | ||
490 | then | ||
491 | [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}" | ||
492 | ${grubby} --extlinux -c ${extlinuxConfig} \ | ||
493 | niro | 2241 | --remove-kernel=${kernelImage} |
494 | niro | 1716 | else |
495 | [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" | ||
496 | fi | ||
497 | niro | 532 | } |
498 | |||
499 | niro | 924 | update() |
500 | { | ||
501 | niro | 2241 | if [ ! -f ${kernelImage} ] |
502 | niro | 1305 | then |
503 | [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" | ||
504 | return | ||
505 | fi | ||
506 | |||
507 | niro | 2961 | set_title |
508 | |||
509 | niro | 1305 | INITRD="" |
510 | if [ -f ${initrdfile} ] | ||
511 | then | ||
512 | [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" | ||
513 | INITRD="--initrd ${initrdfile}" | ||
514 | niro | 1334 | |
515 | if [[ -n ${addplymouthinitrd} ]] | ||
516 | then | ||
517 | INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img" | ||
518 | fi | ||
519 | niro | 1305 | fi |
520 | |||
521 | niro | 2971 | DEVTREE="" |
522 | niro | 2972 | if [[ -n ${devtreefile} ]] && [ -f ${devtreefile} ] |
523 | niro | 2971 | then |
524 | [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby" | ||
525 | DEVTREE="--devtree ${devtreefile}" | ||
526 | fi | ||
527 | |||
528 | niro | 2972 | DEVTREEDIR="" |
529 | if [[ -n ${devtreedir} ]] && [ -d ${devtreedir} ] | ||
530 | then | ||
531 | [[ -n ${verbose} ]] && echo "found ${devtreedir} and using it with grubby" | ||
532 | DEVTREEDIR="--devtreedir ${devtreedir}" | ||
533 | fi | ||
534 | |||
535 | niro | 924 | if [[ -n ${cfgGrub} ]] |
536 | then | ||
537 | [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" | ||
538 | niro | 2961 | ARGS="--grub -c ${grubConfig} --update-kernel=${kernelImage} ${INITRD} \ |
539 | ${kernargs:+--args=\"${kernargs}\"} \ | ||
540 | ${removeargs:+--remove-args=\"${removeargs}\"} \ | ||
541 | ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \ | ||
542 | --title=\"${title}\${debugtitle}\"" | ||
543 | rungrubby --debug ${ARGS} | ||
544 | rungrubby ${ARGS} | ||
545 | niro | 924 | else |
546 | [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" | ||
547 | fi | ||
548 | niro | 923 | |
549 | niro | 1697 | if [[ -n ${cfgGrub2} ]] |
550 | then | ||
551 | [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}" | ||
552 | niro | 2961 | ARGS="--grub2 -c ${grub2Config} --update-kernel=${kernelImage} ${INITRD} \ |
553 | ${kernargs:+--args=\"${kernargs}\"} \ | ||
554 | ${removeargs:+--remove-args=\"${removeargs}\"} \ | ||
555 | --title=\"${title}\${debugtitle}\"" | ||
556 | rungrubby --debug ${ARGS} | ||
557 | rungrubby ${ARGS} | ||
558 | niro | 1697 | else |
559 | [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby" | ||
560 | fi | ||
561 | |||
562 | if [[ -n ${cfgGrub2Efi} ]] | ||
563 | then | ||
564 | [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}" | ||
565 | niro | 2961 | ARGS="--grub2 -c ${grub2EfiConfig} --efi --update-kernel=${kernelImage} \ |
566 | ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \ | ||
567 | ${removeargs:+--remove-args=\"${removeargs}\"} \ | ||
568 | --title=\"${title}\${debugtitle}\"" | ||
569 | rungrubby --debug ${ARGS} | ||
570 | rungrubby ${ARGS} | ||
571 | niro | 1697 | else |
572 | [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby" | ||
573 | fi | ||
574 | |||
575 | niro | 924 | if [[ -n ${cfgLilo} ]] |
576 | then | ||
577 | [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" | ||
578 | niro | 2961 | ARGS="--${liloFlag} --update-kernel=${kernelImage} ${INITRD} \ |
579 | ${kernargs:+--args=\"${kernargs}\"} \ | ||
580 | ${removeargs:+--remove-args=\"${removeargs}\"} \ | ||
581 | --title=\"${title}\${debugtitle}\"" | ||
582 | rungrubby --debug ${ARGS} | ||
583 | rungrubby ${ARGS} | ||
584 | niro | 923 | |
585 | niro | 924 | if [[ -n ${runLilo} ]] |
586 | then | ||
587 | [[ -n ${verbose} ]] && echo "running ${lilo}" | ||
588 | if [ ! -x ${lilo} ] | ||
589 | then | ||
590 | [[ -n ${verbose} ]] && echo "${lilo} does not exist" | ||
591 | else | ||
592 | ${lilo} > /dev/null | ||
593 | fi | ||
594 | fi | ||
595 | else | ||
596 | [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" | ||
597 | niro | 923 | fi |
598 | niro | 1691 | |
599 | if [[ -n ${cfguBoot} ]] | ||
600 | then | ||
601 | [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." | ||
602 | |||
603 | [[ -n ${verbose} ]] && echo "creating uImage-${version}" | ||
604 | niro | 1752 | mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \ |
605 | -e ${ubootAddress} -n ${version} \ | ||
606 | niro | 2241 | -d ${kernelImage} ${ubootDir}/uImage-${version} |
607 | niro | 1691 | |
608 | [[ -n ${verbose} ]] && echo "creating uInitrd-${version}" | ||
609 | mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ | ||
610 | -n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version} | ||
611 | |||
612 | if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ] | ||
613 | then | ||
614 | cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage} | ||
615 | if [ $? -ne 0 ] | ||
616 | then | ||
617 | [[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit | ||
618 | fi | ||
619 | cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd} | ||
620 | if [ $? -ne 0 ] | ||
621 | then | ||
622 | [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit | ||
623 | fi | ||
624 | echo ${version} >> ${ubootDir}/${ubootKList} | ||
625 | niro | 2248 | [ -x /sbin/a-b-c ] && /sbin/a-b-c |
626 | niro | 1691 | else |
627 | [[ -n ${verbose} ]] && echo "cannot make ${version} the default" | ||
628 | fi | ||
629 | else | ||
630 | [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" | ||
631 | fi | ||
632 | niro | 1716 | |
633 | if [[ -n ${cfgExtlinux} ]] | ||
634 | then | ||
635 | [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}" | ||
636 | niro | 2961 | ARGS="--extlinux -c ${extlinuxConfig} --update-kernel=${kernelImage} \ |
637 | niro | 2972 | ${DEVTREE} ${DEVTREEDIR} ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \ |
638 | niro | 2961 | ${removeargs:+--remove-args=\"${removeargs}\"} \ |
639 | --title=\"${title}\${debugtitle}\"" | ||
640 | rungrubby --debug ${ARGS} | ||
641 | rungrubby ${ARGS} | ||
642 | niro | 1716 | else |
643 | [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby" | ||
644 | fi | ||
645 | niro | 923 | } |
646 | |||
647 | niro | 1756 | makeinitrd() |
648 | niro | 924 | { |
649 | niro | 1334 | if [[ -n ${dracut} ]] |
650 | then | ||
651 | niro | 1728 | tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
652 | niro | 1334 | else |
653 | niro | 1749 | tool="mkinitrd --allow-missing -f ${initrdfile} ${version}" |
654 | niro | 1334 | fi |
655 | niro | 924 | [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
656 | niro | 1334 | ${tool} |
657 | niro | 924 | rc=$? |
658 | if [ ${rc} != 0 ] | ||
659 | then | ||
660 | echo "mkinitrd failed" >&2 | ||
661 | exit 1 | ||
662 | fi | ||
663 | niro | 532 | } |
664 | |||
665 | niro | 924 | rminitrd() |
666 | { | ||
667 | [[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}" | ||
668 | [ -f ${initrdfile} ] && rm -f ${initrdfile} | ||
669 | niro | 532 | } |
670 | |||
671 | niro | 924 | doDepmod() |
672 | { | ||
673 | [[ -n ${verbose} ]] && echo "running depmod for ${version}" | ||
674 | depmod -ae -F /boot/System.map-${version} ${version} | ||
675 | niro | 532 | } |
676 | |||
677 | niro | 924 | doRmmoddep() |
678 | { | ||
679 | [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}" | ||
680 | niro | 2242 | if [ -d /lib/modules/${version} ] |
681 | then | ||
682 | rm -f /lib/modules/${version}/modules.*.bin \ | ||
683 | niro | 2244 | /lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep} |
684 | niro | 2242 | fi |
685 | niro | 532 | } |
686 | |||
687 | niro | 2965 | # kernel image for 2.4 is kernel |
688 | if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] | ||
689 | then | ||
690 | if [[ ${kernelmajor} = 2.4 ]] | ||
691 | then | ||
692 | kernelName=kernel | ||
693 | fi | ||
694 | fi | ||
695 | niro | 532 | |
696 | niro | 924 | while [ $# -gt 0 ] |
697 | do | ||
698 | case $1 in | ||
699 | --mkinitrd) | ||
700 | initrd="make" | ||
701 | ;; | ||
702 | niro | 532 | |
703 | niro | 924 | --rminitrd) |
704 | initrd="remove" | ||
705 | ;; | ||
706 | niro | 532 | |
707 | niro | 2685 | --devtree*) |
708 | if [[ $1 == --devtree\=* ]] | ||
709 | then | ||
710 | devtreefile="${1#--devtreefile=}" | ||
711 | else | ||
712 | devtreefile="$2" | ||
713 | shift | ||
714 | fi | ||
715 | ;; | ||
716 | |||
717 | niro | 2972 | --devtreedir*) |
718 | if [[ $1 == --devtreedir\=* ]] | ||
719 | then | ||
720 | devtreedir=${1#--devtreedir=} | ||
721 | else | ||
722 | devtreedir=$2 | ||
723 | shift | ||
724 | fi | ||
725 | ;; | ||
726 | |||
727 | niro | 1334 | --dracut) |
728 | dracut=--dracut | ||
729 | ;; | ||
730 | |||
731 | --host-only) | ||
732 | dracuthostonly=-H | ||
733 | ;; | ||
734 | |||
735 | niro | 924 | --initrdfile*) |
736 | niro | 2240 | if [[ $1 == --initrdfile\=* ]] |
737 | niro | 924 | then |
738 | niro | 2240 | initrdfile=${1#--initrdfile=} |
739 | niro | 924 | else |
740 | initrdfile=$2 | ||
741 | shift | ||
742 | fi | ||
743 | ;; | ||
744 | niro | 532 | |
745 | niro | 924 | --kernel-args*) |
746 | niro | 2240 | if [[ $1 == --kernel-args\=* ]] |
747 | niro | 924 | then |
748 | niro | 2240 | kernargs=${1#--kernel-args=} |
749 | niro | 924 | else |
750 | kernargs=$2 | ||
751 | shift | ||
752 | fi | ||
753 | ;; | ||
754 | niro | 532 | |
755 | niro | 924 | --remove-args*) |
756 | niro | 2240 | if [[ $1 == --remove-args\=* ]] |
757 | niro | 924 | then |
758 | niro | 2240 | removeargs=${1#--remove-args=} |
759 | niro | 924 | else |
760 | removeargs=$2 | ||
761 | shift | ||
762 | fi | ||
763 | ;; | ||
764 | niro | 923 | |
765 | niro | 924 | --banner*) |
766 | niro | 2240 | if [[ $1 == --banner\=* ]] |
767 | niro | 924 | then |
768 | niro | 2240 | banner=${1#--banner=} |
769 | niro | 924 | else |
770 | banner=$2 | ||
771 | shift | ||
772 | fi | ||
773 | ;; | ||
774 | niro | 532 | |
775 | niro | 924 | --multiboot*) |
776 | niro | 2240 | if [[ $1 == --multiboot\=* ]] |
777 | niro | 924 | then |
778 | niro | 2240 | mbkernel=${1#--multiboot=} |
779 | niro | 924 | else |
780 | # can't really support having an optional second arg here | ||
781 | # sorry! | ||
782 | mbkernel="/boot/xen.gz" | ||
783 | fi | ||
784 | ;; | ||
785 | niro | 532 | |
786 | niro | 924 | --mbargs*) |
787 | niro | 2240 | if [[ $1 == --mbargs\=* ]] |
788 | niro | 924 | then |
789 | niro | 2240 | mbargs=${1#--mbargs=} |
790 | niro | 924 | else |
791 | mbargs="$2" | ||
792 | shift | ||
793 | fi | ||
794 | ;; | ||
795 | niro | 532 | |
796 | niro | 924 | --depmod) |
797 | moddep="make" | ||
798 | ;; | ||
799 | niro | 532 | |
800 | niro | 924 | --rmmoddep) |
801 | moddep="remove" | ||
802 | ;; | ||
803 | niro | 532 | |
804 | niro | 924 | --make-default) |
805 | makedefault="--make-default" | ||
806 | ;; | ||
807 | niro | 532 | |
808 | niro | 2240 | --package*) |
809 | if [[ $1 == --package\=* ]] | ||
810 | niro | 924 | then |
811 | niro | 2240 | package=${1#--package=} |
812 | niro | 924 | else |
813 | package=$2 | ||
814 | shift | ||
815 | fi | ||
816 | ;; | ||
817 | niro | 532 | |
818 | niro | 1334 | --add-dracut-args) |
819 | adddracutargs=--add-dracut-args | ||
820 | ;; | ||
821 | |||
822 | --add-plymouth-initrd) | ||
823 | addplymouthinitrd=--add-plymouth-initrd | ||
824 | ;; | ||
825 | |||
826 | niro | 2241 | --kernel-image*) |
827 | if [[ $1 == --kernel-image\=* ]] | ||
828 | then | ||
829 | kernelImage=${1#--kernel-image=} | ||
830 | else | ||
831 | kernelImage="$2" | ||
832 | shift | ||
833 | fi | ||
834 | if ! [[ -f ${kernelImage} ]] | ||
835 | then | ||
836 | echo "Can't find kernel image '${kernelImage}'" >&2 | ||
837 | usage | ||
838 | exit 1 | ||
839 | fi | ||
840 | ;; | ||
841 | |||
842 | niro | 2965 | --kernel-name*) |
843 | if [[ $1 == --kernel-name\=* ]] | ||
844 | then | ||
845 | kernelName=${1#--kernel-name=} | ||
846 | else | ||
847 | kernelName="$2" | ||
848 | shift | ||
849 | fi | ||
850 | ;; | ||
851 | |||
852 | niro | 924 | -v) |
853 | verbose=-v | ||
854 | ;; | ||
855 | niro | 532 | |
856 | niro | 924 | *) |
857 | if [[ -z ${mode} ]] | ||
858 | then | ||
859 | mode=$1 | ||
860 | elif [[ -z ${version} ]] | ||
861 | then | ||
862 | version=$1 | ||
863 | else | ||
864 | usage | ||
865 | fi | ||
866 | ;; | ||
867 | esac | ||
868 | niro | 532 | |
869 | niro | 924 | shift |
870 | niro | 532 | done |
871 | |||
872 | # make sure the mode is valid | ||
873 | niro | 924 | if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]] |
874 | then | ||
875 | usage | ||
876 | niro | 532 | fi |
877 | |||
878 | niro | 924 | if [[ -z ${version} ]] |
879 | then | ||
880 | usage | ||
881 | niro | 532 | fi |
882 | |||
883 | niro | 924 | if [ "${mode}" != "--install" -a "${makedefault}" ] |
884 | then | ||
885 | usage | ||
886 | niro | 532 | fi |
887 | |||
888 | niro | 924 | kernelmajor=$(echo ${kernel} | cut -d . -f 1,2) |
889 | niro | 532 | |
890 | niro | 2241 | [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}" |
891 | |||
892 | niro | 532 | # set the initrd file based on arch; ia64 is the only currently known oddball |
893 | niro | 924 | if [[ -z ${initrdfile} ]] |
894 | then | ||
895 | INITRD_NAME_PREFIX="initrd" | ||
896 | niro | 1334 | if [[ -n ${dracut} ]] |
897 | then | ||
898 | INITRD_NAME_PREFIX="initramfs" | ||
899 | fi | ||
900 | niro | 923 | |
901 | niro | 924 | if [[ $(uname -m) = ia64 ]] |
902 | then | ||
903 | initrdfile="/boot/efi/EFI/redhat/${INITRD_NAME_PREFIX}-${version}.img" | ||
904 | else | ||
905 | initrdfile="/boot/${INITRD_NAME_PREFIX}-${version}.img" | ||
906 | fi | ||
907 | niro | 532 | fi |
908 | niro | 924 | [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}" |
909 | niro | 532 | |
910 | niro | 2971 | if [[ ${ARCH} =~ armv[5|7].*l ]] |
911 | then | ||
912 | niro | 2973 | if [[ -z ${SHIPSDTB} ]] || [[ ${SHIPSDTB} != yes ]] |
913 | niro | 2971 | then |
914 | niro | 2973 | if [[ -n ${dtbfile} ]] && [ -f ${bootPrefix}/dtb-${version}/${dtbfile} ] |
915 | niro | 2971 | then |
916 | niro | 2973 | devtreefile="${bootPrefix}/dtb-${version}/${dtbfile}" |
917 | [[ -n ${verbose} ]] && echo "devtreefile is ${devtreefile}" | ||
918 | elif [ -d ${bootPrefix}/dtb-${version}/ ] | ||
919 | then | ||
920 | devtreedir="${bootPrefix}/dtb-${version}/" | ||
921 | [[ -n ${verbose} ]] && echo "devtreedir is ${devtreedir}" | ||
922 | niro | 2971 | fi |
923 | fi | ||
924 | fi | ||
925 | [[ -n ${verbose} ]] && echo "devtreedir is ${devtreedir}" | ||
926 | |||
927 | niro | 1334 | # add dracut i18n, keyboard and plymouth kernel args if requested |
928 | if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]] | ||
929 | then | ||
930 | niro | 2059 | if [ -r /etc/vconsole.conf ] |
931 | then | ||
932 | . /etc/vconsole.conf | ||
933 | niro | 1334 | |
934 | niro | 2059 | for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE |
935 | do | ||
936 | val=$(eval echo \$$i) | ||
937 | [[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}" | ||
938 | done | ||
939 | else | ||
940 | if [ -r /etc/conf.d/consolefont ] | ||
941 | then | ||
942 | . /etc/conf.d/consolefont | ||
943 | |||
944 | if [[ -n ${CONSOLEFONT} ]] | ||
945 | then | ||
946 | kernargs="${kernargs} SYSFONT=${CONSOLEFONT}" | ||
947 | fi | ||
948 | fi | ||
949 | |||
950 | if [ -r /etc/conf.d/keymap ] | ||
951 | then | ||
952 | . /etc/conf.d/keymap | ||
953 | |||
954 | if [[ -n ${KEYMAP} ]] | ||
955 | then | ||
956 | kernargs="${kernargs} KEYTABLE=${KEYMAP}" | ||
957 | fi | ||
958 | fi | ||
959 | niro | 1334 | fi |
960 | |||
961 | niro | 2059 | if [ -r /etc/locale.conf ] |
962 | niro | 1334 | then |
963 | niro | 2059 | . /etc/locale.conf |
964 | |||
965 | if [[ -n ${LANG} ]] | ||
966 | then | ||
967 | kernargs="${kernargs} LANG=${LANG}" | ||
968 | fi | ||
969 | niro | 1334 | fi |
970 | fi | ||
971 | |||
972 | niro | 532 | # set this as the default if we have the package and it matches |
973 | niro | 2964 | if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && [[ -n ${DEFAULTKERNEL} ]] |
974 | niro | 924 | then |
975 | niro | 2964 | if [[ ${package} = ${DEFAULTKERNEL} ]] || [[ ${package}-core = ${DEFAULTKERNEL} ]] |
976 | then | ||
977 | makedefault="--make-default" | ||
978 | [[ -n ${verbose} ]] && echo "making it the default based on config" | ||
979 | fi | ||
980 | niro | 532 | fi |
981 | |||
982 | niro | 924 | if [[ ${moddep} = make ]] |
983 | then | ||
984 | doDepmod | ||
985 | elif [[ ${moddep} = remove ]] | ||
986 | then | ||
987 | doRmmoddep | ||
988 | niro | 532 | fi |
989 | |||
990 | niro | 924 | if [[ ${initrd} = make ]] |
991 | then | ||
992 | niro | 1756 | makeinitrd |
993 | niro | 924 | elif [[ ${initrd} = remove ]] |
994 | then | ||
995 | rminitrd | ||
996 | niro | 532 | fi |
997 | |||
998 | niro | 924 | if [ ! -x ${grubby} ] |
999 | then | ||
1000 | [[ -n ${verbose} ]] && echo "${grubby} does not exist" | ||
1001 | exit 0 | ||
1002 | niro | 532 | fi |
1003 | |||
1004 | niro | 924 | [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
1005 | niro | 1697 | [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1 |
1006 | [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1 | ||
1007 | niro | 924 | [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
1008 | niro | 1716 | [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
1009 | niro | 532 | |
1010 | niro | 1752 | # if we have a U-Boot directory, but no boot script, check if the directory |
1011 | # is mounted. If not, mount it, and then check if a boot script exists. | ||
1012 | niro | 1691 | if [[ -n ${ubootDir} ]] |
1013 | then | ||
1014 | niro | 1752 | if [ -f ${ubootScript} ] |
1015 | niro | 1691 | then |
1016 | niro | 1752 | cfguBoot=1 |
1017 | else | ||
1018 | mountEntry=$(mount | grep ${ubootDir}) | ||
1019 | if [[ -z ${mountEntry} ]] | ||
1020 | then | ||
1021 | mount ${ubootDevice} ${ubootDir} | ||
1022 | mounted=1 | ||
1023 | fi | ||
1024 | [ -f ${ubootScript} ] && cfguBoot=1 | ||
1025 | niro | 1691 | fi |
1026 | fi | ||
1027 | |||
1028 | niro | 1937 | # if we're using U-Boot, check if the default load address should change |
1029 | if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]] | ||
1030 | then | ||
1031 | [[ ${version} =~ .([^.]*)$ ]] | ||
1032 | platform=${BASH_REMATCH[1]} | ||
1033 | # A few platforms use an alternate kernel load address | ||
1034 | if [[ ${platform} = omap ]] | ||
1035 | then | ||
1036 | ubootAddress=0x80008000 | ||
1037 | elif [[ ${platform} = imx ]] | ||
1038 | then | ||
1039 | ubootAddress=0x90008000 | ||
1040 | fi | ||
1041 | fi | ||
1042 | |||
1043 | niro | 532 | # if we have a lilo config on an x86 box, see if the default boot loader |
1044 | # is lilo to determine if it should be run | ||
1045 | niro | 924 | if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]] |
1046 | then | ||
1047 | runLilo=$(${grubby} --bootloader-probe | grep lilo) | ||
1048 | niro | 532 | fi |
1049 | |||
1050 | niro | 924 | if [[ ${mode} = --install ]] |
1051 | then | ||
1052 | install | ||
1053 | elif [[ ${mode} = --remove ]] | ||
1054 | then | ||
1055 | remove | ||
1056 | elif [[ ${mode} = --update ]] | ||
1057 | then | ||
1058 | update | ||
1059 | niro | 532 | fi |
1060 | |||
1061 | niro | 1752 | # if we mounted the U-Boot directory, unmount it. |
1062 | [[ -n ${mounted} ]] && umount ${ubootDir} | ||
1063 | |||
1064 | niro | 2996 | # make sure changes make it to the disk. |
1065 | # if /boot is a mountpoint, force the meta data on disk | ||
1066 | # to by-pass writeback delay. | ||
1067 | # PPC64LE-only to deal with Petitboot issues | ||
1068 | if [[ ${ARCH} = ppc64le ]] | ||
1069 | then | ||
1070 | sync && mountpoint -q /boot && fsfreeze -f /boot && fsfreeze -u /boot | ||
1071 | fi | ||
1072 | |||
1073 | niro | 532 | exit 0 |
Properties
Name | Value |
---|---|
svn:executable | * |