New package: u-boot-menu

Add a kernel hook to create an extlinux boot menu for u-boot. All
kernels and initirds found in /boot/ are added to the boot menu. The
timeout, kernel command line and DTB name to be used can be configured
in /etc/default/extlinux.

Then u-boot can be set to boot with this menu with :
sysboot mmc <bootpart> any <extaddr> extlinux/extlinux.conf
This commit is contained in:
Remi Pommarel 2019-01-16 14:57:34 +01:00 committed by maxice8
parent 754f50e3b7
commit 617eab313a
3 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,3 @@
TIMEOUT=10
CMDLINE=""
DTBPATH=""

View File

@ -0,0 +1,63 @@
#!/bin/sh
header() {
echo "TIMEOUT ${TIMEOUT}" > ${OUTFILE}
echo "DEFAULT entry0" >> ${OUTFILE}
echo "MENU TITLE Boot menu" >> ${OUTFILE}
}
get_bootpath() {
echo ${1} | sed "s#${BOOTPART}/#/#"
}
add_kernel() {
ver=${1}
kernel=$(get_bootpath "/boot/vmlinux-${ver}")
initrd=$(get_bootpath "/boot/initramfs-${ver}.img")
fdt=$(get_bootpath "/boot/dtbs/dtbs-${ver}/${DTBPATH}")
cmdline="${CMDLINE}"
echo "LABEL entry${ENTRY}" >> ${OUTFILE}
echo "\tMENU LABEL Void Linux Version ${ver}" >> ${OUTFILE}
echo "\tLINUX ${kernel}" >> ${OUTFILE}
if [ -e "${BOOTPART}/${initrd}" ]; then
echo "\tINITRD ${initrd}" >> ${OUTFILE}
fi
if [ -n "${DTBPATH}" ] && [ -e "${BOOTPART}/${fdt}" ]; then
echo "\tFDT ${fdt}" >> ${OUTFILE}
fi
if [ -n "${cmdline}" ]; then
echo "\tAPPEND ${cmdline}" >> ${OUTFILE}
fi
ENTRY=$(expr ${ENTRY} + 1)
}
main() {
if [ ! -d /boot/extlinux ]; then
rm ${OUTFILE}
exit 0
fi
if [ -e ${CONF} ]; then
. ${CONF}
fi
if [ -z "${CMDLINE}" ]; then
CMDLINE=$(cat /proc/cmdline)
fi
header
for kernel in $(ls /boot/vmlinu[xz]-* | sort -rV); do
ver=$(echo ${kernel} | sed "s#/boot/vmlinu[xz]-\(.*\)#\\1#")
echo "Add kernel ${ver}"
add_kernel ${ver}
done
mv ${OUTFILE} /boot/extlinux/extlinux.conf
}
CONF=/etc/default/extlinux
OUTFILE=$(mktemp)
BOOTPART=$(df -P /boot | tail -1 | awk '{ print $6 }')
ENTRY=0
main

View File

@ -0,0 +1,18 @@
# Template file for 'u-boot-menu'
pkgname=u-boot-menu
version=0.1
revision=1
noarch=yes
conf_files="/etc/default/extlinux"
short_desc="Create an u-boot menu with currently available kernels"
maintainer="Remi Pommarel <repk@triplefau.lt>"
license="Public domain"
homepage="https://www.voidlinux.org"
do_install() {
vinstall ${FILESDIR}/extlinux.default 644 etc/default extlinux
vinstall ${FILESDIR}/kernel.d/extlinux 750 \
etc/kernel.d/post-install 60-extlinux
vinstall ${FILESDIR}/kernel.d/extlinux 750 \
etc/kernel.d/post-remove 60-extlinux
}