1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Nikolay Amiantov <ab@fmap.me>
3Date: Tue, 11 Oct 2016 13:12:08 +0300
4Subject: [PATCH] Change /usr/share/zoneinfo to /etc/zoneinfo
5
6NixOS uses this path.
7---
8 man/localtime.xml | 4 ++--
9 src/basic/time-util.c | 8 ++++----
10 src/firstboot/firstboot.c | 2 +-
11 src/nspawn/nspawn.c | 4 ++--
12 src/timedate/timedated.c | 8 ++++----
13 5 files changed, 13 insertions(+), 13 deletions(-)
14
15diff --git a/man/localtime.xml b/man/localtime.xml
16index 3a13e04a27..4fd58068a1 100644
17--- a/man/localtime.xml
18+++ b/man/localtime.xml
19@@ -20,7 +20,7 @@
20 </refnamediv>
21
22 <refsynopsisdiv>
23- <para><filename>/etc/localtime</filename> -> <filename>../usr/share/zoneinfo/…</filename></para>
24+ <para><filename>/etc/localtime</filename> -> <filename>zoneinfo/…</filename></para>
25 </refsynopsisdiv>
26
27 <refsect1>
28@@ -30,7 +30,7 @@
29 system-wide timezone of the local system that is used by
30 applications for presentation to the user. It should be an
31 absolute or relative symbolic link pointing to
32- <filename>/usr/share/zoneinfo/</filename>, followed by a timezone
33+ <filename>/etc/zoneinfo/</filename>, followed by a timezone
34 identifier such as <literal>Europe/Berlin</literal> or
35 <literal>Etc/UTC</literal>. The resulting link should lead to the
36 corresponding binary
37diff --git a/src/basic/time-util.c b/src/basic/time-util.c
38index 29afb08ebc..398ff340cd 100644
39--- a/src/basic/time-util.c
40+++ b/src/basic/time-util.c
41@@ -1418,7 +1418,7 @@ static int get_timezones_from_zone1970_tab(char ***ret) {
42
43 assert(ret);
44
45- f = fopen("/usr/share/zoneinfo/zone1970.tab", "re");
46+ f = fopen("/etc/zoneinfo/zone1970.tab", "re");
47 if (!f)
48 return -errno;
49
50@@ -1459,7 +1459,7 @@ static int get_timezones_from_tzdata_zi(char ***ret) {
51
52 assert(ret);
53
54- f = fopen("/usr/share/zoneinfo/tzdata.zi", "re");
55+ f = fopen("/etc/zoneinfo/tzdata.zi", "re");
56 if (!f)
57 return -errno;
58
59@@ -1570,7 +1570,7 @@ int verify_timezone(const char *name, int log_level) {
60 if (p - name >= PATH_MAX)
61 return -ENAMETOOLONG;
62
63- t = strjoina("/usr/share/zoneinfo/", name);
64+ t = strjoina("/etc/zoneinfo/", name);
65
66 fd = open(t, O_RDONLY|O_CLOEXEC);
67 if (fd < 0)
68@@ -1622,7 +1622,7 @@ int get_timezone(char **ret) {
69 if (r < 0)
70 return r; /* Return EINVAL if not a symlink */
71
72- const char *e = PATH_STARTSWITH_SET(t, "/usr/share/zoneinfo/", "../usr/share/zoneinfo/");
73+ const char *e = PATH_STARTSWITH_SET(t, "/etc/zoneinfo/", "../etc/zoneinfo/");
74 if (!e)
75 return -EINVAL;
76 if (!timezone_is_valid(e, LOG_DEBUG))
77diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
78index 9be62b8df3..2044e9f8d0 100644
79--- a/src/firstboot/firstboot.c
80+++ b/src/firstboot/firstboot.c
81@@ -598,7 +598,7 @@ static int process_timezone(int rfd) {
82 if (isempty(arg_timezone))
83 return 0;
84
85- e = strjoina("../usr/share/zoneinfo/", arg_timezone);
86+ e = strjoina("zoneinfo/", arg_timezone);
87
88 r = symlinkat_atomic_full(e, pfd, f, /* make_relative= */ false);
89 if (r < 0)
90diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
91index 2b735e4df4..7a21f34edd 100644
92--- a/src/nspawn/nspawn.c
93+++ b/src/nspawn/nspawn.c
94@@ -1851,8 +1851,8 @@ int userns_mkdir(const char *root, const char *path, mode_t mode, uid_t uid, gid
95 static const char *timezone_from_path(const char *path) {
96 return PATH_STARTSWITH_SET(
97 path,
98- "../usr/share/zoneinfo/",
99- "/usr/share/zoneinfo/");
100+ "../etc/zoneinfo/",
101+ "/etc/zoneinfo/");
102 }
103
104 static bool etc_writable(void) {
105diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
106index cbd30214b7..b9b2f533a4 100644
107--- a/src/timedate/timedated.c
108+++ b/src/timedate/timedated.c
109@@ -280,7 +280,7 @@ static int context_read_data(Context *c) {
110
111 r = get_timezone(&t);
112 if (r == -EINVAL)
113- log_warning_errno(r, "/etc/localtime should be a symbolic link to a time zone data file in /usr/share/zoneinfo/.");
114+ log_warning_errno(r, "/etc/localtime should be a symbolic link to a time zone data file in /etc/zoneinfo/.");
115 else if (r < 0)
116 log_warning_errno(r, "Failed to get target of /etc/localtime: %m");
117
118@@ -304,7 +304,7 @@ static int context_write_data_timezone(Context *c) {
119
120 if (isempty(c->zone) || streq(c->zone, "UTC")) {
121
122- if (access("/usr/share/zoneinfo/UTC", F_OK) < 0) {
123+ if (access("/etc/zoneinfo/UTC", F_OK) < 0) {
124
125 if (unlink("/etc/localtime") < 0 && errno != ENOENT)
126 return -errno;
127@@ -312,9 +312,9 @@ static int context_write_data_timezone(Context *c) {
128 return 0;
129 }
130
131- source = "../usr/share/zoneinfo/UTC";
132+ source = "../etc/zoneinfo/UTC";
133 } else {
134- p = path_join("../usr/share/zoneinfo", c->zone);
135+ p = path_join("../etc/zoneinfo", c->zone);
136 if (!p)
137 return -ENOMEM;
138