aboutsummaryrefslogtreecommitdiffstats
path: root/main/syslinux/update-extlinux
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-08-03 16:49:48 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-08-03 19:28:23 +0000
commitb0740647731bf96a401540e02ce54753da77057f (patch)
treeba378968f65997bdf0141fee861edf9006e8f206 /main/syslinux/update-extlinux
parentc504465e61a866c92c41e38ccc888d58abc73d09 (diff)
downloadaports-b0740647731bf96a401540e02ce54753da77057f.tar.bz2
aports-b0740647731bf96a401540e02ce54753da77057f.tar.xz
main/syslinux: misc update-extlinux fixes
- rename /etc/extlinux-conf to /etc/update-extlinux.conf - Do not exit with fail if update-extlinux.conf is missing - Always warn if root= is not defined in update-extlinux.conf - Try harder to detect the root device by parsing /proc/mounts - Exit with error if we cannot detect the Root device - Rename fancy_menu to vesa_menu - Unifiy the code generating vesa/standard menus - Keep a backup of old extlinux.conf - add "overwrite" config option so it is possible to skip overwriting the extlinux.conf. - Added a post-upgrade that imports current extlinux.conf to update-extlinux.conf
Diffstat (limited to 'main/syslinux/update-extlinux')
-rwxr-xr-xmain/syslinux/update-extlinux118
1 files changed, 82 insertions, 36 deletions
diff --git a/main/syslinux/update-extlinux b/main/syslinux/update-extlinux
index 25585334be..a2488cc8df 100755
--- a/main/syslinux/update-extlinux
+++ b/main/syslinux/update-extlinux
@@ -4,8 +4,13 @@ default=0
timeout=5
verbose=0
+conf=/boot/extlinux.conf
+myconf=/etc/update-extlinux.conf
+
# read in extlinux settings
-source /etc/extlinux.conf
+if [ -f "$myconf" ]; then
+ . $myconf
+fi
everbose() {
if [ "$verbose" = "0" ]; then
@@ -15,14 +20,44 @@ everbose() {
echo $*
}
+ewarn() {
+ echo "WARNING:" $@ >&2
+}
+
+eerror() {
+ echo "ERROR:" $@ >&2
+ return 1
+}
+
everbose "Updating extlinux configuration."
if [ "x$root" = "x" ]; then
- everbose "WARNING: Root device not specified, determining automatically."
- everbose -n "Root device is: "
- export `blkid -o export /dev/root`
- root=UUID=$UUID
- everbose $root
+ 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
everbose "Installing mboot.c32 to /boot."
@@ -32,29 +67,26 @@ everbose "Installing menu.c32 to /boot."
cp /usr/share/syslinux/menu.c32 /boot
rtimeout=$((${timeout}\*10))
+syslinux_menu=menu.c32
+menu_hidden=
+
# vesa menu has been requested?
-if [ "$fancy_menu" = "1" ]; then
- everbose "Installing vesamenu.c32 to /boot."
- cp /usr/share/syslinux/vesamenu.c32 /boot
-
- echo "DEFAULT vesamenu.c32" > /boot/extlinux.conf.new
- echo "PROMPT 0" >> /boot/extlinux.conf.new
- echo "MENU TITLE Alpine/$(uname -s) Boot Menu" >> /boot/extlinux.conf.new
- if [ "$hidden" = "1" ]; then
- echo "MENU HIDDEN" >> /boot/extlinux.conf.new
- fi
- echo "MENU AUTOBOOT Alpine will be booted automatically in # seconds." >> /boot/extlinux.conf.new
- echo "TIMEOUT $rtimeout" >> /boot/extlinux.conf.new
-else
- echo "DEFAULT menu.c32" > /boot/extlinux.conf.new
- echo "PROMPT 0" >> /boot/extlinux.conf.new
- echo "MENU TITLE Alpine/$(uname -s) Boot Menu" >> /boot/extlinux.conf.new
- if [ "$hidden" = "1" ]; then
- echo "MENU HIDDEN" >> /boot/extlinux.conf.new
- fi
- echo "MENU AUTOBOOT Alpine will be booted automatically in # seconds." >> /boot/extlinux.conf.new
- echo "TIMEOUT $rtimeout" >> /boot/extlinux.conf.new
+if [ "$vesa_menu" = "1" ]; then
+ syslinux_menu=vesamenu.c32
+fi
+
+everbose "Installing $syslinux_menu to /boot."
+cp /usr/share/syslinux/vesamenu.c32 /boot
+
+echo "# Generated by update-extlinux" > $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
for kernel in $(find /boot -name vmlinuz-* -type f); do
@@ -66,24 +98,38 @@ for kernel in $(find /boot -name vmlinuz-* -type f); do
initramfs="initrd=initramfs-$tag"
fi
- echo "LABEL $lst" >> /boot/extlinux.conf.new
+ echo "LABEL $lst" >> $conf.new
if [ "$lst" = "$default" ]; then
- echo " MENU DEFAULT" >> /boot/extlinux.conf.new
+ echo " MENU DEFAULT" >> $conf.new
fi
- echo " MENU LABEL Linux $tag" >> /boot/extlinux.conf.new
- echo " KERNEL $(basename $kernel)" >> /boot/extlinux.conf.new
- echo " APPEND $initramfs root=$root modules=$modules,$TYPE $default_kernel_opts" >> /boot/extlinux.conf.new
+ echo " MENU LABEL Linux $tag" >> $conf.new
+ echo " KERNEL $(basename $kernel)" >> $conf.new
+ echo " APPEND $initramfs root=$root modules=${modules}${TYPE:+,$TYPE} $default_kernel_opts" >> $conf.new
+ echo "" >> $conf.new
lst=$(($lst + 1))
done
if [ -f "/boot/memtest" ]; then
everbose "Found memtest86+: /boot/memtest"
- echo "LABEL $lst" >> /boot/extlinux.conf.new
- echo " MENU LABEL Memtest86+" >> /boot/extlinux.conf.new
- echo " KERNEL memtest" >> /boot/extlinux.conf.new
+ echo "LABEL $lst" >> $conf.new
+ echo " MENU LABEL Memtest86+" >> $conf.new
+ echo " KERNEL memtest" >> $conf.new
+ echo "" >> $conf.new
lst=$(($lst + 1))
fi
everbose "$lst entries found."
-mv /boot/extlinux.conf.new /boot/extlinux.conf
+for entry in /etc/update-extlinux.d/*; do
+ [ -f "$entry" ] && cat $entry >> $conf.new
+done
+
+if [ "$overwrite" = "1" ]; then
+ # keep a backup just in case
+ if [ -f "$conf" ]; then
+ mv $conf $conf.old
+ fi
+
+ mv $conf.new $conf
+fi
+