Package: live-boot
Version: 1:20160511
Severity: normal

If a preferred medium (device or medium type) is given with the
live-media parameter then waiting for the timeout to expire before
scanning for these devices is not necessary. Just pick the device as soon
as it appears. If a criterion would match several devices the outcome is
undefined anyway. So choosing the first one is good enough.

The attached patch fixes this issue.

-- Package-specific info:

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_CH.UTF-8, LC_CTYPE=de_CH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages live-boot depends on:
ii  live-boot-initramfs-tools [live-boot-backend]  1:20160511

Versions of packages live-boot recommends:
ii  live-boot-doc  1:20160511
ii  live-tools     1:20151214+nmu1
ii  rsync          3.1.2-1
ii  uuid-runtime   2.28.2-1

Versions of packages live-boot suggests:
ii  cryptsetup  2:1.7.2-5
pn  curlftpfs   <none>
pn  httpfs2     <none>
ii  wget        1.18-4

-- no debconf information

From 2fcda59eb298d5e2009569f8e9410ccd4ab9b3d7 Mon Sep 17 00:00:00 2001
From: Ronny Standtke <ronny.stand...@gmx.net>
Date: Sun, 13 Nov 2016 15:17:11 +0100
Subject: [PATCH 1/1] 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
scanning for these devices is not necessary. Just pick the device as soon
as it appears. If a criterion would match several devices the outcome is
undefined anyway. So choosing the first one is good enough.
---
 components/9990-misc-helpers.sh | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/components/9990-misc-helpers.sh b/components/9990-misc-helpers.sh
index 1a06ccf..fed9850 100755
--- a/components/9990-misc-helpers.sh
+++ b/components/9990-misc-helpers.sh
@@ -235,16 +235,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")
@@ -257,7 +251,6 @@ find_livefs ()
 					fi
 				done
 			done
-			return 1
 			;;
 
 		removable)
@@ -271,7 +264,6 @@ find_livefs ()
 					fi
 				done
 			done
-			return 1
 			;;
 
 		*)
@@ -285,7 +277,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')"
 
-- 
2.9.3

Reply via email to