From 4613dcf43a52077ac13e61cb3631aac529a739cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Sat, 29 Oct 2022 11:27:20 +0700 Subject: [PATCH] tzutils: update to 2022f. --- ...-zdump-undefined-behavior-if-USE_LTZ.patch | 135 ++++++++++++++++++ srcpkgs/tzutils/template | 6 +- 2 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 srcpkgs/tzutils/patches/0001-Revert-Fix-zdump-undefined-behavior-if-USE_LTZ.patch diff --git a/srcpkgs/tzutils/patches/0001-Revert-Fix-zdump-undefined-behavior-if-USE_LTZ.patch b/srcpkgs/tzutils/patches/0001-Revert-Fix-zdump-undefined-behavior-if-USE_LTZ.patch new file mode 100644 index 00000000000..352e47bb119 --- /dev/null +++ b/srcpkgs/tzutils/patches/0001-Revert-Fix-zdump-undefined-behavior-if-USE_LTZ.patch @@ -0,0 +1,135 @@ +Subject: [PATCH] Revert "Fix zdump undefined behavior if !USE_LTZ" + +This reverts commit fdd270534fc2e843ac24cbdd9b40cfceffcce3c7. + +Broken on musl +--- + Makefile | 1 - + NEWS | 4 ---- + private.h | 4 ---- + zdump.c | 57 +++++++++++++++++-------------------------------------- + 4 files changed, 17 insertions(+), 49 deletions(-) + +diff --git a/Makefile b/Makefile +index 34cec49d..d3cfbd07 100644 +--- a/Makefile ++++ b/Makefile +@@ -223,7 +223,6 @@ LDLIBS= + # -DHAVE_MALLOC_ERRNO=0 if malloc etc. do not set errno on failure. + # -DHAVE_POSIX_DECLS=0 if your system's include files do not declare + # functions like 'link' or variables like 'tzname' required by POSIX +-# -DHAVE_SETENV=0 if your system lacks the setenv function + # -DHAVE_SNPRINTF=0 if your system lacks the snprintf function + # -DHAVE_STDINT_H if you have a non-C99 compiler with * + # -DHAVE_STRFTIME_L if declares locale_t and strftime_l +diff --git a/NEWS b/NEWS +index 08615107..0215e2fb 100644 +--- a/NEWS ++++ b/NEWS +@@ -96,10 +96,6 @@ Release 2022f - 2022-10-28 18:04:57 -0700 + releases have been out of support since 2019. This change affects + only fat TZif files, as thin files never had the workaround. + +- zdump no longer modifies the environ vector when compiled on +- platforms lacking tm_zone or when compiled with -DUSE_LTZ=0. +- This avoid undefined behavior on POSIX platforms. +- + + Release 2022e - 2022-10-11 11:13:02 -0700 + +diff --git a/private.h b/private.h +index 18f6a055..b2faa726 100644 +--- a/private.h ++++ b/private.h +@@ -99,10 +99,6 @@ + # define HAVE_POSIX_DECLS 1 + #endif + +-#ifndef HAVE_SETENV +-# define HAVE_SETENV 1 +-#endif +- + #ifndef HAVE_STRDUP + # define HAVE_STRDUP 1 + #endif +diff --git a/zdump.c b/zdump.c +index ffb321a0..168f72a4 100644 +--- a/zdump.c ++++ b/zdump.c +@@ -228,56 +228,33 @@ mktime_z(timezone_t tz, struct tm *tmp) + static timezone_t + tzalloc(char const *val) + { +-# if HAVE_SETENV +- if (setenv("TZ", val, 1) != 0) { +- perror("setenv"); +- exit(EXIT_FAILURE); +- } +- tzset(); +- return NULL; +-# else +- enum { TZeqlen = 3 }; +- static char const TZeq[TZeqlen] = "TZ="; + static char **fakeenv; +- static size_t fakeenv0size; +- void *freeable = NULL; +- char **env = fakeenv, **initial_environ; +- size_t valsize = strlen(val) + 1; +- if (fakeenv0size < valsize) { +- char **e = environ, **to; +- ptrdiff_t initial_nenvptrs; /* Counting the trailing NULL pointer. */ ++ char **env = fakeenv; ++ char *env0; ++ if (! env) { ++ char **e = environ; ++ int to; + + while (*e++) + continue; +- initial_nenvptrs = e - environ; +- fakeenv0size = sumsize(valsize, valsize); +- fakeenv0size = max(fakeenv0size, 64); +- freeable = env; +- fakeenv = env = +- xmalloc(sumsize(sumsize(sizeof *environ, +- initial_nenvptrs * sizeof *environ), +- sumsize(TZeqlen, fakeenv0size))); +- to = env + 1; +- for (e = environ; (*to = *e); e++) +- to += strncmp(*e, TZeq, TZeqlen) != 0; +- env[0] = memcpy(to + 1, TZeq, TZeqlen); ++ env = xmalloc(sumsize(sizeof *environ, ++ (e - environ) * sizeof *environ)); ++ to = 1; ++ for (e = environ; (env[to] = *e); e++) ++ to += strncmp(*e, "TZ=", 3) != 0; + } +- memcpy(env[0] + TZeqlen, val, valsize); +- initial_environ = environ; +- environ = env; ++ env0 = xmalloc(sumsize(sizeof "TZ=", strlen(val))); ++ env[0] = strcat(strcpy(env0, "TZ="), val); ++ environ = fakeenv = env; + tzset(); +- free(freeable); +- return initial_environ; +-# endif ++ return env; + } + + static void +-tzfree(timezone_t initial_environ) ++tzfree(timezone_t env) + { +-# if !HAVE_SETENV +- environ = initial_environ; +- tzset(); +-# endif ++ environ = env + 1; ++ free(env[0]); + } + #endif /* ! USE_LOCALTIME_RZ */ + +-- +2.38.1.157.gedabe22e0a + diff --git a/srcpkgs/tzutils/template b/srcpkgs/tzutils/template index 541d51dafc9..c2564c87c7a 100644 --- a/srcpkgs/tzutils/template +++ b/srcpkgs/tzutils/template @@ -1,6 +1,6 @@ # Template file for 'tzutils' pkgname=tzutils -version=2022e +version=2022f revision=1 bootstrap=yes wrksrc="tzdb-${version}" @@ -9,7 +9,7 @@ maintainer="Đoàn Trần Công Danh " license="Public Domain" homepage="https://www.iana.org/time-zones" distfiles="https://www.iana.org/time-zones/repository/releases/tzdb-${version}.tar.lz" -checksum=4e2258a521ae0daff5a5715f9b0620eb4471bcda65397663bbd706b3eee73d62 +checksum=180343dda8b24e000d8f718ab5871efa2ec0ed7725ba9a4267b8bd36af155bc2 if [ "$CROSS_BUILD" ]; then hostmakedepends="tzutils" @@ -29,7 +29,7 @@ do_build() { } do_check() { - make ${makejobs} check + make check } do_install() {