summaryrefslogtreecommitdiffstats
path: root/config/binary_local-hooks
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2011-10-19 17:26:35 +0200
committerTails developers <amnesia@boum.org>2012-09-04 12:35:47 +0200
commit91ab49a4e9871dc30bdaa7955cce2730a457a488 (patch)
tree11f25136016a82132576e017b7efdcad3965f7ed /config/binary_local-hooks
parent6d514bc26fb249c2ff2ee2a6d134a1c06f43e540 (diff)
Replace syslinux menu with entries that autodetects the best kernel and boot it.
Diffstat (limited to 'config/binary_local-hooks')
-rwxr-xr-xconfig/binary_local-hooks/20-syslinux_detect_cpu87
1 files changed, 87 insertions, 0 deletions
diff --git a/config/binary_local-hooks/20-syslinux_detect_cpu b/config/binary_local-hooks/20-syslinux_detect_cpu
new file mode 100755
index 0000000..144281a
--- /dev/null
+++ b/config/binary_local-hooks/20-syslinux_detect_cpu
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# Including common functions
+. "${LB_BASE:-/usr/share/live/build}"/scripts/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'adding CPU autodetection to the syslinux menu')"
+HELP=""
+USAGE="${PROGRAM}"
+
+# Reading configuration files
+Read_conffiles config/all config/bootstrap config/common config/binary
+Set_defaults
+
+# Safeguards
+if [ "${LB_BOOTLOADER}" != "syslinux" ]
+then
+ exit 0
+fi
+if [ "${LB_ARCHITECTURE}" != "i386" ]
+then
+ exit 0
+fi
+
+# Seems like we'll have work to do
+Echo_message "adding CPU autodetection to the syslinux menu"
+
+# Setting boot method specific variables
+case "${LB_BINARY_IMAGES}" in
+ iso|iso-hybrid)
+ SYSLINUX_PATH="binary/isolinux"
+ SYSLINUX_CFG="${SYSLINUX_PATH}/isolinux.cfg"
+ ;;
+ usb-hdd)
+ SYSLINUX_PATH="binary/syslinux"
+ SYSLINUX_CFG="${SYSLINUX_PATH}/syslinux.cfg"
+ ;;
+esac
+
+# Setting variables
+SYSLINUX_LIVE_CFG="${SYSLINUX_PATH}/live.cfg"
+SYSLINUX_MENU_CFG="${SYSLINUX_PATH}/menu.cfg"
+
+# Copy necessary syslinux modules
+for module in ifcpu64.c32
+do
+ cp "/usr/lib/syslinux/${module}" "${SYSLINUX_PATH}/"
+done
+
+# Replace syslinux.cfg with autodetection "code"
+cat > "${SYSLINUX_CFG}" <<EOF
+label select_menu
+ com32 ifcpu64.c32
+ append menu_686-pae -- menu_686-pae -- menu_486
+label menu_686-pae
+ kernel vesamenu.c32
+ append live686.cfg
+label menu_486
+ kernel vesamenu.c32
+ append live486.cfg
+default select_menu
+prompt 0
+EOF
+
+# Set a few variables in menu.cfg as loading vesamenu.c32 resets its
+# state to the defaults
+sed -i -e "1i prompt 0\ntimeout 40\n" "${SYSLINUX_MENU_CFG}"
+
+# Copy and adapt live.cfg for each kernel
+for arch in 486 686
+do
+ (
+ echo "include menu.cfg"
+
+ if [ $arch = 486 ]; then
+ append=""
+ else
+ append=2
+ fi
+ sed -e "s,/vmlinuz$,/vmlinuz${append}, ; s,initrd\.img,initrd${append}.img," "${SYSLINUX_LIVE_CFG}"
+ ) | sed -n -e '/^label live-686-pae.*/ { q } ; p' \
+ > "${SYSLINUX_PATH}/live${arch}.cfg"
+done
+
+# Don't load live.cfg from menu.cfg:
+# syslinux_cfg automatically loads arch-specific menus
+sed -i -e '/^include live\.cfg/d' "${SYSLINUX_MENU_CFG}"