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 |
liloConfig="" |
liloConfig="" |
118 |
bootPrefix=/boot |
bootPrefix=/boot |
119 |
ubootDir=${UBOOT_DIR:-"/boot/uboot"} |
ubootDir=${UBOOT_DIR:-"/boot"} |
120 |
ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} |
ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} |
121 |
ubootKList=${UBOOT_KLIST:-"klist.txt"} |
ubootKList=${UBOOT_KLIST:-"klist.txt"} |
122 |
ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} |
ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} |
125 |
mounted="" |
mounted="" |
126 |
liloFlag="" |
liloFlag="" |
127 |
isx86="" |
isx86="" |
128 |
|
if [[ -z ${UBOOT_IMGADDR} ]] |
129 |
|
then |
130 |
|
machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//') |
131 |
|
if [ "${machine}" == "OMAP3 Beagle Board" ] || [ "${machine}" == "OMAP4 Panda board" ] |
132 |
|
then |
133 |
|
ubootAddress=0x80008000 |
134 |
|
else |
135 |
|
ubootAddress=0x00008000 |
136 |
|
fi |
137 |
|
else |
138 |
|
ubootAddress="${UBOOT_IMGADDR}" |
139 |
|
fi |
140 |
else |
else |
141 |
# this leaves i?86 and x86_64 |
# this leaves i?86 and x86_64 |
142 |
liloConfig=/etc/lilo.conf |
liloConfig=/etc/lilo.conf |
230 |
|
|
231 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
232 |
then |
then |
233 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
234 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
235 |
then |
then |
236 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
237 |
|
elif [[ $(read_os_release id) = magellan ]] |
238 |
|
then |
239 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
240 |
else |
else |
241 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
242 |
fi |
fi |
243 |
${grubby} --grub -c ${grubConfig} \ |
${grubby} --grub -c ${grubConfig} \ |
244 |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
254 |
|
|
255 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
256 |
then |
then |
257 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
258 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
259 |
then |
then |
260 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
261 |
|
elif [[ $(read_os_release id) = magellan ]] |
262 |
|
then |
263 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
264 |
else |
else |
265 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
266 |
fi |
fi |
267 |
${grubby} --grub2 -c ${grub2Config} \ |
${grubby} --grub2 -c ${grub2Config} \ |
268 |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
279 |
|
|
280 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
281 |
then |
then |
282 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
283 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
284 |
then |
then |
285 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
286 |
|
elif [[ $(read_os_release id) = magellan ]] |
287 |
|
then |
288 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
289 |
else |
else |
290 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
291 |
fi |
fi |
292 |
${grubby} --grub2 -c ${grub2EfiConfig} \ |
${grubby} --grub2 -c ${grub2EfiConfig} \ |
293 |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
329 |
|
|
330 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
331 |
then |
then |
332 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
333 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
334 |
then |
then |
335 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
336 |
|
elif [[ $(read_os_release id) = magellan ]] |
337 |
|
then |
338 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
339 |
else |
else |
340 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
341 |
fi |
fi |
342 |
${grubby} --extlinux -c ${extlinuxConfig} \ |
${grubby} --extlinux -c ${extlinuxConfig} \ |
343 |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
411 |
then |
then |
412 |
tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) |
tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) |
413 |
curversion=$(tail -n1 ${ubootDir}/${ubootKList}) |
curversion=$(tail -n1 ${ubootDir}/${ubootKList}) |
414 |
sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
415 |
newversion=$(tail -n1 ${tmpKList}) |
newversion=$(tail -n1 ${tmpKList}) |
416 |
if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] |
if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] |
417 |
then |
then |
451 |
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
452 |
fi |
fi |
453 |
else |
else |
454 |
[[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!" |
[[ -n ${verbose} ]] && echo "No previous kernel version. U-Boot images not removed!" |
455 |
fi |
fi |
456 |
else |
else |
457 |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
551 |
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
552 |
|
|
553 |
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
554 |
mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \ |
mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \ |
555 |
-n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
-e ${ubootAddress} -n ${version} \ |
556 |
|
-d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
557 |
|
|
558 |
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
559 |
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 \ |
592 |
fi |
fi |
593 |
} |
} |
594 |
|
|
595 |
mkinitrd() |
makeinitrd() |
596 |
{ |
{ |
597 |
if [[ -n ${dracut} ]] |
if [[ -n ${dracut} ]] |
598 |
then |
then |
599 |
tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
600 |
else |
else |
601 |
tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}" |
tool="mkinitrd --allow-missing -f ${initrdfile} ${version}" |
602 |
fi |
fi |
603 |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
604 |
${tool} |
${tool} |
839 |
|
|
840 |
if [[ ${initrd} = make ]] |
if [[ ${initrd} = make ]] |
841 |
then |
then |
842 |
mkinitrd |
makeinitrd |
843 |
elif [[ ${initrd} = remove ]] |
elif [[ ${initrd} = remove ]] |
844 |
then |
then |
845 |
rminitrd |
rminitrd |
857 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
858 |
[[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
[[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
859 |
|
|
860 |
# 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 |
861 |
# 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. |
862 |
if [[ -n ${ubootDir} ]] |
if [[ -n ${ubootDir} ]] |
863 |
then |
then |
864 |
mountEntry=$(mount | grep ${ubootDir}) |
if [ -f ${ubootScript} ] |
|
if [[ -z ${mountEntry} ]] |
|
865 |
then |
then |
866 |
mount ${ubootDevice} ${ubootDir} |
cfguBoot=1 |
867 |
mounted=1 |
else |
868 |
|
mountEntry=$(mount | grep ${ubootDir}) |
869 |
|
if [[ -z ${mountEntry} ]] |
870 |
|
then |
871 |
|
mount ${ubootDevice} ${ubootDir} |
872 |
|
mounted=1 |
873 |
|
fi |
874 |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
875 |
fi |
fi |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
|
876 |
fi |
fi |
877 |
|
|
878 |
# 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 |
893 |
update |
update |
894 |
fi |
fi |
895 |
|
|
896 |
|
# if we mounted the U-Boot directory, unmount it. |
897 |
|
[[ -n ${mounted} ]] && umount ${ubootDir} |
898 |
|
|
899 |
exit 0 |
exit 0 |