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

Bug#497110: boot loader installation failed when dmraid=true



On Thursday 04 September 2008, Frans Pop wrote:
> - partman does not build the fields correctly when the first (valid)
>   option is a divider

Right. This problem is in partman-base/lib/base.sh in debconf_select().
This has:
    descriptions="${descriptions:+${descriptions}, }$(
        echo "${x#*$TAB}" |
        sed "s/ *\$//g; s/^ /$debconf_select_lead/g; s/,/\\\\,/g; s/^ /\\\\ /")"

If the first field is a separator, 'descriptions' will remain empty and
thus, when the next field is processed, no leading comma is added.

One question regarding this code: why is the "$" in 's/ *\$//g' escaped?
AFAICT this is not necessary. Jérémy?


As it does not really make sense to have a divider as a first field anyway,
the following patch for debconf_select() could solve this issue.

@@ -125,13 +125,19 @@
 	descriptions=""
 	IFS="$NL"
 	for x in $choices; do
-		local key plugin
+		local key description plugin
 		restore_ifs
 		key="${x%$TAB*}"
+		description="$(echo "${x#*$TAB}" | sed "s/ *\$//g")"
+		# Skip dividers (empty description) if they are the first field
+		if [ -z "$descriptions" ] && [ -z "$description" ]; then
+			continue
+		fi
+
 		keys="${keys:+${keys}, }$key"
 		descriptions="${descriptions:+${descriptions}, }$(
-			echo "${x#*$TAB}" |
-			sed "s/ *\$//g; s/^ /$debconf_select_lead/g; s/,/\\\\,/g; s/^ /\\\\ /")"
+			echo "$description" |
+			sed "s/^ /$debconf_select_lead/g; s/,/\\\\,/g; s/^ /\\\\ /")"
 
 		# If the question was asked via ask_user, this allow preseeding
 		# by using the name of the plugin responsible for the answer.

The same could possibly also, or maybe even better, be done in ask_user()
instead, using the following patch:

@@ -172,12 +178,21 @@
 		default=""
 	fi
 	choices=$(
+		local first=1
 		for plugin in $dir/*; do
 			[ -d $plugin ] || continue
 			name=$(basename $plugin)
 			IFS="$NL"
 			for option in $($plugin/choices "$@"); do
-				printf "%s__________%s\n" $name "$option"
+				if [ "$first" ] && \
+				   echo "$option" | grep -q "$TAB *$"; then
+					# Skip dividers (empty description)
+					# if they are the first option
+					continue
+				else
+					printf "%s__________%s\n" $name "$option"
+					first=
+				fi
 			done
 			restore_ifs
 		done

The second patch is probably "cheaper" in execution and has the logic as
early as possible.
This second patch could even be changed to test for "divider" in the name,
but I think I prefer to test the actual description.

I've tested both alternatives and both seem to work fine.

Note: the problem can be easily reproduced by adding adding an 'exit 0'
early in /lib/partman/active_partition/15method/choices and then selecting
a "normal" partition from the main partman dialog.

Giuseppe: if you want to work around this bug to test dmraid support, you
can do so by changing /lib/partman/active_partition/25divider/choices
before you start partman: just make that script 'exit 0'.
This would allow you to provide further details on the "p" in created
dmraid devices and confirm Jérémy's conclusion that it is a libparted issue.

Cheers,
FJP

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: