summaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/syslinux/APKBUILD60
-rw-r--r--system/syslinux/syslinux.post-upgrade61
-rw-r--r--system/syslinux/syslinux.trigger3
-rwxr-xr-xsystem/syslinux/update-extlinux252
-rw-r--r--system/syslinux/update-extlinux.conf75
5 files changed, 451 insertions, 0 deletions
diff --git a/system/syslinux/APKBUILD b/system/syslinux/APKBUILD
new file mode 100644
index 000000000..25e7cb252
--- /dev/null
+++ b/system/syslinux/APKBUILD
@@ -0,0 +1,60 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=syslinux
+pkgver=6.04_pre1
+pkgrel=2
+_ver=${pkgver/_/-}
+pkgdesc="Boot loader for the Linux operating system"
+url="http://syslinux.org"
+arch="x86 x86_64"
+license="GPL"
+makedepends="linux-headers nasm perl util-linux-dev gnu-efi-dev"
+depends="mtools blkid mawk"
+triggers="syslinux.trigger=/boot"
+install="syslinux.post-upgrade"
+options="!check textrels" # does not ship tests in tarball
+ldpath="/usr/share/syslinux"
+
+source="https://www.kernel.org/pub/linux/utils/boot/syslinux/Testing/${pkgver%_pre*}/syslinux-$_ver.tar.xz
+ update-extlinux.conf
+ update-extlinux
+ "
+subpackages="$pkgname-doc $pkgname-dev"
+
+_loaderarch=
+case "$CARCH" in
+x86) _loaderarch=efi32;;
+x86_64) _loaderarch=efi64;;
+esac
+
+builddir="$srcdir"/$pkgname-$_ver
+prepare() {
+ cd "$builddir"
+ for i in $source; do
+ i=${i%%::*}
+ case "$i" in
+ *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+ esac
+ done
+}
+
+build() {
+ cd "$builddir"
+ unset LDFLAGS
+ make $_loaderarch installer || return 1
+}
+
+package() {
+ cd "$builddir"
+ make -j1 INSTALLROOT="$pkgdir" MANDIR=/usr/share/man \
+ bios $_loaderarch install || return 1
+
+ mkdir -p "$pkgdir"/etc/update-extlinux.d
+ cp "$srcdir"/update-extlinux.conf "$pkgdir"/etc/
+ sed "/^version=/s/=.*/=$pkgver-r$pkgrel/" "$srcdir"/update-extlinux \
+ > "$pkgdir"/sbin/update-extlinux
+ chmod 755 "$pkgdir"/sbin/update-extlinux
+}
+
+sha512sums="7927dd39be8e2dcf4138a6fea33def67d19d938379d694f15b48fdd2f5924c028b7a9e7bd71d0c7c6630c203e9e2a54296628e530632ad5e6f55b1ebefe8fc98 syslinux-6.04-pre1.tar.xz
+9071be450e543597f6f95b9a5811869c5351a71f4c42f7879b9f7ec1b13e2e4d455e9f2900e3897d5e5870bd87c934b7168328186c5f17631f2b09a524e10a1a update-extlinux.conf
+23fd69b5f42af063744289f64e60eddd0fa35db83d988b24635e6eb47b5c8fada8585c9aea60f398cfc1e5be8565230a81192d71df705368a90e0927f35fb60d update-extlinux"
diff --git a/system/syslinux/syslinux.post-upgrade b/system/syslinux/syslinux.post-upgrade
new file mode 100644
index 000000000..90388668d
--- /dev/null
+++ b/system/syslinux/syslinux.post-upgrade
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# find given append opt
+get_append_opt() {
+ awk -v search="$1" '
+ $1 == "append" || $1 == "APPEND" {
+ split($0, a);
+ for (i in a) {
+ if (index(a[i], search) == 1) {
+ print a[i];
+ }
+ }
+ }' /boot/extlinux.conf | sort | uniq
+}
+
+# print default kernel options
+get_default_opts() {
+ awk '
+ $1 == "append" || $1 == "APPEND" {
+ opts="";
+ space="";
+ split($0, a);
+ for (i in a) {
+ if (i != 1 \
+ && (index(a[i], "root=") != 1) \
+ && (index(a[i], "initrd=") != 1) \
+ && (index(a[i], "modules=") != 1)) {
+ opts = opts space a[i];
+ space = " ";
+ }
+ }
+ print opts;
+ }
+ ' /boot/extlinux.conf | sort | uniq
+}
+
+if ! [ -f /boot/extlinux.conf ]; then
+ exit 0
+fi
+
+# check if we already have a generated extlinux.conf
+if grep -q '^# Generated by update-extlinux' /boot/extlinux.conf; then
+ exit 0
+fi
+
+# try fish out the kernel opts from extlinuix.conf's append line
+root=$(get_append_opt 'root=' | head -n 1)
+modules=$(get_append_opt 'modules=' | head -n 1)
+opts=$(get_default_opts | head -n 1)
+
+# populate update-extlinux.conf with the info we know
+if [ -n "$root" ]; then
+ sed -i -e "/^root=/s|.*|$root|g" /etc/update-extlinux.conf
+fi
+if [ -n "$modules" ]; then
+ sed -i -e "/^modules=/s|.*|$modules|g" /etc/update-extlinux.conf
+fi
+if [ -n "$opts" ]; then
+ sed -i -e "/^default_kernel_opts=/s|.*|default_kernel_opts=\"$opts\"|g" /etc/update-extlinux.conf
+fi
+
diff --git a/system/syslinux/syslinux.trigger b/system/syslinux/syslinux.trigger
new file mode 100644
index 000000000..fe91f4379
--- /dev/null
+++ b/system/syslinux/syslinux.trigger
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+update-extlinux --warn-only
diff --git a/system/syslinux/update-extlinux b/system/syslinux/update-extlinux
new file mode 100755
index 000000000..b0d8d97f7
--- /dev/null
+++ b/system/syslinux/update-extlinux
@@ -0,0 +1,252 @@
+#!/bin/sh
+
+version=
+default=0
+timeout=5
+verbose=0
+
+conf=/boot/extlinux.conf
+myconf=/etc/update-extlinux.conf
+
+# read in extlinux settings
+if [ -f "$myconf" ]; then
+ . $myconf
+fi
+
+everbose() {
+ if [ "$verbose" = "0" ]; then
+ return
+ fi
+
+ echo $*
+}
+
+ewarn() {
+ echo "WARNING:" $@ >&2
+}
+
+eerror() {
+ echo "ERROR:" $@ >&2
+ return 1
+}
+
+usage() {
+ echo "usage: $0 [-v|--verbose] [--warn-only]"
+}
+
+while [ $# -gt 0 ]; do
+ opt="$1"
+ shift
+ case "$opt" in
+ -v|--verbose)
+ verbose=1
+ ;;
+ --warn-only)
+ warn_only=1
+ ;;
+ --)
+ break
+ ;;
+ -*)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+everbose "Updating extlinux configuration."
+
+if [ "x$root" = "x" ]; then
+ ewarn "Root device is not specified in $myconf."
+ blkid_export=$(blkid -o export /dev/root)
+ if [ -n "$blkid_export" ]; then
+ export $blkid_export
+ fi
+ if [ -z "$UUID" ]; then
+ # try parse /proc/mount for mounted /
+ dev=$(awk '$2 == "/" {dev=$1} END {print dev}' /proc/mounts)
+ if [ -n "$dev" ]; then
+ blkid_export=$(blkid -o export $dev)
+ if [ -n "$blkid_export" ]; then
+ export "$blkid_export"
+ fi
+ fi
+ fi
+ if [ -z "$UUID" ]; then
+ if [ -z "$dev" ]; then
+ if [ -n "$warn_only" ]; then
+ ewarn "Failed to detect root device. extlinux.conf is not updated"
+ exit 0
+ else
+ eerror "Failed to detect root device"
+ exit 1
+ fi
+ else
+ root=$dev
+ fi
+ else
+ root=UUID=$UUID
+ fi
+ everbose "Root device is: $root"
+fi
+
+rtimeout=$(( ${timeout} * 10 ))
+syslinux_menu=menu.c32
+menu_hidden=
+
+# vesa menu has been requested?
+if [ "$vesa_menu" = "1" ]; then
+ syslinux_menu=vesamenu.c32
+fi
+
+umask 0022
+rm -f $conf.new
+echo "# Generated by update-extlinux $version" > $conf.new
+if [ -n "$serial_port" ]; then
+ echo "SERIAL $serial_port ${serial_baud:-115200}" >> $conf.new
+fi
+echo "DEFAULT $syslinux_menu" >> $conf.new
+echo "PROMPT 0" >> $conf.new
+echo "MENU TITLE Addelie $(uname -s) Boot Menu" >> $conf.new
+if [ "$hidden" = "1" ]; then
+ echo "MENU HIDDEN" >> $conf.new
+fi
+echo "MENU AUTOBOOT Adelie will be booted automatically in # seconds." >> $conf.new
+echo "TIMEOUT $rtimeout" >> $conf.new
+
+lst=0
+if [ -f "/boot/xen.gz" ]; then
+ for kernel in $(find /boot -name "vmlinuz-*" -type f); do
+ tag=$(basename $kernel | cut -b9-)
+ everbose "Found Xen hypervisor: /boot/xen.gz, kernel: $kernel"
+
+ if [ -f "/boot/initramfs-$tag" ]; then
+ everbose "Found initramfs: /boot/initramfs-$tag"
+ initramfs="initramfs-$tag"
+ else
+ initramfs=
+ fi
+ label=xen-$(grep -w -l $tag /usr/share/kernel/*/kernel.release \
+ | cut -d/ -f5)
+ if [ "$label" = "xen-" ]; then
+ label=xen-$lst
+ fi
+
+ echo "LABEL $label" >> $conf.new
+ if [ "$label" = "$default" ]; then
+ echo " MENU DEFAULT" >> $conf.new
+ fi
+ echo " MENU LABEL Xen + Linux $tag" >> $conf.new
+ echo " COM32 mboot.c32" >> $conf.new
+ echo " APPEND xen.gz $xen_opts --- $(basename $kernel) root=$root modules=${modules}${TYPE:+,$TYPE} $default_kernel_opts --- $initramfs" >> $conf.new
+ echo "" >> $conf.new
+ lst=$(($lst + 1))
+ done
+fi
+
+for kernel in $(find /boot -name "vmlinuz*" -type f); do
+ case $kernel in
+ *vmlinuz) tag=vanilla;;
+ *vmlinuz-*) tag=$(basename $kernel | cut -b9-);;
+ *) continue;;
+ esac
+ everbose "Found kernel: $kernel"
+ label=$(grep -w -l $tag /usr/share/kernel/*/kernel.release | cut -d/ -f5)
+ if [ -z "$label" ]; then
+ if [ "$tag" = vanilla ]; then
+ label="vanilla"
+ else
+ label=$lst
+ fi
+ fi
+ echo "LABEL $label" >> $conf.new
+ if [ "$label" = "$default" ]; then
+ echo " MENU DEFAULT" >> $conf.new
+ fi
+ echo " MENU LABEL Linux $tag" >> $conf.new
+ echo " LINUX $(basename $kernel)" >> $conf.new
+ if [ -f "/boot/initramfs-$tag" ]; then
+ everbose "Found initramfs: /boot/initramfs-$tag"
+ echo " INITRD initramfs-$tag" >> $conf.new
+ fi
+ echo " APPEND root=$root modules=${modules}${TYPE:+,$TYPE} $default_kernel_opts" >> $conf.new
+ echo "" >> $conf.new
+ lst=$(($lst + 1))
+done
+
+if [ -n "$password" ]; then
+ echo "NOESCAPE 1" >> $conf.new
+ echo "MENU MASTER PASSWD $password" >> $conf.new
+ echo "" >> $conf.new
+ chmod o-r $conf.new
+fi
+
+everbose "$lst entries found."
+
+for entry in /etc/update-extlinux.d/*; do
+ [ -f "$entry" ] && { cat $entry; echo ""; } >> $conf.new
+done
+
+echo "MENU SEPARATOR" >> $conf.new
+echo "" >> $conf.new
+
+if [ -f "/boot/hdt.c32" ]; then
+ everbose "Found Hardware Detection Tool: /boot/hdt.c32"
+ echo "LABEL hdt" >> $conf.new
+ echo " MENU LABEL Hardware info" >> $conf.new
+ if [ -n "$password" ]; then
+ echo " MENU PASSWD" >> $conf.new
+ fi
+ echo " COM32 hdt.c32" >> $conf.new
+ if [ -f "/boot/memtest" ]; then
+ everbose "Found memtest86+: /boot/memtest"
+ echo " APPEND memtest=memtest" >> $conf.new
+ fi
+ echo "" >> $conf.new
+elif [ -f "/boot/memtest" ]; then
+ everbose "Found memtest86+: /boot/memtest"
+ echo "LABEL memtest" >> $conf.new
+ echo " MENU LABEL Memtest86+" >> $conf.new
+ echo " KERNEL memtest" >> $conf.new
+ echo "" >> $conf.new
+fi
+
+for i in reboot poweroff; do
+ [ -f "/boot/$i.c32" ] || continue
+ everbose "Found $i"
+ # make first char capital
+ cap=$( echo $i | awk '{sub(".", substr(toupper($0),1,1), $0); print}' )
+ echo "LABEL $i" >> $conf.new
+ echo " MENU LABEL $cap" >> $conf.new
+ echo " COM32 $i.c32" >> $conf.new
+ echo "" >> $conf.new
+done
+
+if cmp -s $conf.new $conf; then
+ everbose "Configuration unchanged."
+ rm $conf.new
+fi
+
+if [ "$overwrite" != "1" ]; then
+ exit 0
+elif [ -f "$conf.new" ]; then
+ # keep a backup just in case
+ if [ -f "$conf" ]; then
+ mv $conf $conf.old
+ fi
+
+ mv $conf.new $conf
+fi
+
+everbose "Installing libutil.c32 libcom32.c32 mboot.c32 menu.c32 vesamenu.c32 to /boot."
+cp /usr/share/syslinux/libutil.c32 \
+ /usr/share/syslinux/libcom32.c32 \
+ /usr/share/syslinux/mboot.c32 \
+ /usr/share/syslinux/menu.c32 \
+ /usr/share/syslinux/vesamenu.c32 \
+ /boot
+
+case "$(stat -f -c '%T' /boot)" in
+ext*) extlinux --update /boot || [ -n "$warn_only" ];;
+esac
+
diff --git a/system/syslinux/update-extlinux.conf b/system/syslinux/update-extlinux.conf
new file mode 100644
index 000000000..39598cb99
--- /dev/null
+++ b/system/syslinux/update-extlinux.conf
@@ -0,0 +1,75 @@
+# configuration for extlinux config builder
+
+# overwrite
+# Overwrite current /boot/extlinux.conf. If this is not '1' we will only
+# write to /boot/extlinux.conf.new
+overwrite=1
+
+# vesa_menu
+# use fancy vesa menu (vesamenu.c32) menus, won't work with serial
+vesa_menu=1
+
+# default_kernel_opts
+# default kernel options
+default_kernel_opts=ro
+
+# modules
+# modules which should be loaded before pivot_root
+modules=
+#sd-mod,usb-storage,ext3
+
+# root
+# root device - if not specified, will be guessed using
+# blkid -o export /dev/root
+root=
+
+# verbose
+# if set to non-zero, update-extlinux will be a lot more verbose.
+verbose=0
+
+# hidden
+# if set to non-zero, the boot menu will be hidden by default.
+hidden=0
+
+# timeout
+# number of seconds to wait before booting default
+timeout=5
+
+# default
+# default kernel to boot
+default=vanilla
+
+# serial_port
+# serial port number - if not specified, serial console will be disabled
+serial_port=
+
+# serial_baud
+# the baudrate for the serial port. Will use 115200 if unset
+serial_baud=115200
+
+# xen_opts
+# options to hand to xen hypervisor, useful ones are:
+# dom0_mem=256M (give domain-0 environment 256M ram)
+xen_opts=dom0_mem=256M
+
+# if you copy /usr/share/syslinux/reboot.c32 to /boot/, a menu entry
+# will be auto-generated for it
+
+# if you copy hdt.c32, libgpl.c32, and libmenu.c32 from /usr/share/syslinux/
+# to /boot/, a menu entry will be auto-generated for HDT
+
+# if you download and install /boot/memtest, then if HDT is present it
+# will use it, else a separate menu entry will be auto-generated for
+# memtest
+
+# optional password
+# you can generate a SHA512 password using: mkpasswd
+#
+# if you assign a password, you should make this file world-unreadable
+#
+# if a password is assigned, the menu entries can't be edited at boot
+# time, and HDT if present is password-protected
+#
+# you can also include "MENU PASSWD" in any custom entries you have in
+# /etc/update-extlinux.d/
+password=''