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