Bug 1135981

Summary: DateTime::TimeZone::Local->TimeZone does not use /etc/locatime content (Cannot determine local time zone)
Product: [Fedora] Fedora Reporter: Petr Pisar <ppisar>
Component: perl-DateTime-TimeZoneAssignee: Petr Pisar <ppisar>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: iarnell, msuchy, perl-devel
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: perl-DateTime-TimeZone-1.74-2.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-02 16:03:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1132483, 1135450, 1138185    
Attachments:
Description Flags
Fix none

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.