40 |
fi |
fi |
41 |
|
|
42 |
[ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby |
[ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby |
43 |
|
[ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot |
44 |
|
|
45 |
cfgGrub="" |
cfgGrub="" |
46 |
cfgLilo="" |
cfgLilo="" |
47 |
|
cfguBoot="" |
48 |
runLilo="" |
runLilo="" |
49 |
grubConfig="" |
grubConfig="" |
50 |
|
|
79 |
lilo=/sbin/zipl |
lilo=/sbin/zipl |
80 |
runLilo="yes" |
runLilo="yes" |
81 |
isx86="" |
isx86="" |
82 |
|
elif [[ ${ARCH} = armv7l ]] |
83 |
|
then |
84 |
|
liloConfig="" |
85 |
|
bootPrefix=/boot |
86 |
|
ubootDir=${UBOOT_DIR:-"/boot/uboot"} |
87 |
|
ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} |
88 |
|
ubootKList=${UBOOT_KLIST:-"klist.txt"} |
89 |
|
ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} |
90 |
|
ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} |
91 |
|
ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} |
92 |
|
mounted="" |
93 |
|
liloFlag="" |
94 |
|
isx86="" |
95 |
else |
else |
96 |
# this leaves i?86 and x86_64 |
# this leaves i?86 and x86_64 |
97 |
liloConfig=/etc/lilo.conf |
liloConfig=/etc/lilo.conf |
273 |
else |
else |
274 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
275 |
fi |
fi |
276 |
|
|
277 |
|
if [[ -n ${cfguBoot} ]] |
278 |
|
then |
279 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..." |
280 |
|
|
281 |
|
if [ -f ${ubootDir}/${ubootKList} ] |
282 |
|
then |
283 |
|
tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) |
284 |
|
curversion=$(tail -n1 ${ubootDir}/${ubootKList}) |
285 |
|
sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
286 |
|
newversion=$(tail -n1 ${tmpKList}) |
287 |
|
if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] |
288 |
|
then |
289 |
|
if [[ ${curversion} != ${newversion} ]] |
290 |
|
then |
291 |
|
cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage} |
292 |
|
if [ $? -ne 0 ] |
293 |
|
then |
294 |
|
[[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit |
295 |
|
fi |
296 |
|
cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd} |
297 |
|
if [ $? -ne 0 ] |
298 |
|
then |
299 |
|
[[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit |
300 |
|
fi |
301 |
|
fi |
302 |
|
|
303 |
|
[[ -n ${verbose} ]] && echo "removing uImage-${version}" |
304 |
|
if [ -f ${ubootDir}/uImage-${version} ] |
305 |
|
then |
306 |
|
rm -f ${ubootDir}/uImage-${version} |
307 |
|
else |
308 |
|
[[ -n ${verbose} ]] && echo "uImage-${version} did not exist!" |
309 |
|
fi |
310 |
|
|
311 |
|
[[ -n ${verbose} ]] && echo "removing uInitrd-${version}" |
312 |
|
if [ -f ${ubootDir}/uInitrd-${version} ] |
313 |
|
then |
314 |
|
rm -f ${ubootDir}/uInitrd-${version} |
315 |
|
else |
316 |
|
[[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!" |
317 |
|
fi |
318 |
|
|
319 |
|
mv ${tmpKList} ${ubootDir}/${ubootKList} |
320 |
|
else |
321 |
|
[[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!" |
322 |
|
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
323 |
|
fi |
324 |
|
else |
325 |
|
[[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!" |
326 |
|
fi |
327 |
|
else |
328 |
|
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
329 |
|
fi |
330 |
} |
} |
331 |
|
|
332 |
update() |
update() |
385 |
else |
else |
386 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
387 |
fi |
fi |
388 |
|
|
389 |
|
if [[ -n ${cfguBoot} ]] |
390 |
|
then |
391 |
|
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
392 |
|
|
393 |
|
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
394 |
|
mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \ |
395 |
|
-n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
396 |
|
|
397 |
|
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
398 |
|
mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ |
399 |
|
-n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version} |
400 |
|
|
401 |
|
if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ] |
402 |
|
then |
403 |
|
cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage} |
404 |
|
if [ $? -ne 0 ] |
405 |
|
then |
406 |
|
[[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit |
407 |
|
fi |
408 |
|
cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd} |
409 |
|
if [ $? -ne 0 ] |
410 |
|
then |
411 |
|
[[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit |
412 |
|
fi |
413 |
|
echo ${version} >> ${ubootDir}/${ubootKList} |
414 |
|
else |
415 |
|
[[ -n ${verbose} ]] && echo "cannot make ${version} the default" |
416 |
|
fi |
417 |
|
else |
418 |
|
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" |
419 |
|
fi |
420 |
} |
} |
421 |
|
|
422 |
mkinitrd() |
mkinitrd() |
681 |
[[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
[[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
682 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
683 |
|
|
684 |
|
# if we have a uBoot directory, check if it is mounted. |
685 |
|
# if not, mount it. Then check if a boot script exists. |
686 |
|
if [[ -n ${ubootDir} ]] |
687 |
|
then |
688 |
|
mountEntry=$(mount | grep ${ubootDir}) |
689 |
|
if [[ -z ${mountEntry} ]] |
690 |
|
then |
691 |
|
mount ${ubootDevice} ${ubootDir} |
692 |
|
mounted=1 |
693 |
|
fi |
694 |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
695 |
|
fi |
696 |
|
|
697 |
# 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 |
698 |
# is lilo to determine if it should be run |
# is lilo to determine if it should be run |
699 |
if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]] |
if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]] |