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

Bug#343495: localechooser: Proposed patch to fix the "full language list is displayed when run twice" bug



Today, I worked on a patch to avoid showing the full language list
when localechooser is run twice.

It uses a dedicated debconf value which is set to "true" as soon as
localechooser has be run once. This allows the dedicated code, at the
beginning of the script, that handles with preseeded
debian-installer/locale value, to be run only when localechooser is
executed for the very first time.

I attach this patch for comments as I don't want to commit it right
now, because I prefer building 0.27 which will indluce Kazakh support.


-- 


diff -Nru localechooser.old/debian/localechooser.templates-in localechooser/debian/localechooser.templates-in
--- localechooser.old/debian/localechooser.templates-in	2005-12-23 18:13:29.468684878 +0100
+++ localechooser/debian/localechooser.templates-in	2005-12-23 16:02:42.411164629 +0100
@@ -111,6 +111,10 @@
 Type: string
 Description: Internal use
 
+Template: localechooser/alreadyrun
+Type: boolean
+Description: Internal use
+
 Template: debian-installer/invalidlocale
 Type: note
 _Description: Unsupported locale
diff -Nru localechooser.old/localechooser localechooser/localechooser
--- localechooser.old/localechooser	2005-12-23 18:13:29.867617118 +0100
+++ localechooser/localechooser	2005-12-23 18:26:40.502297148 +0100
@@ -137,47 +137,59 @@
 fi
 
 # Support preseeding of the locale all in one variable for convenience.
-db_get $localecode
-if [ "$RET" ] ; then
-	LOCALE="$RET"
-	log "Locale has been preseeded to $LOCALE"
-
-	# Only mark variables seen if this one was preseeded seen.
-	db_fget $localecode seen
-	seenflag=$RET
+
+# The localechooser/alreadyrun variable will keep track 
+# of whether the locale was preseeded
+# We NEVER initialize it, so it is empty ONLY at the first run of localechooser
+# then it is set to either True or False
+db_get localechooser/alreadyrun || true
+if [ -z "$RET" ]; then
+	db_get $localecode
+	if [ "$RET" ] ; then
+		LOCALE="$RET"
+		log "Locale has been preseeded to $LOCALE"
+
+		# Only mark variables seen if this one was preseeded seen.
+		db_fget $localecode seen
+		seenflag=$RET
 	
-	# Only populate debconf if this is a supported locale
-	# and if the language is supported in D-I
-	LANGUAGE=$(locale2langcode "$LOCALE")
-	LANGNAME=$(locale2langname "$LOCALE" "$LANGUAGELISTFILE")
-	if [ -n "$LANGNAME" ] ; then
-		db_set ${langname_all} $LANGNAME
-		log "Set ${langname_all} = '$LANGNAME'"
-		db_fset ${langname_all} seen $seenflag || true
-		COUNTRY=$(locale2countrycode "$LOCALE")
-		if [ -n "$COUNTRY" ] ; then
-			if grep -q "$LANGUAGE" $SHORTLISTS ; then
-				db_set $shortlist-$LANGUAGE "$COUNTRY"
-				log "Set $shortlist-$LANGUAGE = '$COUNTRY'"
-				db_register $shortlist-$LANGUAGE $shortlist
-				db_fset $shortlist seen $seenflag || true
-			fi
-			db_fset $fulllist seen $seenflag || true
-			if grep -q "$LOCALE" $SUPPORTEDLOCALES ; then
-				db_set $localecode $LOCALE
-				db_fset $localecode seen $seenflag || true
-				log "Set $localecode = '$LOCALE'"
+		# Only populate debconf if this is a supported locale
+		# and if the language is supported in D-I
+		LANGUAGE=$(locale2langcode "$LOCALE")
+		LANGNAME=$(locale2langname "$LOCALE" "$LANGUAGELISTFILE")
+		if [ -n "$LANGNAME" ] ; then
+			db_set ${langname_all} $LANGNAME
+			log "Set ${langname_all} = '$LANGNAME'"
+			db_fset ${langname_all} seen $seenflag || true
+			COUNTRY=$(locale2countrycode "$LOCALE")
+			if [ -n "$COUNTRY" ] ; then
+				if grep -q "$LANGUAGE" $SHORTLISTS ; then
+					db_set $shortlist-$LANGUAGE "$COUNTRY"
+					log "Set $shortlist-$LANGUAGE = '$COUNTRY'"
+					db_register $shortlist-$LANGUAGE $shortlist
+					db_fset $shortlist seen $seenflag || true
+				fi
+				db_fset $fulllist seen $seenflag || true
+				if grep -q "$LOCALE" $SUPPORTEDLOCALES ; then
+					db_set $localecode $LOCALE
+					db_fset $localecode seen $seenflag || true
+					log "Set $localecode = '$LOCALE'"
+				else
+					# The locale was invalid, empty it
+					LOCALE=""
+				fi
 			else
 				# The locale was invalid, empty it
 				LOCALE=""
 			fi
-		else
-			# The locale was invalid, empty it
-			LOCALE=""
 		fi
 	fi
 fi
 
+# Record that we don't want to handle the debian-installer/locale
+# one more time
+db_set localechooser/alreadyrun "true"
+
 # Find the display level
 #
 # No framebuffer and text interface      -->level 0 (only ASCII)

Reply to: