[Pkg-uml-pkgs] Bug#446795: Obtain the local time zone

Peder Chr. Nørgaard pcn at pogt.dk
Thu Dec 20 18:55:47 UTC 2007


On Thursday 01 November 2007, you wrote:
> Instead of reading /etc/timezone, you can obtain the local time zone
> reading the output of the command:
>
> $ date +%Z
>
> So I think that it would be enough to substitute
> in /usr/lib/rootstrap/modules/uml the line
>
> [ ! -e $HOST/etc/timezone ] || TARGET_TIMEZONE="$(cat
> $HOST/etc/timezone)"
>
> with
>
> TARGET_TIMEZONE=`date +%Z`
>
> Regards, Giovanni.

Thanks for the hint.  However, I am sorry to point out, this is not good 
enough.   But then again, I've learned a little bit more since I first filed 
this report.  What I wrote there was not wholly correct.

I wrote 

> for me, in Denmark, "echo CET > /etc/timezone" on the host makes rootstrap
> work just fine. 

What I really should have written in my original posting was

echo Europe/Paris > /etc/timezone

that is, the "tzdata" code, not the timezone.  The problem with your proposal 
is that "CET" only gives the timezone; the tzdata indication gives the DST 
logic, too.  And that is what is needed.

I *think* - but I don't *know*, knowing too little about how tzdata is used in 
modern Debian - that the whole problem can be reduced to copying the 
host /etc/localtime to the target /etc/localtime.

The alternative seems to be copying some of the code in tzdata.postinst, 
something like:

LC_ALL=C
LANG=C
unset TZ
umask 022

. /usr/share/debconf/confmodule
db_version 2.0

# Get the values from debconf
AREA=Etc
ZONE=UTC
db_get tzdata/Areas && AREA="$RET"
db_get tzdata/Zones/$AREA && ZONE="$RET"
db_stop

chroot $TARGET cp -f /usr/share/zoneinfo/$AREA/$ZONE /etc/localtime



I would dearly like second opinions on this topic.

best regards
-- 
Peder Chr. Nørgaard     e-mail: pcn at pogt.dk
Gefionsvej 19           spejder-e-mail: hathi at gallerne.dk
DK-8230 Åbyhøj          tel: +45 87 44 11 99
Denmark                 mob: +45 30 91 84 31






More information about the Pkg-uml-pkgs mailing list