From 3294839f3472670f3d6f37f45463074fafef29e8 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 16:19:04 +0700 Subject: [PATCH] tzutils: rebuild with upstream suggestion for musl --- ...-zdump-undefined-behavior-if-USE_LTZ.patch | 135 ------------------ srcpkgs/tzutils/template | 7 +- 2 files changed, 6 insertions(+), 136 deletions(-) delete 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 deleted file mode 100644 index 352e47bb119..00000000000 --- a/srcpkgs/tzutils/patches/0001-Revert-Fix-zdump-undefined-behavior-if-USE_LTZ.patch +++ /dev/null @@ -1,135 +0,0 @@ -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 c2564c87c7a..045fc0e65f0 100644 --- a/srcpkgs/tzutils/template +++ b/srcpkgs/tzutils/template @@ -1,7 +1,7 @@ # Template file for 'tzutils' pkgname=tzutils version=2022f -revision=1 +revision=2 bootstrap=yes wrksrc="tzdb-${version}" short_desc="Time zone and daylight-saving time utilities" @@ -21,6 +21,11 @@ if [ "$XBPS_TARGET_WORDSIZE" = 32 ]; then license+=", BSD-3-Clause" fi +# https://mm.icann.org/pipermail/tz/2022-October/032154.html +if [ "$XBPS_TARGET_LIBC" = musl ]; then + CFLAGS+=" -DTM_ZONE=tm_zone -DTM_GMTOFF=tm_gmtoff" +fi + do_build() { touch version make ${makejobs} KSHELL=/bin/sh \