[arch-releng] [PATCH] allow changing labels of existing filesystems

Matthias Dienstbier matthias_dienstbier at yahoo.de
Fri Apr 29 10:05:31 EDT 2011


---
 src/core/libs/lib-blockdevices-filesystems.sh |    1 +
 src/core/libs/lib-ui-interactive.sh           |   26 +++++++++++++++++-------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 13160c9..5bf554b 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -830,6 +830,7 @@ process_filesystem ()
 		sleep 2
 	fi
 
+	# Labeling is an extra step because we allow this to be done on existing filesystems
 	if [ -n "$fs_label" ] && check_is_in $fs_type "${!label_programs[@]}"
 	then
 		program="${label_programs[$fs_type]}"
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 1600cef..22d44a3 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -441,15 +441,25 @@ interactive_filesystem ()
 		fi
 
 		# ask label, if relevant
-		if [ "$fs_create" == yes ] && check_is_in "$fs_type" "${fs_label_mandatory[@]}"
+		if check_is_in "$fs_type" "${fs_label_mandatory[@]}" "${fs_label_optional[@]}"
 		then
-			default="$fs_label" # can be empty
-			ask_string "Enter the label/name for this $fs_type on $part (Mandatory for this type of FS!)" "$default" || return 1 #TODO: check that you can't give LV's labels that have been given already or the installer will break.
-			fs_label=$ANSWER_STRING
-		elif [ "$fs_create" == yes ] && check_is_in "$fs_type" "${fs_label_optional[@]}"
-		then
-			default="$fs_label" # can be empty
-			ask_string "Enter the label for this $fs_type on $part (optional) [keep it short and don't use spaces]" "$default" 0
+			if [ -n "$fs_label" ]
+			then
+				default="$fs_label"
+			else
+				default="$(getlabel $part)"
+			fi
+			if [ "$fs_create" == yes ]
+			then
+				local string="Enter the label/name for this $fs_type on $part"
+			else
+				local string="You can change the label/name for this $fs_type on $part"
+			fi
+			if check_is_in "$fs_type" "${fs_label_mandatory[@]}"
+				ask_string "$string (Label/Name is mandatory for this type of FS!) [keep it short and don't use spaces]" "$default" || return 1 #TODO: check that you can't give labels that have been given already or the installer will break.
+			else
+				ask_string "$string (Label is optional) [keep it short and don't use spaces]" "$default" 0
+			fi
 			fs_label=${ANSWER_STRING// } # strip spaces to prevent problems in our bash code and to keep things simple.
 		fi
 
-- 
1.7.5



More information about the arch-releng mailing list