Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/timezone-data/, sys-libs/timezone-data/files/
Date: Mon, 07 Nov 2022 04:35:29
Message-Id: 1667795713.c06f818ab387c8ab6e722fa0c4bbd1b801589595.sam@gentoo
1 commit: c06f818ab387c8ab6e722fa0c4bbd1b801589595
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Mon Nov 7 04:35:13 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 7 04:35:13 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c06f818a
7
8 sys-libs/timezone-data: fix musl issues
9
10 Signed-off-by: Sam James <sam <AT> gentoo.org>
11
12 .../files/timezone-data-2022f-musl.patch | 181 +++++++++++++++++++
13 .../timezone-data/timezone-data-2022f-r1.ebuild | 201 +++++++++++++++++++++
14 2 files changed, 382 insertions(+)
15
16 diff --git a/sys-libs/timezone-data/files/timezone-data-2022f-musl.patch b/sys-libs/timezone-data/files/timezone-data-2022f-musl.patch
17 new file mode 100644
18 index 000000000000..3bbb1ea2a772
19 --- /dev/null
20 +++ b/sys-libs/timezone-data/files/timezone-data-2022f-musl.patch
21 @@ -0,0 +1,181 @@
22 +https://github.com/eggert/tz/commit/a91830b783db3bb481930c67914d3c16b821f717
23 +https://github.com/eggert/tz/commit/dbe87fe421f76a3d1ac31082868ce60dfcbdefc4
24 +https://github.com/eggert/tz/commit/b037132599996358fe4774912b7405db0f5b0ee1
25 +https://github.com/eggert/tz/commit/317cc2c05a0acd02597e9db2b97af078630c1dde
26 +https://github.com/eggert/tz/commit/f4808ee8fa61b0df82337e8f0fa02ca3db598cb8
27 +
28 +From a91830b783db3bb481930c67914d3c16b821f717 Mon Sep 17 00:00:00 2001
29 +From: Paul Eggert <eggert@×××××××.edu>
30 +Date: Fri, 28 Oct 2022 22:55:10 -0700
31 +Subject: [PATCH] Fix tzalloc bug on platforms lacking tm_zone
32 +MIME-Version: 1.0
33 +Content-Type: text/plain; charset=UTF-8
34 +Content-Transfer-Encoding: 8bit
35 +
36 +Problem reported by Đoàn Trần Công Danh in:
37 +https://mm.icann.org/pipermail/tz/2022-October/032153.html
38 +* zdump.c (tzalloc) [!USE_LOCALTIME_RZ && HAVE_SETENV]:
39 +Return a nonnull pointer.
40 +--- a/zdump.c
41 ++++ b/zdump.c
42 +@@ -234,7 +234,7 @@ tzalloc(char const *val)
43 + exit(EXIT_FAILURE);
44 + }
45 + tzset();
46 +- return NULL;
47 ++ return &progname; /* Any valid non-null char ** will do. */
48 + # else
49 + enum { TZeqlen = 3 };
50 + static char const TZeq[TZeqlen] = "TZ=";
51 +
52 +From dbe87fe421f76a3d1ac31082868ce60dfcbdefc4 Mon Sep 17 00:00:00 2001
53 +From: Paul Eggert <eggert@×××××××.edu>
54 +Date: Fri, 28 Oct 2022 23:22:26 -0700
55 +Subject: [PATCH] Port struct tm guessing to musl
56 +MIME-Version: 1.0
57 +Content-Type: text/plain; charset=UTF-8
58 +Content-Transfer-Encoding: 8bit
59 +
60 +Prompted by report from Đoàn Trần Công Danh in:
61 +https://mm.icann.org/pipermail/tz/2022-October/032153.html
62 +* private.h (TM_GMTOFF, TM_ZONE): By default, assume they
63 +work on musl, which #defines __tm_zone.
64 +--- a/private.h
65 ++++ b/private.h
66 +@@ -613,6 +613,7 @@ time_t posix2time(time_t);
67 + /* Infer TM_ZONE on systems where this information is known, but suppress
68 + guessing if NO_TM_ZONE is defined. Similarly for TM_GMTOFF. */
69 + #if (defined __GLIBC__ \
70 ++ || defined __tm_zone /* musl */ \
71 + || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \
72 + || (defined __APPLE__ && defined __MACH__))
73 + # if !defined TM_GMTOFF && !defined NO_TM_GMTOFF
74 +
75 +From b037132599996358fe4774912b7405db0f5b0ee1 Mon Sep 17 00:00:00 2001
76 +From: Paul Eggert <eggert@×××××××.edu>
77 +Date: Fri, 28 Oct 2022 23:52:59 -0700
78 +Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20assume=20nonempty=20argv?=
79 +MIME-Version: 1.0
80 +Content-Type: text/plain; charset=UTF-8
81 +Content-Transfer-Encoding: 8bit
82 +
83 +Don’t dump core if argv[0] is NULL, which is allowed on
84 +GNU/Linux if the invoker is sufficiently perverse.
85 +* zdump.c (progname): Now char const *, so that it can be given
86 +the address of a string constant.
87 +(tzalloc): Use optarg, not progname, since progname’s type is no
88 +longer correct.
89 +* zdump.c, zic.c (main): Initialize progname to non-null.
90 +--- a/zdump.c
91 ++++ b/zdump.c
92 +@@ -84,7 +84,7 @@ static time_t const absolute_max_time =
93 + ? (((time_t) 1 << atime_shift) - 1 + ((time_t) 1 << atime_shift))
94 + : -1);
95 + static int longest;
96 +-static char * progname;
97 ++static char const *progname;
98 + static bool warned;
99 + static bool errout;
100 +
101 +@@ -234,7 +234,7 @@ tzalloc(char const *val)
102 + exit(EXIT_FAILURE);
103 + }
104 + tzset();
105 +- return &progname; /* Any valid non-null char ** will do. */
106 ++ return &optarg; /* Any valid non-null char ** will do. */
107 + # else
108 + enum { TZeqlen = 3 };
109 + static char const TZeq[TZeqlen] = "TZ=";
110 +@@ -463,7 +463,7 @@ main(int argc, char *argv[])
111 + # endif /* defined TEXTDOMAINDIR */
112 + textdomain(TZ_DOMAIN);
113 + #endif /* HAVE_GETTEXT */
114 +- progname = argv[0];
115 ++ progname = argv[0] ? argv[0] : "zdump";
116 + for (i = 1; i < argc; ++i)
117 + if (strcmp(argv[i], "--version") == 0) {
118 + printf("zdump %s%s\n", PKGVERSION, TZVERSION);
119 +--- a/zic.c
120 ++++ b/zic.c
121 +@@ -943,7 +943,7 @@ main(int argc, char **argv)
122 + textdomain(TZ_DOMAIN);
123 + #endif /* HAVE_GETTEXT */
124 + main_argv = argv;
125 +- progname = argv[0];
126 ++ progname = argv[0] ? argv[0] : "zic";
127 + if (TYPE_BIT(zic_t) < 64) {
128 + fprintf(stderr, "%s: %s\n", progname,
129 + _("wild compilation-time specification of zic_t"));
130 +
131 +From 317cc2c05a0acd02597e9db2b97af078630c1dde Mon Sep 17 00:00:00 2001
132 +From: Paul Eggert <eggert@×××××××.edu>
133 +Date: Mon, 31 Oct 2022 12:41:48 -0700
134 +Subject: [PATCH] Port better to old Linux kernels
135 +MIME-Version: 1.0
136 +Content-Type: text/plain; charset=UTF-8
137 +Content-Transfer-Encoding: 8bit
138 +
139 +Problem reported by Igor Ivanov in:
140 +https://mm.icann.org/pipermail/tz/2022-October/032192.html
141 +* zic.c (get_rand_u64): Don’t use clock_gettime; it’s too much of
142 +a configuration hassle.
143 +---
144 + zic.c | 15 +++------------
145 + 2 files changed, 5 insertions(+), 15 deletions(-)
146 +
147 +diff --git a/zic.c b/zic.c
148 +index a85f2a4c..14393a3d 100644
149 +--- a/zic.c
150 ++++ b/zic.c
151 +@@ -1210,21 +1210,12 @@ get_rand_u64(void)
152 + #endif
153 +
154 + /* getrandom didn't work, so fall back on portable code that is
155 +- not the best because the seed doesn't necessarily have enough bits,
156 +- the seed isn't cryptographically random on platforms lacking
157 +- getrandom, and 'rand' might not be cryptographically secure. */
158 ++ not the best because the seed isn't cryptographically random and
159 ++ 'rand' might not be cryptographically secure. */
160 + {
161 + static bool initialized;
162 + if (!initialized) {
163 +- unsigned seed;
164 +-#ifdef CLOCK_REALTIME
165 +- struct timespec now;
166 +- clock_gettime (CLOCK_REALTIME, &now);
167 +- seed = now.tv_sec ^ now.tv_nsec;
168 +-#else
169 +- seed = time(NULL);
170 +-#endif
171 +- srand(seed);
172 ++ srand(time(NULL));
173 + initialized = true;
174 + }
175 + }
176 +
177 +
178 +From f4808ee8fa61b0df82337e8f0fa02ca3db598cb8 Mon Sep 17 00:00:00 2001
179 +From: Paul Eggert <eggert@×××××××.edu>
180 +Date: Fri, 4 Nov 2022 19:57:00 -0700
181 +Subject: [PATCH] Fix unlikely conversion bug in zic
182 +MIME-Version: 1.0
183 +Content-Type: text/plain; charset=UTF-8
184 +Content-Transfer-Encoding: 8bit
185 +
186 +* zic.c (puttzcode): Arg is zic_t, not int_fast32_t. This fixes a
187 +portability bug on platforms where int_fast32_t is a 32-bit ones’
188 +complement or signed-magnitude integer, and where the argument is
189 +-2**31 before conversion to int_fast32_t. Although I don’t know
190 +of any such platforms, the C standard allows them.
191 +--- a/zic.c
192 ++++ b/zic.c
193 +@@ -2216,7 +2216,7 @@ convert64(uint_fast64_t val, char *buf)
194 + }
195 +
196 + static void
197 +-puttzcode(const int_fast32_t val, FILE *const fp)
198 ++puttzcode(zic_t val, FILE *fp)
199 + {
200 + char buf[4];
201 +
202 +
203
204 diff --git a/sys-libs/timezone-data/timezone-data-2022f-r1.ebuild b/sys-libs/timezone-data/timezone-data-2022f-r1.ebuild
205 new file mode 100644
206 index 000000000000..7924f88d5a42
207 --- /dev/null
208 +++ b/sys-libs/timezone-data/timezone-data-2022f-r1.ebuild
209 @@ -0,0 +1,201 @@
210 +# Copyright 1999-2022 Gentoo Authors
211 +# Distributed under the terms of the GNU General Public License v2
212 +
213 +EAPI=8
214 +
215 +inherit toolchain-funcs flag-o-matic
216 +
217 +MY_CODE_VER=${PV}
218 +MY_DATA_VER=${PV}
219 +DESCRIPTION="Timezone data (/usr/share/zoneinfo) and utilities (tzselect/zic/zdump)"
220 +HOMEPAGE="https://www.iana.org/time-zones"
221 +SRC_URI="https://www.iana.org/time-zones/repository/releases/tzdata${MY_DATA_VER}.tar.gz
222 + https://www.iana.org/time-zones/repository/releases/tzcode${MY_CODE_VER}.tar.gz"
223 +
224 +LICENSE="BSD public-domain"
225 +SLOT="0"
226 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
227 +IUSE="nls leaps-timezone zic-slim"
228 +
229 +DEPEND="nls? ( virtual/libintl )"
230 +RDEPEND="
231 + ${DEPEND}
232 + !sys-libs/glibc[vanilla(+)]
233 +"
234 +
235 +PATCHES=(
236 + "${FILESDIR}"/${P}-musl.patch
237 +)
238 +
239 +src_unpack() {
240 + mkdir "${S}" && cd "${S}" || die
241 + default
242 +}
243 +
244 +src_prepare() {
245 + default
246 +
247 + # check_web contacts validator.w3.org
248 + sed -i -e 's/check_tables check_web/check_tables/g' \
249 + Makefile || die "Failed to disable check_web"
250 +
251 + if tc-is-cross-compiler ; then
252 + cp -pR "${S}" "${S}"-native || die
253 + fi
254 +}
255 +
256 +src_configure() {
257 + tc-export CC
258 +
259 + # bug #471102
260 + append-lfs-flags
261 +
262 + if use elibc_Darwin ; then
263 + # bug #138251
264 + append-cppflags -DSTD_INSPIRED
265 + fi
266 +
267 + append-cppflags -DHAVE_GETTEXT=$(usex nls 1 0) -DTZ_DOMAIN='\"libc\"'
268 +
269 + # Upstream default is 'slim', but it breaks quite a few programs
270 + # that parse /etc/localtime directly: bug #747538.
271 + append-cppflags -DZIC_BLOAT_DEFAULT='\"'$(usex zic-slim slim fat)'\"'
272 +
273 + LDLIBS=""
274 + if use nls ; then
275 + # See if an external libintl is available. bug #154181, bug #578424
276 + local c="${T}/test"
277 + echo 'main(){}' > "${c}.c" || die
278 + if $(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} "${c}.c" -o "${c}" -lintl 2>/dev/null ; then
279 + LDLIBS+=" -lintl"
280 + fi
281 + fi
282 +}
283 +
284 +_emake() {
285 + emake \
286 + REDO=$(usex leaps-timezone posix_right posix_only) \
287 + TOPDIR="${EPREFIX}" \
288 + ZICDIR='$(TOPDIR)/usr/bin' \
289 + "$@"
290 +}
291 +
292 +src_compile() {
293 + _emake \
294 + AR="$(tc-getAR)" \
295 + cc="$(tc-getCC)" \
296 + RANLIB="$(tc-getRANLIB)" \
297 + CFLAGS="${CFLAGS} -std=gnu99 ${CPPFLAGS}" \
298 + LDFLAGS="${LDFLAGS}" \
299 + LDLIBS="${LDLIBS}"
300 +
301 + if tc-is-cross-compiler ; then
302 + _emake -C "${S}"-native \
303 + AR="$(tc-getBUILD_AR)" \
304 + cc="$(tc-getBUILD_CC)" \
305 + RANLIB="$(tc-getBUILD_RANLIB)" \
306 + CFLAGS="${BUILD_CFLAGS} ${BUILD_CPPFLAGS}" \
307 + LDFLAGS="${BUILD_LDFLAGS}" \
308 + LDLIBS="${LDLIBS}" \
309 + zic
310 + fi
311 +}
312 +
313 +src_test() {
314 + # VALIDATE_ENV is used for extended/web based tests. Punt on them.
315 + emake check VALIDATE_ENV=true
316 +}
317 +
318 +src_install() {
319 + local zic=""
320 + tc-is-cross-compiler && zic="zic=${S}-native/zic"
321 + _emake install ${zic} DESTDIR="${D}" LIBDIR="/nukeit"
322 + rm -rf "${D}/nukeit" "${ED}/etc" || die
323 +
324 + insinto /usr/share/zoneinfo
325 + doins "${S}"/leap-seconds.list
326 +
327 + # Delete man pages installed by man-pages package.
328 + rm "${ED}"/usr/share/man/man5/tzfile.5* "${ED}"/usr/share/man/man8/{tzselect,zdump,zic}.8 || die
329 + dodoc CONTRIBUTING README NEWS *.html
330 +}
331 +
332 +get_TIMEZONE() {
333 + local tz src="${EROOT}/etc/timezone"
334 + if [[ -e ${src} ]] ; then
335 + tz=$(sed -e 's:#.*::' -e 's:[[:space:]]*::g' -e '/^$/d' "${src}")
336 + else
337 + tz="FOOKABLOIE"
338 + fi
339 +
340 + [[ -z ${tz} ]] && return 1 || echo "${tz}"
341 +}
342 +
343 +pkg_preinst() {
344 + local tz=$(get_TIMEZONE)
345 + if [[ ${tz} == right/* || ${tz} == posix/* ]] ; then
346 + eerror "The right & posix subdirs are no longer installed as subdirs -- they have been"
347 + eerror "relocated to match upstream paths as sibling paths. Further, posix/xxx is the"
348 + eerror "same as xxx, so you should simply drop the posix/ prefix. You also should not"
349 + eerror "be using right/xxx for the system timezone as it breaks programs."
350 + die "Please fix your timezone setting"
351 + fi
352 +
353 + # Trim the symlink by hand to avoid portage's automatic protection checks.
354 + rm -f "${EROOT}"/usr/share/zoneinfo/posix
355 +}
356 +
357 +configure_tz_data() {
358 + # Make sure the /etc/localtime file does not get stale, bug #127899
359 + local tz src="${EROOT}/etc/timezone" etc_lt="${EROOT}/etc/localtime"
360 +
361 + # If it's a symlink, assume the user knows what they're doing and
362 + # they're managing it themselves, bug #511474
363 + if [[ -L "${etc_lt}" ]] ; then
364 + einfo "Assuming your ${etc_lt} symlink is what you want; skipping update."
365 + return 0
366 + fi
367 +
368 + if ! tz=$(get_TIMEZONE) ; then
369 + einfo "Assuming your empty ${src} file is what you want; skipping update."
370 + return 0
371 + fi
372 +
373 + if [[ "${tz}" == "FOOKABLOIE" ]] ; then
374 + einfo "You do not have a timezone set in ${src}; skipping update."
375 + return 0
376 + fi
377 +
378 + local tzpath="${EROOT}/usr/share/zoneinfo/${tz}"
379 +
380 + if [[ ! -e ${tzpath} ]]; then
381 + ewarn "The timezone specified in ${src} is not valid!"
382 + return 1
383 + fi
384 +
385 + if [[ -f ${etc_lt} ]]; then
386 + # If a regular file already exists, copy over it.
387 + ewarn "Found a regular file at ${etc_lt}."
388 + ewarn "Some software may expect a symlink instead."
389 + ewarn "You may convert it to a symlink by removing the file and running:"
390 + ewarn " emerge --config sys-libs/timezone-data"
391 + einfo "Copying ${tzpath} to ${etc_lt}."
392 + cp -f "${tzpath}" "${etc_lt}"
393 + else
394 + # Otherwise, create a symlink and remove the timezone file.
395 + tzpath="../usr/share/zoneinfo/${tz}"
396 + einfo "Linking ${tzpath} at ${etc_lt}."
397 + if ln -snf "${tzpath}" "${etc_lt}"; then
398 + einfo "Removing ${src}."
399 + rm -f "${src}"
400 + fi
401 + fi
402 +}
403 +
404 +pkg_config() {
405 + configure_tz_data
406 +}
407 +
408 +pkg_postinst() {
409 + configure_tz_data
410 +}