46 |
cfgGrub2Efi="" |
cfgGrub2Efi="" |
47 |
cfgGrub="" |
cfgGrub="" |
48 |
cfgLilo="" |
cfgLilo="" |
49 |
|
cfgExtlinux="" |
50 |
cfguBoot="" |
cfguBoot="" |
51 |
runLilo="" |
runLilo="" |
52 |
grubConfig="" |
grubConfig="" |
53 |
grub2Config="" |
grub2Config="" |
54 |
grub2EfiConfig="" |
grub2EfiConfig="" |
55 |
|
extlinuxConfig="" |
56 |
|
|
57 |
ARCH=$(uname -m) |
ARCH=$(uname -m) |
58 |
|
|
85 |
lilo=/sbin/zipl |
lilo=/sbin/zipl |
86 |
runLilo="yes" |
runLilo="yes" |
87 |
isx86="" |
isx86="" |
88 |
elif [[ ${ARCH} = armv7l ]] |
elif [[ ${ARCH} = armv7l ]] || [[ ${ARCH} = armv7hl ]] |
89 |
then |
then |
90 |
|
machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//') |
91 |
liloConfig="" |
liloConfig="" |
92 |
bootPrefix=/boot |
bootPrefix=/boot |
93 |
ubootDir=${UBOOT_DIR:-"/boot/uboot"} |
ubootDir=${UBOOT_DIR:-"/boot/uboot"} |
99 |
mounted="" |
mounted="" |
100 |
liloFlag="" |
liloFlag="" |
101 |
isx86="" |
isx86="" |
102 |
|
if [[ ${machine} == "OMAP3 Beagle Board" ]] || [[ ${machine} == "OMAP4 Panda board" ]] |
103 |
|
then |
104 |
|
ubootAddress=0x80008000 |
105 |
|
else |
106 |
|
ubootAddress=0x00008000 |
107 |
|
fi |
108 |
else |
else |
109 |
# this leaves i?86 and x86_64 |
# this leaves i?86 and x86_64 |
110 |
liloConfig=/etc/lilo.conf |
liloConfig=/etc/lilo.conf |
111 |
grubConfig=/boot/grub/grub.conf |
grubConfig=/boot/grub/grub.conf |
112 |
grub2Config=/boot/grub/grub.cfg |
grub2Config=/boot/grub/grub.cfg |
113 |
grub2EfiConfig=/boot/grub/grub-efi.cfg |
grub2EfiConfig=/boot/grub/grub-efi.cfg |
114 |
|
extlinuxConfig=/boot/extlinux/extlinux.conf |
115 |
bootPrefix=/boot |
bootPrefix=/boot |
116 |
liloFlag=lilo |
liloFlag=lilo |
117 |
isx86="yes" |
isx86="yes" |
205 |
else |
else |
206 |
title="Magellan Linux (${version})" |
title="Magellan Linux (${version})" |
207 |
fi |
fi |
208 |
${grubby} --grub --add-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --grub -c ${grubConfig} \ |
209 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
210 |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
211 |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
212 |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
281 |
else |
else |
282 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
283 |
fi |
fi |
284 |
|
|
285 |
|
if [[ -n ${cfgExtlinux} ]] |
286 |
|
then |
287 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}" |
288 |
|
|
289 |
|
if [[ -n ${banner} ]] |
290 |
|
then |
291 |
|
title="${banner} (${version})" |
292 |
|
elif [ -f /etc/mageversion ] |
293 |
|
then |
294 |
|
title="Magellan Linux $(< /etc/mageversion) (${version})" |
295 |
|
else |
296 |
|
title="Magellan Linux (${version})" |
297 |
|
fi |
298 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
299 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
300 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
301 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
302 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
303 |
|
else |
304 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
305 |
|
fi |
306 |
} |
} |
307 |
|
|
308 |
remove() |
remove() |
318 |
if [[ -n ${cfgGrub} ]] |
if [[ -n ${cfgGrub} ]] |
319 |
then |
then |
320 |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
321 |
${grubby} --grub --remove-kernel=${bootPrefix}/${kernelName}-${version} |
${grubby} --grub -c ${grubConfig} \ |
322 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
323 |
else |
else |
324 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
325 |
fi |
fi |
407 |
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
408 |
fi |
fi |
409 |
else |
else |
410 |
[[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!" |
[[ -n ${verbose} ]] && echo "No previous kernel version. U-Boot images not removed!" |
411 |
fi |
fi |
412 |
else |
else |
413 |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
414 |
fi |
fi |
415 |
|
|
416 |
|
if [[ -n ${cfgExtlinux} ]] |
417 |
|
then |
418 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}" |
419 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
420 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
421 |
|
else |
422 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
423 |
|
fi |
424 |
} |
} |
425 |
|
|
426 |
update() |
update() |
446 |
if [[ -n ${cfgGrub} ]] |
if [[ -n ${cfgGrub} ]] |
447 |
then |
then |
448 |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
449 |
${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --grub -c ${grubConfig} \ |
450 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
451 |
${INITRD} \ |
${INITRD} \ |
452 |
${kernargs:+--args="${kernargs}"} \ |
${kernargs:+--args="${kernargs}"} \ |
453 |
${removeargs:+--remove-args="${removeargs}"} |
${removeargs:+--remove-args="${removeargs}"} |
507 |
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
508 |
|
|
509 |
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
510 |
mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \ |
mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \ |
511 |
-n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
-e ${ubootAddress} -n ${version} \ |
512 |
|
-d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
513 |
|
|
514 |
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
515 |
mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ |
mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ |
534 |
else |
else |
535 |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" |
536 |
fi |
fi |
537 |
|
|
538 |
|
if [[ -n ${cfgExtlinux} ]] |
539 |
|
then |
540 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}" |
541 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
542 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
543 |
|
${INITRD} \ |
544 |
|
${kernargs:+--args="${kernargs}"} \ |
545 |
|
${removeargs:+--remove-args="${removeargs}"} |
546 |
|
else |
547 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby" |
548 |
|
fi |
549 |
} |
} |
550 |
|
|
551 |
mkinitrd() |
mkinitrd() |
552 |
{ |
{ |
553 |
if [[ -n ${dracut} ]] |
if [[ -n ${dracut} ]] |
554 |
then |
then |
555 |
tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
556 |
else |
else |
557 |
tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}" |
tool="mkinitrd --allow-missing -f ${initrdfile} ${version}" |
558 |
fi |
fi |
559 |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
560 |
${tool} |
${tool} |
811 |
[[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1 |
[[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1 |
812 |
[[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1 |
[[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1 |
813 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
814 |
|
[[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
815 |
|
|
816 |
# if we have a uBoot directory, check if it is mounted. |
# if we have a U-Boot directory, but no boot script, check if the directory |
817 |
# if not, mount it. Then check if a boot script exists. |
# is mounted. If not, mount it, and then check if a boot script exists. |
818 |
if [[ -n ${ubootDir} ]] |
if [[ -n ${ubootDir} ]] |
819 |
then |
then |
820 |
mountEntry=$(mount | grep ${ubootDir}) |
if [ -f ${ubootScript} ] |
|
if [[ -z ${mountEntry} ]] |
|
821 |
then |
then |
822 |
mount ${ubootDevice} ${ubootDir} |
cfguBoot=1 |
823 |
mounted=1 |
else |
824 |
|
mountEntry=$(mount | grep ${ubootDir}) |
825 |
|
if [[ -z ${mountEntry} ]] |
826 |
|
then |
827 |
|
mount ${ubootDevice} ${ubootDir} |
828 |
|
mounted=1 |
829 |
|
fi |
830 |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
831 |
fi |
fi |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
|
832 |
fi |
fi |
833 |
|
|
834 |
# 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 |
849 |
update |
update |
850 |
fi |
fi |
851 |
|
|
852 |
|
# if we mounted the U-Boot directory, unmount it. |
853 |
|
[[ -n ${mounted} ]] && umount ${ubootDir} |
854 |
|
|
855 |
exit 0 |
exit 0 |