Bug 14370

Summary: Toaster fails to start in CentOS 8 because it can't detect the timezone
Product: [Build System, Metadata & Runtime] Toaster Reporter: spynet314
Component: toasterAssignee: David Reyna <david.reyna>
Status: RESOLVED WONTFIX QA Contact: Toaster default assignee <toaster>
Severity: normal    
Priority: Medium CC: randy.macleod
Version: 3.2.3   
Target Milestone: 5.2 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description spynet314 2021-05-01 11:11:30 UTC
Hello,

in my CentOS 8 setup, the script 'bitbake/lib/toaster/toastermain/settings.py' generates the following exception on start:

  File "/home/paolo/poky/bitbake/lib/toaster/toastermain/settings.py", line 86, in <module>
    if pytz.timezone(zonename) is not None:
  File "/usr/lib/python3.6/site-packages/pytz/__init__.py", line 168, in timezone
    _tzinfo_cache[zone] = build_tzinfo(zone, fp)
  File "/usr/lib/python3.6/site-packages/pytz/tzfile.py", line 33, in build_tzinfo
    assert magic == _byte_string('TZif'), 'Got magic %s' % repr(magic)
AssertionError: Got magic b'# Al'

After digging for a while, I found that the above assertion is generated because the folder /usr/share/zoneinfo, that is scanned by the script, contains files that are not timezone descriptors, like for example 'leapseconds', 'zone1970.tab' and 'zone.tab'.

It is possible to avoid this error by exporting the timezone with:
TZ='Europe/Rome'; export TZ

It would be better to modify the script like this:

            try:
                import pytz
                from pytz.exceptions import UnknownTimeZoneError
                try:
                    if pytz.timezone(zonename) is not None:
                        zonefilelist[hashlib.md5(open(filepath, 'rb').rea$
                except UnknownTimeZoneError as ValueError:
                    # we expect timezone failures here, just move over
                    pass
  -->           except AssertionError:
  -->               # there may be files in the folder that generate assertion
  -->               pass
            except ImportError:
                zonefilelist[hashlib.md5(open(filepath, 'rb').read()).hex

Regards,
Paolo
Comment 1 David Reyna 2025-03-13 04:49:25 UTC
CentOS 8 is EOL