[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#700920: Immediately detect medium from live-media parameter



Daniel Baumann <daniel.baumann@progress-technologies.net> writes:

> On 02/19/2013 11:19 AM, Gaudenz Steinlin wrote:
>> The attached patch implements a solution to both of these issues.
>
> can you split it in two patches please?

OK. See attached patches. 

Gaudenz

>From 8b6eb6772526e2a9ab1b944132e8887cd2b2761a Mon Sep 17 00:00:00 2001
From: Gaudenz Steinlin <gaudenz@debian.org>
Date: Thu, 17 Jan 2013 16:45:27 +0100
Subject: [PATCH 1/2] Immediately detect medium from live-media parameter

If a preferred medium (device or medium type) is given with the
live-media parameter then waiting for the timeout to expire before
scaning for these devices is not necessary. Just pick the device as soon
as it appears. If a criterium would match several devices the outcome is
undefined anyway. So choosing the first one is good enough.
---
 scripts/boot/9990-misc-helpers.sh |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/scripts/boot/9990-misc-helpers.sh b/scripts/boot/9990-misc-helpers.sh
index 888eeaf..2813ac0 100755
--- a/scripts/boot/9990-misc-helpers.sh
+++ b/scripts/boot/9990-misc-helpers.sh
@@ -259,16 +259,10 @@ find_livefs ()
 {
 	timeout="${1}"
 
-	# don't start autodetection before timeout has expired
-	if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
-	then
-		if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
-		then
-			return 1
-		fi
-	fi
-
-	# first look at the one specified in the command line
+	# first look at the one specified in the command line This is OK
+	# before the timeout has expired, if more than one device matches the
+	# criteria the outcome is undefined anyway, so we can pick the first
+	# one that appears.
 	case "${LIVE_MEDIA}" in
 		removable-usb)
 			for sysblock in $(removable_usb_dev "sys")
@@ -309,7 +303,16 @@ find_livefs ()
 			;;
 	esac
 
-	# or do the scan of block devices
+	# don't start autodetection before timeout has expired
+	if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
+	then
+		if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
+		then
+			return 1
+		fi
+	fi
+
+	# autodetection of live media
 	# prefer removable devices over non-removable devices, so scan them first
 	devices_to_scan="$(removable_dev 'sys') $(non_removable_dev 'sys')"
 
-- 
1.7.10.4

>From 1b7d2426f39309bacd282768ef7a6d8bddd9a961 Mon Sep 17 00:00:00 2001
From: Gaudenz Steinlin <gaudenz@debian.org>
Date: Tue, 19 Feb 2013 11:50:19 +0100
Subject: [PATCH 2/2] Use any medium if preferred medium type is not found

Use any available live medium if the preferred medium type given with
the live-media parameter is not found. This aligns the behavior of the
"removeable" and "removeable-usb" values with the behavior already
present when specifying a device path.

This makes it possible to have a non-wirteable (ISO) live-image with the
default boot parameter set to live-media=removable-usb for machines that
can't boot directly from USB devices. If a live medium on an USB device
is present it'll be preferred, but the ISO will also boot without an USB
device.
---
 scripts/boot/9990-misc-helpers.sh |    2 --
 1 file changed, 2 deletions(-)

diff --git a/scripts/boot/9990-misc-helpers.sh b/scripts/boot/9990-misc-helpers.sh
index 2813ac0..1341972 100755
--- a/scripts/boot/9990-misc-helpers.sh
+++ b/scripts/boot/9990-misc-helpers.sh
@@ -275,7 +275,6 @@ find_livefs ()
 					fi
 				done
 			done
-			return 1
 			;;
 
 		removable)
@@ -289,7 +288,6 @@ find_livefs ()
 					fi
 				done
 			done
-			return 1
 			;;
 
 		*)
-- 
1.7.10.4

-- 
Ever tried. Ever failed. No matter.
Try again. Fail again. Fail better.
~ Samuel Beckett ~

Reply to: