[SCM] live-boot branch, debian-next, updated. debian/3.0_a26-1-33-g447d3ef

Tails developers amnesia at boum.org
Wed May 9 14:02:25 UTC 2012


The following commit has been merged in the debian-next branch:
commit 447d3ef74a396bf078a9d724de4e5ea138afa7b7
Author: Tails developers <amnesia at boum.org>
Date:   Wed May 9 12:55:03 2012 +0200

    Implement and make use of robust list functions.

diff --git a/scripts/live b/scripts/live
index 9d699b7..a6da175 100755
--- a/scripts/live
+++ b/scripts/live
@@ -1001,12 +1001,12 @@ setup_unionfs ()
 				;;
 		esac
 
-		if echo ${PERSISTENCE_METHOD} | grep -qe "\<overlay\>"
+		if is_in_comma_sep_list overlay ${PERSISTENCE_METHOD}
 		then
 			overlays="${old_root_overlay_label} ${old_home_overlay_label} ${custom_overlay_label}"
 		fi
 
-		if echo ${PERSISTENCE_METHOD} | grep -qe "\<snapshot\>"
+		if is_in_comma_sep_list snapshot ${PERSISTENCE_METHOD}
 		then
 			snapshots="${root_snapshot_label} ${home_snapshot_label}"
 		fi
diff --git a/scripts/live-helpers b/scripts/live-helpers
index 1414156..2fcf441 100644
--- a/scripts/live-helpers
+++ b/scripts/live-helpers
@@ -388,7 +388,7 @@ Arguments ()
 	then
 		PERSISTENCE_ENCRYPTION="none"
 		export PERSISTENCE_ENCRYPTION
-	elif echo ${PERSISTENCE_ENCRYPTION} | grep -qe "\<luks\>"
+	elif is_in_comma_sep_list luks ${PERSISTENCE_ENCRYPTION}
 	then
 		if ! modprobe dm-crypt
 		then
@@ -418,6 +418,27 @@ Arguments ()
 	fi
 }
 
+is_in_list_separator_helper () {
+	local sep=${1}
+	shift
+	local element=${1}
+	shift
+	local list=${*}
+	echo ${list} | grep -qe "^\(.*${sep}\)\?${element}\(${sep}.*\)\?$"
+}
+
+is_in_space_sep_list () {
+	local element=${1}
+	shift
+	is_in_list_separator_helper "[[:space:]]" "${element}" "${*}"
+}
+
+is_in_comma_sep_list () {
+	local element=${1}
+	shift
+	is_in_list_separator_helper "," "${element}" "${*}"
+}
+
 sys2dev ()
 {
 	sysdev=${1#/sys}
@@ -449,9 +470,9 @@ storage_devices()
 	do
 		fulldevname=$(sys2dev "${sysblock}")
 
-		if echo "${black_listed_devices}" | grep -qe "\<${fulldevname}\>" || \
+		if is_in_space_sep_list ${fulldevname} ${black_listed_devices} || \
 			[ -n "${white_listed_devices}" ] && \
-			echo "${white_listed_devices}" | grep -qve "\<${fulldevname}\>"
+			! is_in_space_sep_list ${fulldevname} ${white_listed_devices}
 		then
 			# skip this device entirely
 			continue
@@ -461,7 +482,7 @@ storage_devices()
 		do
 			devname=$(sys2dev "${dev}")
 
-			if echo "${black_listed_devices}" | grep -qe "\<${devname}\>"
+			if is_in_space_sep_list ${devname} ${black_listed_devices}
 			then
 				# skip this subdevice
 				continue
@@ -984,7 +1005,7 @@ find_persistence_media ()
 		# in order to probe any filesystem it contains, like we do
 		# below. activate_custom_mounts() also depends on that any luks
 		# device already has been opened.
-		if echo ${PERSISTENCE_ENCRYPTION} | grep -qe "\<luks\>" && \
+		if is_in_comma_sep_list luks ${PERSISTENCE_ENCRYPTION} && \
 		   is_luks_partition ${dev}
 		then
 			if luks_device=$(open_luks_device "${dev}")
@@ -994,14 +1015,14 @@ find_persistence_media ()
 				# skip $dev since we failed/chose not to open it
 				continue
 			fi
-		elif echo ${PERSISTENCE_ENCRYPTION} | grep -qve "\<none\>"
+		elif ! is_in_comma_sep_list none ${PERSISTENCE_ENCRYPTION}
 		then
 			# skip $dev since we don't allow unencrypted storage
 			continue
 		fi
 
 		# Probe for matching GPT partition names or filesystem labels
-		if echo ${PERSISTENCE_STORAGE} | grep -qe "\<filesystem\>"
+		if is_in_comma_sep_list filesystem ${PERSISTENCE_STORAGE}
 		then
 			result=$(probe_for_gpt_name "${overlays}" "${snapshots}" ${dev})
 			if [ -n "${result}" ]
@@ -1019,7 +1040,7 @@ find_persistence_media ()
 		fi
 
 		# Probe for files with matching name on mounted partition
-		if echo ${PERSISTENCE_STORAGE} | grep -qe "\<file\>"
+		if is_in_comma_sep_list file ${PERSISTENCE_STORAGE}
 		then
 			result=$(probe_for_file_name "${overlays}" "${snapshots}" ${dev})
 			if [ -n "${result}" ]

-- 
live-boot



More information about the debian-live-changes mailing list