diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-03-28 14:43:48 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-04-01 10:22:42 +0100 |
commit | 8f791ce59d5fb0b0bc502838c44bb597f80d3979 (patch) | |
tree | f7bf78fc79781c3d97727fcff5f33fc80bdda2ce /bitbake/lib/toaster/toastermain | |
parent | e1bfb5dd61fb684cbde29692f6f957c8737aa41d (diff) | |
download | openembedded-core-contrib-8f791ce59d5fb0b0bc502838c44bb597f80d3979.tar.gz |
bitbake: toaster: fix timezone detection
This patch replaces faulty timezone detection with a version
that simply reads the TZ environment variable if it is set.
If the TZ is not set, we do a reverse match search among known
timezone definitions and take the first match.
[YOCTO #5499]
(Bitbake rev: 3a0a556a65368f02635606e4eb707ca08e25007a)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastermain')
-rw-r--r-- | bitbake/lib/toaster/toastermain/settings.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py index 51fa3ccd03..e26ee3c9ee 100644 --- a/bitbake/lib/toaster/toastermain/settings.py +++ b/bitbake/lib/toaster/toastermain/settings.py @@ -50,9 +50,23 @@ ALLOWED_HOSTS = [] # although not all choices may be available on all operating systems. # 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] +# Always use local computer's time zone, find +import os, hashlib +if 'TZ' in os.environ: + TIME_ZONE = os.environ['TZ'] +else: + # need to read the /etc/localtime file which is the libc standard + # and do a reverse-mapping to /usr/share/zoneinfo/; + # since the timezone may match any number of identical timezone definitions, + + zonefilelist = {} + ZONEINFOPATH = '/usr/share/zoneinfo/' + for dirpath, dirnames, filenames in os.walk(ZONEINFOPATH): + for fn in filenames: + filepath = os.path.join(dirpath, fn) + zonefilelist[hashlib.md5(open(filepath).read()).hexdigest()] = filepath.lstrip(ZONEINFOPATH).strip() + + TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime').read()).hexdigest()] # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html |