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

Bug#503189: tzsetup: Preseeding timezone doesn't work as described



On Thursday 23 October 2008, Durk Strooisma wrote:
> I noticed that somewhere between lenny beta 2 and the latest daily
> builds there's a difference in how you effectivily preseed the
> timezone.

There have not been any changes in tzsetup and the changes in 
localechooser also do not explain this. I'm fairly sure that the correct 
explanation is a change in cdebconf (0.132):
  * Handle the special case of a noninteractive select with no (or a bad)
    default the same as debconf does; when such a question is asked,
    set the value to the first item in the select list.

> In lenny beta 2, these lines were sufficient to set the timezone to
> Europe/Amsterdam while having the locale set to en_US:
>
> d-i debian-installer/locale string en_US
> d-i time/zone string Europe/Amsterdam
>
> Unlike the latest D-I manual states, this doesn't work in the latest
> daily builds anymore. The timezone will be forced to US/Eastern. To
> figure this out, I ran a manual (expert) installation and noticed that
> the timezone choices are based on the locale settings.

What you are doing here is essentially invalid for interactive 
installations, and thus also for preseeded installations: you are 
selecting English as language and US as country, and then trying to set 
the time zone for NL, which is of course an invalid time zone for the US.

And that is exactly what the change in cdebconf does: it will ignore an 
invalid default and instead select the first value in the list.

> I tried to add:
> d-i localechooser/shortlist select other
> d-i localechooser/continentlist select Europe
> d-i localechooser/countrylist/Europe select NL

That will not work as it does not match what is documented for language 
and country preseeding [1]. You need d-i/locale=en_NL as Christian 
already explained. That will automatically give you the Dutch time zone 
(and you don't even need to preseed it at all!).

> In a discussion on the debian-boot mailinglist, Christian Perrier
> proposed[1] to try changing the locale from "en_US" to "en_NL". This
> actually works! Unlike you would expect, but desired however, the
> locale on the target system will be en_US.UTF-8.

No, that's *exactly* what you'd expect.

> So, if this is the way we should preseed the timezone from now on, the
> D-I manual must be changed to reflect this.

No change needed as basically you should always have done it like this. 
The fact that in the past an invalid timezone was accepted for the 
selected country could be seen as a bug.

HOWEVER....

This is still a change in behavior and as such could be seen as a 
regression.

Also, in the case of tzsetup I think it is probably OK to allow a bit more 
freedom for preseeding than for interactive installs and allow to select 
any time zone.

The attached patch should restore the old behavior. The patch also adds a 
sanity check that a (preseeded) value should be valid before the target 
system is actually modified.

Patch is completely untested.

[1] I have some patches that will allow this kind of preseeding for 
localechooser in the future, but they are fairly invasive and need a lot 
of testing and thus not suitable for Lenny.

diff --git a/packages/tzsetup/debian/changelog b/packages/tzsetup/debian/changelog
index 99201e3..b743509 100644
--- a/packages/tzsetup/debian/changelog
+++ b/packages/tzsetup/debian/changelog
@@ -1,3 +1,14 @@
+tzsetup (1:0.24) UNRELEASED; urgency=low
+
+  * Accept any preseeded time zone if the seen flag is set. This is needed to
+    undo a change in behavior introduced with cdebconf (0.132) which results
+    in invalid defaults for current choices list being rejected.
+    Closes: #503189.
+  * Check that (preseeded) time zone is valid before setting it for the target
+    system.
+
+ -- Frans Pop <fjp@debian.org>  Wed, 22 Oct 2008 20:20:13 +0200
+
 tzsetup (1:0.23) unstable; urgency=low
 
   [ Otavio Salvador ]
diff --git a/packages/tzsetup/post-base-installer.d/05tzsetup b/packages/tzsetup/post-base-installer.d/05tzsetup
index 876cdca..593862d 100755
--- a/packages/tzsetup/post-base-installer.d/05tzsetup
+++ b/packages/tzsetup/post-base-installer.d/05tzsetup
@@ -5,6 +5,12 @@ set -e
 
 db_get time/zone
 zone="$RET"
+
+if [ ! -e /target/usr/share/zoneinfo/$zone ]; then
+	logger -t tzsetup "Warning: ignoring invalid time zone '$zone'"
+	exit 0
+fi
+
 echo "$zone" > /target/etc/timezone
 rm -f /target/etc/localtime
 cp -f /target/usr/share/zoneinfo/$zone /target/etc/localtime
diff --git a/packages/tzsetup/tzsetup b/packages/tzsetup/tzsetup
index 8ac0d00..5c25707 100755
--- a/packages/tzsetup/tzsetup
+++ b/packages/tzsetup/tzsetup
@@ -4,6 +4,12 @@ set -e
 . /usr/share/debconf/confmodule
 db_capb backup
 
+# Leave preseeded time zone untouched if seen flag is set 
+db_fget time/zone seen
+if [ "$RET" = true ]; then
+	exit 0
+fi
+
 db_get debian-installer/country
 CC="$RET"
 # per-country templates are used for countries with multiple choices
@@ -15,16 +21,12 @@ if db_get "tzsetup/country/$CC"; then
 	fi
 else
 	db_register time/zone time/zone # might be registered to something else
-	# detect preseeding and avoid replacing with other value
-	db_fget time/zone seen
-	if [ "$RET" = false ]; then
-		zone=$(grep "^$CC" /usr/share/tzsetup/tzmap | cut -d ' ' -f 2)
-		db_set time/zone "$zone"
+	zone=$(grep "^$CC" /usr/share/tzsetup/tzmap | cut -d ' ' -f 2)
+	db_set time/zone "$zone"
 
-		db_subst tzsetup/selected ZONE $zone
-		db_input medium tzsetup/selected || true
-		if ! db_go; then
-			exit 10 # back to menu
-		fi
+	db_subst tzsetup/selected ZONE $zone
+	db_input medium tzsetup/selected || true
+	if ! db_go; then
+		exit 10 # back to menu
 	fi
 fi

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


Reply to: