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 |
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 |
[ -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="" |
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} = armv7l ]] |
elif [[ ${ARCH} =~ armv[5|7].*l ]] |
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"} |
123 |
ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} |
ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} |
124 |
ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} |
ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} |
125 |
|
ubootAddress=${UBOOT_IMGADDR:-"0x00008000"} |
126 |
mounted="" |
mounted="" |
127 |
liloFlag="" |
liloFlag="" |
128 |
isx86="" |
isx86="" |
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" |
148 |
verbose="" |
verbose="" |
149 |
makedefault="" |
makedefault="" |
150 |
package="" |
package="" |
151 |
mbkernel="" |
mbkernel="${HYPERVISOR}" |
152 |
mbargs="" |
mbargs="${HYPERVISOR_ARGS}" |
153 |
adddracutargs="" |
adddracutargs="" |
154 |
addplymouthinitrd="" |
addplymouthinitrd="" |
155 |
|
|
167 |
exit 1 |
exit 1 |
168 |
} |
} |
169 |
|
|
|
run_grub2() |
|
|
{ |
|
|
if [ -d /boot/grub -a -x /sbin/grub-mkconfig ] |
|
|
then |
|
|
cp /boot/grub/grub.cfg /boot/grub/grub.cfg.old |
|
|
/sbin/grub-mkconfig -o /boot/grub/grub.cfg |
|
|
fi |
|
|
} |
|
|
|
|
170 |
install() |
install() |
171 |
{ |
{ |
172 |
# XXX kernel should be able to be specified also (or work right on ia64) |
# XXX kernel should be able to be specified also (or work right on ia64) |
173 |
if [ ! -f ${bootPrefix}/${kernelName}-${version} ] |
if [ ! -f ${kernelImage} ] |
174 |
then |
then |
175 |
[[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
176 |
return |
return |
195 |
if [[ -z ${initrdfile} ]] |
if [[ -z ${initrdfile} ]] |
196 |
then |
then |
197 |
[[ -n ${verbose} ]] && echo "No initrd, just adding system map" |
[[ -n ${verbose} ]] && echo "No initrd, just adding system map" |
198 |
/sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version} |
/sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinitrd-${version} |
199 |
else |
else |
200 |
/sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version} |
/sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinux.sm-${version} |
201 |
/sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null |
/sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null |
202 |
rm ${bootPrefix}/vmlinux.sm-${version} |
rm ${bootPrefix}/vmlinux.sm-${version} |
203 |
fi |
fi |
204 |
return |
return |
205 |
fi |
fi |
206 |
|
|
|
# Run grub2's configuration update in parallel, if it is installed |
|
|
run_grub2 |
|
|
|
|
207 |
# get the root filesystem to use |
# get the root filesystem to use |
208 |
rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab) |
rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab 2>/dev/null) |
209 |
|
if [[ -z $rootdevice ]] |
210 |
|
then |
211 |
|
rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline) |
212 |
|
fi |
213 |
|
|
214 |
if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]] |
if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]] |
215 |
then |
then |
217 |
cfgLilo="" |
cfgLilo="" |
218 |
fi |
fi |
219 |
|
|
220 |
|
if [[ -n ${banner} ]] |
221 |
|
then |
222 |
|
title="${banner} [ ${version} ]" |
223 |
|
elif [[ $(read_os_release id) = magellan ]] |
224 |
|
then |
225 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
226 |
|
elif [ -f /etc/mageversion ] |
227 |
|
then |
228 |
|
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
229 |
|
else |
230 |
|
title="Magellan Linux [ ${version} ]" |
231 |
|
fi |
232 |
|
|
233 |
if [[ -n ${cfgGrub} ]] |
if [[ -n ${cfgGrub} ]] |
234 |
then |
then |
235 |
[[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}" |
[[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}" |
236 |
|
|
237 |
if [[ -n ${banner} ]] |
${grubby} --grub -c ${grubConfig} \ |
238 |
then |
--add-kernel=${kernelImage} \ |
|
title="${banner} (${version})" |
|
|
elif [ -f /etc/mageversion ] |
|
|
then |
|
|
title="Magellan Linux $(< /etc/mageversion) (${version})" |
|
|
else |
|
|
title="Magellan Linux (${version})" |
|
|
fi |
|
|
${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \ |
|
239 |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
240 |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
241 |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
242 |
else |
else |
243 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
244 |
|
fi |
245 |
|
if [[ -n ${cfgGrub2} ]] |
246 |
|
then |
247 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}" |
248 |
|
|
249 |
|
${grubby} --grub2 -c ${grub2Config} \ |
250 |
|
--add-kernel=${kernelImage} \ |
251 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
252 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} \ |
253 |
|
${mbargs:+--mbargs="${mbargs}"} \ |
254 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
255 |
|
else |
256 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" |
257 |
|
fi |
258 |
|
if [[ -n ${cfgGrub2Efi} ]] |
259 |
|
then |
260 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}" |
261 |
|
|
262 |
|
${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
263 |
|
--add-kernel=${kernelImage} \ |
264 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
265 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} \ |
266 |
|
${mbargs:+--mbargs="${mbargs}"} \ |
267 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
268 |
|
else |
269 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI" |
270 |
fi |
fi |
271 |
|
|
272 |
if [[ -n ${cfgLilo} ]] |
if [[ -n ${cfgLilo} ]] |
273 |
then |
then |
274 |
[[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}" |
[[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}" |
275 |
|
|
276 |
${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \ |
${grubby} --add-kernel=${kernelImage} ${INITRD} \ |
277 |
--copy-default ${makedefault} --title ${version} \ |
--copy-default ${makedefault} --title ${version} \ |
278 |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
279 |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \ |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \ |
292 |
else |
else |
293 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
294 |
fi |
fi |
295 |
|
|
296 |
|
if [[ -n ${cfgExtlinux} ]] |
297 |
|
then |
298 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}" |
299 |
|
|
300 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
301 |
|
--add-kernel=${kernelImage} \ |
302 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
303 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
304 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
305 |
|
else |
306 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
307 |
|
fi |
308 |
} |
} |
309 |
|
|
310 |
remove() |
remove() |
313 |
if [ -d /proc/iSeries ] |
if [ -d /proc/iSeries ] |
314 |
then |
then |
315 |
[[ -n ${verbose} ]] && echo "On an iSeries, remove img file" |
[[ -n ${verbose} ]] && echo "On an iSeries, remove img file" |
316 |
rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null |
rm -f ${kernelImage}.img 2>/dev/null |
317 |
return |
return |
318 |
fi |
fi |
319 |
|
|
|
# Run grub2's configuration update in parallel, if it is installed |
|
|
run_grub2 |
|
|
|
|
320 |
if [[ -n ${cfgGrub} ]] |
if [[ -n ${cfgGrub} ]] |
321 |
then |
then |
322 |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
323 |
${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} |
${grubby} --grub -c ${grubConfig} \ |
324 |
|
--remove-kernel=${kernelImage} |
325 |
else |
else |
326 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
327 |
|
fi |
328 |
|
if [[ -n ${cfgGrub2} ]] |
329 |
|
then |
330 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}" |
331 |
|
${grubby} --grub2 -c ${grub2Config} \ |
332 |
|
--remove-kernel=${kernelImage} |
333 |
|
else |
334 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" |
335 |
|
fi |
336 |
|
if [[ -n ${cfgGrub2Efi} ]] |
337 |
|
then |
338 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}" |
339 |
|
${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
340 |
|
--remove-kernel=${kernelImage} |
341 |
|
else |
342 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI" |
343 |
fi |
fi |
344 |
|
|
345 |
if [[ -n ${cfgLilo} ]] |
if [[ -n ${cfgLilo} ]] |
346 |
then |
then |
347 |
[[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}" |
[[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}" |
348 |
${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag} |
${grubby} --remove-kernel=${kernelImage} --${liloFlag} |
349 |
|
|
350 |
if [[ -n ${runLilo} ]] |
if [[ -n ${runLilo} ]] |
351 |
then |
then |
369 |
then |
then |
370 |
tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) |
tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) |
371 |
curversion=$(tail -n1 ${ubootDir}/${ubootKList}) |
curversion=$(tail -n1 ${ubootDir}/${ubootKList}) |
372 |
sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
373 |
newversion=$(tail -n1 ${tmpKList}) |
newversion=$(tail -n1 ${tmpKList}) |
374 |
if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] |
if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] |
375 |
then |
then |
404 |
fi |
fi |
405 |
|
|
406 |
mv ${tmpKList} ${ubootDir}/${ubootKList} |
mv ${tmpKList} ${ubootDir}/${ubootKList} |
407 |
|
[ -x /sbin/a-b-c ] && /sbin/a-b-c |
408 |
else |
else |
409 |
[[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!" |
[[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!" |
410 |
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
411 |
fi |
fi |
412 |
else |
else |
413 |
[[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!" |
[[ -n ${verbose} ]] && echo "No previous kernel version. U-Boot images not removed!" |
414 |
fi |
fi |
415 |
else |
else |
416 |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
417 |
fi |
fi |
418 |
|
|
419 |
|
if [[ -n ${cfgExtlinux} ]] |
420 |
|
then |
421 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}" |
422 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
423 |
|
--remove-kernel=${kernelImage} |
424 |
|
else |
425 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
426 |
|
fi |
427 |
} |
} |
428 |
|
|
429 |
update() |
update() |
430 |
{ |
{ |
431 |
if [ ! -f ${bootPrefix}/${kernelName}-${version} ] |
if [ ! -f ${kernelImage} ] |
432 |
then |
then |
433 |
[[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
434 |
return |
return |
446 |
fi |
fi |
447 |
fi |
fi |
448 |
|
|
|
# Run grub2's configuration update in parallel, if it is installed |
|
|
run_grub2 |
|
|
|
|
449 |
if [[ -n ${cfgGrub} ]] |
if [[ -n ${cfgGrub} ]] |
450 |
then |
then |
451 |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
452 |
${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --grub -c ${grubConfig} \ |
453 |
|
--update-kernel=${kernelImage} \ |
454 |
${INITRD} \ |
${INITRD} \ |
455 |
${kernargs:+--args="${kernargs}"} \ |
${kernargs:+--args="${kernargs}"} \ |
456 |
${removeargs:+--remove-args="${removeargs}"} |
${removeargs:+--remove-args="${removeargs}"} |
458 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
459 |
fi |
fi |
460 |
|
|
461 |
|
if [[ -n ${cfgGrub2} ]] |
462 |
|
then |
463 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}" |
464 |
|
${grubby} --grub2 -c ${grub2Config} \ |
465 |
|
--update-kernel=${kernelImage} \ |
466 |
|
${INITRD} \ |
467 |
|
${kernargs:+--args="${kernargs}"} \ |
468 |
|
${removeargs:+--remove-args="${removeargs}"} |
469 |
|
else |
470 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby" |
471 |
|
fi |
472 |
|
|
473 |
|
if [[ -n ${cfgGrub2Efi} ]] |
474 |
|
then |
475 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}" |
476 |
|
${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
477 |
|
--update-kernel=${kernelImage} \ |
478 |
|
${INITRD} \ |
479 |
|
${kernargs:+--args="${kernargs}"} \ |
480 |
|
${removeargs:+--remove-args="${removeargs}"} |
481 |
|
else |
482 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby" |
483 |
|
fi |
484 |
|
|
485 |
if [[ -n ${cfgLilo} ]] |
if [[ -n ${cfgLilo} ]] |
486 |
then |
then |
487 |
[[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" |
[[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" |
488 |
${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --update-kernel=${kernelImage} \ |
489 |
${INITRD} \ |
${INITRD} \ |
490 |
${kernargs:+--args="${kernargs}"} \ |
${kernargs:+--args="${kernargs}"} \ |
491 |
${removeargs:+--remove-args="${removeargs}"} \ |
${removeargs:+--remove-args="${removeargs}"} \ |
510 |
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
511 |
|
|
512 |
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
513 |
mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \ |
mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \ |
514 |
-n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
-e ${ubootAddress} -n ${version} \ |
515 |
|
-d ${kernelImage} ${ubootDir}/uImage-${version} |
516 |
|
|
517 |
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
518 |
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 \ |
531 |
[[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit |
[[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit |
532 |
fi |
fi |
533 |
echo ${version} >> ${ubootDir}/${ubootKList} |
echo ${version} >> ${ubootDir}/${ubootKList} |
534 |
|
[ -x /sbin/a-b-c ] && /sbin/a-b-c |
535 |
else |
else |
536 |
[[ -n ${verbose} ]] && echo "cannot make ${version} the default" |
[[ -n ${verbose} ]] && echo "cannot make ${version} the default" |
537 |
fi |
fi |
538 |
else |
else |
539 |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" |
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" |
540 |
fi |
fi |
541 |
|
|
542 |
|
if [[ -n ${cfgExtlinux} ]] |
543 |
|
then |
544 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}" |
545 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
546 |
|
--update-kernel=${kernelImage} \ |
547 |
|
${INITRD} \ |
548 |
|
${kernargs:+--args="${kernargs}"} \ |
549 |
|
${removeargs:+--remove-args="${removeargs}"} |
550 |
|
else |
551 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby" |
552 |
|
fi |
553 |
} |
} |
554 |
|
|
555 |
mkinitrd() |
makeinitrd() |
556 |
{ |
{ |
557 |
if [[ -n ${dracut} ]] |
if [[ -n ${dracut} ]] |
558 |
then |
then |
559 |
tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
560 |
else |
else |
561 |
tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}" |
tool="mkinitrd --allow-missing -f ${initrdfile} ${version}" |
562 |
fi |
fi |
563 |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
564 |
${tool} |
${tool} |
585 |
doRmmoddep() |
doRmmoddep() |
586 |
{ |
{ |
587 |
[[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}" |
[[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}" |
588 |
[ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.* |
if [ -d /lib/modules/${version} ] |
589 |
|
then |
590 |
|
rm -f /lib/modules/${version}/modules.*.bin \ |
591 |
|
/lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep} |
592 |
|
fi |
593 |
} |
} |
594 |
|
|
595 |
|
|
613 |
;; |
;; |
614 |
|
|
615 |
--initrdfile*) |
--initrdfile*) |
616 |
if echo $1 | grep '=' >/dev/null |
if [[ $1 == --initrdfile\=* ]] |
617 |
then |
then |
618 |
initrdfile=$(echo $1 | sed 's/^--initrdfile=//') |
initrdfile=${1#--initrdfile=} |
619 |
else |
else |
620 |
initrdfile=$2 |
initrdfile=$2 |
621 |
shift |
shift |
623 |
;; |
;; |
624 |
|
|
625 |
--kernel-args*) |
--kernel-args*) |
626 |
if echo $1 | grep '=' >/dev/null |
if [[ $1 == --kernel-args\=* ]] |
627 |
then |
then |
628 |
kernargs=$(echo $1 | sed 's/^--kernel-args=//') |
kernargs=${1#--kernel-args=} |
629 |
else |
else |
630 |
kernargs=$2 |
kernargs=$2 |
631 |
shift |
shift |
633 |
;; |
;; |
634 |
|
|
635 |
--remove-args*) |
--remove-args*) |
636 |
if echo $1 | grep '=' >/dev/null |
if [[ $1 == --remove-args\=* ]] |
637 |
then |
then |
638 |
removeargs=$(echo $1 | sed 's/^--remove-args=//') |
removeargs=${1#--remove-args=} |
639 |
else |
else |
640 |
removeargs=$2 |
removeargs=$2 |
641 |
shift |
shift |
643 |
;; |
;; |
644 |
|
|
645 |
--banner*) |
--banner*) |
646 |
if echo $1 | grep '=' >/dev/null |
if [[ $1 == --banner\=* ]] |
647 |
then |
then |
648 |
banner=$(echo $1 | sed 's/^--banner=//') |
banner=${1#--banner=} |
649 |
else |
else |
650 |
banner=$2 |
banner=$2 |
651 |
shift |
shift |
653 |
;; |
;; |
654 |
|
|
655 |
--multiboot*) |
--multiboot*) |
656 |
if echo $1 |grep '=' >/dev/null |
if [[ $1 == --multiboot\=* ]] |
657 |
then |
then |
658 |
mbkernel=$(echo $1 | sed 's/^--multiboot=//') |
mbkernel=${1#--multiboot=} |
659 |
else |
else |
660 |
# can't really support having an optional second arg here |
# can't really support having an optional second arg here |
661 |
# sorry! |
# sorry! |
664 |
;; |
;; |
665 |
|
|
666 |
--mbargs*) |
--mbargs*) |
667 |
if echo $1 |grep '=' >/dev/null |
if [[ $1 == --mbargs\=* ]] |
668 |
then |
then |
669 |
mbargs=$(echo $1 | sed 's/^--mbargs=//') |
mbargs=${1#--mbargs=} |
670 |
else |
else |
671 |
mbargs="$2" |
mbargs="$2" |
672 |
shift |
shift |
685 |
makedefault="--make-default" |
makedefault="--make-default" |
686 |
;; |
;; |
687 |
|
|
688 |
--package) |
--package*) |
689 |
if echo $1 | grep '=' >/dev/null |
if [[ $1 == --package\=* ]] |
690 |
then |
then |
691 |
package=$(echo $1 | sed 's/^--package=//') |
package=${1#--package=} |
692 |
else |
else |
693 |
package=$2 |
package=$2 |
694 |
shift |
shift |
703 |
addplymouthinitrd=--add-plymouth-initrd |
addplymouthinitrd=--add-plymouth-initrd |
704 |
;; |
;; |
705 |
|
|
706 |
|
--kernel-image*) |
707 |
|
if [[ $1 == --kernel-image\=* ]] |
708 |
|
then |
709 |
|
kernelImage=${1#--kernel-image=} |
710 |
|
else |
711 |
|
kernelImage="$2" |
712 |
|
shift |
713 |
|
fi |
714 |
|
if ! [[ -f ${kernelImage} ]] |
715 |
|
then |
716 |
|
echo "Can't find kernel image '${kernelImage}'" >&2 |
717 |
|
usage |
718 |
|
exit 1 |
719 |
|
fi |
720 |
|
;; |
721 |
|
|
722 |
-v) |
-v) |
723 |
verbose=-v |
verbose=-v |
724 |
;; |
;; |
766 |
fi |
fi |
767 |
fi |
fi |
768 |
|
|
769 |
|
[[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}" |
770 |
|
|
771 |
# set the initrd file based on arch; ia64 is the only currently known oddball |
# set the initrd file based on arch; ia64 is the only currently known oddball |
772 |
if [[ -z ${initrdfile} ]] |
if [[ -z ${initrdfile} ]] |
773 |
then |
then |
789 |
# add dracut i18n, keyboard and plymouth kernel args if requested |
# add dracut i18n, keyboard and plymouth kernel args if requested |
790 |
if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]] |
if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]] |
791 |
then |
then |
792 |
[ -r /etc/conf.d/keymap ] && . /etc/conf.d/keymap |
if [ -r /etc/vconsole.conf ] |
|
[ -r /etc/conf.d/consolefont ] && . /etc/conf.d/consolefont |
|
|
|
|
|
if [[ -n ${KEYMAP} ]] |
|
793 |
then |
then |
794 |
kernargs="${kernargs} KEYTABLE=${KEYMAP}" |
. /etc/vconsole.conf |
795 |
|
|
796 |
|
for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE |
797 |
|
do |
798 |
|
val=$(eval echo \$$i) |
799 |
|
[[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}" |
800 |
|
done |
801 |
|
else |
802 |
|
if [ -r /etc/conf.d/consolefont ] |
803 |
|
then |
804 |
|
. /etc/conf.d/consolefont |
805 |
|
|
806 |
|
if [[ -n ${CONSOLEFONT} ]] |
807 |
|
then |
808 |
|
kernargs="${kernargs} SYSFONT=${CONSOLEFONT}" |
809 |
|
fi |
810 |
|
fi |
811 |
|
|
812 |
|
if [ -r /etc/conf.d/keymap ] |
813 |
|
then |
814 |
|
. /etc/conf.d/keymap |
815 |
|
|
816 |
|
if [[ -n ${KEYMAP} ]] |
817 |
|
then |
818 |
|
kernargs="${kernargs} KEYTABLE=${KEYMAP}" |
819 |
|
fi |
820 |
|
fi |
821 |
fi |
fi |
822 |
|
|
823 |
if [[ -n ${CONSOLEFONT} ]] |
if [ -r /etc/locale.conf ] |
824 |
then |
then |
825 |
kernargs="${kernargs} SYSFONT=${CONSOLEFONT}" |
. /etc/locale.conf |
826 |
|
|
827 |
|
if [[ -n ${LANG} ]] |
828 |
|
then |
829 |
|
kernargs="${kernargs} LANG=${LANG}" |
830 |
|
fi |
831 |
fi |
fi |
832 |
fi |
fi |
833 |
|
|
849 |
|
|
850 |
if [[ ${initrd} = make ]] |
if [[ ${initrd} = make ]] |
851 |
then |
then |
852 |
mkinitrd |
makeinitrd |
853 |
elif [[ ${initrd} = remove ]] |
elif [[ ${initrd} = remove ]] |
854 |
then |
then |
855 |
rminitrd |
rminitrd |
862 |
fi |
fi |
863 |
|
|
864 |
[[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
[[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
865 |
|
[[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1 |
866 |
|
[[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1 |
867 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
868 |
|
[[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
869 |
|
|
870 |
# 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 |
871 |
# 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. |
872 |
if [[ -n ${ubootDir} ]] |
if [[ -n ${ubootDir} ]] |
873 |
then |
then |
874 |
mountEntry=$(mount | grep ${ubootDir}) |
if [ -f ${ubootScript} ] |
875 |
if [[ -z ${mountEntry} ]] |
then |
876 |
|
cfguBoot=1 |
877 |
|
else |
878 |
|
mountEntry=$(mount | grep ${ubootDir}) |
879 |
|
if [[ -z ${mountEntry} ]] |
880 |
|
then |
881 |
|
mount ${ubootDevice} ${ubootDir} |
882 |
|
mounted=1 |
883 |
|
fi |
884 |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
885 |
|
fi |
886 |
|
fi |
887 |
|
|
888 |
|
# if we're using U-Boot, check if the default load address should change |
889 |
|
if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]] |
890 |
|
then |
891 |
|
[[ ${version} =~ .([^.]*)$ ]] |
892 |
|
platform=${BASH_REMATCH[1]} |
893 |
|
# A few platforms use an alternate kernel load address |
894 |
|
if [[ ${platform} = omap ]] |
895 |
|
then |
896 |
|
ubootAddress=0x80008000 |
897 |
|
elif [[ ${platform} = imx ]] |
898 |
then |
then |
899 |
mount ${ubootDevice} ${ubootDir} |
ubootAddress=0x90008000 |
|
mounted=1 |
|
900 |
fi |
fi |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
|
901 |
fi |
fi |
902 |
|
|
903 |
# 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 |
918 |
update |
update |
919 |
fi |
fi |
920 |
|
|
921 |
|
# if we mounted the U-Boot directory, unmount it. |
922 |
|
[[ -n ${mounted} ]] && umount ${ubootDir} |
923 |
|
|
924 |
exit 0 |
exit 0 |