toaster: fix timezone detection
PATCH 1/1 toaster: fix timezone detection
From: Alexandru DAMIAN <[email protected]>
This patch replaces faulty timezone detection with a version that simply reads the TZ environment variable if it is set.
This has been tested with the list of TZ values from
http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[YOCTO #5499]
--- bitbake/lib/toaster/toastermain/settings.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
lib/toaster/toastermain/settings.py +4 -2
@@ -51,8 +51,10 @@ ALLOWED_HOSTS = [] # In a Windows environment this must be set to your system time zone. # Always use local computer's time zone -import time -TIME_ZONE = time.tzname[0] +TIME_ZONE = "posix/GMT-0" # have a sane default +import os +if 'TZ' in os.environ: + TIME_ZONE = os.environ['TZ'] # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html
Signature · 1 line
1.8.3.2
Quoted 2 lines · Alex DAMIAN
This patch replaces faulty timezone detection with a version that simply reads the TZ environment variable if it is set.
My Debian system doesn't have a TZ environment variable but does have /etc/localtime which is the current timezone data. Yes, determining the local timezone is a pain. :)
Ross
This is a Debian-ism :(
Does toaster show you improper times, or refuses to start ?
Alex
Quoted 20 lines · Ross
Quoted 2 lines · Alex DAMIAN
This patch replaces faulty timezone detection with a version that simply reads the TZ environment variable if it is set.
My Debian system doesn't have a TZ environment variable but does have
/etc/localtimewhich is the current timezone data. Yes, determining the local timezone is a pain. :)Ross
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Signature · 3 lines
Alex Damian Yocto Project SSG / OTC
Quoted 3 lines · Alexandru
This is a Debian-ism :(
Does toaster show you improper times, or refuses to start ?
I've never tried Toaster, but I'm in GMT so I wouldn't be able to tell :)
It may be a Debianism but TZ isn't set at all so that's equally unreliable. I wonder what time.tznames is actually doing.
/etc/localtime was originally a Debianism but is also the canonical file that systemd handles, so it's got a much wider install base now. The similar file that Fedora has used to be /etc/sysconfig/clock.
http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/jana/trusty/view/head:/libjana-ecal/jana-ecal-utils.c#L113
is the first hit for some code I was involved in some time ago that tried to work everywhere. It's probably bitrotted quite dramatically though...
Ross
Quoted 1 line · Alexandru
This is a Debian-ism :(
You say that, but the Fedora 20 install I have here (a) doesn't have TZ and
(b) has /etc/localtime -> ../usr/share/zoneinfo/Europe/London. On my CentOS 6.5 machine (possibly irrelevant for Toaster, but...) TZ is also unset but /etc/localtime is just a plain copy of some timezone file rather than a symlink. Older RH-style systems such as CentOS 6 have a ZONE value in /etc/sysconfig/clock but Fedora appears to have eliminated this file.
Given that, I don't think this is a complete fix.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
I hear you, thanks for the input on various configurations.
Please do not submit this patch, I'll come back with a v2.
Ross, I tried time.tzname (as it currently stands) and it doesn't provide a /usr/share/zoneinfo/ compatible name :(.
Alex
Quoted 20 lines · Paul Eggleton
Quoted 1 line · Alexandru
This is a Debian-ism :(
You say that, but the Fedora 20 install I have here (a) doesn't have TZ and
(b) has/etc/localtime-> ../usr/share/zoneinfo/Europe/London. On my CentOS 6.5 machine (possibly irrelevant for Toaster, but...) TZ is also unset but/etc/localtimeis just a plain copy of some timezone file rather than a symlink. Older RH-style systems such as CentOS 6 have a ZONE value in/etc/sysconfig/clockbut Fedora appears to have eliminated this file.Given that, I don't think this is a complete fix.
Cheers,
Paul--
Paul Eggleton
Intel Open Source Technology Centre
Signature · 3 lines
Alex Damian Yocto Project SSG / OTC
Quoted 9 lines · Ross
Quoted 2 lines · Alex DAMIAN
This patch replaces faulty timezone detection with a version that simply reads the TZ environment variable if it is set.
My Debian system doesn't have a TZ environment variable but does have
/etc/localtimewhich is the current timezone data. Yes, determining the local timezone is a pain. :)Ross
FWIW, my Fedora 20 system doesn't have a TZ environment variable. It uses the same /etc/localtime symbolic link as Debian.
Cheers,
Stefan