Merge pull request #41320 from matthewbauer/bsd-switch

Switch Nixpkgs to using more NetBSD stuff for MUSL

authored by

John Ericson and committed by
GitHub
7a2dd975 19fa9b2e

+52 -1137
-222
pkgs/development/libraries/libbsd/cdefs.patch
··· 1 - From 11ec8f1e5dfa1c10e0c9fb94879b6f5b96ba52dd Mon Sep 17 00:00:00 2001 2 - From: Guillem Jover <guillem@hadrons.org> 3 - Date: Tue, 6 Mar 2018 01:41:35 +0100 4 - Subject: Handle systems missing <sys/cdefs.h> 5 - 6 - This is a non-portable header, and we cannot expect it to be provided by 7 - the system libc (e.g. musl). We just need and rely on declaration that 8 - we have defined ourselves in our own <bsd/sys/cdefs.h>. So we switch to 9 - only ever assume that. 10 - 11 - Fixes: https://bugs.freedesktop.org/105281 12 - --- 13 - include/bsd/libutil.h | 4 ++++ 14 - include/bsd/md5.h | 4 ++++ 15 - include/bsd/nlist.h | 4 ++++ 16 - include/bsd/readpassphrase.h | 4 ++++ 17 - include/bsd/stdlib.h | 4 ++++ 18 - include/bsd/string.h | 4 ++++ 19 - include/bsd/stringlist.h | 5 +++++ 20 - include/bsd/sys/queue.h | 4 ++++ 21 - include/bsd/sys/tree.h | 4 ++++ 22 - include/bsd/timeconv.h | 4 ++++ 23 - include/bsd/vis.h | 4 ++++ 24 - include/bsd/wchar.h | 4 ++++ 25 - 12 files changed, 49 insertions(+) 26 - 27 - diff --git a/include/bsd/libutil.h b/include/bsd/libutil.h 28 - index 45b3b15..ccca29a 100644 29 - --- a/include/bsd/libutil.h 30 - +++ b/include/bsd/libutil.h 31 - @@ -40,7 +40,11 @@ 32 - #define LIBBSD_LIBUTIL_H 33 - 34 - #include <features.h> 35 - +#ifdef LIBBSD_OVERLAY 36 - #include <sys/cdefs.h> 37 - +#else 38 - +#include <bsd/sys/cdefs.h> 39 - +#endif 40 - #include <sys/types.h> 41 - #include <stdint.h> 42 - #include <stdio.h> 43 - diff --git a/include/bsd/md5.h b/include/bsd/md5.h 44 - index 5f3ae46..bf36a30 100644 45 - --- a/include/bsd/md5.h 46 - +++ b/include/bsd/md5.h 47 - @@ -27,7 +27,11 @@ typedef struct MD5Context { 48 - uint8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */ 49 - } MD5_CTX; 50 - 51 - +#ifdef LIBBSD_OVERLAY 52 - #include <sys/cdefs.h> 53 - +#else 54 - +#include <bsd/sys/cdefs.h> 55 - +#endif 56 - #include <sys/types.h> 57 - 58 - __BEGIN_DECLS 59 - diff --git a/include/bsd/nlist.h b/include/bsd/nlist.h 60 - index cb297e8..8767117 100644 61 - --- a/include/bsd/nlist.h 62 - +++ b/include/bsd/nlist.h 63 - @@ -27,7 +27,11 @@ 64 - #ifndef LIBBSD_NLIST_H 65 - #define LIBBSD_NLIST_H 66 - 67 - +#ifdef LIBBSD_OVERLAY 68 - #include <sys/cdefs.h> 69 - +#else 70 - +#include <bsd/sys/cdefs.h> 71 - +#endif 72 - 73 - struct nlist { 74 - union { 75 - diff --git a/include/bsd/readpassphrase.h b/include/bsd/readpassphrase.h 76 - index 14744b8..5eb8021 100644 77 - --- a/include/bsd/readpassphrase.h 78 - +++ b/include/bsd/readpassphrase.h 79 - @@ -31,7 +31,11 @@ 80 - #define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */ 81 - #define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */ 82 - 83 - +#ifdef LIBBSD_OVERLAY 84 - #include <sys/cdefs.h> 85 - +#else 86 - +#include <bsd/sys/cdefs.h> 87 - +#endif 88 - #include <sys/types.h> 89 - 90 - __BEGIN_DECLS 91 - diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h 92 - index ebc9638..8d33d1f 100644 93 - --- a/include/bsd/stdlib.h 94 - +++ b/include/bsd/stdlib.h 95 - @@ -42,7 +42,11 @@ 96 - #ifndef LIBBSD_STDLIB_H 97 - #define LIBBSD_STDLIB_H 98 - 99 - +#ifdef LIBBSD_OVERLAY 100 - #include <sys/cdefs.h> 101 - +#else 102 - +#include <bsd/sys/cdefs.h> 103 - +#endif 104 - #include <sys/stat.h> 105 - #include <stdint.h> 106 - 107 - diff --git a/include/bsd/string.h b/include/bsd/string.h 108 - index 6798bf6..29097f6 100644 109 - --- a/include/bsd/string.h 110 - +++ b/include/bsd/string.h 111 - @@ -33,7 +33,11 @@ 112 - #ifndef LIBBSD_STRING_H 113 - #define LIBBSD_STRING_H 114 - 115 - +#ifdef LIBBSD_OVERLAY 116 - #include <sys/cdefs.h> 117 - +#else 118 - +#include <bsd/sys/cdefs.h> 119 - +#endif 120 - #include <sys/types.h> 121 - 122 - __BEGIN_DECLS 123 - diff --git a/include/bsd/stringlist.h b/include/bsd/stringlist.h 124 - index ff30cac..dd71496 100644 125 - --- a/include/bsd/stringlist.h 126 - +++ b/include/bsd/stringlist.h 127 - @@ -31,7 +31,12 @@ 128 - 129 - #ifndef LIBBSD_STRINGLIST_H 130 - #define LIBBSD_STRINGLIST_H 131 - + 132 - +#ifdef LIBBSD_OVERLAY 133 - #include <sys/cdefs.h> 134 - +#else 135 - +#include <bsd/sys/cdefs.h> 136 - +#endif 137 - #include <sys/types.h> 138 - 139 - /* 140 - diff --git a/include/bsd/sys/queue.h b/include/bsd/sys/queue.h 141 - index 4a94ea7..ac00026 100644 142 - --- a/include/bsd/sys/queue.h 143 - +++ b/include/bsd/sys/queue.h 144 - @@ -33,7 +33,11 @@ 145 - #ifndef LIBBSD_SYS_QUEUE_H 146 - #define LIBBSD_SYS_QUEUE_H 147 - 148 - +#ifdef LIBBSD_OVERLAY 149 - #include <sys/cdefs.h> 150 - +#else 151 - +#include <bsd/sys/cdefs.h> 152 - +#endif 153 - 154 - /* 155 - * This file defines four types of data structures: singly-linked lists, 156 - diff --git a/include/bsd/sys/tree.h b/include/bsd/sys/tree.h 157 - index 628bec0..325b382 100644 158 - --- a/include/bsd/sys/tree.h 159 - +++ b/include/bsd/sys/tree.h 160 - @@ -30,7 +30,11 @@ 161 - #ifndef LIBBSD_SYS_TREE_H 162 - #define LIBBSD_SYS_TREE_H 163 - 164 - +#ifdef LIBBSD_OVERLAY 165 - #include <sys/cdefs.h> 166 - +#else 167 - +#include <bsd/sys/cdefs.h> 168 - +#endif 169 - 170 - /* 171 - * This file defines data structures for different types of trees: 172 - diff --git a/include/bsd/timeconv.h b/include/bsd/timeconv.h 173 - index e2a2c55..a426bd3 100644 174 - --- a/include/bsd/timeconv.h 175 - +++ b/include/bsd/timeconv.h 176 - @@ -41,7 +41,11 @@ 177 - #ifndef LIBBSD_TIMECONV_H 178 - #define LIBBSD_TIMECONV_H 179 - 180 - +#ifdef LIBBSD_OVERLAY 181 - #include <sys/cdefs.h> 182 - +#else 183 - +#include <bsd/sys/cdefs.h> 184 - +#endif 185 - #include <stdint.h> 186 - #include <time.h> 187 - 188 - diff --git a/include/bsd/vis.h b/include/bsd/vis.h 189 - index 970dfdd..ab5430c 100644 190 - --- a/include/bsd/vis.h 191 - +++ b/include/bsd/vis.h 192 - @@ -72,7 +72,11 @@ 193 - */ 194 - #define UNVIS_END 1 /* no more characters */ 195 - 196 - +#ifdef LIBBSD_OVERLAY 197 - #include <sys/cdefs.h> 198 - +#else 199 - +#include <bsd/sys/cdefs.h> 200 - +#endif 201 - 202 - __BEGIN_DECLS 203 - char *vis(char *, int, int, int); 204 - diff --git a/include/bsd/wchar.h b/include/bsd/wchar.h 205 - index 33a500e..7216503 100644 206 - --- a/include/bsd/wchar.h 207 - +++ b/include/bsd/wchar.h 208 - @@ -40,7 +40,11 @@ 209 - #define LIBBSD_WCHAR_H 210 - 211 - #include <stddef.h> 212 - +#ifdef LIBBSD_OVERLAY 213 - #include <sys/cdefs.h> 214 - +#else 215 - +#include <bsd/sys/cdefs.h> 216 - +#endif 217 - #include <sys/types.h> 218 - 219 - __BEGIN_DECLS 220 - -- 221 - cgit v1.1 222 -
-703
pkgs/development/libraries/libbsd/darwin.patch
··· 1 - diff --git a/configure.ac b/configure.ac 2 - index 88ccd91..0857782 100644 3 - --- a/configure.ac 4 - +++ b/configure.ac 5 - @@ -59,7 +59,7 @@ AS_CASE([$host_os], 6 - ) 7 - 8 - # Checks for header files. 9 - -AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h]) 10 - +AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h stdio_ext.h]) 11 - 12 - # Checks for typedefs, structures, and compiler characteristics. 13 - AC_C_INLINE 14 - @@ -146,6 +146,31 @@ AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \ 15 - pstat_getproc sysconf]) 16 - AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"]) 17 - 18 - +HostOS=`echo "$host" | sed 's/.*-//'` 19 - +os_is_macosx=false 20 - +nonLinuxOS=false 21 - +AC_SUBST(HostOS) 22 - +case ${HostOS} in 23 - + darwin* | powerpc*-*-darwin* | freebsd* | netbsd* | openbsd*) 24 - + os_is_macosx=true 25 - + nonLinuxOS=true 26 - + echo HostOS="$HostOS" 27 - + ;; 28 - + *) 29 - + echo host="$host" 30 - + echo HostOS="$HostOS" 31 - + os_is_macosx=false 32 - + nonLinuxOS=false 33 - + ;; 34 - +esac 35 - +AM_CONDITIONAL([IS_DARWIN], [test x$os_is_macosx = xtrue]) 36 - +AM_COND_IF([IS_DARWIN], 37 - + [AC_DEFINE([IS_DARWIN], [1], [Get HostOS Type is Darwin])]) 38 - + 39 - +AM_CONDITIONAL([NON_LINUX], [test x$userdefine_gethostbyname_r = xtrue]) 40 - +AM_COND_IF([NON_LINUX], 41 - + [AC_DEFINE([NON_LINUX], [1], [Get HostOS Type])]) 42 - + 43 - AC_CONFIG_FILES([ 44 - Makefile 45 - include/Makefile 46 - diff --git a/include/bsd/libutil.h b/include/bsd/libutil.h 47 - index 45b3b15..d0d4043 100644 48 - --- a/include/bsd/libutil.h 49 - +++ b/include/bsd/libutil.h 50 - @@ -39,7 +39,9 @@ 51 - #ifndef LIBBSD_LIBUTIL_H 52 - #define LIBBSD_LIBUTIL_H 53 - 54 - +#ifdef HAVE_FEATURES_H 55 - #include <features.h> 56 - +#endif 57 - #include <sys/cdefs.h> 58 - #include <sys/types.h> 59 - #include <stdint.h> 60 - diff --git a/include/bsd/stdio.h b/include/bsd/stdio.h 61 - index 4b69983..c75151b 100644 62 - --- a/include/bsd/stdio.h 63 - +++ b/include/bsd/stdio.h 64 - @@ -48,12 +48,16 @@ 65 - __BEGIN_DECLS 66 - const char *fmtcheck(const char *, const char *); 67 - 68 - +#if !defined(darwin) && !defined(__APPLE__) && !defined(MACOSX) 69 - /* XXX: The function requires cooperation from the system libc to store the 70 - * line buffer in the FILE struct itself. */ 71 - char *fgetln(FILE *fp, size_t *lenp) 72 - - LIBBSD_DEPRECATED("This functions cannot be safely ported, " 73 - - "use getline(3) instead, as it is supported " 74 - - "by GNU and POSIX.1-2008."); 75 - + __attribute__((deprecated("This functions cannot be safely ported, " 76 - + "use getline(3) instead, as it is supported " 77 - + "by GNU and POSIX.1-2008."))); 78 - +#else 79 - +char *fgetln(FILE *fp, size_t *lenp); 80 - +#endif 81 - 82 - /* 83 - * Note: We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations, 84 - diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h 85 - index ebc9638..6cd7943 100644 86 - --- a/include/bsd/stdlib.h 87 - +++ b/include/bsd/stdlib.h 88 - @@ -67,9 +67,11 @@ int sradixsort(const unsigned char **base, int nmemb, 89 - const unsigned char *table, unsigned endbyte); 90 - 91 - void *reallocf(void *ptr, size_t size); 92 - -#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 26) 93 - +#if defined(_GNU_SOURCE) && defined(__GLIBC__) && defined(__GLIBC_PREREQ) 94 - +#if !__GLIBC_PREREQ(2, 26) 95 - void *reallocarray(void *ptr, size_t nmemb, size_t size); 96 - #endif 97 - +#endif 98 - 99 - long long strtonum(const char *nptr, long long minval, long long maxval, 100 - const char **errstr); 101 - diff --git a/include/bsd/string.h b/include/bsd/string.h 102 - index 6798bf6..6baaa14 100644 103 - --- a/include/bsd/string.h 104 - +++ b/include/bsd/string.h 105 - @@ -37,6 +37,12 @@ 106 - #include <sys/types.h> 107 - 108 - __BEGIN_DECLS 109 - +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX) 110 - +size_t bsd_strlcpy(char *dst, const char *src, size_t siz); 111 - +size_t bsd_strlcat(char *dst, const char *src, size_t siz); 112 - +char *bsd_strnstr(const char *str, const char *find, size_t str_len); 113 - +void bsd_strmode(mode_t mode, char *str); 114 - +#else 115 - size_t strlcpy(char *dst, const char *src, size_t siz); 116 - size_t strlcat(char *dst, const char *src, size_t siz); 117 - char *strnstr(const char *str, const char *find, size_t str_len); 118 - @@ -45,6 +51,7 @@ void strmode(mode_t mode, char *str); 119 - #if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 25) 120 - void explicit_bzero(void *buf, size_t len); 121 - #endif 122 - +#endif 123 - __END_DECLS 124 - 125 - #endif 126 - diff --git a/src/Makefile.am b/src/Makefile.am 127 - index ad83dbf..0f2a7ee 100644 128 - --- a/src/Makefile.am 129 - +++ b/src/Makefile.am 130 - @@ -54,17 +54,21 @@ libbsd_la_DEPENDENCIES = \ 131 - libbsd.map 132 - libbsd_la_LIBADD = \ 133 - $(CLOCK_GETTIME_LIBS) 134 - + 135 - +if IS_DARWIN 136 - +libbsd_la_LDFLAGS = \ 137 - + -Wl \ 138 - + -version-number $(LIBBSD_ABI) 139 - +else 140 - libbsd_la_LDFLAGS = \ 141 - -Wl,--version-script=$(srcdir)/libbsd.map \ 142 - -version-number $(LIBBSD_ABI) 143 - +endif 144 - + 145 - libbsd_la_SOURCES = \ 146 - arc4random.c \ 147 - - arc4random.h \ 148 - - arc4random_unix.h \ 149 - - arc4random_openbsd.h \ 150 - arc4random_uniform.c \ 151 - bsd_getopt.c \ 152 - - chacha_private.h \ 153 - closefrom.c \ 154 - dehumanize_number.c \ 155 - err.c \ 156 - @@ -117,6 +121,15 @@ libbsd_la_SOURCES += \ 157 - $(nil) 158 - endif 159 - 160 - +noinst_HEADERS = \ 161 - + arc4random.h \ 162 - + arc4random_bsd.h \ 163 - + arc4random_linux.h \ 164 - + arc4random_unix.h \ 165 - + arc4random_osx.h \ 166 - + arc4random_openbsd.h \ 167 - + chacha_private.h 168 - + 169 - libbsd_ctor_a_SOURCES = \ 170 - setproctitle_ctor.c \ 171 - $(nil) 172 - diff --git a/src/arc4random_bsd.h b/src/arc4random_bsd.h 173 - new file mode 100644 174 - index 0000000..ece2f85 175 - --- /dev/null 176 - +++ b/src/arc4random_bsd.h 177 - @@ -0,0 +1,86 @@ 178 - +/* $OpenBSD: arc4random_freebsd.h,v 1.2 2015/01/15 06:57:18 deraadt Exp $ */ 179 - + 180 - +/* 181 - + * Copyright (c) 1996, David Mazieres <dm@uun.org> 182 - + * Copyright (c) 2008, Damien Miller <djm@openbsd.org> 183 - + * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> 184 - + * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> 185 - + * 186 - + * Permission to use, copy, modify, and distribute this software for any 187 - + * purpose with or without fee is hereby granted, provided that the above 188 - + * copyright notice and this permission notice appear in all copies. 189 - + * 190 - + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 191 - + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 192 - + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 193 - + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 194 - + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 195 - + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 196 - + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 197 - + */ 198 - + 199 - +/* 200 - + * Stub functions for portability. 201 - + */ 202 - + 203 - +#include <sys/mman.h> 204 - + 205 - +#include <pthread.h> 206 - +#include <signal.h> 207 - + 208 - +static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; 209 - +#define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) 210 - +#define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) 211 - + 212 - +/* 213 - + * Unfortunately, pthread_atfork() is broken on FreeBSD (at least 9 and 10) if 214 - + * a program does not link to -lthr. Callbacks registered with pthread_atfork() 215 - + * appear to fail silently. So, it is not always possible to detect a PID 216 - + * wraparound. 217 - + */ 218 - +#define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) 219 - + 220 - +static inline void 221 - +_getentropy_fail(void) 222 - +{ 223 - + raise(SIGKILL); 224 - +} 225 - + 226 - +static volatile sig_atomic_t _rs_forked; 227 - + 228 - +static inline void 229 - +_rs_forkhandler(void) 230 - +{ 231 - + _rs_forked = 1; 232 - +} 233 - + 234 - +static inline void 235 - +_rs_forkdetect(void) 236 - +{ 237 - + static pid_t _rs_pid = 0; 238 - + pid_t pid = getpid(); 239 - + 240 - + if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { 241 - + _rs_pid = pid; 242 - + _rs_forked = 0; 243 - + if (rs) 244 - + memset(rs, 0, sizeof(*rs)); 245 - + } 246 - +} 247 - + 248 - +static inline int 249 - +_rs_allocate(struct _rs **rsp, struct _rsx **rsxp) 250 - +{ 251 - + if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, 252 - + MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) 253 - + return (-1); 254 - + 255 - + if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, 256 - + MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { 257 - + munmap(*rsp, sizeof(**rsp)); 258 - + return (-1); 259 - + } 260 - + 261 - + _ARC4_ATFORK(_rs_forkhandler); 262 - + return (0); 263 - +} 264 - diff --git a/src/arc4random_linux.h b/src/arc4random_linux.h 265 - new file mode 100644 266 - index 0000000..d61a8db 267 - --- /dev/null 268 - +++ b/src/arc4random_linux.h 269 - @@ -0,0 +1,86 @@ 270 - +/* $OpenBSD: arc4random_linux.h,v 1.8 2014/08/13 06:04:10 deraadt Exp $ */ 271 - + 272 - +/* 273 - + * Copyright (c) 1996, David Mazieres <dm@uun.org> 274 - + * Copyright (c) 2008, Damien Miller <djm@openbsd.org> 275 - + * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> 276 - + * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> 277 - + * 278 - + * Permission to use, copy, modify, and distribute this software for any 279 - + * purpose with or without fee is hereby granted, provided that the above 280 - + * copyright notice and this permission notice appear in all copies. 281 - + * 282 - + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 283 - + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 284 - + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 285 - + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 286 - + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 287 - + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 288 - + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 289 - + */ 290 - + 291 - +/* 292 - + * Stub functions for portability. 293 - + */ 294 - + 295 - +#include <sys/mman.h> 296 - + 297 - +#include <pthread.h> 298 - +#include <signal.h> 299 - + 300 - +static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; 301 - +#define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) 302 - +#define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) 303 - + 304 - +#ifdef __GLIBC__ 305 - +extern void *__dso_handle; 306 - +extern int __register_atfork(void (*)(void), void(*)(void), void (*)(void), void *); 307 - +#define _ARC4_ATFORK(f) __register_atfork(NULL, NULL, (f), __dso_handle) 308 - +#else 309 - +#define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) 310 - +#endif 311 - + 312 - +static inline void 313 - +_getentropy_fail(void) 314 - +{ 315 - + raise(SIGKILL); 316 - +} 317 - + 318 - +static volatile sig_atomic_t _rs_forked; 319 - + 320 - +static inline void 321 - +_rs_forkhandler(void) 322 - +{ 323 - + _rs_forked = 1; 324 - +} 325 - + 326 - +static inline void 327 - +_rs_forkdetect(void) 328 - +{ 329 - + static pid_t _rs_pid = 0; 330 - + pid_t pid = getpid(); 331 - + 332 - + if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { 333 - + _rs_pid = pid; 334 - + _rs_forked = 0; 335 - + if (rs) 336 - + memset(rs, 0, sizeof(*rs)); 337 - + } 338 - +} 339 - + 340 - +static inline int 341 - +_rs_allocate(struct _rs **rsp, struct _rsx **rsxp) 342 - +{ 343 - + if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, 344 - + MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) 345 - + return (-1); 346 - + 347 - + if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, 348 - + MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { 349 - + munmap(*rsp, sizeof(**rsp)); 350 - + return (-1); 351 - + } 352 - + 353 - + _ARC4_ATFORK(_rs_forkhandler); 354 - + return (0); 355 - +} 356 - diff --git a/src/arc4random_osx.h b/src/arc4random_osx.h 357 - new file mode 100644 358 - index 0000000..14771a6 359 - --- /dev/null 360 - +++ b/src/arc4random_osx.h 361 - @@ -0,0 +1,82 @@ 362 - +/* $OpenBSD: arc4random_osx.h,v 1.10 2015/09/11 11:52:55 deraadt Exp $ */ 363 - + 364 - +/* 365 - + * Copyright (c) 1996, David Mazieres <dm@uun.org> 366 - + * Copyright (c) 2008, Damien Miller <djm@openbsd.org> 367 - + * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> 368 - + * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> 369 - + * 370 - + * Permission to use, copy, modify, and distribute this software for any 371 - + * purpose with or without fee is hereby granted, provided that the above 372 - + * copyright notice and this permission notice appear in all copies. 373 - + * 374 - + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 375 - + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 376 - + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 377 - + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 378 - + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 379 - + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 380 - + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 381 - + */ 382 - + 383 - +/* 384 - + * Stub functions for portability. 385 - + */ 386 - + 387 - +#include <sys/mman.h> 388 - + 389 - +#include <unistd.h> 390 - +#include <pthread.h> 391 - +#include <signal.h> 392 - + 393 - +static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; 394 - +#define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) 395 - +#define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) 396 - + 397 - +#define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) 398 - + 399 - +static inline void 400 - +_getentropy_fail(void) 401 - +{ 402 - + raise(SIGKILL); 403 - +} 404 - + 405 - +static volatile sig_atomic_t _rs_forked; 406 - + 407 - +static inline void 408 - +_rs_forkhandler(void) 409 - +{ 410 - + _rs_forked = 1; 411 - +} 412 - + 413 - +static inline void 414 - +_rs_forkdetect(void) 415 - +{ 416 - + static pid_t _rs_pid = 0; 417 - + pid_t pid = getpid(); 418 - + 419 - + if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { 420 - + _rs_pid = pid; 421 - + _rs_forked = 0; 422 - + if (rs) 423 - + memset(rs, 0, sizeof(*rs)); 424 - + } 425 - +} 426 - + 427 - +static inline int 428 - +_rs_allocate(struct _rs **rsp, struct _rsx **rsxp) 429 - +{ 430 - + if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, 431 - + MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) 432 - + return (-1); 433 - + 434 - + if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, 435 - + MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { 436 - + munmap(*rsp, sizeof(**rsp)); 437 - + *rsp = NULL; 438 - + return (-1); 439 - + } 440 - + 441 - + _ARC4_ATFORK(_rs_forkhandler); 442 - + return (0); 443 - +} 444 - diff --git a/src/fgetln.c b/src/fgetln.c 445 - index 4d1726e..9c73788 100644 446 - --- a/src/fgetln.c 447 - +++ b/src/fgetln.c 448 - @@ -30,7 +30,9 @@ 449 - #include <sys/types.h> 450 - #include <string.h> 451 - 452 - +#if !defined(darwin) && !defined(__APPLE__) && !defined(MACOSX) 453 - #include "local-link.h" 454 - +#endif 455 - 456 - #ifdef HAVE_GETLINE 457 - struct filebuf { 458 - @@ -75,9 +77,11 @@ fgetln(FILE *stream, size_t *len) 459 - return fb->buf; 460 - } 461 - } 462 - +#if !defined(darwin) && !defined(__APPLE__) && !defined(MACOSX) 463 - libbsd_link_warning(fgetln, 464 - "This functions cannot be safely ported, use getline(3) " 465 - "instead, as it is supported by GNU and POSIX.1-2008.") 466 - +#endif 467 - #else 468 - #error "Function fgetln() needs to be ported." 469 - #endif 470 - diff --git a/src/fpurge.c b/src/fpurge.c 471 - index 462535a..e7eb46f 100644 472 - --- a/src/fpurge.c 473 - +++ b/src/fpurge.c 474 - @@ -26,9 +26,11 @@ 475 - 476 - #include <errno.h> 477 - #include <stdio.h> 478 - +#if HAVE___FPURGE 479 - #include <stdio_ext.h> 480 - +#endif 481 - 482 - -#ifdef HAVE___FPURGE 483 - +#ifdef HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7 */ 484 - int 485 - fpurge(FILE *fp) 486 - { 487 - @@ -42,5 +44,55 @@ fpurge(FILE *fp) 488 - return 0; 489 - } 490 - #else 491 - -#error "Function fpurge() needs to be ported." 492 - +#define fp_ fp 493 - +//#error "Function fpurge() needs to be ported." 494 - +//#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin 1.7 */ 495 - +int 496 - +fpurge(FILE *fp) 497 - +{ 498 - + if (fp == NULL || fileno(fp) < 0) { 499 - + errno = EBADF; 500 - + return EOF; 501 - + } 502 - + 503 - + /* Call the system's fpurge function. */ 504 - +# undef fpurge 505 - +# if !HAVE_DECL_FPURGE 506 - + extern int fpurge (FILE *); 507 - +# endif 508 - + int result = fpurge (fp); 509 - +# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ 510 - + if (result == 0) 511 - + /* Correct the invariants that fpurge broke. 512 - + <stdio.h> on BSD systems says: 513 - + "The following always hold: if _flags & __SRD, _w is 0." 514 - + If this invariant is not fulfilled and the stream is read-write but 515 - + currently reading, subsequent putc or fputc calls will write directly 516 - + into the buffer, although they shouldn't be allowed to. */ 517 - + if ((fp_->_flags & __SRD) != 0) 518 - + fp_->_w = 0; 519 - +#endif 520 - + return result; 521 - +} 522 - +//#endif 523 - +#endif 524 - + 525 - +#ifdef TEST 526 - +int 527 - +main() 528 - +{ 529 - + static FILE fp_bad; 530 - + FILE *fp; 531 - + 532 - + if (fpurge(&fp_bad) == 0) 533 - + return 1; 534 - + 535 - + fp = fopen("/dev/zero", "r"); 536 - + if (fpurge(fp) < 0) 537 - + return 1; 538 - + 539 - + fclose(fp); 540 - + 541 - + return 0; 542 - +} 543 - #endif 544 - diff --git a/src/funopen.c b/src/funopen.c 545 - index 1e05c7e..75e61ea 100644 546 - --- a/src/funopen.c 547 - +++ b/src/funopen.c 548 - @@ -143,6 +143,7 @@ funopen(const void *cookie, 549 - * they will not add the needed support to implement it. Just ignore this 550 - * interface there, as it has never been provided anyway. 551 - */ 552 - +#elif defined(darwin) || defined(__APPLE__) || defined(MACOSX) 553 - #else 554 - #error "Function funopen() needs to be ported or disabled." 555 - #endif 556 - diff --git a/src/getentropy.c b/src/getentropy.c 557 - index 3f11a1e..8a23a07 100644 558 - --- a/src/getentropy.c 559 - +++ b/src/getentropy.c 560 - @@ -28,9 +28,7 @@ 561 - #include "getentropy_linux.c" 562 - #elif defined(__GNU__) 563 - #include "getentropy_hurd.c" 564 - -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) 565 - -#include "getentropy_bsd.c" 566 - -#elif defined(__NetBSD__) 567 - +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) 568 - #include "getentropy_bsd.c" 569 - #elif defined(__sun) 570 - #include "getentropy_solaris.c" 571 - diff --git a/src/hash/sha512.h b/src/hash/sha512.h 572 - index 4f368a1..ab22fc1 100644 573 - --- a/src/hash/sha512.h 574 - +++ b/src/hash/sha512.h 575 - @@ -29,7 +29,11 @@ 576 - #ifndef _SHA512_H_ 577 - #define _SHA512_H_ 578 - 579 - +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX) 580 - +#include <stdint.h> 581 - +#else 582 - #include <sys/types.h> 583 - +#endif 584 - 585 - #define SHA512_DIGEST_LENGTH 64 586 - 587 - diff --git a/src/hash/sha512c.c b/src/hash/sha512c.c 588 - index b3c8d5e..f69013d 100644 589 - --- a/src/hash/sha512c.c 590 - +++ b/src/hash/sha512c.c 591 - @@ -25,7 +25,13 @@ 592 - */ 593 - 594 - #include <sys/cdefs.h> 595 - +__FBSDID("$FreeBSD$"); 596 - + 597 - +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX) 598 - +#include <machine/endian.h> 599 - +#else 600 - #include <sys/endian.h> 601 - +#endif 602 - #include <sys/types.h> 603 - 604 - #include <string.h> 605 - diff --git a/src/nlist.c b/src/nlist.c 606 - index 0932f59..598a329 100644 607 - --- a/src/nlist.c 608 - +++ b/src/nlist.c 609 - @@ -27,6 +27,10 @@ 610 - * SUCH DAMAGE. 611 - */ 612 - 613 - +#if !defined(darwin) && !defined(__APPLE__) && !defined(MACOSX) 614 - +#if defined(LIBC_SCCS) && !defined(lint) 615 - +static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93"; 616 - +#endif /* LIBC_SCCS and not lint */ 617 - #include <sys/cdefs.h> 618 - 619 - #include <sys/param.h> 620 - @@ -265,3 +269,4 @@ nlist(const char *name, struct nlist *list) 621 - (void)close(fd); 622 - return (n); 623 - } 624 - +#endif /* _NLIST_DO_ELF */ 625 - diff --git a/src/setproctitle.c b/src/setproctitle.c 626 - index 038ac7d..d0ef01b 100644 627 - --- a/src/setproctitle.c 628 - +++ b/src/setproctitle.c 629 - @@ -32,6 +32,11 @@ 630 - #include <unistd.h> 631 - #include <string.h> 632 - 633 - +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX) 634 - +#define __asm__(x) 635 - +extern char **environ; 636 - +#endif 637 - + 638 - static struct { 639 - /* Original value. */ 640 - const char *arg0; 641 - @@ -287,7 +292,14 @@ __asm__(".symver setproctitle_impl,setproctitle@@LIBBSD_0.5"); 642 - * for code linking against that version, and change the default to use the 643 - * new version, so that new code depends on the implemented version. */ 644 - #ifdef HAVE_TYPEOF 645 - +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX) 646 - +// 647 - +// HACK: even weak aliasing breaks in clang so just comment this out for now 648 - +// 649 - +// extern typeof(setproctitle_impl) setproctitle_stub __attribute__((weak, alias("setproctitle_impl"))); 650 - +#else 651 - extern typeof(setproctitle_impl) setproctitle_stub __attribute__((alias("setproctitle_impl"))); 652 - +#endif 653 - #else 654 - void setproctitle_stub(const char *fmt, ...) 655 - __attribute__((alias("setproctitle_impl"))); 656 - diff --git a/src/strlcat.c b/src/strlcat.c 657 - index 14c53a1..e01cb60 100644 658 - --- a/src/strlcat.c 659 - +++ b/src/strlcat.c 660 - @@ -27,7 +27,11 @@ 661 - * If retval >= dsize, truncation occurred. 662 - */ 663 - size_t 664 - +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX) 665 - +bsd_strlcat(char *dst, const char *src, size_t dsize) 666 - +#else 667 - strlcat(char *dst, const char *src, size_t dsize) 668 - +#endif 669 - { 670 - const char *odst = dst; 671 - const char *osrc = src; 672 - diff --git a/src/strlcpy.c b/src/strlcpy.c 673 - index e9a7fe4..10a855f 100644 674 - --- a/src/strlcpy.c 675 - +++ b/src/strlcpy.c 676 - @@ -25,7 +25,11 @@ 677 - * Returns strlen(src); if retval >= dsize, truncation occurred. 678 - */ 679 - size_t 680 - +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX) 681 - +bsd_strlcpy(char *dst, const char *src, size_t dsize) 682 - +#else 683 - strlcpy(char *dst, const char *src, size_t dsize) 684 - +#endif 685 - { 686 - const char *osrc = src; 687 - size_t nleft = dsize; 688 - diff --git a/src/strmode.c b/src/strmode.c 689 - index e6afde5..c463243 100644 690 - --- a/src/strmode.c 691 - +++ b/src/strmode.c 692 - @@ -33,7 +33,11 @@ 693 - #include <string.h> 694 - 695 - void 696 - +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX) 697 - +bsd_strmode(mode_t mode, char *p) 698 - +#else 699 - strmode(mode_t mode, char *p) 700 - +#endif 701 - { 702 - /* print type */ 703 - switch (mode & S_IFMT) {
-34
pkgs/development/libraries/libbsd/default.nix
··· 1 - { stdenv, fetchurl, autoreconfHook }: 2 - 3 - stdenv.mkDerivation rec { 4 - name = "libbsd-${version}"; 5 - version = "0.8.7"; 6 - 7 - src = fetchurl { 8 - url = "http://libbsd.freedesktop.org/releases/${name}.tar.xz"; 9 - sha256 = "0c9bl49zs0xdddcwj5dh0lay9sxi2m1yi74848g8p87mb87g2j7m"; 10 - }; 11 - 12 - # darwin changes configure.ac which means we need to regenerate 13 - # the configure scripts 14 - nativeBuildInputs = [ autoreconfHook ]; 15 - 16 - patches = stdenv.lib.optional stdenv.isDarwin ./darwin.patch 17 - # Suitable for all, but limited to musl to avoid rebuilds 18 - ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ 19 - # https://cgit.freedesktop.org/libbsd/commit/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490 20 - ./non-glibc.patch 21 - # https://cgit.freedesktop.org/libbsd/commit/?id=11ec8f1e5dfa1c10e0c9fb94879b6f5b96ba52dd 22 - ./cdefs.patch 23 - # https://cgit.freedesktop.org/libbsd/commit/?id=b20272f5a966333b49fdf2bda797e2a9f0227404 24 - ./features.patch 25 - ]; 26 - 27 - meta = with stdenv.lib; { 28 - description = "Common functions found on BSD systems"; 29 - homepage = https://libbsd.freedesktop.org/; 30 - license = licenses.bsd3; 31 - platforms = platforms.linux ++ platforms.darwin; 32 - maintainers = with maintainers; [ matthewbauer ]; 33 - }; 34 - }
-26
pkgs/development/libraries/libbsd/features.patch
··· 1 - From b20272f5a966333b49fdf2bda797e2a9f0227404 Mon Sep 17 00:00:00 2001 2 - From: Guillem Jover <guillem@hadrons.org> 3 - Date: Tue, 6 Mar 2018 01:42:52 +0100 4 - Subject: Remove <features.h> inclusion from <bsd/libutil.h> 5 - 6 - This is a non-portable header, and we should not assume it is present. 7 - Let the first system header pull it in if needed. 8 - --- 9 - include/bsd/libutil.h | 1 - 10 - 1 file changed, 1 deletion(-) 11 - 12 - diff --git a/include/bsd/libutil.h b/include/bsd/libutil.h 13 - index ccca29a..e5f148a 100644 14 - --- a/include/bsd/libutil.h 15 - +++ b/include/bsd/libutil.h 16 - @@ -39,7 +39,6 @@ 17 - #ifndef LIBBSD_LIBUTIL_H 18 - #define LIBBSD_LIBUTIL_H 19 - 20 - -#include <features.h> 21 - #ifdef LIBBSD_OVERLAY 22 - #include <sys/cdefs.h> 23 - #else 24 - -- 25 - cgit v1.1 26 -
-74
pkgs/development/libraries/libbsd/non-glibc.patch
··· 1 - From 1f8a3f7bccfc84b195218ad0086ebd57049c3490 Mon Sep 17 00:00:00 2001 2 - From: Guillem Jover <guillem@hadrons.org> 3 - Date: Tue, 6 Mar 2018 01:39:45 +0100 4 - Subject: Fix function declaration protection for glibc already providing them 5 - MIME-Version: 1.0 6 - Content-Type: text/plain; charset=UTF-8 7 - Content-Transfer-Encoding: 8bit 8 - 9 - On non-glibc based systems we cannot unconditionally use the 10 - __GLIBC_PREREQ macro as it gets expanded before evaluation. Instead, 11 - if it is undefined, define it to 0. 12 - 13 - We should also always declare these functions on non-glibc based 14 - systems. And on systems with a new enough glibc, which provides these 15 - functions, we should still provide the declarations if _GNU_SOURCE 16 - is *not* defined. 17 - 18 - Reported-by: Jörg Krause <joerg.krause@embedded.rocks> 19 - --- 20 - include/bsd/stdlib.h | 3 ++- 21 - include/bsd/string.h | 3 ++- 22 - include/bsd/sys/cdefs.h | 8 ++++++++ 23 - 3 files changed, 12 insertions(+), 2 deletions(-) 24 - 25 - diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h 26 - index 8d33d1f..a5b063c 100644 27 - --- a/include/bsd/stdlib.h 28 - +++ b/include/bsd/stdlib.h 29 - @@ -71,7 +71,8 @@ int sradixsort(const unsigned char **base, int nmemb, 30 - const unsigned char *table, unsigned endbyte); 31 - 32 - void *reallocf(void *ptr, size_t size); 33 - -#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 26) 34 - +#if !defined(__GLIBC__) || \ 35 - + (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 26) || !defined(_GNU_SOURCE))) 36 - void *reallocarray(void *ptr, size_t nmemb, size_t size); 37 - #endif 38 - 39 - diff --git a/include/bsd/string.h b/include/bsd/string.h 40 - index 29097f6..f987fee 100644 41 - --- a/include/bsd/string.h 42 - +++ b/include/bsd/string.h 43 - @@ -46,7 +46,8 @@ size_t strlcat(char *dst, const char *src, size_t siz); 44 - char *strnstr(const char *str, const char *find, size_t str_len); 45 - void strmode(mode_t mode, char *str); 46 - 47 - -#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 25) 48 - +#if !defined(__GLIBC__) || \ 49 - + (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 25) || !defined(_GNU_SOURCE))) 50 - void explicit_bzero(void *buf, size_t len); 51 - #endif 52 - __END_DECLS 53 - diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h 54 - index b4c8f30..d1cc419 100644 55 - --- a/include/bsd/sys/cdefs.h 56 - +++ b/include/bsd/sys/cdefs.h 57 - @@ -59,6 +59,14 @@ 58 - #endif 59 - 60 - /* 61 - + * On non-glibc based systems, we cannot unconditionally use the 62 - + * __GLIBC_PREREQ macro as it gets expanded before evaluation. 63 - + */ 64 - +#ifndef __GLIBC_PREREQ 65 - +#define __GLIBC_PREREQ(maj, min) 0 66 - +#endif 67 - + 68 - +/* 69 - * Some kFreeBSD headers expect those macros to be set for sanity checks. 70 - */ 71 - #ifndef _SYS_CDEFS_H_ 72 - -- 73 - cgit v1.1 74 -
+18
pkgs/os-specific/bsd/netbsd/compat.patch
··· 1 + diff -u -r1.35.2.1 nbtool_config.h.in 2 + --- a/nbtool_config.h.in 22 Apr 2015 07:18:58 -0000 1.35.2.1 3 + +++ b/nbtool_config.h.in 31 May 2018 01:46:53 -0000 4 + @@ -680,5 +680,14 @@ 5 + /* Define if you have u_int8_t, but not uint8_t. */ 6 + #undef uint8_t 7 + 8 + +#ifdef __cplusplus 9 + +extern "C" { 10 + +#endif 11 + + 12 + #include "compat_defs.h" 13 + + 14 + +#ifdef __cplusplus 15 + +} 16 + +#endif 17 + + 18 + #endif /* !__NETBSD_NBTOOL_CONFIG_H__ */
+9 -1
pkgs/os-specific/bsd/netbsd/default.nix
··· 162 162 extraPaths = [ make.src ] ++ make.extraPaths; 163 163 }; 164 164 165 - compat = netBSDDerivation { 165 + compat = netBSDDerivation rec { 166 166 path = "tools/compat"; 167 167 sha256 = "17phkfafybxwhzng44k5bhmag6i55br53ky1nwcmw583kg2fa86z"; 168 168 version = "7.1.2"; ··· 181 181 makeFlags = [ "INSTALL=${coreutils}/bin/install" ]; 182 182 installFlags = []; 183 183 RENAME = "-D"; 184 + 185 + patches = [ ./compat.patch ]; 184 186 185 187 postInstall = '' 186 188 mv $out/include/compat/* $out/include ··· 203 205 install -D $NETBSDSRCDIR/include/rpc/types.h $out/include/rpc/types.h 204 206 install -D $NETBSDSRCDIR/include/utmpx.h $out/include/utmpx.h 205 207 install -D $NETBSDSRCDIR/include/tzfile.h $out/include/tzfile.h 208 + install -D $NETBSDSRCDIR/sys/sys/tree.h $out/include/sys/tree.h 209 + 210 + mkdir -p $out/lib/pkgconfig 211 + substitute ${./libbsd-overlay.pc} $out/lib/pkgconfig/libbsd-overlay.pc \ 212 + --subst-var-by out $out \ 213 + --subst-var-by version ${version} 206 214 207 215 # Remove lingering /usr references 208 216 if [ -d $out/usr ]; then
+11
pkgs/os-specific/bsd/netbsd/libbsd-overlay.pc
··· 1 + prefix=@out@ 2 + exec_prefix=${prefix} 3 + libdir=${exec_prefix}/lib 4 + includedir=${prefix}/include 5 + 6 + Name: nbcompat 7 + Description: NetBSD compatibility framework 8 + Version: @version@ 9 + URL: https://www.netbsd.org/ 10 + Libs: -L${libdir} -lnbcompat 11 + Cflags: -I${includedir} -DHAVE_NBTOOL_CONFIG_H -include nbtool_config.h
+3 -4
pkgs/os-specific/linux/libselinux/default.nix
··· 1 1 { stdenv, fetchurl, pcre, pkgconfig, libsepol 2 2 , enablePython ? true, swig ? null, python ? null 3 - , musl-fts 3 + , fts 4 4 }: 5 5 6 6 assert enablePython -> swig != null && python != null; ··· 18 18 }; 19 19 20 20 nativeBuildInputs = [ pkgconfig ]; 21 - buildInputs = [ libsepol pcre ] 22 - ++ optionals enablePython [ swig python ] 23 - ++ optional stdenv.hostPlatform.isMusl musl-fts; 21 + buildInputs = [ libsepol pcre fts ] 22 + ++ optionals enablePython [ swig python ]; 24 23 25 24 # drop fortify here since package uses it by default, leading to compile error: 26 25 # command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
-4
pkgs/os-specific/linux/musl/fts-setup-hook.sh
··· 1 - # See pkgs/build-support/setup-hooks/role.bash 2 - getHostRole 3 - 4 - export NIX_${role_pre}LDFLAGS+=" -lfts"
-19
pkgs/os-specific/linux/musl/fts.nix
··· 1 - { stdenv, fetchFromGitHub, autoreconfHook, pkgconfig }: 2 - 3 - stdenv.mkDerivation rec { 4 - name = "musl-fts-${version}"; 5 - version = "2017-01-13"; 6 - src = fetchFromGitHub { 7 - owner = "pullmoll"; 8 - repo = "musl-fts"; 9 - rev = "0bde52df588e8969879a2cae51c3a4774ec62472"; 10 - sha256 = "1q8cpzisziysrs08b89wj0rm4p6dsyl177cclpfa0f7spjm3jg03"; 11 - }; 12 - 13 - nativeBuildInputs = [ autoreconfHook pkgconfig ]; 14 - 15 - setupHooks = [ 16 - ../../../build-support/setup-hooks/role.bash 17 - ./fts-setup-hook.sh 18 - ]; 19 - }
-19
pkgs/os-specific/linux/musl/getconf.nix
··· 1 - { stdenv, fetchurl }: 2 - 3 - stdenv.mkDerivation { 4 - name = "musl-getconf"; 5 - src = fetchurl { 6 - url = "https://raw.githubusercontent.com/alpinelinux/aports/48b16204aeeda5bc1f87e49c6b8e23d9abb07c73/main/musl/getconf.c"; 7 - sha256 = "0z14ml5343p5gapxw9fnbn2r72r7v2gk8662iifjrblh6sxhqzfq"; 8 - }; 9 - 10 - unpackPhase = ":"; 11 - 12 - buildPhase = ''$CC $src -o getconf''; 13 - installPhase = '' 14 - mkdir -p $out/bin 15 - cp getconf $out/bin/ 16 - ''; 17 - } 18 - 19 -
-18
pkgs/os-specific/linux/musl/getent.nix
··· 1 - { stdenv, fetchurl }: 2 - 3 - stdenv.mkDerivation { 4 - name = "musl-getent"; 5 - src = fetchurl { 6 - url = "https://raw.githubusercontent.com/alpinelinux/aports/89a718d88ec7466e721f3bbe9ede5ffe58061d78/main/musl/getent.c"; 7 - sha256 = "0b4jqnsmv1hjgcz7db3vd61k682aphl59c3yhwya2q7mkc6g48xk"; 8 - }; 9 - 10 - unpackPhase = ":"; 11 - 12 - buildPhase = ''$CC $src -o getent''; 13 - installPhase = '' 14 - mkdir -p $out/bin 15 - cp getent $out/bin/ 16 - ''; 17 - } 18 -
+2 -3
pkgs/tools/compression/xar/default.nix
··· 1 - { stdenv, fetchurl, libxml2, openssl, zlib, bzip2, musl-fts }: 1 + { stdenv, fetchurl, libxml2, openssl, zlib, bzip2, fts }: 2 2 3 3 stdenv.mkDerivation rec { 4 4 version = "1.6.1"; ··· 9 9 sha256 = "0ghmsbs6xwg1092v7pjcibmk5wkyifwxw6ygp08gfz25d2chhipf"; 10 10 }; 11 11 12 - buildInputs = [ libxml2 openssl zlib bzip2 ] 13 - ++ stdenv.lib.optional stdenv.hostPlatform.isMusl musl-fts; 12 + buildInputs = [ libxml2 openssl zlib bzip2 fts ]; 14 13 15 14 meta = { 16 15 homepage = https://mackyle.github.io/xar/;
+4 -5
pkgs/top-level/all-packages.nix
··· 2371 2371 2372 2372 flvstreamer = callPackage ../tools/networking/flvstreamer { }; 2373 2373 2374 - libbsd = callPackage ../development/libraries/libbsd { }; 2375 - 2376 2374 libbladeRF = callPackage ../development/libraries/libbladeRF { }; 2377 2375 2378 2376 lp_solve = callPackage ../applications/science/math/lp_solve { }; ··· 13847 13845 multipath-tools = callPackage ../os-specific/linux/multipath-tools { }; 13848 13846 13849 13847 musl = callPackage ../os-specific/linux/musl { }; 13850 - musl-fts = callPackage ../os-specific/linux/musl/fts.nix { }; 13851 - musl-getconf = callPackage ../os-specific/linux/musl/getconf.nix { }; 13852 - musl-getent = callPackage ../os-specific/linux/musl/getent.nix { }; 13853 13848 13854 13849 nettools = if stdenv.isLinux then callPackage ../os-specific/linux/net-tools { } 13855 13850 else unixtools.nettools; ··· 21466 21461 inherit (unixtools) hexdump ps logger eject umount 21467 21462 mount wall hostname more sysctl getconf 21468 21463 getent; 21464 + 21465 + fts = if hostPlatform.isMusl then netbsd.fts else null; 21466 + 21467 + libbsd = netbsd.compat; 21469 21468 21470 21469 inherit (recurseIntoAttrs (callPackages ../os-specific/bsd { })) 21471 21470 netbsd;
+5 -5
pkgs/top-level/unix-tools.nix
··· 50 50 linux = pkgs.utillinux; 51 51 }; 52 52 getconf = { 53 - linux = if hostPlatform.isMusl then pkgs.musl-getconf 54 - else lib.getBin stdenv.cc.libc; 53 + linux = if hostPlatform.libc == "glibc" then lib.getBin pkgs.glibc 54 + else pkgs.netbsd.getconf; 55 55 darwin = pkgs.darwin.system_cmds; 56 56 }; 57 57 getent = { 58 - linux = if hostPlatform.isMusl then pkgs.musl-getent 59 - # This may not be right on other platforms, but preserves existing behavior 60 - else /* if hostPlatform.libc == "glibc" then */ pkgs.glibc.bin; 58 + linux = if hostPlatform.libc == "glibc" then lib.getBin pkgs.glibc 59 + else pkgs.netbsd.getent; 60 + darwin = pkgs.netbsd.getent; 61 61 }; 62 62 getopt = { 63 63 linux = pkgs.utillinux;