From 357481d9252549aa3762b44cf0bd0e42c9bac032 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 25 Oct 2013 12:33:57 +0000 Subject: testing/syslinux: test syslinux 6 --- testing/syslinux/APKBUILD | 65 ++++++++++ testing/syslinux/syslinux.post-upgrade | 61 ++++++++++ testing/syslinux/syslinux.trigger | 3 + testing/syslinux/update-extlinux | 212 +++++++++++++++++++++++++++++++++ testing/syslinux/update-extlinux.conf | 66 ++++++++++ 5 files changed, 407 insertions(+) create mode 100644 testing/syslinux/APKBUILD create mode 100644 testing/syslinux/syslinux.post-upgrade create mode 100644 testing/syslinux/syslinux.trigger create mode 100755 testing/syslinux/update-extlinux create mode 100644 testing/syslinux/update-extlinux.conf diff --git a/testing/syslinux/APKBUILD b/testing/syslinux/APKBUILD new file mode 100644 index 000000000..191ae4915 --- /dev/null +++ b/testing/syslinux/APKBUILD @@ -0,0 +1,65 @@ +# Maintainer: Natanael Copa +pkgname=syslinux +pkgver=6.02 +pkgrel=0 +_ver=${pkgver/_/-} +pkgdesc="Boot loader for the Linux operating system" +url="http://syslinux.org" +arch="x86 x86_64" +license="GPL" +makedepends="nasm perl util-linux-dev gnu-efi-dev" +depends="mtools blkid mkinitfs" +triggers="syslinux.trigger=/boot" +install="syslinux.post-upgrade" +options="textrels" +ldpath="/usr/share/syslinux" +#source="http://www.kernel.org/pub/linux/utils/boot/syslinux/${pkgver%%.*}.xx/$pkgname-$_ver.tar.bz2 +source="https://www.kernel.org/pub/linux/utils/boot/syslinux/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 + 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 +} + +md5sums="6f275813a1b08cf852e55c0a3f8fbc78 syslinux-6.02.tar.xz +603c7e3745c2cdded5332c7acb390fa0 update-extlinux.conf +89fb72c4dd47516402bc91a3cdf2b4d5 update-extlinux" +sha256sums="afa31b7cbf72e1c0c1752a0636ba724ce01c0e374366e46e61db6862b4685478 syslinux-6.02.tar.xz +99c8864958daf6f7bb2460082ceb809e0ce49aec3f0b847c7644565da14595e3 update-extlinux.conf +0dce3d534ab4288872c7654d7408d35896f508d486ad7d02cdaaf5fee37f6ae5 update-extlinux" +sha512sums="919d165e9cba2b964cec8b015f0a4281a5f90e908f247441d6edefe289170e697b933554d12fa90e698b6d2e8b5b40fdb3b7a95d746a41c580e3a44f8859818f syslinux-6.02.tar.xz +6e01a8c181812218eef38f183475d5b96079cbefe635b57b23cb2322fed552ff4d0c3e974a7defa7ea84b015659725b35aee247bc1ab9dc5903ffd124ae7ff25 update-extlinux.conf +848940244b9547c8d5d721b494cda199ea5785e306e8ac2124640f89ba7837d4a6e3a9a09fd2c5cd662d3ba66c5f81fcb1ec1f52fae9fade45b1ff10d7fc2b61 update-extlinux" diff --git a/testing/syslinux/syslinux.post-upgrade b/testing/syslinux/syslinux.post-upgrade new file mode 100644 index 000000000..90388668d --- /dev/null +++ b/testing/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/testing/syslinux/syslinux.trigger b/testing/syslinux/syslinux.trigger new file mode 100644 index 000000000..1e463cdda --- /dev/null +++ b/testing/syslinux/syslinux.trigger @@ -0,0 +1,3 @@ +#!/bin/sh + +update-extlinux diff --git a/testing/syslinux/update-extlinux b/testing/syslinux/update-extlinux new file mode 100755 index 000000000..26eb4c70b --- /dev/null +++ b/testing/syslinux/update-extlinux @@ -0,0 +1,212 @@ +#!/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 +} + +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 + eerror "Failed to detect root device" + exit 1 + 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 +echo "DEFAULT $syslinux_menu" >> $conf.new +echo "PROMPT 0" >> $conf.new +echo "MENU TITLE Alpine/$(uname -s) Boot Menu" >> $conf.new +if [ "$hidden" = "1" ]; then + echo "MENU HIDDEN" >> $conf.new +fi +echo "MENU AUTOBOOT Alpine 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 + tag=$(basename $kernel | cut -b9-) + everbose "Found kernel: $kernel" + label=$(grep -w -l $tag /usr/share/kernel/*/kernel.release | cut -d/ -f5) + if [ -z "$label" ]; then + label=$lst + 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;; +esac + diff --git a/testing/syslinux/update-extlinux.conf b/testing/syslinux/update-extlinux.conf new file mode 100644 index 000000000..a34d5a962 --- /dev/null +++ b/testing/syslinux/update-extlinux.conf @@ -0,0 +1,66 @@ +# 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=0 + +# default_kernel_opts +# default kernel options +default_kernel_opts=quiet + +# 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=1 + +# timeout +# number of seconds to wait before booting default +timeout=3 + +# default +# default kernel to boot +default=grsec + +# 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='' -- cgit v1.2.3