tags 587727 + patch
thanks

Am 11.01.2011 18:35, schrieb Daniel Baumann:
i was wrong, 'hd 1 2' would be equivalent to sdb2, 'hd 1 0' would be
the MBR of sdb. thanks Gene for pointing it out.

Please find a patch attached.

 - Fabian
From: Fabian Greffrath <[email protected]>
Date: Tue, 18 Jan 2011 10:11:49 +0100
Subject: [PATCH] Other operating systems which are detected by os-prober can be booted via chainloading

Restrict this to chainloadable OSes for the time being to avoid having to guess 
boot and root partitions of other Linux installations.
---
 debian/extlinux.README.Debian  |    4 ++
 debian/extlinux.install        |    1 
 debian/local/extlinux-update   |   79 +++++++++++++++++++++++++++++++++++++++++
 debian/local/extlinux-update.8 |    2 +
 4 files changed, 86 insertions(+)

--- a/debian/extlinux.README.Debian
+++ b/debian/extlinux.README.Debian
@@ -48,4 +48,8 @@ Notes:
   * any ISO (*.iso) or HDD (*.img) image stored in /boot/ can be booted through
     memdisk. In order to enable these, set EXTLINUX_MEMDISK=true in /etc/default/extlinux.
 
+  * other operating systems which are detected by os-prober can be booted via
+    chainloading. In order to enable this feature, install the os-prober package and
+    set EXTLINUX_OSPROBER=true in /etc/default/extlinux.
+
  -- Daniel Baumann <[email protected]>  Tue, 22 Jun 2010 02:56:04 +0200
--- a/debian/extlinux.install
+++ b/debian/extlinux.install
@@ -2,6 +2,7 @@ sbin/extlinux			/usr/sbin
 usr/man/man1/extlinux.1		/usr/share/man/man1
 usr/share/syslinux/mbr.bin	/usr/lib/extlinux
 usr/share/syslinux/memdisk	/usr/lib/extlinux
+usr/share/syslinux/chain.c32	/usr/lib/extlinux
 
 debian/local/zz-extlinux	/etc/kernel/postrm.d
 debian/local/zz-extlinux	/etc/kernel/postinst.d
--- a/debian/local/extlinux-update
+++ b/debian/local/extlinux-update
@@ -71,6 +71,7 @@ EXTLINUX_ALTERNATIVES="${EXTLINUX_ALTERN
 EXTLINUX_DEFAULT="${EXTLINUX_DEFAULT:-0}"
 EXTLINUX_ENTRIES="${EXTLINUX_ENTRIES:-all}"
 EXTLINUX_MEMDISK="${EXTLINUX_MEMDISK:-true}"
+EXTLINUX_OSPROBER="${EXTLINUX_OSPROBER:-true}"
 
 if [ -z "${EXTLINUX_MENU_LABEL}" ]
 then
@@ -125,6 +126,7 @@ EXTLINUX_ALTERNATIVES="${EXTLINUX_ALTERN
 EXTLINUX_DEFAULT="${EXTLINUX_DEFAULT}"
 EXTLINUX_ENTRIES="${EXTLINUX_ENTRIES}"
 EXTLINUX_MEMDISK="${EXTLINUX_MEMDISK}"
+EXTLINUX_OSPROBER="${EXTLINUX_OSPROBER}"
 EXTLINUX_MENU_LABEL="${EXTLINUX_MENU_LABEL}"
 EXTLINUX_PARAMETERS="${EXTLINUX_PARAMETERS}"
 EXTLINUX_ROOT="${EXTLINUX_ROOT}"
@@ -289,6 +291,75 @@ label m${_NUMBER}
 	Update "${_DIRECTORY}/memdisk.cfg" "${_CONFIG}"
 fi
 
+if [ "${EXTLINUX_OSPROBER}" = "true" ]
+then
+	if [ ! -e /usr/lib/extlinux/chain.c32 ]
+	then
+		echo "E: /usr/lib/extlinux/chain.c32: No such file"
+		exit 1
+	fi
+
+	cp -f /usr/lib/extlinux/chain.c32 "${_DIRECTORY}"
+
+# Create os-prober.cfg
+_CONFIG="\
+## ${_DIRECTORY}/os-prober.cfg
+##
+## IMPORTANT WARNING
+##
+## The configuration of this file is generated automatically.
+## Do not edit this file manually, use: extlinux-update
+
+
+"
+
+	if [ -n "$(which os-prober 2> /dev/null)" ]
+	then
+		_OSPROBED="$(os-prober | tr ' ' '^' | paste -s -d ' ')"
+	else
+		echo "E: Could not find os-prober!"
+		exit 1
+	fi
+
+	for _OS in ${_OSPROBED}
+	do
+		_DEVICE="$(echo ${_OS} | cut -d ':' -f 1)"
+		_LONGNAME="$(echo ${_OS} | cut -d ':' -f 2 | tr '^' ' ')"
+		_LABEL="$(echo ${_OS} | cut -d ':' -f 3 | tr '^' ' ')"
+		_BOOT="$(echo ${_OS} | cut -d ':' -f 4)"
+
+		if [ "${_BOOT}" != "chain" ]
+		then
+			continue
+		fi
+
+		if [ -z "${_LONGNAME}" ]
+		then
+			_LONGNAME="${_LABEL}"
+		fi
+
+		_NUMBER="${_NUMBER:-0}"
+
+		echo "P: Writing config for ${_LONGNAME} on ${_DEVICE}..."
+
+		_DEVICENAME="$(echo _DEVICE | sed -e 's/^\/dev\/[sh]d//' -e 'y/abcdefghij/0123456789/' -e 's/./& /')"
+
+		# Writing other os entry
+		_CONFIG="${_CONFIG}
+
+label o${_NUMBER}
+	menu label Other OS, ${_LONGNAME} (on ${_DEVICE})
+	kernel chain.c32
+	append hd${_DEVICENAME}"
+
+		_NUMBER="$((${_NUMBER} + 1))"
+	done
+
+	_NUMBER=""
+
+	Update "${_DIRECTORY}/os-prober.cfg" "${_CONFIG}"
+fi
+
 # Create the main extlinux.conf file
 _CONFIG="\
 ## ${_DIRECTORY}/extlinux.conf
@@ -346,6 +417,14 @@ include memdisk.cfg"
 
 	fi
 
+	if [ "${EXTLINUX_OSPROBER}" = "true" ] && [ -e "${_DIRECTORY}/os-prober.cfg" ]
+	then
+
+		_CONFIG="${_CONFIG}
+include os-prober.cfg"
+
+	fi
+
 	if [ ! -e "${_DIRECTORY}/boot.txt" ]
 	then
 		echo "Wait 5 seconds or press ENTER to " > "${_DIRECTORY}/boot.txt"
--- a/debian/local/extlinux-update.8
+++ b/debian/local/extlinux-update.8
@@ -20,6 +20,8 @@ This variable specifies the default entr
 This variables specifies how many kernel versions should be used to populate the boot configuration. Value is an integer starting with 1, or 'all' to populate for all kernels, default is 'all'.
 .IP "EXTLINUX_MEMDISK=""\fBtrue\fR|false""" 4
 This variable specifies if ISO (*.iso) and HDD (*.img) images in /boot should be added to the EXTLINUX configuration so that they can be booted through memdisk, default is 'true'.
+.IP "EXTLINUX_OSPROBER=""\fBtrue\fR|false""" 4
+This variable specifies if other operating systems detected by os-prober should be added to the EXTLINUX configuration so that they can be booted via chainloading, default is 'true'.
 .IP "EXTLINUX_MENU_LABEL=""\fBDebian GNU/Linux, kernel\fR""" 4
 This variable specifies the text that is used as a description in the boot menu. Value is an arbitrary string. If lsb_release is installed, the distributors id is automatically determined. If lsb_release is not available, it defaults to 'Debian GNU/Linux, kernel'.
 .IP "EXTLINUX_PARAMETERS=""\fBro quiet\fR""" 4

Reply via email to