Closed afbjorklund closed 10 months ago
Some runtimes expect
/etc/localtime
to be present...
Did you mean /etc/timezone
? The content for /etc/localtime
for UTC is normally
TZif2UTCTZif2UTC
UTC0
Regular setup:
lima-alpine:~# apk add tzdata
(1/1) Installing tzdata (2022c-r0)
Executing busybox-1.35.0-r17.trigger
OK: 49 MiB in 81 packages
lima-alpine:~# setup-timezone -z UTC
lima-alpine:~# ls -l /etc/localtime
lrwxrwxrwx 1 root root 17 Oct 17 01:44 /etc/localtime -> /etc/zoneinfo/UTC
lima-alpine:~# cat /etc/localtime
TZif2UTCTZif2UTC
UTC0
But which command needs this; the default for date
is UTC
anyways, so creating the file with default content makes no difference.
I just realized that zoneinfo files are binary files, so we would actually need to copy it from the tzdata
package:
lima-alpine:~# hexdump -C /etc/localtime
00000000 54 5a 69 66 32 00 00 00 00 00 00 00 00 00 00 00 |TZif2...........|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 01 00 00 00 04 00 00 00 00 |................|
00000030 00 00 55 54 43 00 54 5a 69 66 32 00 00 00 00 00 |..UTC.TZif2.....|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 |................|
00000060 00 04 00 00 00 00 00 00 55 54 43 00 0a 55 54 43 |........UTC..UTC|
00000070 30 0a |0.|
00000072
Did you mean
/etc/timezone
? The content for/etc/localtime
for UTC is normally
Good catch! I will make sure to adjust the workaround then.... (it was for apptainer)
https://github.com/apptainer/apptainer/blob/v1.1.2/pkg/util/apptainerconf/config.go#L107
In the Fedora VM, it is a symlink: /etc/localtime -> ../usr/share/zoneinfo/Etc/UTC
There is no /etc/timezone
, only a /etc/adjtime
. zoneinfo was from tzdata-2022a-1.fc36
Your approach with adding tzdata
package etc to alpine-lima, seems like the best one.
The symlink is resolved automatically, so the end result is a 114-byte binary /etc/localtime
.
lima-alpine-apptainer:~$ apptainer run docker://busybox
INFO: Using cached SIF image
INFO: fuse2fs not found, will not be able to mount EXT3 filesystems
Apptainer> ls -l /etc/localtime
-rw-r--r-- 1 nobody nobody 114 Oct 17 08:24 /etc/localtime
Apptainer> exit
lima-alpine-apptainer:~$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 17 Oct 17 08:24 /etc/localtime -> /etc/zoneinfo/UTC
Your approach with adding
tzdata
package etc to alpine-lima, seems like the best one. The symlink is resolved automatically, so the end result is a 114-byte binary/etc/localtime
.
I would not install all of tzdata
into the ISO; I would just copy the single UTC
file over after including it on the mkimage
.
But first I wanted to make sure we are talking about the right thing; and I want a comment explaining why we are doing this.
You don't have to keep tzdata
installed, the generated /etc/localtime and /etc/zoneinfo would be fine.
Here is what alpine-conf is actually doing:
+ rm -r //etc/zoneinfo
+ mkdir -p /etc/zoneinfo/
+ cp //usr/share/zoneinfo/UTC /etc/zoneinfo//
+ zonepath=/etc/zoneinfo/UTC
+ rm -f /etc/localtime
+ ln -s /etc/zoneinfo/UTC /etc/localtime
/bin/sh -x /sbin/setup-timezone -z UTC
I would not install all of
tzdata
into the ISO;
I'm not sure why I wrote this, but tools are supposed to treat a missing zoneinfo database the same as if it was configured for UTC. So there wouldn't be a good reason to just copy the UTC data (unless we are dealing with a broken tool).
The whole of tzdata
is 3MB, so I think we can just include it completely. Most people don't seem to care about image size anymore (within reason).
Some runtimes expect
/etc/localtime
to be present...Maybe it can be created, to match the output of
date
?Something similar to this workaround:
echo UTC | sudo tee /etc/localtime