25 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
26 |
# |
# |
27 |
|
|
28 |
|
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 |
PATH=/sbin:/bin:$PATH |
PATH=/sbin:/bin:$PATH |
55 |
|
|
56 |
lilo=/sbin/lilo |
lilo=/sbin/lilo |
66 |
fi |
fi |
67 |
|
|
68 |
[ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby |
[ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby |
69 |
|
[ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot |
70 |
|
|
71 |
|
cfgGrub2="" |
72 |
|
cfgGrub2Efi="" |
73 |
cfgGrub="" |
cfgGrub="" |
74 |
cfgLilo="" |
cfgLilo="" |
75 |
|
cfgExtlinux="" |
76 |
|
cfguBoot="" |
77 |
runLilo="" |
runLilo="" |
78 |
grubConfig="" |
grubConfig="" |
79 |
|
grub2Config="" |
80 |
|
grub2EfiConfig="" |
81 |
|
extlinuxConfig="" |
82 |
|
|
83 |
ARCH=$(uname -m) |
ARCH=$(uname -m) |
84 |
|
|
91 |
elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
92 |
then |
then |
93 |
liloConfig=/etc/yaboot.conf |
liloConfig=/etc/yaboot.conf |
94 |
|
grub2Config=/boot/grub/grub.cfg |
95 |
bootPrefix=/boot |
bootPrefix=/boot |
96 |
lilo=/sbin/ybin |
lilo=/sbin/ybin |
97 |
liloFlag=yaboot |
liloFlag=yaboot |
112 |
lilo=/sbin/zipl |
lilo=/sbin/zipl |
113 |
runLilo="yes" |
runLilo="yes" |
114 |
isx86="" |
isx86="" |
115 |
|
elif [[ ${ARCH} =~ armv[5|7].*l ]] |
116 |
|
then |
117 |
|
liloConfig="" |
118 |
|
bootPrefix=/boot |
119 |
|
ubootDir=${UBOOT_DIR:-"/boot"} |
120 |
|
ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} |
121 |
|
ubootKList=${UBOOT_KLIST:-"klist.txt"} |
122 |
|
ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} |
123 |
|
ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} |
124 |
|
ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} |
125 |
|
ubootAddress=${UBOOT_IMGADDR:-"0x00008000"} |
126 |
|
mounted="" |
127 |
|
liloFlag="" |
128 |
|
isx86="" |
129 |
else |
else |
130 |
# this leaves i?86 and x86_64 |
# this leaves i?86 and x86_64 |
131 |
liloConfig=/etc/lilo.conf |
liloConfig=/etc/lilo.conf |
132 |
grubConfig=/boot/grub/grub.conf |
grubConfig=/boot/grub/grub.conf |
133 |
|
grub2Config=/boot/grub/grub.cfg |
134 |
|
grub2EfiConfig=/boot/grub/grub-efi.cfg |
135 |
|
extlinuxConfig=/boot/extlinux/extlinux.conf |
136 |
bootPrefix=/boot |
bootPrefix=/boot |
137 |
liloFlag=lilo |
liloFlag=lilo |
138 |
isx86="yes" |
isx86="yes" |
141 |
mode="" |
mode="" |
142 |
version="" |
version="" |
143 |
initrd="" |
initrd="" |
144 |
|
dracut="" |
145 |
|
dracuthostonly="" |
146 |
initrdfile="" |
initrdfile="" |
147 |
moddep="" |
moddep="" |
148 |
verbose="" |
verbose="" |
149 |
makedefault="" |
makedefault="" |
150 |
package="" |
package="" |
151 |
mbkernel="" |
mbkernel="${HYPERVISOR}" |
152 |
mbargs="" |
mbargs="${HYPERVISOR_ARGS}" |
153 |
|
adddracutargs="" |
154 |
|
addplymouthinitrd="" |
155 |
|
|
156 |
usage() |
usage() |
157 |
{ |
{ |
158 |
echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd]" >&2 |
echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2 |
159 |
echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2 |
echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2 |
160 |
echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2 |
echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2 |
161 |
echo " [--banner=<banner>] [--multiboot=multiboot]" >&2 |
echo " [--banner=<banner>] [--multiboot=multiboot]" >&2 |
162 |
echo " [--mbargs=mbargs] [--make-default]" >&2 |
echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2 |
163 |
|
echo " [--add-plymouth-initrd]" >&2 |
164 |
|
echo " [--host-only]" >&2 |
165 |
echo " <--install | --remove | --update> <kernel-version>" >&2 |
echo " <--install | --remove | --update> <kernel-version>" >&2 |
166 |
echo " (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2 |
echo " (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2 |
167 |
exit 1 |
exit 1 |
181 |
then |
then |
182 |
[[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" |
[[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" |
183 |
INITRD="--initrd ${initrdfile}" |
INITRD="--initrd ${initrdfile}" |
184 |
|
|
185 |
|
if [[ -n ${addplymouthinitrd} ]] |
186 |
|
then |
187 |
|
INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img" |
188 |
|
fi |
189 |
fi |
fi |
190 |
|
|
191 |
# FIXME: is this a good heuristic to find out if we're on iSeries? |
# FIXME: is this a good heuristic to find out if we're on iSeries? |
219 |
|
|
220 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
221 |
then |
then |
222 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
223 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
224 |
then |
then |
225 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
226 |
|
elif [[ $(read_os_release id) = magellan ]] |
227 |
|
then |
228 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
229 |
else |
else |
230 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
231 |
fi |
fi |
232 |
${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --grub -c ${grubConfig} \ |
233 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
234 |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
235 |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
236 |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
237 |
else |
else |
238 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
239 |
|
fi |
240 |
|
if [[ -n ${cfgGrub2} ]] |
241 |
|
then |
242 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}" |
243 |
|
|
244 |
|
if [[ -n ${banner} ]] |
245 |
|
then |
246 |
|
title="${banner} [ ${version} ]" |
247 |
|
elif [ -f /etc/mageversion ] |
248 |
|
then |
249 |
|
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
250 |
|
elif [[ $(read_os_release id) = magellan ]] |
251 |
|
then |
252 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
253 |
|
else |
254 |
|
title="Magellan Linux [ ${version} ]" |
255 |
|
fi |
256 |
|
${grubby} --grub2 -c ${grub2Config} \ |
257 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
258 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
259 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} \ |
260 |
|
${mbargs:+--mbargs="${mbargs}"} \ |
261 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
262 |
|
else |
263 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" |
264 |
|
fi |
265 |
|
if [[ -n ${cfgGrub2Efi} ]] |
266 |
|
then |
267 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}" |
268 |
|
|
269 |
|
if [[ -n ${banner} ]] |
270 |
|
then |
271 |
|
title="${banner} [ ${version} ]" |
272 |
|
elif [ -f /etc/mageversion ] |
273 |
|
then |
274 |
|
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
275 |
|
elif [[ $(read_os_release id) = magellan ]] |
276 |
|
then |
277 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
278 |
|
else |
279 |
|
title="Magellan Linux [ ${version} ]" |
280 |
|
fi |
281 |
|
${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
282 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
283 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
284 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} \ |
285 |
|
${mbargs:+--mbargs="${mbargs}"} \ |
286 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
287 |
|
else |
288 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI" |
289 |
fi |
fi |
290 |
|
|
291 |
if [[ -n ${cfgLilo} ]] |
if [[ -n ${cfgLilo} ]] |
301 |
if [[ -n ${runLilo} ]] |
if [[ -n ${runLilo} ]] |
302 |
then |
then |
303 |
[[ -n ${verbose} ]] && echo "running ${lilo}" |
[[ -n ${verbose} ]] && echo "running ${lilo}" |
304 |
if [ ! -x $lilo ] |
if [ ! -x ${lilo} ] |
305 |
then |
then |
306 |
[[ -n ${verbose} ]] && echo "${lilo} does not exist" |
[[ -n ${verbose} ]] && echo "${lilo} does not exist" |
307 |
else |
else |
311 |
else |
else |
312 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
313 |
fi |
fi |
314 |
|
|
315 |
|
if [[ -n ${cfgExtlinux} ]] |
316 |
|
then |
317 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}" |
318 |
|
|
319 |
|
if [[ -n ${banner} ]] |
320 |
|
then |
321 |
|
title="${banner} [ ${version} ]" |
322 |
|
elif [ -f /etc/mageversion ] |
323 |
|
then |
324 |
|
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
325 |
|
elif [[ $(read_os_release id) = magellan ]] |
326 |
|
then |
327 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
328 |
|
else |
329 |
|
title="Magellan Linux [ ${version} ]" |
330 |
|
fi |
331 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
332 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
333 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
334 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
335 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
336 |
|
else |
337 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
338 |
|
fi |
339 |
} |
} |
340 |
|
|
341 |
remove() |
remove() |
351 |
if [[ -n ${cfgGrub} ]] |
if [[ -n ${cfgGrub} ]] |
352 |
then |
then |
353 |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
354 |
${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} |
${grubby} --grub -c ${grubConfig} \ |
355 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
356 |
else |
else |
357 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
358 |
|
fi |
359 |
|
if [[ -n ${cfgGrub2} ]] |
360 |
|
then |
361 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}" |
362 |
|
${grubby} --grub2 -c ${grub2Config} \ |
363 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
364 |
|
else |
365 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" |
366 |
|
fi |
367 |
|
if [[ -n ${cfgGrub2Efi} ]] |
368 |
|
then |
369 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}" |
370 |
|
${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
371 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
372 |
|
else |
373 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI" |
374 |
fi |
fi |
375 |
|
|
376 |
if [[ -n ${cfgLilo} ]] |
if [[ -n ${cfgLilo} ]] |
377 |
then |
then |
378 |
[[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}" |
[[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}" |
379 |
${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag} |
|
--${liloFlag} |
|
380 |
|
|
381 |
if [[ -n ${runLilo} ]] |
if [[ -n ${runLilo} ]] |
382 |
then |
then |
391 |
else |
else |
392 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
393 |
fi |
fi |
394 |
|
|
395 |
|
if [[ -n ${cfguBoot} ]] |
396 |
|
then |
397 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..." |
398 |
|
|
399 |
|
if [ -f ${ubootDir}/${ubootKList} ] |
400 |
|
then |
401 |
|
tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) |
402 |
|
curversion=$(tail -n1 ${ubootDir}/${ubootKList}) |
403 |
|
sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
404 |
|
newversion=$(tail -n1 ${tmpKList}) |
405 |
|
if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] |
406 |
|
then |
407 |
|
if [[ ${curversion} != ${newversion} ]] |
408 |
|
then |
409 |
|
cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage} |
410 |
|
if [ $? -ne 0 ] |
411 |
|
then |
412 |
|
[[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit |
413 |
|
fi |
414 |
|
cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd} |
415 |
|
if [ $? -ne 0 ] |
416 |
|
then |
417 |
|
[[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit |
418 |
|
fi |
419 |
|
fi |
420 |
|
|
421 |
|
[[ -n ${verbose} ]] && echo "removing uImage-${version}" |
422 |
|
if [ -f ${ubootDir}/uImage-${version} ] |
423 |
|
then |
424 |
|
rm -f ${ubootDir}/uImage-${version} |
425 |
|
else |
426 |
|
[[ -n ${verbose} ]] && echo "uImage-${version} did not exist!" |
427 |
|
fi |
428 |
|
|
429 |
|
[[ -n ${verbose} ]] && echo "removing uInitrd-${version}" |
430 |
|
if [ -f ${ubootDir}/uInitrd-${version} ] |
431 |
|
then |
432 |
|
rm -f ${ubootDir}/uInitrd-${version} |
433 |
|
else |
434 |
|
[[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!" |
435 |
|
fi |
436 |
|
|
437 |
|
mv ${tmpKList} ${ubootDir}/${ubootKList} |
438 |
|
else |
439 |
|
[[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!" |
440 |
|
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
441 |
|
fi |
442 |
|
else |
443 |
|
[[ -n ${verbose} ]] && echo "No previous kernel version. U-Boot images not removed!" |
444 |
|
fi |
445 |
|
else |
446 |
|
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
447 |
|
fi |
448 |
|
|
449 |
|
if [[ -n ${cfgExtlinux} ]] |
450 |
|
then |
451 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}" |
452 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
453 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
454 |
|
else |
455 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
456 |
|
fi |
457 |
} |
} |
458 |
|
|
459 |
update() |
update() |
460 |
{ |
{ |
461 |
|
if [ ! -f ${bootPrefix}/${kernelName}-${version} ] |
462 |
|
then |
463 |
|
[[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
464 |
|
return |
465 |
|
fi |
466 |
|
|
467 |
|
INITRD="" |
468 |
|
if [ -f ${initrdfile} ] |
469 |
|
then |
470 |
|
[[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" |
471 |
|
INITRD="--initrd ${initrdfile}" |
472 |
|
|
473 |
|
if [[ -n ${addplymouthinitrd} ]] |
474 |
|
then |
475 |
|
INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img" |
476 |
|
fi |
477 |
|
fi |
478 |
|
|
479 |
if [[ -n ${cfgGrub} ]] |
if [[ -n ${cfgGrub} ]] |
480 |
then |
then |
481 |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
482 |
${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --grub -c ${grubConfig} \ |
483 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
484 |
|
${INITRD} \ |
485 |
${kernargs:+--args="${kernargs}"} \ |
${kernargs:+--args="${kernargs}"} \ |
486 |
${removeargs:+--remove-args="${removeargs}"} |
${removeargs:+--remove-args="${removeargs}"} |
487 |
else |
else |
488 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
489 |
fi |
fi |
490 |
|
|
491 |
|
if [[ -n ${cfgGrub2} ]] |
492 |
|
then |
493 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}" |
494 |
|
${grubby} --grub2 -c ${grub2Config} \ |
495 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
496 |
|
${INITRD} \ |
497 |
|
${kernargs:+--args="${kernargs}"} \ |
498 |
|
${removeargs:+--remove-args="${removeargs}"} |
499 |
|
else |
500 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby" |
501 |
|
fi |
502 |
|
|
503 |
|
if [[ -n ${cfgGrub2Efi} ]] |
504 |
|
then |
505 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}" |
506 |
|
${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
507 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
508 |
|
${INITRD} \ |
509 |
|
${kernargs:+--args="${kernargs}"} \ |
510 |
|
${removeargs:+--remove-args="${removeargs}"} |
511 |
|
else |
512 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby" |
513 |
|
fi |
514 |
|
|
515 |
if [[ -n ${cfgLilo} ]] |
if [[ -n ${cfgLilo} ]] |
516 |
then |
then |
517 |
[[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" |
[[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" |
518 |
${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
519 |
|
${INITRD} \ |
520 |
${kernargs:+--args="${kernargs}"} \ |
${kernargs:+--args="${kernargs}"} \ |
521 |
${removeargs:+--remove-args="${removeargs}"} \ |
${removeargs:+--remove-args="${removeargs}"} \ |
522 |
--${liloFlag} |
--${liloFlag} |
534 |
else |
else |
535 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
536 |
fi |
fi |
537 |
|
|
538 |
|
if [[ -n ${cfguBoot} ]] |
539 |
|
then |
540 |
|
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
541 |
|
|
542 |
|
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
543 |
|
mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \ |
544 |
|
-e ${ubootAddress} -n ${version} \ |
545 |
|
-d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
546 |
|
|
547 |
|
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
548 |
|
mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ |
549 |
|
-n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version} |
550 |
|
|
551 |
|
if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ] |
552 |
|
then |
553 |
|
cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage} |
554 |
|
if [ $? -ne 0 ] |
555 |
|
then |
556 |
|
[[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit |
557 |
|
fi |
558 |
|
cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd} |
559 |
|
if [ $? -ne 0 ] |
560 |
|
then |
561 |
|
[[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit |
562 |
|
fi |
563 |
|
echo ${version} >> ${ubootDir}/${ubootKList} |
564 |
|
else |
565 |
|
[[ -n ${verbose} ]] && echo "cannot make ${version} the default" |
566 |
|
fi |
567 |
|
else |
568 |
|
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" |
569 |
|
fi |
570 |
|
|
571 |
|
if [[ -n ${cfgExtlinux} ]] |
572 |
|
then |
573 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}" |
574 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
575 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
576 |
|
${INITRD} \ |
577 |
|
${kernargs:+--args="${kernargs}"} \ |
578 |
|
${removeargs:+--remove-args="${removeargs}"} |
579 |
|
else |
580 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby" |
581 |
|
fi |
582 |
} |
} |
583 |
|
|
584 |
mkinitrd() |
makeinitrd() |
585 |
{ |
{ |
586 |
|
if [[ -n ${dracut} ]] |
587 |
|
then |
588 |
|
tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
589 |
|
else |
590 |
|
tool="mkinitrd --allow-missing -f ${initrdfile} ${version}" |
591 |
|
fi |
592 |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
593 |
/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version} |
${tool} |
594 |
rc=$? |
rc=$? |
595 |
if [ ${rc} != 0 ] |
if [ ${rc} != 0 ] |
596 |
then |
then |
629 |
initrd="remove" |
initrd="remove" |
630 |
;; |
;; |
631 |
|
|
632 |
|
--dracut) |
633 |
|
dracut=--dracut |
634 |
|
;; |
635 |
|
|
636 |
|
--host-only) |
637 |
|
dracuthostonly=-H |
638 |
|
;; |
639 |
|
|
640 |
--initrdfile*) |
--initrdfile*) |
641 |
if echo $1 | grep '=' >/dev/null |
if echo $1 | grep '=' >/dev/null |
642 |
then |
then |
660 |
--remove-args*) |
--remove-args*) |
661 |
if echo $1 | grep '=' >/dev/null |
if echo $1 | grep '=' >/dev/null |
662 |
then |
then |
663 |
removeargs=$(echo $1 | sed 's/^--remove-args=//') |
removeargs=$(echo $1 | sed 's/^--remove-args=//') |
664 |
else |
else |
665 |
removeargs=$2 |
removeargs=$2 |
666 |
shift |
shift |
720 |
fi |
fi |
721 |
;; |
;; |
722 |
|
|
723 |
|
--add-dracut-args) |
724 |
|
adddracutargs=--add-dracut-args |
725 |
|
;; |
726 |
|
|
727 |
|
--add-plymouth-initrd) |
728 |
|
addplymouthinitrd=--add-plymouth-initrd |
729 |
|
;; |
730 |
|
|
731 |
-v) |
-v) |
732 |
verbose=-v |
verbose=-v |
733 |
;; |
;; |
766 |
|
|
767 |
kernelmajor=$(echo ${kernel} | cut -d . -f 1,2) |
kernelmajor=$(echo ${kernel} | cut -d . -f 1,2) |
768 |
|
|
769 |
# kernel image for 2.4 is vmlinux |
# kernel image for 2.4 is kernel |
770 |
if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
771 |
then |
then |
772 |
if [[ ${kernelmajor} = 2.4 ]] |
if [[ ${kernelmajor} = 2.4 ]] |
779 |
if [[ -z ${initrdfile} ]] |
if [[ -z ${initrdfile} ]] |
780 |
then |
then |
781 |
INITRD_NAME_PREFIX="initrd" |
INITRD_NAME_PREFIX="initrd" |
782 |
|
if [[ -n ${dracut} ]] |
783 |
|
then |
784 |
|
INITRD_NAME_PREFIX="initramfs" |
785 |
|
fi |
786 |
|
|
787 |
if [[ $(uname -m) = ia64 ]] |
if [[ $(uname -m) = ia64 ]] |
788 |
then |
then |
793 |
fi |
fi |
794 |
[[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}" |
[[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}" |
795 |
|
|
796 |
|
# add dracut i18n, keyboard and plymouth kernel args if requested |
797 |
|
if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]] |
798 |
|
then |
799 |
|
if [ -r /etc/vconsole.conf ] |
800 |
|
then |
801 |
|
. /etc/vconsole.conf |
802 |
|
|
803 |
|
for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE |
804 |
|
do |
805 |
|
val=$(eval echo \$$i) |
806 |
|
[[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}" |
807 |
|
done |
808 |
|
else |
809 |
|
if [ -r /etc/conf.d/consolefont ] |
810 |
|
then |
811 |
|
. /etc/conf.d/consolefont |
812 |
|
|
813 |
|
if [[ -n ${CONSOLEFONT} ]] |
814 |
|
then |
815 |
|
kernargs="${kernargs} SYSFONT=${CONSOLEFONT}" |
816 |
|
fi |
817 |
|
fi |
818 |
|
|
819 |
|
if [ -r /etc/conf.d/keymap ] |
820 |
|
then |
821 |
|
. /etc/conf.d/keymap |
822 |
|
|
823 |
|
if [[ -n ${KEYMAP} ]] |
824 |
|
then |
825 |
|
kernargs="${kernargs} KEYTABLE=${KEYMAP}" |
826 |
|
fi |
827 |
|
fi |
828 |
|
fi |
829 |
|
|
830 |
|
if [ -r /etc/locale.conf ] |
831 |
|
then |
832 |
|
. /etc/locale.conf |
833 |
|
|
834 |
|
if [[ -n ${LANG} ]] |
835 |
|
then |
836 |
|
kernargs="${kernargs} LANG=${LANG}" |
837 |
|
fi |
838 |
|
fi |
839 |
|
fi |
840 |
|
|
841 |
# set this as the default if we have the package and it matches |
# set this as the default if we have the package and it matches |
842 |
if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && |
if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && |
843 |
[[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]] |
[[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]] |
856 |
|
|
857 |
if [[ ${initrd} = make ]] |
if [[ ${initrd} = make ]] |
858 |
then |
then |
859 |
mkinitrd |
makeinitrd |
860 |
elif [[ ${initrd} = remove ]] |
elif [[ ${initrd} = remove ]] |
861 |
then |
then |
862 |
rminitrd |
rminitrd |
869 |
fi |
fi |
870 |
|
|
871 |
[[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
[[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
872 |
|
[[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1 |
873 |
|
[[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1 |
874 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
875 |
|
[[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
876 |
|
|
877 |
|
# if we have a U-Boot directory, but no boot script, check if the directory |
878 |
|
# is mounted. If not, mount it, and then check if a boot script exists. |
879 |
|
if [[ -n ${ubootDir} ]] |
880 |
|
then |
881 |
|
if [ -f ${ubootScript} ] |
882 |
|
then |
883 |
|
cfguBoot=1 |
884 |
|
else |
885 |
|
mountEntry=$(mount | grep ${ubootDir}) |
886 |
|
if [[ -z ${mountEntry} ]] |
887 |
|
then |
888 |
|
mount ${ubootDevice} ${ubootDir} |
889 |
|
mounted=1 |
890 |
|
fi |
891 |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
892 |
|
fi |
893 |
|
fi |
894 |
|
|
895 |
|
# if we're using U-Boot, check if the default load address should change |
896 |
|
if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]] |
897 |
|
then |
898 |
|
[[ ${version} =~ .([^.]*)$ ]] |
899 |
|
platform=${BASH_REMATCH[1]} |
900 |
|
# A few platforms use an alternate kernel load address |
901 |
|
if [[ ${platform} = omap ]] |
902 |
|
then |
903 |
|
ubootAddress=0x80008000 |
904 |
|
elif [[ ${platform} = imx ]] |
905 |
|
then |
906 |
|
ubootAddress=0x90008000 |
907 |
|
fi |
908 |
|
fi |
909 |
|
|
910 |
# if we have a lilo config on an x86 box, see if the default boot loader |
# if we have a lilo config on an x86 box, see if the default boot loader |
911 |
# is lilo to determine if it should be run |
# is lilo to determine if it should be run |
925 |
update |
update |
926 |
fi |
fi |
927 |
|
|
928 |
|
# if we mounted the U-Boot directory, unmount it. |
929 |
|
[[ -n ${mounted} ]] && umount ${ubootDir} |
930 |
|
|
931 |
exit 0 |
exit 0 |