Bug 1135981 - DateTime::TimeZone::Local->TimeZone does not use /etc/locatime content (Cannot determine local time zone)
Summary: DateTime::TimeZone::Local->TimeZone does not use /etc/locatime content (Canno...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: perl-DateTime-TimeZone
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Petr Pisar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1132483 1135450 1138185
TreeView+ depends on / blocked
 
Reported: 2014-09-01 11:59 UTC by Petr Pisar
Modified: 2014-09-04 08:27 UTC (History)
3 users (show)

Fixed In Version: perl-DateTime-TimeZone-1.74-2.fc22
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-02 16:03:16 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Fix (2.30 KB, patch)
2014-09-02 15:33 UTC, Petr Pisar
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
CPAN 55029 0 None None None Never
Red Hat Bugzilla 1136040 0 unspecified CLOSED /etc/localtime is not a symlink 2021-02-22 00:41:40 UTC

Internal Links: 1136040

Description Petr Pisar 2014-09-01 11:59:44 UTC
# perl -MDateTime::TimeZone::Locae::TimeZone::Local->TimeZone'
Cannot determine local time zone

It happens when /etc/localtime file does not have its copy under /usr/share/zoneinfo.

This is a problem for koji builds. The file is copied from mock's hosts and then newer tzdata package installed into the mock environment, so the copy copy does not match anymore. The DateTime::TimeZone::Local::Unix reads:

Some systems just copy the relevant file to F</etc/localtime> instead
of making a symlink.  In this case, we look in F</usr/share/zoneinfo>
for a file that has the same size and content as F</etc/localtime> to
determine the local time zone.

I propose to teach the module to read the zone identifier from /etc/localtime content.

Comment 1 Petr Pisar 2014-09-01 12:04:40 UTC
The correct reproducer is:

$ perl -MDateTime::TimeZone::Local -e 'DateTime::TimeZone::Local->TimeZone'

Comment 2 Miroslav Suchý 2014-09-01 19:05:25 UTC
Does it expect to have copy under /usr/share/zoneinfo? Or /etc/localtime needs to be really symlink?
If it is the first case, then it can be easily fixed by requiring tzdata in spec file.

Comment 3 Petr Pisar 2014-09-02 06:39:36 UTC
perl-DateTime-TimeZone is obsessed with time zone names. What DateTime::TimeZone::Local->TimeZone does is it tries to determine the zone name by many means. If it can figure out the name, it uses it as a key into its own time zone database.

Some of the many means are:

(1) Reading /etc/localtime symbolic link value

(2) If /etc/localtime is not a symbolic link, it finds its copy under /usr/share/zoneinfo whose path name is the zone name.

The tzdata presents in the minimal build root by a transitive dependency. The issue probably is the /etc/localtime is copied by mock into the chroot because the chroot is empty. Then tzadata are installed by @build group. Results the /etc/locatime is a plain file and sometimes out-dated.

Comment 4 Petr Pisar 2014-09-02 06:42:51 UTC
I've already developed a workaround in the perl-DateTime-TimeZone which parses the time zone definition from /etc/localtime content, so the DateTime::TimeZone::Local->TimeZone will return an unnamed timezone. Based on the upstream discussion, I believe the patch will be refused, but there is not other real fix. I just need to verify the patcg does not break anything and it does not create a build cycle.

Comment 5 Petr Pisar 2014-09-02 15:33:33 UTC
Created attachment 933831 [details]
Fix

This patch allows the DateTime::TimeZone::Local to use /etc/localtime content to return an unnamed time zone defintion if there is no other way hot to get the time zone name.

Comment 6 Petr Pisar 2014-09-02 15:43:15 UTC
I will try this patch.


Note You need to log in before you can comment on or make changes to this bug.