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 |
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} = armv7l ]] |
elif [[ ${ARCH} = armv7l ]] || [[ ${ARCH} = armv7hl ]] || [[ ${ARCH} = armv5tel ]] |
116 |
then |
then |
117 |
|
machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//') |
118 |
liloConfig="" |
liloConfig="" |
119 |
bootPrefix=/boot |
bootPrefix=/boot |
120 |
ubootDir=${UBOOT_DIR:-"/boot/uboot"} |
ubootDir=${UBOOT_DIR:-"/boot/uboot"} |
126 |
mounted="" |
mounted="" |
127 |
liloFlag="" |
liloFlag="" |
128 |
isx86="" |
isx86="" |
129 |
|
if [[ ${machine} == "OMAP3 Beagle Board" ]] || [[ ${machine} == "OMAP4 Panda board" ]] |
130 |
|
then |
131 |
|
ubootAddress=0x80008000 |
132 |
|
else |
133 |
|
ubootAddress=0x00008000 |
134 |
|
fi |
135 |
else |
else |
136 |
# this leaves i?86 and x86_64 |
# this leaves i?86 and x86_64 |
137 |
liloConfig=/etc/lilo.conf |
liloConfig=/etc/lilo.conf |
225 |
|
|
226 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
227 |
then |
then |
228 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
229 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
230 |
then |
then |
231 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
232 |
|
elif [[ $(read_os_release id) = magellan ]] |
233 |
|
then |
234 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
235 |
else |
else |
236 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
237 |
fi |
fi |
238 |
${grubby} --grub -c ${grubConfig} \ |
${grubby} --grub -c ${grubConfig} \ |
239 |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
249 |
|
|
250 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
251 |
then |
then |
252 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
253 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
254 |
then |
then |
255 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
256 |
|
elif [[ $(read_os_release id) = magellan ]] |
257 |
|
then |
258 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
259 |
else |
else |
260 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
261 |
fi |
fi |
262 |
${grubby} --grub2 -c ${grub2Config} \ |
${grubby} --grub2 -c ${grub2Config} \ |
263 |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
274 |
|
|
275 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
276 |
then |
then |
277 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
278 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
279 |
then |
then |
280 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
281 |
|
elif [[ $(read_os_release id) = magellan ]] |
282 |
|
then |
283 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
284 |
else |
else |
285 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
286 |
fi |
fi |
287 |
${grubby} --grub2 -c ${grub2EfiConfig} \ |
${grubby} --grub2 -c ${grub2EfiConfig} \ |
288 |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
324 |
|
|
325 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
326 |
then |
then |
327 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
328 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
329 |
then |
then |
330 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
331 |
|
elif [[ $(read_os_release id) = magellan ]] |
332 |
|
then |
333 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
334 |
else |
else |
335 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
336 |
fi |
fi |
337 |
${grubby} --extlinux -c ${extlinuxConfig} \ |
${grubby} --extlinux -c ${extlinuxConfig} \ |
338 |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
446 |
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
447 |
fi |
fi |
448 |
else |
else |
449 |
[[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!" |
[[ -n ${verbose} ]] && echo "No previous kernel version. U-Boot images not removed!" |
450 |
fi |
fi |
451 |
else |
else |
452 |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
546 |
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
547 |
|
|
548 |
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
549 |
mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \ |
mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \ |
550 |
-n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
-e ${ubootAddress} -n ${version} \ |
551 |
|
-d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
552 |
|
|
553 |
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
554 |
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 \ |
587 |
fi |
fi |
588 |
} |
} |
589 |
|
|
590 |
mkinitrd() |
makeinitrd() |
591 |
{ |
{ |
592 |
if [[ -n ${dracut} ]] |
if [[ -n ${dracut} ]] |
593 |
then |
then |
594 |
tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
595 |
else |
else |
596 |
tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}" |
tool="mkinitrd --allow-missing -f ${initrdfile} ${version}" |
597 |
fi |
fi |
598 |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
599 |
${tool} |
${tool} |
834 |
|
|
835 |
if [[ ${initrd} = make ]] |
if [[ ${initrd} = make ]] |
836 |
then |
then |
837 |
mkinitrd |
makeinitrd |
838 |
elif [[ ${initrd} = remove ]] |
elif [[ ${initrd} = remove ]] |
839 |
then |
then |
840 |
rminitrd |
rminitrd |
852 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
853 |
[[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
[[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
854 |
|
|
855 |
# 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 |
856 |
# 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. |
857 |
if [[ -n ${ubootDir} ]] |
if [[ -n ${ubootDir} ]] |
858 |
then |
then |
859 |
mountEntry=$(mount | grep ${ubootDir}) |
if [ -f ${ubootScript} ] |
|
if [[ -z ${mountEntry} ]] |
|
860 |
then |
then |
861 |
mount ${ubootDevice} ${ubootDir} |
cfguBoot=1 |
862 |
mounted=1 |
else |
863 |
|
mountEntry=$(mount | grep ${ubootDir}) |
864 |
|
if [[ -z ${mountEntry} ]] |
865 |
|
then |
866 |
|
mount ${ubootDevice} ${ubootDir} |
867 |
|
mounted=1 |
868 |
|
fi |
869 |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
870 |
fi |
fi |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
|
871 |
fi |
fi |
872 |
|
|
873 |
# 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 |
888 |
update |
update |
889 |
fi |
fi |
890 |
|
|
891 |
|
# if we mounted the U-Boot directory, unmount it. |
892 |
|
[[ -n ${mounted} ]] && umount ${ubootDir} |
893 |
|
|
894 |
exit 0 |
exit 0 |