+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 12_uuid_support.dpatch by Michael Prokop <prokop@grml-forensic.org>
+##
+## DP: This patch enables support for verifying the ISO through bootid=.... bootoption.
+## DP: Logic behind bootoptions and possible combinations:
+## DP: * bootid.txt + wrong bootid=... => fails to boot
+## DP: * bootid.txt + right bootid=... => boots
+## DP: * bootid.txt + ignore_bootid => boots
+## DP: * bootid.txt + no bootid=... + no ignore_bootid => fails to boot
+## DP: * no bootid.txt + no bootid=... + no ignore_bootid => boots
+## DP: * no bootid.txt + bootid=... => fails to boot
+## DP: * no bootid.txt + ignore_bootid=... => boots
+
+@DPATCH@
+diff --git a/scripts/live b/scripts/live
+index abce3cd..851796c 100755
+--- a/scripts/live
++++ b/scripts/live
+@@ -63,6 +63,11 @@ Arguments ()
+ export ACCESS
+ ;;
+
++ bootid=*)
++ BOOTID="${ARGUMENT#bootid=}"
++ export BOOTID
++ ;;
++
+ console=*)
+ DEFCONSOLE="${ARGUMENT#*=}"
+ export DEFCONSOLE
+@@ -140,6 +145,11 @@ Arguments ()
+ export FROMISO
+ ;;
+
++ ignore_bootid)
++ IGNORE_BOOTID="Yes"
++ export IGNORE_BOOTID
++ ;;
++
+ ignore_uuid)
+ IGNORE_UUID="Yes"
+ export IGNORE_UUID
+@@ -392,6 +402,42 @@ is_live_path ()
+ return 1
+ }
+
++grml_match_bootid()
++{
++ path="$1"
++
++ if [ -n "$IGNORE_BOOTID" ] ; then
++ echo " * Ignoring verification of bootid.txt as requested via ignore_bootid.">>/live.log
++ return 0
++ fi
++
++ if [ -n "$BOOTID" ] && ! [ -r "${path}/conf/bootid.txt" ] ; then
++ echo " * Warning: bootid=... specified but no bootid.txt found on currently requested device.">>/live.log
++ return 1
++ fi
++
++ [ -r "${path}/conf/bootid.txt" ] || return 0
++
++ bootid_conf=$(cat "${path}/conf/bootid.txt")
++
++ if [ -z "$BOOTID" -a -z "$IGNORE_BOOTID" ]
++ then
++ echo " * Warning: bootid.txt found but ignore_bootid / bootid=.. bootoption missing...">>/live.log
++ return 1
++ fi
++
++ if [ "$BOOTID" = "$bootid_conf" ]
++ then
++ echo " * Successfully verified /conf/bootid.txt from ISO, continuing... ">>/live.log
++ else
++ echo " * Warning: BOOTID of ISO does not match. Retrying and continuing search...">>/live.log
++ return 1
++ fi
++
++ return 0
++}
++
++
+ matches_uuid ()
+ {
+ if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
+@@ -1550,7 +1596,7 @@ check_dev ()
+ fi
+
+ if is_live_path ${mountpoint} && \
+- ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
++ ([ "${skip_uuid_check}" ] || grml_match_bootid ${mountpoint})
+ then
+ echo ${mountpoint}
+ return 0
+@@ -1665,19 +1711,6 @@ find_livefs ()
+ return 0
+ fi
+ done
+- elif [ "${fstype}" = "squashfs" -o \
+- "${fstype}" = "btrfs" -o \
+- "${fstype}" = "ext2" -o \
+- "${fstype}" = "ext3" -o \
+- "${fstype}" = "ext4" -o \
+- "${fstype}" = "jffs2" ]
+- then
+- # This is an ugly hack situation, the block device has
+- # an image directly on it. It's hopefully
+- # live-boot, so take it and run with it.
+- ln -s "${devname}" "${devname}.${fstype}"
+- echo "${devname}.${fstype}"
+- return 0
+ fi
+ done
+