lol

libbsd: 0.11.7 -> unstable-2023-04-29

The current Git revision has had a lot of work done to it to
better support macOS and lets us drop the huge patch we were using
before. More macOS fixes are apparently on the way, so hopefully the
two that are still required can be dropped on the next release.

Emily e6e8e254 898a23d4

+48 -319
+15
pkgs/development/libraries/libbsd/darwin-fix-libbsd.sym.patch
··· 1 + diff --git a/src/Makefile.am b/src/Makefile.am 2 + index 9d22b00..c6848fc 100644 3 + --- a/src/Makefile.am 4 + +++ b/src/Makefile.am 5 + @@ -198,7 +198,9 @@ libbsd_ctor_a_SOURCES = \ 6 + # Generate a simple libtool symbol export list to be used as a fallback if 7 + # there is no version script support. 8 + libbsd.sym: libbsd.map 9 + - $(AM_V_GEN) $(SED) -ne 's/^[[:space:]]\{1,\}\([A-Za-z0-9_]\{1,\}\);/\1/p' libbsd.map > $@ 10 + + $(AM_V_GEN) $(SED) -ne 's/^[[:space:]]\{1,\}\([A-Za-z0-9_]\{1,\}\);/\1/p' libbsd.map \ 11 + + | grep -Ev '(group_from_gid|user_from_uid|nlist|__fdnlist|bsd_getopt)' \ 12 + + > $@ 13 + 14 + if NEED_TRANSPARENT_LIBMD 15 + TRANSPARENT_LIBMD_DEPENDS = format.ld
-309
pkgs/development/libraries/libbsd/darwin.patch
··· 1 - diff --git a/configure.ac b/configure.ac 2 - index 5b6d22b..98c449b 100644 3 - --- a/configure.ac 4 - +++ b/configure.ac 5 - @@ -145,7 +145,7 @@ AS_CASE([$host_os], 6 - AM_CONDITIONAL([OS_WINDOWS], [test "x$is_windows" = "xyes"]) 7 - 8 - # Checks for header files. 9 - -AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h pwd.h grp.h]) 10 - +AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h pwd.h grp.h nlist.h]) 11 - 12 - # Checks for typedefs, structures, and compiler characteristics. 13 - AC_C_INLINE 14 - @@ -245,7 +245,9 @@ AC_LINK_IFELSE( 15 - 16 - AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \ 17 - getauxval getentropy getexecname getline \ 18 - - pstat_getproc sysconf]) 19 - + pstat_getproc sysconf \ 20 - + strlcpy strlcat strnstr strmode fpurge \ 21 - + user_from_uid group_from_gid]) 22 - AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"]) 23 - 24 - AC_SUBST([MD5_LIBS]) 25 - diff --git a/include/bsd/grp.h b/include/bsd/grp.h 26 - index b2705e5..c9423a2 100644 27 - --- a/include/bsd/grp.h 28 - +++ b/include/bsd/grp.h 29 - @@ -44,8 +44,10 @@ 30 - __BEGIN_DECLS 31 - int 32 - gid_from_group(const char *, gid_t *); 33 - +#if !HAVE_GROUP_FROM_GID 34 - const char * 35 - group_from_gid(gid_t, int); 36 - +#endif 37 - __END_DECLS 38 - 39 - #endif 40 - diff --git a/include/bsd/pwd.h b/include/bsd/pwd.h 41 - index 798af4b..6ae5244 100644 42 - --- a/include/bsd/pwd.h 43 - +++ b/include/bsd/pwd.h 44 - @@ -44,8 +44,10 @@ 45 - __BEGIN_DECLS 46 - int 47 - uid_from_user(const char *, uid_t *); 48 - +#if !HAVE_USER_FROM_UID 49 - const char * 50 - user_from_uid(uid_t, int); 51 - +#endif 52 - __END_DECLS 53 - 54 - #endif 55 - diff --git a/include/bsd/string.h b/include/bsd/string.h 56 - index f987fee..a1e17ed 100644 57 - --- a/include/bsd/string.h 58 - +++ b/include/bsd/string.h 59 - @@ -41,10 +41,21 @@ 60 - #include <sys/types.h> 61 - 62 - __BEGIN_DECLS 63 - +#if !HAVE_STRLCPY 64 - size_t strlcpy(char *dst, const char *src, size_t siz); 65 - +#endif 66 - + 67 - +#if !HAVE_STRLCAT 68 - size_t strlcat(char *dst, const char *src, size_t siz); 69 - +#endif 70 - + 71 - +#if !HAVE_STRNSTR 72 - char *strnstr(const char *str, const char *find, size_t str_len); 73 - +#endif 74 - + 75 - +#if !HAVE_STRMODE 76 - void strmode(mode_t mode, char *str); 77 - +#endif 78 - 79 - #if !defined(__GLIBC__) || \ 80 - (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 25) || !defined(_GNU_SOURCE))) 81 - diff --git a/src/fpurge.c b/src/fpurge.c 82 - index 350f364..ff7f01e 100644 83 - --- a/src/fpurge.c 84 - +++ b/src/fpurge.c 85 - @@ -26,9 +26,10 @@ 86 - 87 - #include <errno.h> 88 - #include <stdio.h> 89 - -#include <stdio_ext.h> 90 - 91 - #ifdef HAVE___FPURGE 92 - +#include <stdio_ext.h> 93 - + 94 - int 95 - fpurge(FILE *fp) 96 - { 97 - @@ -41,6 +42,36 @@ fpurge(FILE *fp) 98 - 99 - return 0; 100 - } 101 - +/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin 1.7 */ 102 - +#elif HAVE_FPURGE 103 - +int 104 - +fpurge(FILE *fp) 105 - +{ 106 - + if (fp == NULL || fileno(fp) < 0) { 107 - + errno = EBADF; 108 - + return EOF; 109 - + } 110 - + 111 - + /* Call the system's fpurge function. */ 112 - +#undef fpurge 113 - +#if !HAVE_DECL_FPURGE 114 - + extern int fpurge (FILE *); 115 - +#endif 116 - + int result = fpurge (fp); 117 - +/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ 118 - +#if defined(__sferror) || defined(__DragonFly__) 119 - + if (result == 0) 120 - + /* Correct the invariants that fpurge broke. 121 - + <stdio.h> on BSD systems says: 122 - + "The following always hold: if _flags & __SRD, _w is 0." 123 - + If this invariant is not fulfilled and the stream is read-write but 124 - + currently reading, subsequent putc or fputc calls will write directly 125 - + into the buffer, although they shouldn't be allowed to. */ 126 - + if ((fp->_flags & __SRD) != 0) 127 - + fp->_w = 0; 128 - +#endif 129 - + return result; 130 - +} 131 - #else 132 - #error "Function fpurge() needs to be ported." 133 - #endif 134 - diff --git a/src/funopen.c b/src/funopen.c 135 - index 1e6f43a..3a3af6a 100644 136 - --- a/src/funopen.c 137 - +++ b/src/funopen.c 138 - @@ -143,6 +143,7 @@ funopen(const void *cookie, 139 - * they will not add the needed support to implement it. Just ignore this 140 - * interface there, as it has never been provided anyway. 141 - */ 142 - +#elif defined(__MACH__) 143 - #else 144 - #error "Function funopen() needs to be ported or disabled." 145 - #endif 146 - diff --git a/src/local-link.h b/src/local-link.h 147 - index 6782d9a..fb76098 100644 148 - --- a/src/local-link.h 149 - +++ b/src/local-link.h 150 - @@ -29,6 +29,12 @@ 151 - 152 - #include <sys/cdefs.h> 153 - 154 - +#ifdef __MACH__ 155 - +#define libbsd_link_warning(symbol, msg) 156 - +#define libbsd_symver_default(alias, symbol, version) 157 - +#define libbsd_symver_variant(alias, symbol, version) 158 - +#define libbsd_symver_weak(alias, symbol, version) 159 - +#else 160 - #define libbsd_link_warning(symbol, msg) \ 161 - static const char libbsd_emit_link_warning_##symbol[] \ 162 - __attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg 163 - @@ -68,3 +74,4 @@ 164 - #endif 165 - 166 - #endif 167 - +#endif 168 - diff --git a/src/nlist.c b/src/nlist.c 169 - index 1cb9d18..b476f1e 100644 170 - --- a/src/nlist.c 171 - +++ b/src/nlist.c 172 - @@ -41,6 +41,7 @@ 173 - #include <unistd.h> 174 - #include <nlist.h> 175 - 176 - +#if !HAVE_NLIST_H 177 - #include "local-elf.h" 178 - 179 - /* Note: This function is used by libkvm0, so we need to export it. 180 - @@ -277,3 +278,4 @@ nlist(const char *name, struct nlist *list) 181 - (void)close(fd); 182 - return (n); 183 - } 184 - +#endif 185 - diff --git a/src/pwcache.c b/src/pwcache.c 186 - index d54daa0..74fde9f 100644 187 - --- a/src/pwcache.c 188 - +++ b/src/pwcache.c 189 - @@ -191,6 +191,7 @@ grptb_start(void) 190 - return 0; 191 - } 192 - 193 - +#if !HAVE_USER_FROM_UID 194 - /* 195 - * user_from_uid() 196 - * caches the name (if any) for the uid. If noname clear, we always 197 - @@ -251,7 +252,9 @@ user_from_uid(uid_t uid, int noname) 198 - } 199 - return ptr->name; 200 - } 201 - +#endif 202 - 203 - +#if !HAVE_USER_FROM_UID 204 - /* 205 - * group_from_gid() 206 - * caches the name (if any) for the gid. If noname clear, we always 207 - @@ -312,6 +315,7 @@ group_from_gid(gid_t gid, int noname) 208 - } 209 - return ptr->name; 210 - } 211 - +#endif 212 - 213 - /* 214 - * uid_from_user() 215 - diff --git a/src/readpassphrase.c b/src/readpassphrase.c 216 - index f9f6195..2bc5fb4 100644 217 - --- a/src/readpassphrase.c 218 - +++ b/src/readpassphrase.c 219 - @@ -36,6 +36,14 @@ 220 - #define TCSASOFT 0 221 - #endif 222 - 223 - +#ifndef _SIGMAX 224 - +#define _SIGMAX 64 225 - +#endif 226 - + 227 - +#ifndef _NSIG 228 - +#define _NSIG (_SIGMAX + 1) 229 - +#endif 230 - + 231 - static volatile sig_atomic_t signo[_NSIG]; 232 - 233 - static void handler(int); 234 - diff --git a/src/setproctitle.c b/src/setproctitle.c 235 - index d3e1087..0e5f64c 100644 236 - --- a/src/setproctitle.c 237 - +++ b/src/setproctitle.c 238 - @@ -33,6 +33,10 @@ 239 - #include <string.h> 240 - #include "local-link.h" 241 - 242 - +#ifdef __MACH__ 243 - +extern char **environ; 244 - +#endif 245 - + 246 - static struct { 247 - /* Original value. */ 248 - const char *arg0; 249 - @@ -291,7 +295,8 @@ libbsd_symver_default(setproctitle, setproctitle_impl, LIBBSD_0.5); 250 - * in 0.5, make the implementation available in the old version as an alias 251 - * for code linking against that version, and change the default to use the 252 - * new version, so that new code depends on the implemented version. */ 253 - -#ifdef HAVE_TYPEOF 254 - +#ifdef __MACH__ 255 - +#elif defined(HAVE_TYPEOF) 256 - extern __typeof__(setproctitle_impl) 257 - setproctitle_stub 258 - __attribute__((__alias__("setproctitle_impl"))); 259 - diff --git a/src/strlcat.c b/src/strlcat.c 260 - index 14c53a1..5961c17 100644 261 - --- a/src/strlcat.c 262 - +++ b/src/strlcat.c 263 - @@ -26,6 +26,7 @@ 264 - * Returns strlen(src) + MIN(dsize, strlen(initial dst)). 265 - * If retval >= dsize, truncation occurred. 266 - */ 267 - +#if !HAVE_STRLCAT 268 - size_t 269 - strlcat(char *dst, const char *src, size_t dsize) 270 - { 271 - @@ -53,3 +54,4 @@ strlcat(char *dst, const char *src, size_t dsize) 272 - 273 - return(dlen + (src - osrc)); /* count does not include NUL */ 274 - } 275 - +#endif 276 - diff --git a/src/strlcpy.c b/src/strlcpy.c 277 - index e9a7fe4..5137acb 100644 278 - --- a/src/strlcpy.c 279 - +++ b/src/strlcpy.c 280 - @@ -24,6 +24,7 @@ 281 - * chars will be copied. Always NUL terminates (unless dsize == 0). 282 - * Returns strlen(src); if retval >= dsize, truncation occurred. 283 - */ 284 - +#if !HAVE_STRLCPY 285 - size_t 286 - strlcpy(char *dst, const char *src, size_t dsize) 287 - { 288 - @@ -48,3 +49,4 @@ strlcpy(char *dst, const char *src, size_t dsize) 289 - 290 - return(src - osrc - 1); /* count does not include NUL */ 291 - } 292 - +#endif 293 - diff --git a/src/strmode.c b/src/strmode.c 294 - index e6afde5..da680c9 100644 295 - --- a/src/strmode.c 296 - +++ b/src/strmode.c 297 - @@ -32,6 +32,7 @@ 298 - #include <sys/stat.h> 299 - #include <string.h> 300 - 301 - +#if !HAVE_STRMODE 302 - void 303 - strmode(mode_t mode, char *p) 304 - { 305 - @@ -141,3 +142,4 @@ strmode(mode_t mode, char *p) 306 - *p++ = ' '; /* will be a '+' if ACL's implemented */ 307 - *p = '\0'; 308 - } 309 - +#endif
+33 -10
pkgs/development/libraries/libbsd/default.nix
··· 1 1 { lib 2 2 , stdenv 3 - , fetchurl 3 + , fetchFromGitLab 4 + , fetchpatch 4 5 , autoreconfHook 5 6 , libmd 6 7 , gitUpdater 7 8 }: 8 9 9 - stdenv.mkDerivation rec { 10 + # Run `./get-version` for the new value when bumping the Git revision. 11 + let gitVersion = "0.11.7-55-g73b2"; in 12 + 13 + stdenv.mkDerivation { 10 14 pname = "libbsd"; 11 - version = "0.11.7"; 15 + version = "unstable-2023-04-29"; 12 16 13 - src = fetchurl { 14 - url = "https://libbsd.freedesktop.org/releases/${pname}-${version}.tar.xz"; 15 - hash = "sha256-m6oYYFnrvyXAYwjp+ZH9ox9xg8DySTGCbYOqar2KAmE="; 17 + src = fetchFromGitLab { 18 + domain = "gitlab.freedesktop.org"; 19 + owner = "libbsd"; 20 + repo = "libbsd"; 21 + rev = "73b25a8f871b3a20f6ff76679358540f95d7dbfd"; 22 + hash = "sha256-LS28taIMjRCl6xqg75eYOIrTDl8PzSa+OvrdiEOP1+U="; 16 23 }; 17 24 18 25 outputs = [ "out" "dev" "man" ]; 19 26 20 - # darwin changes configure.ac which means we need to regenerate 21 - # the configure scripts 27 + enableParallelBuilding = true; 28 + 22 29 nativeBuildInputs = [ autoreconfHook ]; 23 30 propagatedBuildInputs = [ libmd ]; 24 31 25 - patches = [ ./darwin.patch ]; 32 + patches = [ 33 + # Fix `{get,set}progname(3bsd)` conditionalization 34 + # https://gitlab.freedesktop.org/libbsd/libbsd/-/issues/24 35 + (fetchpatch { 36 + url = "https://github.com/emilazy/libbsd/commit/0381f8d92873c5a19ced3ff861ee8ffe7825953e.patch"; 37 + hash = "sha256-+RMg5eHLgC4gyX9zXM0ttNf7rd9E3UzJX/7UVCYGXx4="; 38 + }) 39 + ] ++ lib.optionals stdenv.isDarwin [ 40 + # Temporary build system hack from upstream maintainer 41 + # https://gitlab.freedesktop.org/libbsd/libbsd/-/issues/19#note_2017684 42 + ./darwin-fix-libbsd.sym.patch 43 + ]; 44 + 45 + postPatch = '' 46 + substituteInPlace configure.ac \ 47 + --replace 'm4_esyscmd([./get-version])' '[${gitVersion}]' 48 + ''; 26 49 27 50 passthru.updateScript = gitUpdater { 28 51 # No nicer place to find latest release. ··· 33 56 description = "Common functions found on BSD systems"; 34 57 homepage = "https://libbsd.freedesktop.org/"; 35 58 license = with licenses; [ beerware bsd2 bsd3 bsdOriginal isc mit ]; 36 - platforms = platforms.linux ++ platforms.darwin; 59 + platforms = platforms.unix; 37 60 maintainers = with maintainers; [ matthewbauer ]; 38 61 }; 39 62 }