# 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.
The correct reproducer is: $ perl -MDateTime::TimeZone::Local -e 'DateTime::TimeZone::Local->TimeZone'
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.
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.
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.
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.
I will try this patch.