Using mock to rebuild a package (e.g. in a koji) results in a /etc/localtime being a normal file. That breaks other program's expectation that it's a symlink whose value can be used to retrieve the time zone name (see bug #1135981). According to localtime(5), /etc/localtime may not be a normal file: Because the timezone identifier is extracted from the symlink target name of /etc/localtime, this file may not be a normal file or hardlink.
Created attachment 933502 [details] Naive patch I wrote naïve solution. But then I find that those data files are owned by tzdata package, which is *not* in minimal buildroot. Which is problematic for me. > /etc/localtime may not be a normal file English is not my mother tongue, therefore pardon me if I'm wrong. I undestand this sentence as "There is high chance that the file can be symlink or hardlink.", however that it *can* be normal file as well. In this light, I hesitate to do a change in mock.
(In reply to Miroslav Suchý from comment #1) > Created attachment 933502 [details] > Naive patch > > I wrote naïve solution. But then I find that those data files are owned by > tzdata package, which is *not* in minimal buildroot. Which is problematic > for me. > I know. What about replacing the file with a symlink after installing minimal build root if the /usr/share/zoneinfo is there? > > /etc/localtime may not be a normal file > English is not my mother tongue, therefore pardon me if I'm wrong. I > undestand this sentence as "There is high chance that the file can be > symlink or hardlink.", however that it *can* be normal file as well. > > In this light, I hesitate to do a change in mock. There is no way how to get to know the time zone name from the chrooted system. The file has to be a symlink, or TZ environement variable has to be exported there. Or some Fedora specific mean has to be employed (e.g. setting /etc/sysconfig/something and then calling an updater.) The problem is who else should to do that than mock? tzadata refuses to run any postscripts. Allegedly, glibc run an updater. However it cannot know create the symlink if there is no time zone name saved.
tzdata maintainer says in bug #1136219 comment 5: > I see that much has changed since I was around. The tzdata updating logic and > ownership of /etc/localtime was moved to systemd since bug 858735. > /etc/sysconfig/clock is not used anymore, as you pointed out in the text that > I snipped out. It also seems to have become a symbolic link. > > So let's recap. The problem is due to systemd not being installed in a build > root, _and_ mock copying the contents instead of symlink. But there's no other > way to do it, otherwise mock would create a dangling symlink that would > potentially remain dangling if the in-mock tzdata doesn't have the zone the > host system has. Hmm. > > Outside mock you shouldn't see this problem, as tzdata never drops zones (that > sacred cow of compatibility again). It's really only mock that exposes this. If you conclude that a time zone should be set properly in a mock environment, either @build should involve needed packages (sub-package the timedatectl) and mock should run timedatectl to set the /etc/localtime properly, or mock should use reimplement the logic and create a symlink if tzdata appears in the chroot at the end of initialization.
Just to clarify (In reply to Miroslav Suchý from comment #1) > > /etc/localtime may not be a normal file > English is not my mother tongue, therefore pardon me if I'm wrong. I > undestand this sentence as "There is high chance that the file can be > symlink or hardlink.", however that it *can* be normal file as well. "may not" without qualifying text is generally definitive. i.e. the common reading of the sentence is: Because the timezone identifier is extracted from the symlink target name of /etc/localtime, this file is not allowed be a normal file or hardlink.
This should be fixed as side effect of bug 1132762. Now, mock does not touch /etc/localtime at all.
Fixed in mock-1.2.0, which just landed in rawhide.