From a0c2892c060e6302d2a77ad420f31a45a6e03c66 Mon Sep 17 00:00:00 2001 From: "D. Guthrie" Date: Sat, 1 Feb 2020 22:21:31 +0000 Subject: [PATCH 01/81] Fix mg building on darwin. I am not happy with this at all. It avoids using libbsd at all on darwin because there are conflicting header files, particularly the header string.h. Ideally that would be the thing to fix. But in the meantime, this patch should do the trick. It declares a header file apple.h, which files include if target is darwin (checks for presence of __APPLE__). This header file also references the three source files futimens.c, reallocarray.c and strtonum.c. The former and latter are from https://github.com/ibara/mg which is another portable fork, but building against more platforms. From the OpenBSD source tree is _null.h and tree.h. There is a check so that if __APPLE__ is present then it will include them from this source tree. Now,the makefile GNUMakefile will not link against libbsd on darwin, by checking the output of uname in much the same way as it did already for FreeBSD. --- .../editors/mg/darwin_no_libbsd.patch | 1402 +++++++++++++++++ pkgs/applications/editors/mg/default.nix | 13 +- 2 files changed, 1409 insertions(+), 6 deletions(-) create mode 100644 pkgs/applications/editors/mg/darwin_no_libbsd.patch diff --git a/pkgs/applications/editors/mg/darwin_no_libbsd.patch b/pkgs/applications/editors/mg/darwin_no_libbsd.patch new file mode 100644 index 00000000000..9b6df622324 --- /dev/null +++ b/pkgs/applications/editors/mg/darwin_no_libbsd.patch @@ -0,0 +1,1402 @@ +diff -Naur a/GNUmakefile b/GNUmakefile +--- a/GNUmakefile 2020-02-01 21:23:32.000000000 +0000 ++++ b/GNUmakefile 2020-02-01 21:56:01.000000000 +0000 +@@ -18,7 +18,7 @@ + STRIP= /usr/bin/strip + + UNAME:= $(shell uname) +-ifeq ($(UNAME),FreeBSD) ++ifeq ($(UNAME),Darwin) + BSD_CPPFLAGS:= + BSD_LIBS:= -lutil + else +@@ -35,11 +35,7 @@ + + CURSES_LIBS:= $(shell $(PKG_CONFIG) --libs ncurses) + ifeq ($(CURSES_LIBS),) +- $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.) +-endif +- +-ifdef STATIC +- LDFLAGS=-static -static-libgcc ++ $(error You probably need to install "libncurses5-dev" or "libnnurses6-devel" or something like that.) + endif + + CC?= gcc +@@ -47,14 +43,14 @@ + CFLAGS+= -g -Wall + CPPFLAGS= -DREGEX + CPPFLAGS+= -D_GNU_SOURCE +-CPPFLAGS+= $(BSD_CPPFLAGS) ++CPPFLAGS+= $(BSD_CPPFLAGS) -D__dead=__dead2 + LIBS= $(CURSES_LIBS) $(BSD_LIBS) + + + OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \ +- echo.o extend.o file.o fileio.o funmap.o help.o kbd.o keymap.o \ ++ echo.o extend.o file.o fileio.o funmap.o futimens.o help.o kbd.o keymap.o \ + line.o macro.o main.o match.o modes.o paragraph.o \ +- re_search.o region.o search.o spawn.o tty.o ttyio.o ttykbd.o \ ++ re_search.o reallocarray.o region.o search.o spawn.o strtonum.o tty.o ttyio.o ttykbd.o \ + undo.o util.o version.o window.o word.o yank.o + OBJS+= cmode.o cscope.o dired.o grep.o tags.o + +@@ -68,6 +64,7 @@ + + all: $(name) + ++ + $(name): $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -o $(name) $(LIBS) + +diff -Naur a/_null.h b/_null.h +--- a/_null.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/_null.h 2020-02-01 21:24:22.000000000 +0000 +@@ -0,0 +1,18 @@ ++/* $OpenBSD: _null.h,v 1.2 2016/09/09 22:07:58 millert Exp $ */ ++ ++/* ++ * Written by Todd C. Miller, September 9, 2016 ++ * Public domain. ++ */ ++ ++#ifndef NULL ++#if !defined(__cplusplus) ++#define NULL ((void *)0) ++#elif __cplusplus >= 201103L ++#define NULL nullptr ++#elif defined(__GNUG__) ++#define NULL __null ++#else ++#define NULL 0L ++#endif ++#endif +diff -Naur a/apple.h b/apple.h +--- a/apple.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/apple.h 2020-02-01 21:41:50.000000000 +0000 +@@ -0,0 +1,27 @@ ++/* ++ * Mac OS X-specific support. ++ */ ++ ++#include ++#include ++ ++#include ++#include ++ ++/* ++ * fparseln() specific operation flags. ++ */ ++#define FPARSELN_UNESCESC 0x01 ++#define FPARSELN_UNESCCONT 0x02 ++#define FPARSELN_UNESCCOMM 0x04 ++#define FPARSELN_UNESCREST 0x08 ++#define FPARSELN_UNESCALL 0x0f ++ ++/* struct stat compatibilty */ ++#define st_atim st_atimespec ++#define st_mtim st_mtimespec ++#define st_ctim st_ctimespec ++ ++extern long long strtonum(const char *, long long, long long, const char **); ++extern void *reallocarray(void *, size_t, size_t); ++extern int futimens(int, const struct timespec[2]); +diff -Naur a/autoexec.c b/autoexec.c +--- a/autoexec.c 2020-02-01 21:23:32.000000000 +0000 ++++ b/autoexec.c 2020-02-01 21:34:02.000000000 +0000 +@@ -9,6 +9,9 @@ + #include + #include + ++#if defined(__APPLE__) ++# include "apple.h" ++#endif + #include "def.h" + #include "funmap.h" + +diff -Naur a/basic.c b/basic.c +--- a/basic.c 2020-02-01 21:23:32.000000000 +0000 ++++ b/basic.c 2020-02-01 21:34:26.000000000 +0000 +@@ -19,6 +19,9 @@ + #include + #include + ++#if defined(__APPLE__) ++# include "apple.h" ++#endif + #include "def.h" + + /* +diff -Naur a/cscope.c b/cscope.c +--- a/cscope.c 2020-02-01 21:23:32.000000000 +0000 ++++ b/cscope.c 2020-02-01 21:34:59.000000000 +0000 +@@ -20,6 +20,9 @@ + #include + #include + ++#if defined(__APPLE__) ++# include "apple.h" ++#endif + #include "def.h" + + #define CSSYMBOL 0 +diff -Naur a/display.c b/display.c +--- a/display.c 2020-02-01 21:23:32.000000000 +0000 ++++ b/display.c 2020-02-01 21:34:16.000000000 +0000 +@@ -19,6 +19,9 @@ + #include + #include + ++#if defined(__APPLE__) ++# include "apple.h" ++#endif + #include "def.h" + #include "kbd.h" + +diff -Naur a/fileio.c b/fileio.c +--- a/fileio.c 2020-02-01 21:23:32.000000000 +0000 ++++ b/fileio.c 2020-02-01 21:42:18.000000000 +0000 +@@ -1,4 +1,4 @@ +-/* $OpenBSD: fileio.c,v 1.105 2018/04/13 14:11:37 florian Exp $ */ ++/* $OpenBSD: fileio.c,v 1.104 2017/05/30 07:05:22 florian Exp $ */ + + /* This file is in the public domain. */ + +@@ -22,19 +22,13 @@ + #include + #include + #include +- ++#if defined(__APPLE__) ++# include "apple.h" ++#endif + #include "def.h" + #include "kbd.h" + #include "pathnames.h" + +-#ifndef MAXNAMLEN +-#define MAXNAMLEN 255 +-#endif +- +-#ifndef DEFFILEMODE +-#define DEFFILEMODE 0666 +-#endif +- + static char *bkuplocation(const char *); + static int bkupleavetmp(const char *); + +@@ -714,7 +708,7 @@ + struct stat statbuf; + const char *cp; + char user[LOGIN_NAME_MAX], path[NFILEN]; +- char *ret; ++ char *un, *ret; + size_t ulen, plen; + + path[0] = '\0'; +@@ -733,18 +727,21 @@ + return (NULL); + return(ret); + } +- if (ulen == 0) /* ~/ or ~ */ +- pw = getpwuid(geteuid()); +- else { /* ~user/ or ~user */ ++ if (ulen == 0) { /* ~/ or ~ */ ++ if ((un = getlogin()) != NULL) ++ (void)strlcpy(user, un, sizeof(user)); ++ else ++ user[0] = '\0'; ++ } else { /* ~user/ or ~user */ + memcpy(user, &fn[1], ulen); + user[ulen] = '\0'; +- pw = getpwnam(user); + } ++ pw = getpwnam(user); + if (pw != NULL) { + plen = strlcpy(path, pw->pw_dir, sizeof(path)); + if (plen == 0 || path[plen - 1] != '/') { + if (strlcat(path, "/", sizeof(path)) >= sizeof(path)) { +- dobeep(); ++ dobeep(); + ewprintf("Path too long"); + return (NULL); + } +diff -Naur a/futimens.c b/futimens.c +--- a/futimens.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/futimens.c 2020-02-01 21:55:02.000000000 +0000 +@@ -0,0 +1,14 @@ ++/* This file is in the public domain. */ ++ ++#include ++ ++#include ++ ++int ++futimens(int fildes, const struct timespec times[2]) ++{ ++ struct timeval timevals[2]; ++ TIMESPEC_TO_TIMEVAL(&timevals[0], ×[0]); ++ TIMESPEC_TO_TIMEVAL(&timevals[1], ×[1]); ++ return futimes(fildes, timevals); ++} +diff -Naur a/grep.c b/grep.c +--- a/grep.c 2020-02-01 21:23:32.000000000 +0000 ++++ b/grep.c 2020-02-01 21:35:07.000000000 +0000 +@@ -16,6 +16,9 @@ + #include + #include + ++#if defined(__APPLE__) ++# include "apple.h" ++#endif + #include "def.h" + #include "kbd.h" + #include "funmap.h" +diff -Naur a/main.c b/main.c +--- a/main.c 2020-02-01 21:23:32.000000000 +0000 ++++ b/main.c 2020-02-01 21:34:42.000000000 +0000 +@@ -16,6 +16,9 @@ + #include + #include + ++#if defined(__APPLE__) ++# include "apple.h" ++#endif + #include "def.h" + #include "kbd.h" + #include "funmap.h" +diff -Naur a/paragraph.c b/paragraph.c +--- a/paragraph.c 2020-02-01 21:23:32.000000000 +0000 ++++ b/paragraph.c 2020-02-01 21:34:49.000000000 +0000 +@@ -14,6 +14,9 @@ + #include + #include + ++#if defined(__APPLE__) ++# include "apple.h" ++#endif + #include "def.h" + + static int fillcol = 70; +diff -Naur a/strtonum.c b/strtonum.c +--- a/strtonum.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/strtonum.c 2020-02-01 21:55:24.000000000 +0000 +@@ -0,0 +1,65 @@ ++/* $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $ */ ++ ++/* ++ * Copyright (c) 2004 Ted Unangst and Todd Miller ++ * All rights reserved. ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++#include ++ ++#define INVALID 1 ++#define TOOSMALL 2 ++#define TOOLARGE 3 ++ ++long long ++strtonum(const char *numstr, long long minval, long long maxval, ++ const char **errstrp) ++{ ++ long long ll = 0; ++ int error = 0; ++ char *ep; ++ struct errval { ++ const char *errstr; ++ int err; ++ } ev[4] = { ++ { NULL, 0 }, ++ { "invalid", EINVAL }, ++ { "too small", ERANGE }, ++ { "too large", ERANGE }, ++ }; ++ ++ ev[0].err = errno; ++ errno = 0; ++ if (minval > maxval) { ++ error = INVALID; ++ } else { ++ ll = strtoll(numstr, &ep, 10); ++ if (numstr == ep || *ep != '\0') ++ error = INVALID; ++ else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval) ++ error = TOOSMALL; ++ else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval) ++ error = TOOLARGE; ++ } ++ if (errstrp != NULL) ++ *errstrp = ev[error].errstr; ++ errno = ev[error].err; ++ if (error) ++ ll = 0; ++ ++ return (ll); ++} +diff -Naur a/tags.c b/tags.c +--- a/tags.c 2020-02-01 21:23:32.000000000 +0000 ++++ b/tags.c 2020-02-01 21:27:56.000000000 +0000 +@@ -8,7 +8,11 @@ + + #include + #include +-#include ++#if defined(LIBBSD_OVERLAY) ++# include ++#else ++# include "tree.h" ++#endif + #include + #include + #include +@@ -18,11 +22,14 @@ + #include + #include + #include +-#if defined(LIBBSD_OVERLAY) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__GLIBC__) ++#if defined(LIBBSD_OVERLAY) || defined(__FreeBSD__) || defined(__GLIBC__) || defined(__APPLE__) + # include + #else + #include + #endif ++#if defined(__APPLE__) ++# include "apple.h" ++#endif + + #include "def.h" + +@@ -53,9 +60,6 @@ + char *pat; + }; + RB_HEAD(tagtree, ctag) tags = RB_INITIALIZER(&tags); +-#ifdef __DragonFly__ +-RB_PROTOTYPE(tagtree, ctag, entry, ctagcmp); +-#endif + RB_GENERATE(tagtree, ctag, entry, ctagcmp); + + struct tagpos { +diff -Naur a/tree.h b/tree.h +--- a/tree.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/tree.h 2020-02-01 21:25:11.000000000 +0000 +@@ -0,0 +1,1006 @@ ++/* $OpenBSD: tree.h,v 1.29 2017/07/30 19:27:20 deraadt Exp $ */ ++/* ++ * Copyright 2002 Niels Provos ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef _SYS_TREE_H_ ++#define _SYS_TREE_H_ ++ ++#include "_null.h" ++ ++/* ++ * This file defines data structures for different types of trees: ++ * splay trees and red-black trees. ++ * ++ * A splay tree is a self-organizing data structure. Every operation ++ * on the tree causes a splay to happen. The splay moves the requested ++ * node to the root of the tree and partly rebalances it. ++ * ++ * This has the benefit that request locality causes faster lookups as ++ * the requested nodes move to the top of the tree. On the other hand, ++ * every lookup causes memory writes. ++ * ++ * The Balance Theorem bounds the total access time for m operations ++ * and n inserts on an initially empty tree as O((m + n)lg n). The ++ * amortized cost for a sequence of m accesses to a splay tree is O(lg n); ++ * ++ * A red-black tree is a binary search tree with the node color as an ++ * extra attribute. It fulfills a set of conditions: ++ * - every search path from the root to a leaf consists of the ++ * same number of black nodes, ++ * - each red node (except for the root) has a black parent, ++ * - each leaf node is black. ++ * ++ * Every operation on a red-black tree is bounded as O(lg n). ++ * The maximum height of a red-black tree is 2lg (n+1). ++ */ ++ ++#define SPLAY_HEAD(name, type) \ ++struct name { \ ++ struct type *sph_root; /* root of the tree */ \ ++} ++ ++#define SPLAY_INITIALIZER(root) \ ++ { NULL } ++ ++#define SPLAY_INIT(root) do { \ ++ (root)->sph_root = NULL; \ ++} while (0) ++ ++#define SPLAY_ENTRY(type) \ ++struct { \ ++ struct type *spe_left; /* left element */ \ ++ struct type *spe_right; /* right element */ \ ++} ++ ++#define SPLAY_LEFT(elm, field) (elm)->field.spe_left ++#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right ++#define SPLAY_ROOT(head) (head)->sph_root ++#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) ++ ++/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ ++#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ ++ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ ++ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ ++ (head)->sph_root = tmp; \ ++} while (0) ++ ++#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ ++ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ ++ SPLAY_LEFT(tmp, field) = (head)->sph_root; \ ++ (head)->sph_root = tmp; \ ++} while (0) ++ ++#define SPLAY_LINKLEFT(head, tmp, field) do { \ ++ SPLAY_LEFT(tmp, field) = (head)->sph_root; \ ++ tmp = (head)->sph_root; \ ++ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ ++} while (0) ++ ++#define SPLAY_LINKRIGHT(head, tmp, field) do { \ ++ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ ++ tmp = (head)->sph_root; \ ++ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ ++} while (0) ++ ++#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ ++ SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ ++ SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ ++ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ ++ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ ++} while (0) ++ ++/* Generates prototypes and inline functions */ ++ ++#define SPLAY_PROTOTYPE(name, type, field, cmp) \ ++void name##_SPLAY(struct name *, struct type *); \ ++void name##_SPLAY_MINMAX(struct name *, int); \ ++struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ ++struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ ++ \ ++/* Finds the node with the same key as elm */ \ ++static __unused __inline struct type * \ ++name##_SPLAY_FIND(struct name *head, struct type *elm) \ ++{ \ ++ if (SPLAY_EMPTY(head)) \ ++ return(NULL); \ ++ name##_SPLAY(head, elm); \ ++ if ((cmp)(elm, (head)->sph_root) == 0) \ ++ return (head->sph_root); \ ++ return (NULL); \ ++} \ ++ \ ++static __unused __inline struct type * \ ++name##_SPLAY_NEXT(struct name *head, struct type *elm) \ ++{ \ ++ name##_SPLAY(head, elm); \ ++ if (SPLAY_RIGHT(elm, field) != NULL) { \ ++ elm = SPLAY_RIGHT(elm, field); \ ++ while (SPLAY_LEFT(elm, field) != NULL) { \ ++ elm = SPLAY_LEFT(elm, field); \ ++ } \ ++ } else \ ++ elm = NULL; \ ++ return (elm); \ ++} \ ++ \ ++static __unused __inline struct type * \ ++name##_SPLAY_MIN_MAX(struct name *head, int val) \ ++{ \ ++ name##_SPLAY_MINMAX(head, val); \ ++ return (SPLAY_ROOT(head)); \ ++} ++ ++/* Main splay operation. ++ * Moves node close to the key of elm to top ++ */ ++#define SPLAY_GENERATE(name, type, field, cmp) \ ++struct type * \ ++name##_SPLAY_INSERT(struct name *head, struct type *elm) \ ++{ \ ++ if (SPLAY_EMPTY(head)) { \ ++ SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ ++ } else { \ ++ int __comp; \ ++ name##_SPLAY(head, elm); \ ++ __comp = (cmp)(elm, (head)->sph_root); \ ++ if(__comp < 0) { \ ++ SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ ++ SPLAY_RIGHT(elm, field) = (head)->sph_root; \ ++ SPLAY_LEFT((head)->sph_root, field) = NULL; \ ++ } else if (__comp > 0) { \ ++ SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ ++ SPLAY_LEFT(elm, field) = (head)->sph_root; \ ++ SPLAY_RIGHT((head)->sph_root, field) = NULL; \ ++ } else \ ++ return ((head)->sph_root); \ ++ } \ ++ (head)->sph_root = (elm); \ ++ return (NULL); \ ++} \ ++ \ ++struct type * \ ++name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ ++{ \ ++ struct type *__tmp; \ ++ if (SPLAY_EMPTY(head)) \ ++ return (NULL); \ ++ name##_SPLAY(head, elm); \ ++ if ((cmp)(elm, (head)->sph_root) == 0) { \ ++ if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ ++ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ ++ } else { \ ++ __tmp = SPLAY_RIGHT((head)->sph_root, field); \ ++ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ ++ name##_SPLAY(head, elm); \ ++ SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ ++ } \ ++ return (elm); \ ++ } \ ++ return (NULL); \ ++} \ ++ \ ++void \ ++name##_SPLAY(struct name *head, struct type *elm) \ ++{ \ ++ struct type __node, *__left, *__right, *__tmp; \ ++ int __comp; \ ++\ ++ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ ++ __left = __right = &__node; \ ++\ ++ while ((__comp = (cmp)(elm, (head)->sph_root))) { \ ++ if (__comp < 0) { \ ++ __tmp = SPLAY_LEFT((head)->sph_root, field); \ ++ if (__tmp == NULL) \ ++ break; \ ++ if ((cmp)(elm, __tmp) < 0){ \ ++ SPLAY_ROTATE_RIGHT(head, __tmp, field); \ ++ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ ++ break; \ ++ } \ ++ SPLAY_LINKLEFT(head, __right, field); \ ++ } else if (__comp > 0) { \ ++ __tmp = SPLAY_RIGHT((head)->sph_root, field); \ ++ if (__tmp == NULL) \ ++ break; \ ++ if ((cmp)(elm, __tmp) > 0){ \ ++ SPLAY_ROTATE_LEFT(head, __tmp, field); \ ++ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ ++ break; \ ++ } \ ++ SPLAY_LINKRIGHT(head, __left, field); \ ++ } \ ++ } \ ++ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ ++} \ ++ \ ++/* Splay with either the minimum or the maximum element \ ++ * Used to find minimum or maximum element in tree. \ ++ */ \ ++void name##_SPLAY_MINMAX(struct name *head, int __comp) \ ++{ \ ++ struct type __node, *__left, *__right, *__tmp; \ ++\ ++ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ ++ __left = __right = &__node; \ ++\ ++ while (1) { \ ++ if (__comp < 0) { \ ++ __tmp = SPLAY_LEFT((head)->sph_root, field); \ ++ if (__tmp == NULL) \ ++ break; \ ++ if (__comp < 0){ \ ++ SPLAY_ROTATE_RIGHT(head, __tmp, field); \ ++ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ ++ break; \ ++ } \ ++ SPLAY_LINKLEFT(head, __right, field); \ ++ } else if (__comp > 0) { \ ++ __tmp = SPLAY_RIGHT((head)->sph_root, field); \ ++ if (__tmp == NULL) \ ++ break; \ ++ if (__comp > 0) { \ ++ SPLAY_ROTATE_LEFT(head, __tmp, field); \ ++ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ ++ break; \ ++ } \ ++ SPLAY_LINKRIGHT(head, __left, field); \ ++ } \ ++ } \ ++ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ ++} ++ ++#define SPLAY_NEGINF -1 ++#define SPLAY_INF 1 ++ ++#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) ++#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) ++#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) ++#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) ++#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ ++ : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) ++#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ ++ : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) ++ ++#define SPLAY_FOREACH(x, name, head) \ ++ for ((x) = SPLAY_MIN(name, head); \ ++ (x) != NULL; \ ++ (x) = SPLAY_NEXT(name, head, x)) ++ ++/* Macros that define a red-black tree */ ++#define RB_HEAD(name, type) \ ++struct name { \ ++ struct type *rbh_root; /* root of the tree */ \ ++} ++ ++#define RB_INITIALIZER(root) \ ++ { NULL } ++ ++#define RB_INIT(root) do { \ ++ (root)->rbh_root = NULL; \ ++} while (0) ++ ++#define RB_BLACK 0 ++#define RB_RED 1 ++#define RB_ENTRY(type) \ ++struct { \ ++ struct type *rbe_left; /* left element */ \ ++ struct type *rbe_right; /* right element */ \ ++ struct type *rbe_parent; /* parent element */ \ ++ int rbe_color; /* node color */ \ ++} ++ ++#define RB_LEFT(elm, field) (elm)->field.rbe_left ++#define RB_RIGHT(elm, field) (elm)->field.rbe_right ++#define RB_PARENT(elm, field) (elm)->field.rbe_parent ++#define RB_COLOR(elm, field) (elm)->field.rbe_color ++#define RB_ROOT(head) (head)->rbh_root ++#define RB_EMPTY(head) (RB_ROOT(head) == NULL) ++ ++#define RB_SET(elm, parent, field) do { \ ++ RB_PARENT(elm, field) = parent; \ ++ RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ ++ RB_COLOR(elm, field) = RB_RED; \ ++} while (0) ++ ++#define RB_SET_BLACKRED(black, red, field) do { \ ++ RB_COLOR(black, field) = RB_BLACK; \ ++ RB_COLOR(red, field) = RB_RED; \ ++} while (0) ++ ++#ifndef RB_AUGMENT ++#define RB_AUGMENT(x) do {} while (0) ++#endif ++ ++#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ ++ (tmp) = RB_RIGHT(elm, field); \ ++ if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field))) { \ ++ RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ ++ } \ ++ RB_AUGMENT(elm); \ ++ if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ ++ if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ ++ RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ ++ else \ ++ RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ ++ } else \ ++ (head)->rbh_root = (tmp); \ ++ RB_LEFT(tmp, field) = (elm); \ ++ RB_PARENT(elm, field) = (tmp); \ ++ RB_AUGMENT(tmp); \ ++ if ((RB_PARENT(tmp, field))) \ ++ RB_AUGMENT(RB_PARENT(tmp, field)); \ ++} while (0) ++ ++#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ ++ (tmp) = RB_LEFT(elm, field); \ ++ if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field))) { \ ++ RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ ++ } \ ++ RB_AUGMENT(elm); \ ++ if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ ++ if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ ++ RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ ++ else \ ++ RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ ++ } else \ ++ (head)->rbh_root = (tmp); \ ++ RB_RIGHT(tmp, field) = (elm); \ ++ RB_PARENT(elm, field) = (tmp); \ ++ RB_AUGMENT(tmp); \ ++ if ((RB_PARENT(tmp, field))) \ ++ RB_AUGMENT(RB_PARENT(tmp, field)); \ ++} while (0) ++ ++/* Generates prototypes and inline functions */ ++#define RB_PROTOTYPE(name, type, field, cmp) \ ++ RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) ++#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ ++ RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static) ++#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ ++attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ ++attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ ++attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ ++attr struct type *name##_RB_INSERT(struct name *, struct type *); \ ++attr struct type *name##_RB_FIND(struct name *, struct type *); \ ++attr struct type *name##_RB_NFIND(struct name *, struct type *); \ ++attr struct type *name##_RB_NEXT(struct type *); \ ++attr struct type *name##_RB_PREV(struct type *); \ ++attr struct type *name##_RB_MINMAX(struct name *, int); \ ++ \ ++ ++/* Main rb operation. ++ * Moves node close to the key of elm to top ++ */ ++#define RB_GENERATE(name, type, field, cmp) \ ++ RB_GENERATE_INTERNAL(name, type, field, cmp,) ++#define RB_GENERATE_STATIC(name, type, field, cmp) \ ++ RB_GENERATE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static) ++#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ ++attr void \ ++name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ ++{ \ ++ struct type *parent, *gparent, *tmp; \ ++ while ((parent = RB_PARENT(elm, field)) && \ ++ RB_COLOR(parent, field) == RB_RED) { \ ++ gparent = RB_PARENT(parent, field); \ ++ if (parent == RB_LEFT(gparent, field)) { \ ++ tmp = RB_RIGHT(gparent, field); \ ++ if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ ++ RB_COLOR(tmp, field) = RB_BLACK; \ ++ RB_SET_BLACKRED(parent, gparent, field);\ ++ elm = gparent; \ ++ continue; \ ++ } \ ++ if (RB_RIGHT(parent, field) == elm) { \ ++ RB_ROTATE_LEFT(head, parent, tmp, field);\ ++ tmp = parent; \ ++ parent = elm; \ ++ elm = tmp; \ ++ } \ ++ RB_SET_BLACKRED(parent, gparent, field); \ ++ RB_ROTATE_RIGHT(head, gparent, tmp, field); \ ++ } else { \ ++ tmp = RB_LEFT(gparent, field); \ ++ if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ ++ RB_COLOR(tmp, field) = RB_BLACK; \ ++ RB_SET_BLACKRED(parent, gparent, field);\ ++ elm = gparent; \ ++ continue; \ ++ } \ ++ if (RB_LEFT(parent, field) == elm) { \ ++ RB_ROTATE_RIGHT(head, parent, tmp, field);\ ++ tmp = parent; \ ++ parent = elm; \ ++ elm = tmp; \ ++ } \ ++ RB_SET_BLACKRED(parent, gparent, field); \ ++ RB_ROTATE_LEFT(head, gparent, tmp, field); \ ++ } \ ++ } \ ++ RB_COLOR(head->rbh_root, field) = RB_BLACK; \ ++} \ ++ \ ++attr void \ ++name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ ++{ \ ++ struct type *tmp; \ ++ while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ ++ elm != RB_ROOT(head)) { \ ++ if (RB_LEFT(parent, field) == elm) { \ ++ tmp = RB_RIGHT(parent, field); \ ++ if (RB_COLOR(tmp, field) == RB_RED) { \ ++ RB_SET_BLACKRED(tmp, parent, field); \ ++ RB_ROTATE_LEFT(head, parent, tmp, field);\ ++ tmp = RB_RIGHT(parent, field); \ ++ } \ ++ if ((RB_LEFT(tmp, field) == NULL || \ ++ RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ ++ (RB_RIGHT(tmp, field) == NULL || \ ++ RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ ++ RB_COLOR(tmp, field) = RB_RED; \ ++ elm = parent; \ ++ parent = RB_PARENT(elm, field); \ ++ } else { \ ++ if (RB_RIGHT(tmp, field) == NULL || \ ++ RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ ++ struct type *oleft; \ ++ if ((oleft = RB_LEFT(tmp, field)))\ ++ RB_COLOR(oleft, field) = RB_BLACK;\ ++ RB_COLOR(tmp, field) = RB_RED; \ ++ RB_ROTATE_RIGHT(head, tmp, oleft, field);\ ++ tmp = RB_RIGHT(parent, field); \ ++ } \ ++ RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ ++ RB_COLOR(parent, field) = RB_BLACK; \ ++ if (RB_RIGHT(tmp, field)) \ ++ RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\ ++ RB_ROTATE_LEFT(head, parent, tmp, field);\ ++ elm = RB_ROOT(head); \ ++ break; \ ++ } \ ++ } else { \ ++ tmp = RB_LEFT(parent, field); \ ++ if (RB_COLOR(tmp, field) == RB_RED) { \ ++ RB_SET_BLACKRED(tmp, parent, field); \ ++ RB_ROTATE_RIGHT(head, parent, tmp, field);\ ++ tmp = RB_LEFT(parent, field); \ ++ } \ ++ if ((RB_LEFT(tmp, field) == NULL || \ ++ RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ ++ (RB_RIGHT(tmp, field) == NULL || \ ++ RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ ++ RB_COLOR(tmp, field) = RB_RED; \ ++ elm = parent; \ ++ parent = RB_PARENT(elm, field); \ ++ } else { \ ++ if (RB_LEFT(tmp, field) == NULL || \ ++ RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ ++ struct type *oright; \ ++ if ((oright = RB_RIGHT(tmp, field)))\ ++ RB_COLOR(oright, field) = RB_BLACK;\ ++ RB_COLOR(tmp, field) = RB_RED; \ ++ RB_ROTATE_LEFT(head, tmp, oright, field);\ ++ tmp = RB_LEFT(parent, field); \ ++ } \ ++ RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ ++ RB_COLOR(parent, field) = RB_BLACK; \ ++ if (RB_LEFT(tmp, field)) \ ++ RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\ ++ RB_ROTATE_RIGHT(head, parent, tmp, field);\ ++ elm = RB_ROOT(head); \ ++ break; \ ++ } \ ++ } \ ++ } \ ++ if (elm) \ ++ RB_COLOR(elm, field) = RB_BLACK; \ ++} \ ++ \ ++attr struct type * \ ++name##_RB_REMOVE(struct name *head, struct type *elm) \ ++{ \ ++ struct type *child, *parent, *old = elm; \ ++ int color; \ ++ if (RB_LEFT(elm, field) == NULL) \ ++ child = RB_RIGHT(elm, field); \ ++ else if (RB_RIGHT(elm, field) == NULL) \ ++ child = RB_LEFT(elm, field); \ ++ else { \ ++ struct type *left; \ ++ elm = RB_RIGHT(elm, field); \ ++ while ((left = RB_LEFT(elm, field))) \ ++ elm = left; \ ++ child = RB_RIGHT(elm, field); \ ++ parent = RB_PARENT(elm, field); \ ++ color = RB_COLOR(elm, field); \ ++ if (child) \ ++ RB_PARENT(child, field) = parent; \ ++ if (parent) { \ ++ if (RB_LEFT(parent, field) == elm) \ ++ RB_LEFT(parent, field) = child; \ ++ else \ ++ RB_RIGHT(parent, field) = child; \ ++ RB_AUGMENT(parent); \ ++ } else \ ++ RB_ROOT(head) = child; \ ++ if (RB_PARENT(elm, field) == old) \ ++ parent = elm; \ ++ (elm)->field = (old)->field; \ ++ if (RB_PARENT(old, field)) { \ ++ if (RB_LEFT(RB_PARENT(old, field), field) == old)\ ++ RB_LEFT(RB_PARENT(old, field), field) = elm;\ ++ else \ ++ RB_RIGHT(RB_PARENT(old, field), field) = elm;\ ++ RB_AUGMENT(RB_PARENT(old, field)); \ ++ } else \ ++ RB_ROOT(head) = elm; \ ++ RB_PARENT(RB_LEFT(old, field), field) = elm; \ ++ if (RB_RIGHT(old, field)) \ ++ RB_PARENT(RB_RIGHT(old, field), field) = elm; \ ++ if (parent) { \ ++ left = parent; \ ++ do { \ ++ RB_AUGMENT(left); \ ++ } while ((left = RB_PARENT(left, field))); \ ++ } \ ++ goto color; \ ++ } \ ++ parent = RB_PARENT(elm, field); \ ++ color = RB_COLOR(elm, field); \ ++ if (child) \ ++ RB_PARENT(child, field) = parent; \ ++ if (parent) { \ ++ if (RB_LEFT(parent, field) == elm) \ ++ RB_LEFT(parent, field) = child; \ ++ else \ ++ RB_RIGHT(parent, field) = child; \ ++ RB_AUGMENT(parent); \ ++ } else \ ++ RB_ROOT(head) = child; \ ++color: \ ++ if (color == RB_BLACK) \ ++ name##_RB_REMOVE_COLOR(head, parent, child); \ ++ return (old); \ ++} \ ++ \ ++/* Inserts a node into the RB tree */ \ ++attr struct type * \ ++name##_RB_INSERT(struct name *head, struct type *elm) \ ++{ \ ++ struct type *tmp; \ ++ struct type *parent = NULL; \ ++ int comp = 0; \ ++ tmp = RB_ROOT(head); \ ++ while (tmp) { \ ++ parent = tmp; \ ++ comp = (cmp)(elm, parent); \ ++ if (comp < 0) \ ++ tmp = RB_LEFT(tmp, field); \ ++ else if (comp > 0) \ ++ tmp = RB_RIGHT(tmp, field); \ ++ else \ ++ return (tmp); \ ++ } \ ++ RB_SET(elm, parent, field); \ ++ if (parent != NULL) { \ ++ if (comp < 0) \ ++ RB_LEFT(parent, field) = elm; \ ++ else \ ++ RB_RIGHT(parent, field) = elm; \ ++ RB_AUGMENT(parent); \ ++ } else \ ++ RB_ROOT(head) = elm; \ ++ name##_RB_INSERT_COLOR(head, elm); \ ++ return (NULL); \ ++} \ ++ \ ++/* Finds the node with the same key as elm */ \ ++attr struct type * \ ++name##_RB_FIND(struct name *head, struct type *elm) \ ++{ \ ++ struct type *tmp = RB_ROOT(head); \ ++ int comp; \ ++ while (tmp) { \ ++ comp = cmp(elm, tmp); \ ++ if (comp < 0) \ ++ tmp = RB_LEFT(tmp, field); \ ++ else if (comp > 0) \ ++ tmp = RB_RIGHT(tmp, field); \ ++ else \ ++ return (tmp); \ ++ } \ ++ return (NULL); \ ++} \ ++ \ ++/* Finds the first node greater than or equal to the search key */ \ ++attr struct type * \ ++name##_RB_NFIND(struct name *head, struct type *elm) \ ++{ \ ++ struct type *tmp = RB_ROOT(head); \ ++ struct type *res = NULL; \ ++ int comp; \ ++ while (tmp) { \ ++ comp = cmp(elm, tmp); \ ++ if (comp < 0) { \ ++ res = tmp; \ ++ tmp = RB_LEFT(tmp, field); \ ++ } \ ++ else if (comp > 0) \ ++ tmp = RB_RIGHT(tmp, field); \ ++ else \ ++ return (tmp); \ ++ } \ ++ return (res); \ ++} \ ++ \ ++/* ARGSUSED */ \ ++attr struct type * \ ++name##_RB_NEXT(struct type *elm) \ ++{ \ ++ if (RB_RIGHT(elm, field)) { \ ++ elm = RB_RIGHT(elm, field); \ ++ while (RB_LEFT(elm, field)) \ ++ elm = RB_LEFT(elm, field); \ ++ } else { \ ++ if (RB_PARENT(elm, field) && \ ++ (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ ++ elm = RB_PARENT(elm, field); \ ++ else { \ ++ while (RB_PARENT(elm, field) && \ ++ (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ ++ elm = RB_PARENT(elm, field); \ ++ elm = RB_PARENT(elm, field); \ ++ } \ ++ } \ ++ return (elm); \ ++} \ ++ \ ++/* ARGSUSED */ \ ++attr struct type * \ ++name##_RB_PREV(struct type *elm) \ ++{ \ ++ if (RB_LEFT(elm, field)) { \ ++ elm = RB_LEFT(elm, field); \ ++ while (RB_RIGHT(elm, field)) \ ++ elm = RB_RIGHT(elm, field); \ ++ } else { \ ++ if (RB_PARENT(elm, field) && \ ++ (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ ++ elm = RB_PARENT(elm, field); \ ++ else { \ ++ while (RB_PARENT(elm, field) && \ ++ (elm == RB_LEFT(RB_PARENT(elm, field), field)))\ ++ elm = RB_PARENT(elm, field); \ ++ elm = RB_PARENT(elm, field); \ ++ } \ ++ } \ ++ return (elm); \ ++} \ ++ \ ++attr struct type * \ ++name##_RB_MINMAX(struct name *head, int val) \ ++{ \ ++ struct type *tmp = RB_ROOT(head); \ ++ struct type *parent = NULL; \ ++ while (tmp) { \ ++ parent = tmp; \ ++ if (val < 0) \ ++ tmp = RB_LEFT(tmp, field); \ ++ else \ ++ tmp = RB_RIGHT(tmp, field); \ ++ } \ ++ return (parent); \ ++} ++ ++#define RB_NEGINF -1 ++#define RB_INF 1 ++ ++#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) ++#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) ++#define RB_FIND(name, x, y) name##_RB_FIND(x, y) ++#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) ++#define RB_NEXT(name, x, y) name##_RB_NEXT(y) ++#define RB_PREV(name, x, y) name##_RB_PREV(y) ++#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) ++#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) ++ ++#define RB_FOREACH(x, name, head) \ ++ for ((x) = RB_MIN(name, head); \ ++ (x) != NULL; \ ++ (x) = name##_RB_NEXT(x)) ++ ++#define RB_FOREACH_SAFE(x, name, head, y) \ ++ for ((x) = RB_MIN(name, head); \ ++ ((x) != NULL) && ((y) = name##_RB_NEXT(x), 1); \ ++ (x) = (y)) ++ ++#define RB_FOREACH_REVERSE(x, name, head) \ ++ for ((x) = RB_MAX(name, head); \ ++ (x) != NULL; \ ++ (x) = name##_RB_PREV(x)) ++ ++#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ ++ for ((x) = RB_MAX(name, head); \ ++ ((x) != NULL) && ((y) = name##_RB_PREV(x), 1); \ ++ (x) = (y)) ++ ++ ++/* ++ * Copyright (c) 2016 David Gwynne ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++struct rb_type { ++ int (*t_compare)(const void *, const void *); ++ void (*t_augment)(void *); ++ unsigned int t_offset; /* offset of rb_entry in type */ ++}; ++ ++struct rb_tree { ++ struct rb_entry *rbt_root; ++}; ++ ++struct rb_entry { ++ struct rb_entry *rbt_parent; ++ struct rb_entry *rbt_left; ++ struct rb_entry *rbt_right; ++ unsigned int rbt_color; ++}; ++ ++#define RBT_HEAD(_name, _type) \ ++struct _name { \ ++ struct rb_tree rbh_root; \ ++} ++ ++#define RBT_ENTRY(_type) struct rb_entry ++ ++static inline void ++_rb_init(struct rb_tree *rbt) ++{ ++ rbt->rbt_root = NULL; ++} ++ ++static inline int ++_rb_empty(struct rb_tree *rbt) ++{ ++ return (rbt->rbt_root == NULL); ++} ++ ++void *_rb_insert(const struct rb_type *, struct rb_tree *, void *); ++void *_rb_remove(const struct rb_type *, struct rb_tree *, void *); ++void *_rb_find(const struct rb_type *, struct rb_tree *, const void *); ++void *_rb_nfind(const struct rb_type *, struct rb_tree *, const void *); ++void *_rb_root(const struct rb_type *, struct rb_tree *); ++void *_rb_min(const struct rb_type *, struct rb_tree *); ++void *_rb_max(const struct rb_type *, struct rb_tree *); ++void *_rb_next(const struct rb_type *, void *); ++void *_rb_prev(const struct rb_type *, void *); ++void *_rb_left(const struct rb_type *, void *); ++void *_rb_right(const struct rb_type *, void *); ++void *_rb_parent(const struct rb_type *, void *); ++void _rb_set_left(const struct rb_type *, void *, void *); ++void _rb_set_right(const struct rb_type *, void *, void *); ++void _rb_set_parent(const struct rb_type *, void *, void *); ++void _rb_poison(const struct rb_type *, void *, unsigned long); ++int _rb_check(const struct rb_type *, void *, unsigned long); ++ ++#define RBT_INITIALIZER(_head) { { NULL } } ++ ++#define RBT_PROTOTYPE(_name, _type, _field, _cmp) \ ++extern const struct rb_type *const _name##_RBT_TYPE; \ ++ \ ++__unused static inline void \ ++_name##_RBT_INIT(struct _name *head) \ ++{ \ ++ _rb_init(&head->rbh_root); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_INSERT(struct _name *head, struct _type *elm) \ ++{ \ ++ return _rb_insert(_name##_RBT_TYPE, &head->rbh_root, elm); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_REMOVE(struct _name *head, struct _type *elm) \ ++{ \ ++ return _rb_remove(_name##_RBT_TYPE, &head->rbh_root, elm); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_FIND(struct _name *head, const struct _type *key) \ ++{ \ ++ return _rb_find(_name##_RBT_TYPE, &head->rbh_root, key); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_NFIND(struct _name *head, const struct _type *key) \ ++{ \ ++ return _rb_nfind(_name##_RBT_TYPE, &head->rbh_root, key); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_ROOT(struct _name *head) \ ++{ \ ++ return _rb_root(_name##_RBT_TYPE, &head->rbh_root); \ ++} \ ++ \ ++__unused static inline int \ ++_name##_RBT_EMPTY(struct _name *head) \ ++{ \ ++ return _rb_empty(&head->rbh_root); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_MIN(struct _name *head) \ ++{ \ ++ return _rb_min(_name##_RBT_TYPE, &head->rbh_root); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_MAX(struct _name *head) \ ++{ \ ++ return _rb_max(_name##_RBT_TYPE, &head->rbh_root); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_NEXT(struct _type *elm) \ ++{ \ ++ return _rb_next(_name##_RBT_TYPE, elm); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_PREV(struct _type *elm) \ ++{ \ ++ return _rb_prev(_name##_RBT_TYPE, elm); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_LEFT(struct _type *elm) \ ++{ \ ++ return _rb_left(_name##_RBT_TYPE, elm); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_RIGHT(struct _type *elm) \ ++{ \ ++ return _rb_right(_name##_RBT_TYPE, elm); \ ++} \ ++ \ ++__unused static inline struct _type * \ ++_name##_RBT_PARENT(struct _type *elm) \ ++{ \ ++ return _rb_parent(_name##_RBT_TYPE, elm); \ ++} \ ++ \ ++__unused static inline void \ ++_name##_RBT_SET_LEFT(struct _type *elm, struct _type *left) \ ++{ \ ++ return _rb_set_left(_name##_RBT_TYPE, elm, left); \ ++} \ ++ \ ++__unused static inline void \ ++_name##_RBT_SET_RIGHT(struct _type *elm, struct _type *right) \ ++{ \ ++ return _rb_set_right(_name##_RBT_TYPE, elm, right); \ ++} \ ++ \ ++__unused static inline void \ ++_name##_RBT_SET_PARENT(struct _type *elm, struct _type *parent) \ ++{ \ ++ return _rb_set_parent(_name##_RBT_TYPE, elm, parent); \ ++} \ ++ \ ++__unused static inline void \ ++_name##_RBT_POISON(struct _type *elm, unsigned long poison) \ ++{ \ ++ return _rb_poison(_name##_RBT_TYPE, elm, poison); \ ++} \ ++ \ ++__unused static inline int \ ++_name##_RBT_CHECK(struct _type *elm, unsigned long poison) \ ++{ \ ++ return _rb_check(_name##_RBT_TYPE, elm, poison); \ ++} ++ ++#define RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug) \ ++static int \ ++_name##_RBT_COMPARE(const void *lptr, const void *rptr) \ ++{ \ ++ const struct _type *l = lptr, *r = rptr; \ ++ return _cmp(l, r); \ ++} \ ++static const struct rb_type _name##_RBT_INFO = { \ ++ _name##_RBT_COMPARE, \ ++ _aug, \ ++ offsetof(struct _type, _field), \ ++}; \ ++const struct rb_type *const _name##_RBT_TYPE = &_name##_RBT_INFO ++ ++#define RBT_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug) \ ++static void \ ++_name##_RBT_AUGMENT(void *ptr) \ ++{ \ ++ struct _type *p = ptr; \ ++ return _aug(p); \ ++} \ ++RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RBT_AUGMENT) ++ ++#define RBT_GENERATE(_name, _type, _field, _cmp) \ ++ RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL) ++ ++#define RBT_INIT(_name, _head) _name##_RBT_INIT(_head) ++#define RBT_INSERT(_name, _head, _elm) _name##_RBT_INSERT(_head, _elm) ++#define RBT_REMOVE(_name, _head, _elm) _name##_RBT_REMOVE(_head, _elm) ++#define RBT_FIND(_name, _head, _key) _name##_RBT_FIND(_head, _key) ++#define RBT_NFIND(_name, _head, _key) _name##_RBT_NFIND(_head, _key) ++#define RBT_ROOT(_name, _head) _name##_RBT_ROOT(_head) ++#define RBT_EMPTY(_name, _head) _name##_RBT_EMPTY(_head) ++#define RBT_MIN(_name, _head) _name##_RBT_MIN(_head) ++#define RBT_MAX(_name, _head) _name##_RBT_MAX(_head) ++#define RBT_NEXT(_name, _elm) _name##_RBT_NEXT(_elm) ++#define RBT_PREV(_name, _elm) _name##_RBT_PREV(_elm) ++#define RBT_LEFT(_name, _elm) _name##_RBT_LEFT(_elm) ++#define RBT_RIGHT(_name, _elm) _name##_RBT_RIGHT(_elm) ++#define RBT_PARENT(_name, _elm) _name##_RBT_PARENT(_elm) ++#define RBT_SET_LEFT(_name, _elm, _l) _name##_RBT_SET_LEFT(_elm, _l) ++#define RBT_SET_RIGHT(_name, _elm, _r) _name##_RBT_SET_RIGHT(_elm, _r) ++#define RBT_SET_PARENT(_name, _elm, _p) _name##_RBT_SET_PARENT(_elm, _p) ++#define RBT_POISON(_name, _elm, _p) _name##_RBT_POISON(_elm, _p) ++#define RBT_CHECK(_name, _elm, _p) _name##_RBT_CHECK(_elm, _p) ++ ++#define RBT_FOREACH(_e, _name, _head) \ ++ for ((_e) = RBT_MIN(_name, (_head)); \ ++ (_e) != NULL; \ ++ (_e) = RBT_NEXT(_name, (_e))) ++ ++#define RBT_FOREACH_SAFE(_e, _name, _head, _n) \ ++ for ((_e) = RBT_MIN(_name, (_head)); \ ++ (_e) != NULL && ((_n) = RBT_NEXT(_name, (_e)), 1); \ ++ (_e) = (_n)) ++ ++#define RBT_FOREACH_REVERSE(_e, _name, _head) \ ++ for ((_e) = RBT_MAX(_name, (_head)); \ ++ (_e) != NULL; \ ++ (_e) = RBT_PREV(_name, (_e))) ++ ++#define RBT_FOREACH_REVERSE_SAFE(_e, _name, _head, _n) \ ++ for ((_e) = RBT_MAX(_name, (_head)); \ ++ (_e) != NULL && ((_n) = RBT_PREV(_name, (_e)), 1); \ ++ (_e) = (_n)) ++ ++#endif /* _SYS_TREE_H_ */ diff --git a/pkgs/applications/editors/mg/default.nix b/pkgs/applications/editors/mg/default.nix index de1a5ce7879..f97e34aff8d 100644 --- a/pkgs/applications/editors/mg/default.nix +++ b/pkgs/applications/editors/mg/default.nix @@ -1,12 +1,12 @@ -{ stdenv, fetchurl, pkgconfig, libbsd, ncurses, buildPackages }: +{ stdenv, fetchurl, pkgconfig, ncurses, buildPackages, libbsd }: stdenv.mkDerivation rec { pname = "mg"; - version = "20171014"; + version = "20180927"; src = fetchurl { - url = "http://homepage.boetes.org/software/mg/${pname}-${version}.tar.gz"; - sha256 = "0hakfikzsml7z0hja8m8mcahrmfy2piy81bq9nccsjplyfc9clai"; + url = "https://github.com/hboetes/mg/archive/${version}.tar.gz"; + sha256 = "fbb09729ea00fe42dcdbc96ac7fc1d2b89eac651dec49e4e7af52fad4f5788f6"; }; enableParallelBuilding = true; @@ -17,10 +17,11 @@ stdenv.mkDerivation rec { install -m 555 -Dt $out/bin mg install -m 444 -Dt $out/share/man/man1 mg.1 ''; - nativeBuildInputs = [ pkgconfig ]; - buildInputs = [ libbsd ncurses ]; + patches = ./darwin_no_libbsd.patch; + + buildInputs = [ ncurses ] ++ stdenv.lib.optional (!stdenv.isDarwin) libbsd; meta = with stdenv.lib; { description = "Micro GNU/emacs, a portable version of the mg maintained by the OpenBSD team"; From dcda9df724960e19713d856f1308ae4c1bae14ef Mon Sep 17 00:00:00 2001 From: Matt Wittmann Date: Fri, 13 Mar 2020 10:23:38 -0700 Subject: [PATCH 02/81] r-mvtnorm: add libiconv to buildInputs Fixes build failure with `ld: library not found for -liconv` --- pkgs/development/r-modules/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/r-modules/default.nix b/pkgs/development/r-modules/default.nix index d340f3c4636..9c4229a826b 100644 --- a/pkgs/development/r-modules/default.nix +++ b/pkgs/development/r-modules/default.nix @@ -452,6 +452,7 @@ let sundialr = [ pkgs.libiconv ]; ucminf = [ pkgs.libiconv ]; glmnet = [ pkgs.libiconv ]; + mvtnorm = [ pkgs.libiconv ]; }; packagesRequireingX = [ From 385289b9bd46347d4f8347d3297049c687d6d274 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Wed, 15 Apr 2020 16:13:43 +0200 Subject: [PATCH 03/81] yubioath-desktop: 5.0.2 -> 5.0.3 --- .../applications/misc/yubioath-desktop/default.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/applications/misc/yubioath-desktop/default.nix b/pkgs/applications/misc/yubioath-desktop/default.nix index eb39a702f93..2fffee0f0bb 100644 --- a/pkgs/applications/misc/yubioath-desktop/default.nix +++ b/pkgs/applications/misc/yubioath-desktop/default.nix @@ -6,11 +6,11 @@ mkDerivation rec { pname = "yubioath-desktop"; - version = "5.0.2"; + version = "5.0.3"; src = fetchurl { url = "https://developers.yubico.com/yubioath-desktop/Releases/yubioath-desktop-${version}.tar.gz"; - sha256 = "19ingk0ab88a22s04apcw8kx9xygxlbk8kp4xnb8pmf8z3k6l2gf"; + sha256 = "1g0jd7mmch6a6n8k5pp3w27qd5cijnvzk05lwraf0i96m68h7x1k"; }; doCheck = false; @@ -38,13 +38,13 @@ mkDerivation rec { --prefix LD_LIBRARY_PATH : "${stdenv.lib.getLib pcsclite}/lib:${yubikey-personalization}/lib" mkdir -p $out/share/applications - cp resources/yubioath-desktop.desktop \ - $out/share/applications/yubioath-desktop.desktop + cp resources/com.yubico.yubioath.desktop \ + $out/share/applications/com.yubico.yubioath.desktop mkdir -p $out/share/yubioath/icons - cp resources/icons/*.{icns,ico,png,xpm} $out/share/yubioath/icons - substituteInPlace $out/share/applications/yubioath-desktop.desktop \ + cp resources/icons/*.{icns,ico,png,svg} $out/share/yubioath/icons + substituteInPlace $out/share/applications/com.yubico.yubioath.desktop \ --replace 'Exec=yubioath-desktop' "Exec=$out/bin/yubioath-desktop" \ - --replace 'Icon=yubioath' "Icon=$out/share/yubioath/icons/yubioath.png" + --replace 'Icon=yubioath' "Icon=$out/share/yubioath/icons/com.yubico.yubioath.png" ''; meta = with stdenv.lib; { From 3d7acfd078071bdf8c2bc603786596b28a41129f Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Mon, 30 Mar 2020 05:49:08 +0200 Subject: [PATCH 04/81] jadx: init at 1.1.0 --- pkgs/tools/security/jadx/default.nix | 103 +++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 105 insertions(+) create mode 100644 pkgs/tools/security/jadx/default.nix diff --git a/pkgs/tools/security/jadx/default.nix b/pkgs/tools/security/jadx/default.nix new file mode 100644 index 00000000000..961f1e6954a --- /dev/null +++ b/pkgs/tools/security/jadx/default.nix @@ -0,0 +1,103 @@ +{ stdenv, fetchFromGitHub, gradle, jdk, makeWrapper, perl }: + +let + pname = "jadx"; + version = "1.1.0"; + + src = fetchFromGitHub { + owner = "skylot"; + repo = pname; + rev = "v${version}"; + sha256 = "1dx3g0sm46qy57gggpg8bpmin5glzbxdbf0qzvha9r2dwh4mrwlg"; + }; + + deps = stdenv.mkDerivation { + name = "${pname}-deps"; + inherit src; + + nativeBuildInputs = [ gradle jdk perl ]; + + buildPhase = '' + export GRADLE_USER_HOME=$(mktemp -d) + export JADX_VERSION=${version} + gradle --no-daemon jar + ''; + + # Mavenize dependency paths + # e.g. org.codehaus.groovy/groovy/2.4.0/{hash}/groovy-2.4.0.jar -> org/codehaus/groovy/groovy/2.4.0/groovy-2.4.0.jar + installPhase = '' + find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \ + | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \ + | sh + ''; + + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = "083r4hg6m9cxzm2m8nckf10awq8kh901v5i39r60x47xk5yw84ps"; + }; +in stdenv.mkDerivation { + inherit pname version src; + + nativeBuildInputs = [ gradle jdk makeWrapper ]; + + buildPhase = '' + # The installDist Gradle build phase tries to copy some dependency .jar + # files multiple times into the build directory. This ends up failing when + # the dependencies are read directly from the Nix store since they are not + # marked as chmod +w. To work around this, get a local copy of the + # dependency store, and give write permissions. + depsDir=$(mktemp -d) + cp -R ${deps}/* $depsDir + chmod -R u+w $depsDir + + gradleInit=$(mktemp) + cat >$gradleInit < + settings.pluginManagement { + repositories { + maven { url '$depsDir' } + } + } + } + EOF + + export GRADLE_USER_HOME=$(mktemp -d) + export JADX_VERSION=${version} + gradle --offline --no-daemon --info --init-script $gradleInit pack + ''; + + installPhase = '' + mkdir $out $out/bin + cp -R build/jadx/lib $out + for prog in jadx jadx-gui; do + cp build/jadx/bin/$prog $out/bin + wrapProgram $out/bin/$prog --set JAVA_HOME ${jdk.home} + done + ''; + + meta = with stdenv.lib; { + description = "Dex to Java decompiler"; + longDescription = '' + Command line and GUI tools for produce Java source code from Android Dex + and Apk files. + ''; + license = licenses.asl20; + platforms = platforms.unix; + maintainers = with maintainers; [ delroth ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ad4bb9f8a97..8bca4f6ab87 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4366,6 +4366,8 @@ in jade = callPackage ../tools/text/sgml/jade { }; + jadx = callPackage ../tools/security/jadx { }; + jazzy = callPackage ../development/tools/jazzy { }; jc = with python3Packages; toPythonApplication jc; From cdc8f3f3575f39849b09c741f0f269f33c0e7088 Mon Sep 17 00:00:00 2001 From: "D. Guthrie" Date: Mon, 20 Apr 2020 21:34:39 +0100 Subject: [PATCH 05/81] Bump package version to 20200215 The actual most recent version is 20200215, so update the package version to this. Furthermore, update the patch accordingly so it still builds. This adds back the reallocarray.c file. --- .../editors/mg/darwin_no_libbsd.patch | 2481 ++++++++++++++++- pkgs/applications/editors/mg/default.nix | 12 +- 2 files changed, 2431 insertions(+), 62 deletions(-) diff --git a/pkgs/applications/editors/mg/darwin_no_libbsd.patch b/pkgs/applications/editors/mg/darwin_no_libbsd.patch index 9b6df622324..2484c03255b 100644 --- a/pkgs/applications/editors/mg/darwin_no_libbsd.patch +++ b/pkgs/applications/editors/mg/darwin_no_libbsd.patch @@ -1,6 +1,6 @@ diff -Naur a/GNUmakefile b/GNUmakefile ---- a/GNUmakefile 2020-02-01 21:23:32.000000000 +0000 -+++ b/GNUmakefile 2020-02-01 21:56:01.000000000 +0000 +--- a/GNUmakefile 2020-04-20 21:09:41.000000000 +0100 ++++ b/GNUmakefile 2020-04-20 21:31:19.000000000 +0100 @@ -18,7 +18,7 @@ STRIP= /usr/bin/strip @@ -10,20 +10,16 @@ diff -Naur a/GNUmakefile b/GNUmakefile BSD_CPPFLAGS:= BSD_LIBS:= -lutil else -@@ -35,11 +35,7 @@ - - CURSES_LIBS:= $(shell $(PKG_CONFIG) --libs ncurses) - ifeq ($(CURSES_LIBS),) -- $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.) --endif -- --ifdef STATIC -- LDFLAGS=-static -static-libgcc -+ $(error You probably need to install "libncurses5-dev" or "libnnurses6-devel" or something like that.) +@@ -38,24 +38,21 @@ + $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.) endif +-ifdef STATIC +- LDFLAGS=-static -static-libgcc +-endif +- CC?= gcc -@@ -47,14 +43,14 @@ + CFLAGS?= -O2 -pipe CFLAGS+= -g -Wall CPPFLAGS= -DREGEX CPPFLAGS+= -D_GNU_SOURCE @@ -33,25 +29,121 @@ diff -Naur a/GNUmakefile b/GNUmakefile OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \ -- echo.o extend.o file.o fileio.o funmap.o help.o kbd.o keymap.o \ -+ echo.o extend.o file.o fileio.o funmap.o futimens.o help.o kbd.o keymap.o \ - line.o macro.o main.o match.o modes.o paragraph.o \ +- echo.o extend.o file.o fileio.o funmap.o interpreter.o help.o \ +- kbd.o keymap.o line.o macro.o main.o match.o modes.o paragraph.o \ - re_search.o region.o search.o spawn.o tty.o ttyio.o ttykbd.o \ -+ re_search.o reallocarray.o region.o search.o spawn.o strtonum.o tty.o ttyio.o ttykbd.o \ - undo.o util.o version.o window.o word.o yank.o +- undo.o util.o version.o window.o word.o yank.o ++ echo.o extend.o file.o fileio.o funmap.o futimens.o interpreter.o \ ++ help.o kbd.o keymap.o line.o macro.o main.o match.o modes.o \ ++ paragraph.o re_search.o reallocarray.o region.o search.o spawn.o \ ++ strtonum.o tty.o ttyio.o ttykbd.o undo.o util.o version.o window.o \ ++ word.o yank.o OBJS+= cmode.o cscope.o dired.o grep.o tags.o -@@ -68,6 +64,7 @@ - - all: $(name) +diff -Naur a/GNUmakefile~ b/GNUmakefile~ +--- a/GNUmakefile~ 1970-01-01 01:00:00.000000000 +0100 ++++ b/GNUmakefile~ 2020-04-20 21:27:39.000000000 +0100 +@@ -0,0 +1,96 @@ ++# Makefile for mg + - $(name): $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) -o $(name) $(LIBS) - ++# This Makefile has been written by Han Boetes ++# and is released in Public Domain. ++ ++# *sigh* Those debian folks are really tidy on their licenses. ++ ++name= mg ++ ++prefix= /usr/local ++bindir= $(prefix)/bin ++libdir= $(prefix)/lib ++includedir= $(prefix)/include ++mandir= $(prefix)/man ++ ++PKG_CONFIG= /usr/bin/pkg-config --silence-errors ++INSTALL= /usr/bin/install ++STRIP= /usr/bin/strip ++ ++UNAME:= $(shell uname) ++ifeq ($(UNAME),FreeBSD) ++ BSD_CPPFLAGS:= ++ BSD_LIBS:= -lutil ++else ++ BSD_CPPFLAGS:= $(shell $(PKG_CONFIG) --cflags libbsd-overlay) ++ BSD_LIBS:= $(shell $(PKG_CONFIG) --libs libbsd-overlay) ++endif ++ ++# Test is some required libraries are installed. Rather bummer that ++# they are also required to run make clean or uninstall. Oh well... Who ++# does that? ++ifeq ($(BSD_LIBS),) ++ $(error You probably need to install "libbsd-dev" or "libbsd-devel" or something like that.) ++endif ++ ++CURSES_LIBS:= $(shell $(PKG_CONFIG) --libs ncurses) ++ifeq ($(CURSES_LIBS),) ++ $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.) ++endif ++ ++ifdef STATIC ++ LDFLAGS=-static -static-libgcc ++endif ++ ++CC?= gcc ++CFLAGS?= -O2 -pipe ++CFLAGS+= -g -Wall ++CPPFLAGS= -DREGEX ++CPPFLAGS+= -D_GNU_SOURCE ++CPPFLAGS+= $(BSD_CPPFLAGS) ++LIBS= $(CURSES_LIBS) $(BSD_LIBS) ++ ++ ++OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \ ++ echo.o extend.o file.o fileio.o funmap.o interpreter.o help.o \ ++ kbd.o keymap.o line.o macro.o main.o match.o modes.o paragraph.o \ ++ re_search.o region.o search.o spawn.o tty.o ttyio.o ttykbd.o \ ++ undo.o util.o version.o window.o word.o yank.o ++OBJS+= cmode.o cscope.o dired.o grep.o tags.o ++ ++ ++# Portability stuff. ++CFLAGS+= -Wno-strict-aliasing -Wno-deprecated-declarations ++EXE_EXT= ++ ++.c.o: ++ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< ++ ++all: $(name) ++ ++$(name): $(OBJS) ++ $(CC) $(LDFLAGS) $(OBJS) -o $(name) $(LIBS) ++ ++distclean: clean ++ -rm -f *.core core.* ++ ++clean: ++ -rm -f *.o $(name)$(EXE_EXT) ++ ++ ++install: $(name) $(name).1 ++ $(INSTALL) -d $(DESTDIR)$(bindir) ++ $(INSTALL) -d $(DESTDIR)$(mandir)/man1 ++ $(INSTALL) -m 755 $(name) $(DESTDIR)$(bindir)/$(name) ++ $(INSTALL) -m 444 $(name).1 $(DESTDIR)$(mandir)/man1/$(name).1 ++ ++install-strip: install ++ $(STRIP) $(DESTDIR)$(bindir)/$(name) ++ ++uninstall: ++ rm -f \ ++ $(DESTDIR)$(bindir)/$(name)$(EXE_EXT) \ ++ $(DESTDIR)$(mandir)/man1/$(name).1 ++ ++rebuild: ++ make clean all diff -Naur a/_null.h b/_null.h --- a/_null.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/_null.h 2020-02-01 21:24:22.000000000 +0000 ++++ b/_null.h 2020-04-20 21:26:10.000000000 +0100 @@ -0,0 +1,18 @@ +/* $OpenBSD: _null.h,v 1.2 2016/09/09 22:07:58 millert Exp $ */ + @@ -73,7 +165,7 @@ diff -Naur a/_null.h b/_null.h +#endif diff -Naur a/apple.h b/apple.h --- a/apple.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/apple.h 2020-02-01 21:41:50.000000000 +0000 ++++ b/apple.h 2020-04-20 21:26:10.000000000 +0100 @@ -0,0 +1,27 @@ +/* + * Mac OS X-specific support. @@ -103,8 +195,8 @@ diff -Naur a/apple.h b/apple.h +extern void *reallocarray(void *, size_t, size_t); +extern int futimens(int, const struct timespec[2]); diff -Naur a/autoexec.c b/autoexec.c ---- a/autoexec.c 2020-02-01 21:23:32.000000000 +0000 -+++ b/autoexec.c 2020-02-01 21:34:02.000000000 +0000 +--- a/autoexec.c 2020-04-20 21:09:41.000000000 +0100 ++++ b/autoexec.c 2020-04-20 21:26:10.000000000 +0100 @@ -9,6 +9,9 @@ #include #include @@ -116,8 +208,8 @@ diff -Naur a/autoexec.c b/autoexec.c #include "funmap.h" diff -Naur a/basic.c b/basic.c ---- a/basic.c 2020-02-01 21:23:32.000000000 +0000 -+++ b/basic.c 2020-02-01 21:34:26.000000000 +0000 +--- a/basic.c 2020-04-20 21:09:41.000000000 +0100 ++++ b/basic.c 2020-04-20 21:26:10.000000000 +0100 @@ -19,6 +19,9 @@ #include #include @@ -127,10 +219,615 @@ diff -Naur a/basic.c b/basic.c +#endif #include "def.h" - /* + #define percint(n1, n2) ((n1 * (int) n2) * 0.1) +diff -Naur a/basic.c.orig b/basic.c.orig +--- a/basic.c.orig 1970-01-01 01:00:00.000000000 +0100 ++++ b/basic.c.orig 2020-04-20 21:26:06.000000000 +0100 +@@ -0,0 +1,601 @@ ++/* $OpenBSD: basic.c,v 1.49 2019/06/17 11:39:26 lum Exp $ */ ++ ++/* This file is in the public domain */ ++ ++/* ++ * Basic cursor motion commands. ++ * ++ * The routines in this file are the basic ++ * command functions for moving the cursor around on ++ * the screen, setting mark, and swapping dot with ++ * mark. Only moves between lines, which might make the ++ * current buffer framing bad, are hard. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "def.h" ++ ++#define percint(n1, n2) ((n1 * (int) n2) * 0.1) ++ ++/* ++ * Go to beginning of line. ++ */ ++/* ARGSUSED */ ++int ++gotobol(int f, int n) ++{ ++ if (n == 0) ++ return (TRUE); ++ ++ curwp->w_doto = 0; ++ return (TRUE); ++} ++ ++/* ++ * Move cursor backwards. Do the ++ * right thing if the count is less than ++ * 0. Error if you try to move back from ++ * the beginning of the buffer. ++ */ ++/* ARGSUSED */ ++int ++backchar(int f, int n) ++{ ++ struct line *lp; ++ ++ if (n < 0) ++ return (forwchar(f, -n)); ++ while (n--) { ++ if (curwp->w_doto == 0) { ++ if ((lp = lback(curwp->w_dotp)) == curbp->b_headp) { ++ if (!(f & FFRAND)) { ++ dobeep(); ++ ewprintf("Beginning of buffer"); ++ } ++ return (FALSE); ++ } ++ curwp->w_dotp = lp; ++ curwp->w_doto = llength(lp); ++ curwp->w_rflag |= WFMOVE; ++ curwp->w_dotline--; ++ } else ++ curwp->w_doto--; ++ } ++ return (TRUE); ++} ++ ++/* ++ * Go to end of line. ++ */ ++/* ARGSUSED */ ++int ++gotoeol(int f, int n) ++{ ++ if (n == 0) ++ return (TRUE); ++ ++ curwp->w_doto = llength(curwp->w_dotp); ++ return (TRUE); ++} ++ ++/* ++ * Move cursor forwards. Do the ++ * right thing if the count is less than ++ * 0. Error if you try to move forward ++ * from the end of the buffer. ++ */ ++/* ARGSUSED */ ++int ++forwchar(int f, int n) ++{ ++ if (n < 0) ++ return (backchar(f, -n)); ++ while (n--) { ++ if (curwp->w_doto == llength(curwp->w_dotp)) { ++ curwp->w_dotp = lforw(curwp->w_dotp); ++ if (curwp->w_dotp == curbp->b_headp) { ++ curwp->w_dotp = lback(curwp->w_dotp); ++ if (!(f & FFRAND)) { ++ dobeep(); ++ ewprintf("End of buffer"); ++ } ++ return (FALSE); ++ } ++ curwp->w_doto = 0; ++ curwp->w_dotline++; ++ curwp->w_rflag |= WFMOVE; ++ } else ++ curwp->w_doto++; ++ } ++ return (TRUE); ++} ++ ++/* ++ * Go to the beginning of the buffer. Setting WFFULL is conservative, ++ * but almost always the case. A universal argument of higher than 9 ++ * puts the cursor back to the end of buffer. ++ */ ++int ++gotobob(int f, int n) ++{ ++ if (!curwp->w_markp) ++ (void) setmark(f, n); ++ curwp->w_dotp = bfirstlp(curbp); ++ curwp->w_doto = 0; ++ curwp->w_rflag |= WFFULL; ++ curwp->w_dotline = 1; ++ if (f & FFOTHARG && n > 0) { ++ if (n > 9) ++ gotoeob(0, 0); ++ else ++ forwline(f, percint(curwp->w_bufp->b_lines, n) - 1); ++ } ++ return (TRUE); ++} ++ ++/* ++ * Go to the end of the buffer. Leave dot 3 lines from the bottom of the ++ * window if buffer length is longer than window length; same as emacs. ++ * Setting WFFULL is conservative, but almost always the case. A universal ++ * argument of higher than 9 puts the cursor back to the start of buffer. ++ */ ++int ++gotoeob(int f, int n) ++{ ++ int ln; ++ struct line *lp; ++ ++ if (!curwp->w_markp) ++ (void) setmark(f, n); ++ curwp->w_dotp = blastlp(curbp); ++ curwp->w_doto = llength(curwp->w_dotp); ++ curwp->w_dotline = curwp->w_bufp->b_lines; ++ ++ lp = curwp->w_dotp; ++ ln = curwp->w_ntrows - 3; ++ ++ if (ln < curwp->w_bufp->b_lines && ln >= 3) { ++ while (ln--) ++ curwp->w_dotp = lback(curwp->w_dotp); ++ ++ curwp->w_linep = curwp->w_dotp; ++ curwp->w_dotp = lp; ++ } ++ if (f & FFOTHARG && n > 0) { ++ if (n > 9) ++ gotobob(0, 0); ++ else ++ backline(f, percint(curwp->w_bufp->b_lines, n)); ++ } ++ ++ curwp->w_rflag |= WFFULL; ++ return (TRUE); ++} ++ ++/* ++ * Move forward by full lines. ++ * If the number of lines to move is less ++ * than zero, call the backward line function to ++ * actually do it. The last command controls how ++ * the goal column is set. ++ */ ++/* ARGSUSED */ ++int ++forwline(int f, int n) ++{ ++ struct line *dlp; ++ ++ if (n < 0) ++ return (backline(f | FFRAND, -n)); ++ if ((dlp = curwp->w_dotp) == curbp->b_headp) { ++ if (!(f & FFRAND)) { ++ dobeep(); ++ ewprintf("End of buffer"); ++ } ++ return(TRUE); ++ } ++ if ((lastflag & CFCPCN) == 0) /* Fix goal. */ ++ setgoal(); ++ thisflag |= CFCPCN; ++ if (n == 0) ++ return (TRUE); ++ while (n--) { ++ dlp = lforw(dlp); ++ if (dlp == curbp->b_headp) { ++ curwp->w_dotp = lback(dlp); ++ curwp->w_doto = llength(curwp->w_dotp); ++ curwp->w_rflag |= WFMOVE; ++ if (!(f & FFRAND)) { ++ dobeep(); ++ ewprintf("End of buffer"); ++ } ++ return (TRUE); ++ } ++ curwp->w_dotline++; ++ } ++ curwp->w_rflag |= WFMOVE; ++ curwp->w_dotp = dlp; ++ curwp->w_doto = getgoal(dlp); ++ ++ return (TRUE); ++} ++ ++/* ++ * This function is like "forwline", but ++ * goes backwards. The scheme is exactly the same. ++ * Check for arguments that are less than zero and ++ * call your alternate. Figure out the new line and ++ * call "movedot" to perform the motion. ++ */ ++/* ARGSUSED */ ++int ++backline(int f, int n) ++{ ++ struct line *dlp; ++ ++ if (n < 0) ++ return (forwline(f | FFRAND, -n)); ++ if ((lastflag & CFCPCN) == 0) /* Fix goal. */ ++ setgoal(); ++ thisflag |= CFCPCN; ++ dlp = curwp->w_dotp; ++ if (lback(dlp) == curbp->b_headp) { ++ if (!(f & FFRAND)) { ++ dobeep(); ++ ewprintf("Beginning of buffer"); ++ } ++ return(TRUE); ++ } ++ while (n-- && lback(dlp) != curbp->b_headp) { ++ dlp = lback(dlp); ++ curwp->w_dotline--; ++ } ++ if (n > 0 && !(f & FFRAND)) { ++ dobeep(); ++ ewprintf("Beginning of buffer"); ++ } ++ curwp->w_dotp = dlp; ++ curwp->w_doto = getgoal(dlp); ++ curwp->w_rflag |= WFMOVE; ++ return (TRUE); ++} ++ ++/* ++ * Set the current goal column, which is saved in the external variable ++ * "curgoal", to the current cursor column. The column is never off ++ * the edge of the screen; it's more like display then show position. ++ */ ++void ++setgoal(void) ++{ ++ curgoal = getcolpos(curwp); /* Get the position. */ ++ /* we can now display past end of display, don't chop! */ ++} ++ ++/* ++ * This routine looks at a line (pointed ++ * to by the LINE pointer "dlp") and the current ++ * vertical motion goal column (set by the "setgoal" ++ * routine above) and returns the best offset to use ++ * when a vertical motion is made into the line. ++ */ ++int ++getgoal(struct line *dlp) ++{ ++ int c, i, col = 0; ++ char tmp[5]; ++ ++ ++ for (i = 0; i < llength(dlp); i++) { ++ c = lgetc(dlp, i); ++ if (c == '\t' ++#ifdef NOTAB ++ && !(curbp->b_flag & BFNOTAB) ++#endif ++ ) { ++ col |= 0x07; ++ col++; ++ } else if (ISCTRL(c) != FALSE) { ++ col += 2; ++ } else if (isprint(c)) ++ col++; ++ else { ++ col += snprintf(tmp, sizeof(tmp), "\\%o", c); ++ } ++ if (col > curgoal) ++ break; ++ } ++ return (i); ++} ++ ++/* ++ * Scroll forward by a specified number ++ * of lines, or by a full page if no argument. ++ * The "2" is the window overlap (this is the default ++ * value from ITS EMACS). Because the top line in ++ * the window is zapped, we have to do a hard ++ * update and get it back. ++ */ ++/* ARGSUSED */ ++int ++forwpage(int f, int n) ++{ ++ struct line *lp; ++ ++ if (!(f & FFARG)) { ++ n = curwp->w_ntrows - 2; /* Default scroll. */ ++ if (n <= 0) /* Forget the overlap */ ++ n = 1; /* if tiny window. */ ++ } else if (n < 0) ++ return (backpage(f | FFRAND, -n)); ++ ++ lp = curwp->w_linep; ++ while (n--) ++ if ((lp = lforw(lp)) == curbp->b_headp) { ++ dobeep(); ++ ewprintf("End of buffer"); ++ return(TRUE); ++ } ++ ++ curwp->w_linep = lp; ++ curwp->w_rflag |= WFFULL; ++ ++ /* if in current window, don't move dot */ ++ for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) ++ if (lp == curwp->w_dotp) ++ return (TRUE); ++ ++ /* Advance the dot the slow way, for line nos */ ++ while (curwp->w_dotp != curwp->w_linep) { ++ curwp->w_dotp = lforw(curwp->w_dotp); ++ curwp->w_dotline++; ++ } ++ curwp->w_doto = 0; ++ return (TRUE); ++} ++ ++/* ++ * This command is like "forwpage", ++ * but it goes backwards. The "2", like above, ++ * is the overlap between the two windows. The ++ * value is from the ITS EMACS manual. The ++ * hard update is done because the top line in ++ * the window is zapped. ++ */ ++/* ARGSUSED */ ++int ++backpage(int f, int n) ++{ ++ struct line *lp, *lp2; ++ ++ if (!(f & FFARG)) { ++ n = curwp->w_ntrows - 2; /* Default scroll. */ ++ if (n <= 0) /* Don't blow up if the */ ++ return (backline(f, 1));/* window is tiny. */ ++ } else if (n < 0) ++ return (forwpage(f | FFRAND, -n)); ++ ++ lp = lp2 = curwp->w_linep; ++ ++ while (n-- && lback(lp) != curbp->b_headp) { ++ lp = lback(lp); ++ } ++ if (lp == curwp->w_linep) { ++ dobeep(); ++ ewprintf("Beginning of buffer"); ++ } ++ curwp->w_linep = lp; ++ curwp->w_rflag |= WFFULL; ++ ++ /* if in current window, don't move dot */ ++ for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) ++ if (lp == curwp->w_dotp) ++ return (TRUE); ++ ++ lp2 = lforw(lp2); ++ ++ /* Move the dot the slow way, for line nos */ ++ while (curwp->w_dotp != lp2) { ++ if (curwp->w_dotline <= curwp->w_ntrows) ++ goto out; ++ curwp->w_dotp = lback(curwp->w_dotp); ++ curwp->w_dotline--; ++ } ++out: ++ curwp->w_doto = 0; ++ return (TRUE); ++} ++ ++/* ++ * These functions are provided for compatibility with Gosling's Emacs. They ++ * are used to scroll the display up (or down) one line at a time. ++ */ ++int ++forw1page(int f, int n) ++{ ++ if (!(f & FFARG)) { ++ n = 1; ++ f = FFUNIV; ++ } ++ forwpage(f | FFRAND, n); ++ return (TRUE); ++} ++ ++int ++back1page(int f, int n) ++{ ++ if (!(f & FFARG)) { ++ n = 1; ++ f = FFUNIV; ++ } ++ backpage(f | FFRAND, n); ++ return (TRUE); ++} ++ ++/* ++ * Page the other window. Check to make sure it exists, then ++ * nextwind, forwpage and restore window pointers. ++ */ ++int ++pagenext(int f, int n) ++{ ++ struct mgwin *wp; ++ ++ if (wheadp->w_wndp == NULL) { ++ dobeep(); ++ ewprintf("No other window"); ++ return (FALSE); ++ } ++ wp = curwp; ++ (void) nextwind(f, n); ++ (void) forwpage(f, n); ++ curwp = wp; ++ curbp = wp->w_bufp; ++ return (TRUE); ++} ++ ++/* ++ * Internal set mark routine, used by other functions (daveb). ++ */ ++void ++isetmark(void) ++{ ++ curwp->w_markp = curwp->w_dotp; ++ curwp->w_marko = curwp->w_doto; ++ curwp->w_markline = curwp->w_dotline; ++} ++ ++/* ++ * Set the mark in the current window ++ * to the value of dot. A message is written to ++ * the echo line. (ewprintf knows about macros) ++ */ ++/* ARGSUSED */ ++int ++setmark(int f, int n) ++{ ++ isetmark(); ++ ewprintf("Mark set"); ++ return (TRUE); ++} ++ ++/* Clear the mark, if set. */ ++/* ARGSUSED */ ++int ++clearmark(int f, int n) ++{ ++ if (!curwp->w_markp) ++ return (FALSE); ++ ++ curwp->w_markp = NULL; ++ curwp->w_marko = 0; ++ curwp->w_markline = 0; ++ ++ return (TRUE); ++} ++ ++/* ++ * Swap the values of "dot" and "mark" in ++ * the current window. This is pretty easy, because ++ * all of the hard work gets done by the standard routine ++ * that moves the mark about. The only possible ++ * error is "no mark". ++ */ ++/* ARGSUSED */ ++int ++swapmark(int f, int n) ++{ ++ struct line *odotp; ++ int odoto, odotline; ++ ++ if (curwp->w_markp == NULL) { ++ dobeep(); ++ ewprintf("No mark in this window"); ++ return (FALSE); ++ } ++ odotp = curwp->w_dotp; ++ odoto = curwp->w_doto; ++ odotline = curwp->w_dotline; ++ curwp->w_dotp = curwp->w_markp; ++ curwp->w_doto = curwp->w_marko; ++ curwp->w_dotline = curwp->w_markline; ++ curwp->w_markp = odotp; ++ curwp->w_marko = odoto; ++ curwp->w_markline = odotline; ++ curwp->w_rflag |= WFMOVE; ++ return (TRUE); ++} ++ ++/* ++ * Go to a specific line, mostly for ++ * looking up errors in C programs, which give the ++ * error a line number. If an argument is present, then ++ * it is the line number, else prompt for a line number ++ * to use. ++ */ ++/* ARGSUSED */ ++int ++gotoline(int f, int n) ++{ ++ char buf[32], *bufp; ++ const char *err; ++ ++ if (!(f & FFARG)) { ++ if ((bufp = eread("Goto line: ", buf, sizeof(buf), ++ EFNUL | EFNEW | EFCR)) == NULL) ++ return (ABORT); ++ if (bufp[0] == '\0') ++ return (ABORT); ++ n = (int)strtonum(buf, INT_MIN, INT_MAX, &err); ++ if (err) { ++ dobeep(); ++ ewprintf("Line number %s", err); ++ return (FALSE); ++ } ++ } ++ return(setlineno(n)); ++} ++ ++/* ++ * Set the line number and switch to it. ++ */ ++int ++setlineno(int n) ++{ ++ struct line *clp; ++ ++ if (n >= 0) { ++ if (n == 0) ++ n++; ++ curwp->w_dotline = n; ++ clp = lforw(curbp->b_headp); /* "clp" is first line */ ++ while (--n > 0) { ++ if (lforw(clp) == curbp->b_headp) { ++ curwp->w_dotline = curwp->w_bufp->b_lines; ++ break; ++ } ++ clp = lforw(clp); ++ } ++ } else { ++ curwp->w_dotline = curwp->w_bufp->b_lines + n; ++ clp = lback(curbp->b_headp); /* "clp" is last line */ ++ while (n < 0) { ++ if (lback(clp) == curbp->b_headp) { ++ curwp->w_dotline = 1; ++ break; ++ } ++ clp = lback(clp); ++ n++; ++ } ++ } ++ curwp->w_dotp = clp; ++ curwp->w_doto = 0; ++ curwp->w_rflag |= WFMOVE; ++ return (TRUE); ++} diff -Naur a/cscope.c b/cscope.c ---- a/cscope.c 2020-02-01 21:23:32.000000000 +0000 -+++ b/cscope.c 2020-02-01 21:34:59.000000000 +0000 +--- a/cscope.c 2020-04-20 21:09:41.000000000 +0100 ++++ b/cscope.c 2020-04-20 21:26:10.000000000 +0100 @@ -20,6 +20,9 @@ #include #include @@ -142,8 +839,8 @@ diff -Naur a/cscope.c b/cscope.c #define CSSYMBOL 0 diff -Naur a/display.c b/display.c ---- a/display.c 2020-02-01 21:23:32.000000000 +0000 -+++ b/display.c 2020-02-01 21:34:16.000000000 +0000 +--- a/display.c 2020-04-20 21:09:41.000000000 +0100 ++++ b/display.c 2020-04-20 21:26:10.000000000 +0100 @@ -19,6 +19,9 @@ #include #include @@ -155,14 +852,8 @@ diff -Naur a/display.c b/display.c #include "kbd.h" diff -Naur a/fileio.c b/fileio.c ---- a/fileio.c 2020-02-01 21:23:32.000000000 +0000 -+++ b/fileio.c 2020-02-01 21:42:18.000000000 +0000 -@@ -1,4 +1,4 @@ --/* $OpenBSD: fileio.c,v 1.105 2018/04/13 14:11:37 florian Exp $ */ -+/* $OpenBSD: fileio.c,v 1.104 2017/05/30 07:05:22 florian Exp $ */ - - /* This file is in the public domain. */ - +--- a/fileio.c 2020-04-20 21:09:41.000000000 +0100 ++++ b/fileio.c 2020-04-20 21:26:10.000000000 +0100 @@ -22,19 +22,13 @@ #include #include @@ -186,7 +877,7 @@ diff -Naur a/fileio.c b/fileio.c static char *bkuplocation(const char *); static int bkupleavetmp(const char *); -@@ -714,7 +708,7 @@ +@@ -710,7 +704,7 @@ struct stat statbuf; const char *cp; char user[LOGIN_NAME_MAX], path[NFILEN]; @@ -195,7 +886,7 @@ diff -Naur a/fileio.c b/fileio.c size_t ulen, plen; path[0] = '\0'; -@@ -733,18 +727,21 @@ +@@ -729,18 +723,21 @@ return (NULL); return(ret); } @@ -222,9 +913,774 @@ diff -Naur a/fileio.c b/fileio.c ewprintf("Path too long"); return (NULL); } +diff -Naur a/fileio.c.orig b/fileio.c.orig +--- a/fileio.c.orig 1970-01-01 01:00:00.000000000 +0100 ++++ b/fileio.c.orig 2020-04-20 21:26:06.000000000 +0100 +@@ -0,0 +1,761 @@ ++/* $OpenBSD: fileio.c,v 1.106 2019/06/22 10:21:57 lum Exp $ */ ++ ++/* This file is in the public domain. */ ++ ++/* ++ * POSIX fileio.c ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "def.h" ++#include "kbd.h" ++#include "pathnames.h" ++ ++#ifndef MAXNAMLEN ++#define MAXNAMLEN 255 ++#endif ++ ++#ifndef DEFFILEMODE ++#define DEFFILEMODE 0666 ++#endif ++ ++static char *bkuplocation(const char *); ++static int bkupleavetmp(const char *); ++ ++static char *bkupdir; ++static int leavetmp = 0; /* 1 = leave any '~' files in tmp dir */ ++ ++/* ++ * Open a file for reading. ++ */ ++int ++ffropen(FILE ** ffp, const char *fn, struct buffer *bp) ++{ ++ if ((*ffp = fopen(fn, "r")) == NULL) { ++ if (errno == ENOENT) ++ return (FIOFNF); ++ return (FIOERR); ++ } ++ ++ /* If 'fn' is a directory open it with dired. */ ++ if (fisdir(fn) == TRUE) ++ return (FIODIR); ++ ++ ffstat(*ffp, bp); ++ ++ return (FIOSUC); ++} ++ ++/* ++ * Update stat/dirty info ++ */ ++void ++ffstat(FILE *ffp, struct buffer *bp) ++{ ++ struct stat sb; ++ ++ if (bp && fstat(fileno(ffp), &sb) == 0) { ++ /* set highorder bit to make sure this isn't all zero */ ++ bp->b_fi.fi_mode = sb.st_mode | 0x8000; ++ bp->b_fi.fi_uid = sb.st_uid; ++ bp->b_fi.fi_gid = sb.st_gid; ++ /* bp->b_fi.fi_mtime = sb.st_mtimespec; */ ++ bp->b_fi.fi_mtime.tv_sec = sb.st_mtime; ++ bp->b_fi.fi_mtime.tv_nsec = 0; ++ /* Clear the ignore flag */ ++ bp->b_flag &= ~(BFIGNDIRTY | BFDIRTY); ++ } ++} ++ ++/* ++ * Update the status/dirty info. If there is an error, ++ * there's not a lot we can do. ++ */ ++int ++fupdstat(struct buffer *bp) ++{ ++ FILE *ffp; ++ ++ if ((ffp = fopen(bp->b_fname, "r")) == NULL) { ++ if (errno == ENOENT) ++ return (FIOFNF); ++ return (FIOERR); ++ } ++ ffstat(ffp, bp); ++ (void)ffclose(ffp, bp); ++ return (FIOSUC); ++} ++ ++/* ++ * Open a file for writing. ++ */ ++int ++ffwopen(FILE ** ffp, const char *fn, struct buffer *bp) ++{ ++ int fd; ++ mode_t fmode = DEFFILEMODE; ++ ++ if (bp && bp->b_fi.fi_mode) ++ fmode = bp->b_fi.fi_mode & 07777; ++ ++ fd = open(fn, O_RDWR | O_CREAT | O_TRUNC, fmode); ++ if (fd == -1) { ++ ffp = NULL; ++ dobeep(); ++ ewprintf("Cannot open file for writing : %s", strerror(errno)); ++ return (FIOERR); ++ } ++ ++ if ((*ffp = fdopen(fd, "w")) == NULL) { ++ dobeep(); ++ ewprintf("Cannot open file for writing : %s", strerror(errno)); ++ close(fd); ++ return (FIOERR); ++ } ++ ++ /* ++ * If we have file information, use it. We don't bother to check for ++ * errors, because there's no a lot we can do about it. Certainly ++ * trying to change ownership will fail if we aren't root. That's ++ * probably OK. If we don't have info, no need to get it, since any ++ * future writes will do the same thing. ++ */ ++ if (bp && bp->b_fi.fi_mode) { ++ fchmod(fd, bp->b_fi.fi_mode & 07777); ++ fchown(fd, bp->b_fi.fi_uid, bp->b_fi.fi_gid); ++ } ++ return (FIOSUC); ++} ++ ++/* ++ * Close a file. ++ */ ++/* ARGSUSED */ ++int ++ffclose(FILE *ffp, struct buffer *bp) ++{ ++ if (fclose(ffp) == 0) ++ return (FIOSUC); ++ return (FIOERR); ++} ++ ++/* ++ * Write a buffer to the already opened file. bp points to the ++ * buffer. Return the status. ++ */ ++int ++ffputbuf(FILE *ffp, struct buffer *bp, int eobnl) ++{ ++ struct line *lp, *lpend; ++ ++ lpend = bp->b_headp; ++ ++ for (lp = lforw(lpend); lp != lpend; lp = lforw(lp)) { ++ if (fwrite(ltext(lp), 1, llength(lp), ffp) != llength(lp)) { ++ dobeep(); ++ ewprintf("Write I/O error"); ++ return (FIOERR); ++ } ++ if (lforw(lp) != lpend) /* no implied \n on last line */ ++ putc('\n', ffp); ++ } ++ if (eobnl) { ++ lnewline_at(lback(lpend), llength(lback(lpend))); ++ putc('\n', ffp); ++ } ++ return (FIOSUC); ++} ++ ++/* ++ * Read a line from a file, and store the bytes ++ * in the supplied buffer. Stop on end of file or end of ++ * line. When FIOEOF is returned, there is a valid line ++ * of data without the normally implied \n. ++ * If the line length exceeds nbuf, FIOLONG is returned. ++ */ ++int ++ffgetline(FILE *ffp, char *buf, int nbuf, int *nbytes) ++{ ++ int c, i; ++ ++ i = 0; ++ while ((c = getc(ffp)) != EOF && c != '\n') { ++ buf[i++] = c; ++ if (i >= nbuf) ++ return (FIOLONG); ++ } ++ if (c == EOF && ferror(ffp) != FALSE) { ++ dobeep(); ++ ewprintf("File read error"); ++ return (FIOERR); ++ } ++ *nbytes = i; ++ return (c == EOF ? FIOEOF : FIOSUC); ++} ++ ++/* ++ * Make a backup copy of "fname". On Unix the backup has the same ++ * name as the original file, with a "~" on the end; this seems to ++ * be newest of the new-speak. The error handling is all in "file.c". ++ * We do a copy instead of a rename since otherwise another process ++ * with an open fd will get the backup, not the new file. This is ++ * a problem when using mg with things like crontab and vipw. ++ */ ++int ++fbackupfile(const char *fn) ++{ ++ struct stat sb; ++ struct timespec new_times[2]; ++ int from, to, serrno; ++ ssize_t nread; ++ char buf[BUFSIZ]; ++ char *nname, *tname, *bkpth; ++ ++ if (stat(fn, &sb) == -1) { ++ dobeep(); ++ ewprintf("Can't stat %s : %s", fn, strerror(errno)); ++ return (FALSE); ++ } ++ ++ if ((bkpth = bkuplocation(fn)) == NULL) ++ return (FALSE); ++ ++ if (asprintf(&nname, "%s~", bkpth) == -1) { ++ dobeep(); ++ ewprintf("Can't allocate backup file name : %s", strerror(errno)); ++ free(bkpth); ++ return (ABORT); ++ } ++ if (asprintf(&tname, "%s.XXXXXXXXXX", bkpth) == -1) { ++ dobeep(); ++ ewprintf("Can't allocate temp file name : %s", strerror(errno)); ++ free(bkpth); ++ free(nname); ++ return (ABORT); ++ } ++ free(bkpth); ++ ++ if ((from = open(fn, O_RDONLY)) == -1) { ++ free(nname); ++ free(tname); ++ return (FALSE); ++ } ++ to = mkstemp(tname); ++ if (to == -1) { ++ serrno = errno; ++ close(from); ++ free(nname); ++ free(tname); ++ errno = serrno; ++ return (FALSE); ++ } ++ while ((nread = read(from, buf, sizeof(buf))) > 0) { ++ if (write(to, buf, (size_t)nread) != nread) { ++ nread = -1; ++ break; ++ } ++ } ++ serrno = errno; ++ (void) fchmod(to, (sb.st_mode & 0777)); ++ ++ /* copy the mtime to the backupfile */ ++ new_times[0] = sb.st_atim; ++ new_times[1] = sb.st_mtim; ++ futimens(to, new_times); ++ ++ close(from); ++ close(to); ++ if (nread == -1) { ++ if (unlink(tname) == -1) ++ ewprintf("Can't unlink temp : %s", strerror(errno)); ++ } else { ++ if (rename(tname, nname) == -1) { ++ ewprintf("Can't rename temp : %s", strerror(errno)); ++ (void) unlink(tname); ++ nread = -1; ++ } ++ } ++ free(nname); ++ free(tname); ++ errno = serrno; ++ ++ return (nread == -1 ? FALSE : TRUE); ++} ++ ++/* ++ * Convert "fn" to a canonicalized absolute filename, replacing ++ * a leading ~/ with the user's home dir, following symlinks, and ++ * remove all occurrences of /./ and /../ ++ */ ++char * ++adjustname(const char *fn, int slashslash) ++{ ++ static char fnb[PATH_MAX]; ++ const char *cp, *ep = NULL; ++ char *path; ++ ++ if (slashslash == TRUE) { ++ cp = fn + strlen(fn) - 1; ++ for (; cp >= fn; cp--) { ++ if (ep && (*cp == '/')) { ++ fn = ep; ++ break; ++ } ++ if (*cp == '/' || *cp == '~') ++ ep = cp; ++ else ++ ep = NULL; ++ } ++ } ++ if ((path = expandtilde(fn)) == NULL) ++ return (NULL); ++ ++ if (realpath(path, fnb) == NULL) ++ (void)strlcpy(fnb, path, sizeof(fnb)); ++ ++ free(path); ++ return (fnb); ++} ++ ++/* ++ * Find a startup file for the user and return its name. As a service ++ * to other pieces of code that may want to find a startup file (like ++ * the terminal driver in particular), accepts a suffix to be appended ++ * to the startup file name. ++ */ ++char * ++startupfile(char *suffix) ++{ ++ static char file[NFILEN]; ++ char *home; ++ int ret; ++ ++ if ((home = getenv("HOME")) == NULL || *home == '\0') ++ goto nohome; ++ ++ if (suffix == NULL) { ++ ret = snprintf(file, sizeof(file), _PATH_MG_STARTUP, home); ++ if (ret < 0 || ret >= sizeof(file)) ++ return (NULL); ++ } else { ++ ret = snprintf(file, sizeof(file), _PATH_MG_TERM, home, suffix); ++ if (ret < 0 || ret >= sizeof(file)) ++ return (NULL); ++ } ++ ++ if (access(file, R_OK) == 0) ++ return (file); ++nohome: ++#ifdef STARTUPFILE ++ if (suffix == NULL) { ++ ret = snprintf(file, sizeof(file), "%s", STARTUPFILE); ++ if (ret < 0 || ret >= sizeof(file)) ++ return (NULL); ++ } else { ++ ret = snprintf(file, sizeof(file), "%s%s", STARTUPFILE, ++ suffix); ++ if (ret < 0 || ret >= sizeof(file)) ++ return (NULL); ++ } ++ ++ if (access(file, R_OK) == 0) ++ return (file); ++#endif /* STARTUPFILE */ ++ return (NULL); ++} ++ ++int ++copy(char *frname, char *toname) ++{ ++ int ifd, ofd; ++ char buf[BUFSIZ]; ++ mode_t fmode = DEFFILEMODE; /* XXX?? */ ++ struct stat orig; ++ ssize_t sr; ++ ++ if ((ifd = open(frname, O_RDONLY)) == -1) ++ return (FALSE); ++ if (fstat(ifd, &orig) == -1) { ++ dobeep(); ++ ewprintf("fstat: %s", strerror(errno)); ++ close(ifd); ++ return (FALSE); ++ } ++ ++ if ((ofd = open(toname, O_WRONLY|O_CREAT|O_TRUNC, fmode)) == -1) { ++ close(ifd); ++ return (FALSE); ++ } ++ while ((sr = read(ifd, buf, sizeof(buf))) > 0) { ++ if (write(ofd, buf, (size_t)sr) != sr) { ++ ewprintf("write error : %s", strerror(errno)); ++ break; ++ } ++ } ++ if (fchmod(ofd, orig.st_mode) == -1) ++ ewprintf("Cannot set original mode : %s", strerror(errno)); ++ ++ if (sr == -1) { ++ ewprintf("Read error : %s", strerror(errno)); ++ close(ifd); ++ close(ofd); ++ return (FALSE); ++ } ++ /* ++ * It is "normal" for this to fail since we can't guarantee that ++ * we will be running as root. ++ */ ++ if (fchown(ofd, orig.st_uid, orig.st_gid) && errno != EPERM) ++ ewprintf("Cannot set owner : %s", strerror(errno)); ++ ++ (void) close(ifd); ++ (void) close(ofd); ++ ++ return (TRUE); ++} ++ ++/* ++ * return list of file names that match the name in buf. ++ */ ++struct list * ++make_file_list(char *buf) ++{ ++ char *dir, *file, *cp; ++ size_t len, preflen; ++ int ret; ++ DIR *dirp; ++ struct dirent *dent; ++ struct list *last, *current; ++ char fl_name[NFILEN + 2]; ++ char prefixx[NFILEN + 1]; ++ ++ /* ++ * We need three different strings: ++ ++ * dir - the name of the directory containing what the user typed. ++ * Must be a real unix file name, e.g. no ~user, etc.. ++ * Must not end in /. ++ * prefix - the portion of what the user typed that is before the ++ * names we are going to find in the directory. Must have a ++ * trailing / if the user typed it. ++ * names from the directory - We open dir, and return prefix ++ * concatenated with names. ++ */ ++ ++ /* first we get a directory name we can look up */ ++ /* ++ * Names ending in . are potentially odd, because adjustname will ++ * treat foo/bar/.. as a foo/, whereas we are ++ * interested in names starting with .. ++ */ ++ len = strlen(buf); ++ if (len && buf[len - 1] == '.') { ++ buf[len - 1] = 'x'; ++ dir = adjustname(buf, TRUE); ++ buf[len - 1] = '.'; ++ } else ++ dir = adjustname(buf, TRUE); ++ if (dir == NULL) ++ return (NULL); ++ /* ++ * If the user typed a trailing / or the empty string ++ * he wants us to use his file spec as a directory name. ++ */ ++ if (len && buf[len - 1] != '/') { ++ file = strrchr(dir, '/'); ++ if (file) { ++ *file = '\0'; ++ if (*dir == '\0') ++ dir = "/"; ++ } else ++ return (NULL); ++ } ++ /* Now we get the prefix of the name the user typed. */ ++ if (strlcpy(prefixx, buf, sizeof(prefixx)) >= sizeof(prefixx)) ++ return (NULL); ++ cp = strrchr(prefixx, '/'); ++ if (cp == NULL) ++ prefixx[0] = '\0'; ++ else ++ cp[1] = '\0'; ++ ++ preflen = strlen(prefixx); ++ /* cp is the tail of buf that really needs to be compared. */ ++ cp = buf + preflen; ++ len = strlen(cp); ++ ++ /* ++ * Now make sure that file names will fit in the buffers allocated. ++ * SV files are fairly short. For BSD, something more general would ++ * be required. ++ */ ++ if (preflen > NFILEN - MAXNAMLEN) ++ return (NULL); ++ ++ /* loop over the specified directory, making up the list of files */ ++ ++ /* ++ * Note that it is worth our time to filter out names that don't ++ * match, even though our caller is going to do so again, and to ++ * avoid doing the stat if completion is being done, because stat'ing ++ * every file in the directory is relatively expensive. ++ */ ++ ++ dirp = opendir(dir); ++ if (dirp == NULL) ++ return (NULL); ++ last = NULL; ++ ++ while ((dent = readdir(dirp)) != NULL) { ++ int isdir; ++ if (strncmp(cp, dent->d_name, len) != 0) ++ continue; ++ isdir = 0; ++ if (dent->d_type == DT_DIR) { ++ isdir = 1; ++ } else if (dent->d_type == DT_LNK || ++ dent->d_type == DT_UNKNOWN) { ++ struct stat statbuf; ++ ++ if (fstatat(dirfd(dirp), dent->d_name, &statbuf, 0) < 0) ++ continue; ++ if (S_ISDIR(statbuf.st_mode)) ++ isdir = 1; ++ } ++ ++ if ((current = malloc(sizeof(struct list))) == NULL) { ++ free_file_list(last); ++ closedir(dirp); ++ return (NULL); ++ } ++ ret = snprintf(fl_name, sizeof(fl_name), ++ "%s%s%s", prefixx, dent->d_name, isdir ? "/" : ""); ++ if (ret < 0 || ret >= sizeof(fl_name)) { ++ free(current); ++ continue; ++ } ++ current->l_next = last; ++ current->l_name = strdup(fl_name); ++ last = current; ++ } ++ closedir(dirp); ++ ++ return (last); ++} ++ ++/* ++ * Test if a supplied filename refers to a directory ++ * Returns ABORT on error, TRUE if directory. FALSE otherwise ++ */ ++int ++fisdir(const char *fname) ++{ ++ struct stat statbuf; ++ ++ if (stat(fname, &statbuf) != 0) ++ return (ABORT); ++ ++ if (S_ISDIR(statbuf.st_mode)) ++ return (TRUE); ++ ++ return (FALSE); ++} ++ ++/* ++ * Check the mtime of the supplied filename. ++ * Return TRUE if last mtime matches, FALSE if not, ++ * If the stat fails, return TRUE and try the save anyway ++ */ ++int ++fchecktime(struct buffer *bp) ++{ ++ struct stat sb; ++ ++ if (stat(bp->b_fname, &sb) == -1) ++ return (TRUE); ++ ++ /* if (bp->b_fi.fi_mtime.tv_sec != sb.st_mtimespec.tv_sec || ++ bp->b_fi.fi_mtime.tv_nsec != sb.st_mtimespec.tv_nsec) */ ++ if (bp->b_fi.fi_mtime.tv_sec != sb.st_mtime) ++ return (FALSE); ++ ++ return (TRUE); ++ ++} ++ ++/* ++ * Location of backup file. This function creates the correct path. ++ */ ++static char * ++bkuplocation(const char *fn) ++{ ++ struct stat sb; ++ char *ret; ++ ++ if (bkupdir != NULL && (stat(bkupdir, &sb) == 0) && ++ S_ISDIR(sb.st_mode) && !bkupleavetmp(fn)) { ++ char fname[NFILEN]; ++ const char *c; ++ int i = 0, len; ++ ++ c = fn; ++ len = strlen(bkupdir); ++ ++ while (*c != '\0') { ++ /* Make sure we don't go over combined: ++ * strlen(bkupdir + '/' + fname + '\0') ++ */ ++ if (i >= NFILEN - len - 1) ++ return (NULL); ++ if (*c == '/') { ++ fname[i] = '!'; ++ } else if (*c == '!') { ++ if (i >= NFILEN - len - 2) ++ return (NULL); ++ fname[i++] = '!'; ++ fname[i] = '!'; ++ } else ++ fname[i] = *c; ++ i++; ++ c++; ++ } ++ fname[i] = '\0'; ++ if (asprintf(&ret, "%s/%s", bkupdir, fname) == -1) ++ return (NULL); ++ ++ } else if ((ret = strndup(fn, NFILEN)) == NULL) ++ return (NULL); ++ ++ return (ret); ++} ++ ++int ++backuptohomedir(int f, int n) ++{ ++ const char *c = _PATH_MG_DIR; ++ char *p; ++ ++ if (bkupdir == NULL) { ++ p = adjustname(c, TRUE); ++ bkupdir = strndup(p, NFILEN); ++ if (bkupdir == NULL) ++ return(FALSE); ++ ++ if (mkdir(bkupdir, 0700) == -1 && errno != EEXIST) { ++ free(bkupdir); ++ bkupdir = NULL; ++ } ++ } else { ++ free(bkupdir); ++ bkupdir = NULL; ++ } ++ ++ return (TRUE); ++} ++ ++/* ++ * For applications that use mg as the editor and have a desire to keep ++ * '~' files in /tmp, toggle the location: /tmp | ~/.mg.d ++ */ ++int ++toggleleavetmp(int f, int n) ++{ ++ leavetmp = !leavetmp; ++ ++ return (TRUE); ++} ++ ++/* ++ * Returns TRUE if fn is located in the temp directory and we want to save ++ * those backups there. ++ */ ++int ++bkupleavetmp(const char *fn) ++{ ++ if (!leavetmp) ++ return(FALSE); ++ ++ if (strncmp(fn, "/tmp", 4) == 0) ++ return (TRUE); ++ ++ return (FALSE); ++} ++ ++/* ++ * Expand file names beginning with '~' if appropriate: ++ * 1, if ./~fn exists, continue without expanding tilde. ++ * 2, else, if username 'fn' exists, expand tilde with home directory path. ++ * 3, otherwise, continue and create new buffer called ~fn. ++ */ ++char * ++expandtilde(const char *fn) ++{ ++ struct passwd *pw; ++ struct stat statbuf; ++ const char *cp; ++ char user[LOGIN_NAME_MAX], path[NFILEN]; ++ char *ret; ++ size_t ulen, plen; ++ ++ path[0] = '\0'; ++ ++ if (fn[0] != '~' || stat(fn, &statbuf) == 0) { ++ if ((ret = strndup(fn, NFILEN)) == NULL) ++ return (NULL); ++ return(ret); ++ } ++ cp = strchr(fn, '/'); ++ if (cp == NULL) ++ cp = fn + strlen(fn); /* point to the NUL byte */ ++ ulen = cp - &fn[1]; ++ if (ulen >= sizeof(user)) { ++ if ((ret = strndup(fn, NFILEN)) == NULL) ++ return (NULL); ++ return(ret); ++ } ++ if (ulen == 0) /* ~/ or ~ */ ++ pw = getpwuid(geteuid()); ++ else { /* ~user/ or ~user */ ++ memcpy(user, &fn[1], ulen); ++ user[ulen] = '\0'; ++ pw = getpwnam(user); ++ } ++ if (pw != NULL) { ++ plen = strlcpy(path, pw->pw_dir, sizeof(path)); ++ if (plen == 0 || path[plen - 1] != '/') { ++ if (strlcat(path, "/", sizeof(path)) >= sizeof(path)) { ++ dobeep(); ++ ewprintf("Path too long"); ++ return (NULL); ++ } ++ } ++ fn = cp; ++ if (*fn == '/') ++ fn++; ++ } ++ if (strlcat(path, fn, sizeof(path)) >= sizeof(path)) { ++ dobeep(); ++ ewprintf("Path too long"); ++ return (NULL); ++ } ++ if ((ret = strndup(path, NFILEN)) == NULL) ++ return (NULL); ++ ++ return (ret); ++} diff -Naur a/futimens.c b/futimens.c --- a/futimens.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/futimens.c 2020-02-01 21:55:02.000000000 +0000 ++++ b/futimens.c 2020-04-20 21:26:10.000000000 +0100 @@ -0,0 +1,14 @@ +/* This file is in the public domain. */ + @@ -241,9 +1697,9 @@ diff -Naur a/futimens.c b/futimens.c + return futimes(fildes, timevals); +} diff -Naur a/grep.c b/grep.c ---- a/grep.c 2020-02-01 21:23:32.000000000 +0000 -+++ b/grep.c 2020-02-01 21:35:07.000000000 +0000 -@@ -16,6 +16,9 @@ +--- a/grep.c 2020-04-20 21:09:41.000000000 +0100 ++++ b/grep.c 2020-04-20 21:26:10.000000000 +0100 +@@ -15,6 +15,9 @@ #include #include @@ -253,9 +1709,375 @@ diff -Naur a/grep.c b/grep.c #include "def.h" #include "kbd.h" #include "funmap.h" +diff -Naur a/grep.c.orig b/grep.c.orig +--- a/grep.c.orig 1970-01-01 01:00:00.000000000 +0100 ++++ b/grep.c.orig 2020-04-20 21:26:06.000000000 +0100 +@@ -0,0 +1,362 @@ ++/* $OpenBSD: grep.c,v 1.48 2019/07/11 18:20:18 lum Exp $ */ ++ ++/* This file is in the public domain */ ++ ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "def.h" ++#include "kbd.h" ++#include "funmap.h" ++ ++int globalwd = FALSE; ++static int compile_goto_error(int, int); ++int next_error(int, int); ++static int grep(int, int); ++static int gid(int, int); ++static struct buffer *compile_mode(const char *, const char *); ++void grep_init(void); ++ ++static char compile_last_command[NFILEN] = "make "; ++ ++/* ++ * Hints for next-error ++ * ++ * XXX - need some kind of callback to find out when those get killed. ++ */ ++struct mgwin *compile_win; ++struct buffer *compile_buffer; ++ ++static PF compile_pf[] = { ++ compile_goto_error ++}; ++ ++static struct KEYMAPE (1) compilemap = { ++ 1, ++ 1, ++ rescan, ++ { ++ { CCHR('M'), CCHR('M'), compile_pf, NULL } ++ } ++}; ++ ++void ++grep_init(void) ++{ ++ funmap_add(compile_goto_error, "compile-goto-error", 0); ++ funmap_add(next_error, "next-error", 0); ++ funmap_add(grep, "grep", 1); ++ funmap_add(compile, "compile", 0); ++ funmap_add(gid, "gid", 1); ++ maps_add((KEYMAP *)&compilemap, "compile"); ++} ++ ++/* ARGSUSED */ ++static int ++grep(int f, int n) ++{ ++ char cprompt[NFILEN], *bufp; ++ struct buffer *bp; ++ struct mgwin *wp; ++ ++ (void)strlcpy(cprompt, "grep -n ", sizeof(cprompt)); ++ if ((bufp = eread("Run grep: ", cprompt, NFILEN, ++ EFDEF | EFNEW | EFCR)) == NULL) ++ return (ABORT); ++ else if (bufp[0] == '\0') ++ return (FALSE); ++ if (strlcat(cprompt, " /dev/null", sizeof(cprompt)) >= sizeof(cprompt)) ++ return (FALSE); ++ ++ if ((bp = compile_mode("*grep*", cprompt)) == NULL) ++ return (FALSE); ++ if ((wp = popbuf(bp, WNONE)) == NULL) ++ return (FALSE); ++ curbp = bp; ++ compile_win = curwp = wp; ++ return (TRUE); ++} ++ ++/* ARGSUSED */ ++int ++compile(int f, int n) ++{ ++ char cprompt[NFILEN], *bufp; ++ struct buffer *bp; ++ struct mgwin *wp; ++ ++ (void)strlcpy(cprompt, compile_last_command, sizeof(cprompt)); ++ if ((bufp = eread("Compile command: ", cprompt, NFILEN, ++ EFDEF | EFNEW | EFCR)) == NULL) ++ return (ABORT); ++ else if (bufp[0] == '\0') ++ return (FALSE); ++ if (savebuffers(f, n) == ABORT) ++ return (ABORT); ++ (void)strlcpy(compile_last_command, bufp, sizeof(compile_last_command)); ++ ++ if ((bp = compile_mode("*compile*", cprompt)) == NULL) ++ return (FALSE); ++ if ((wp = popbuf(bp, WNONE)) == NULL) ++ return (FALSE); ++ curbp = bp; ++ compile_win = curwp = wp; ++ gotoline(FFARG, 0); ++ return (TRUE); ++} ++ ++/* id-utils foo. */ ++/* ARGSUSED */ ++static int ++gid(int f, int n) ++{ ++ char command[NFILEN]; ++ char cprompt[NFILEN], *bufp; ++ int c; ++ struct buffer *bp; ++ struct mgwin *wp; ++ int i, j, len; ++ ++ /* catch ([^\s(){}]+)[\s(){}]* */ ++ ++ i = curwp->w_doto; ++ /* Skip backwards over delimiters we are currently on */ ++ while (i > 0) { ++ c = lgetc(curwp->w_dotp, i); ++ if (isalnum(c) || c == '_') ++ break; ++ ++ i--; ++ } ++ ++ /* Skip the symbol itself */ ++ for (; i > 0; i--) { ++ c = lgetc(curwp->w_dotp, i - 1); ++ if (!isalnum(c) && c != '_') ++ break; ++ } ++ /* Fill the symbol in cprompt[] */ ++ for (j = 0; j < sizeof(cprompt) - 1 && i < llength(curwp->w_dotp); ++ j++, i++) { ++ c = lgetc(curwp->w_dotp, i); ++ if (!isalnum(c) && c != '_') ++ break; ++ cprompt[j] = c; ++ } ++ cprompt[j] = '\0'; ++ ++ if ((bufp = eread("Run gid (with args): ", cprompt, NFILEN, ++ (j ? EFDEF : 0) | EFNEW | EFCR)) == NULL) ++ return (ABORT); ++ else if (bufp[0] == '\0') ++ return (FALSE); ++ len = snprintf(command, sizeof(command), "gid %s", cprompt); ++ if (len < 0 || len >= sizeof(command)) ++ return (FALSE); ++ ++ if ((bp = compile_mode("*gid*", command)) == NULL) ++ return (FALSE); ++ if ((wp = popbuf(bp, WNONE)) == NULL) ++ return (FALSE); ++ curbp = bp; ++ compile_win = curwp = wp; ++ return (TRUE); ++} ++ ++struct buffer * ++compile_mode(const char *name, const char *command) ++{ ++ struct buffer *bp; ++ FILE *fpipe; ++ char *buf; ++ size_t sz; ++ ssize_t len; ++ int ret, n, status; ++ char cwd[NFILEN], qcmd[NFILEN]; ++ char timestr[NTIME]; ++ time_t t; ++ ++ buf = NULL; ++ sz = 0; ++ ++ n = snprintf(qcmd, sizeof(qcmd), "%s 2>&1", command); ++ if (n < 0 || n >= sizeof(qcmd)) ++ return (NULL); ++ ++ bp = bfind(name, TRUE); ++ if (bclear(bp) != TRUE) ++ return (NULL); ++ ++ if (getbufcwd(bp->b_cwd, sizeof(bp->b_cwd)) != TRUE) ++ return (NULL); ++ addlinef(bp, "cd %s", bp->b_cwd); ++ addline(bp, qcmd); ++ addline(bp, ""); ++ ++ if (getcwd(cwd, sizeof(cwd)) == NULL) ++ panic("Can't get current directory!"); ++ if (chdir(bp->b_cwd) == -1) { ++ dobeep(); ++ ewprintf("Can't change dir to %s", bp->b_cwd); ++ return (NULL); ++ } ++ if ((fpipe = popen(qcmd, "r")) == NULL) { ++ dobeep(); ++ ewprintf("Problem opening pipe"); ++ return (NULL); ++ } ++ while ((len = getline(&buf, &sz, fpipe)) != -1) { ++ if (buf[len - 1] == '\n') ++ buf[len - 1] = '\0'; ++ addline(bp, buf); ++ } ++ free(buf); ++ if (ferror(fpipe)) ++ ewprintf("Problem reading pipe"); ++ ret = pclose(fpipe); ++ t = time(NULL); ++ strftime(timestr, sizeof(timestr), "%a %b %e %T %Y", localtime(&t)); ++ addline(bp, ""); ++ if (WIFEXITED(ret)) { ++ status = WEXITSTATUS(ret); ++ if (status == 0) ++ addlinef(bp, "Command finished at %s", timestr); ++ else ++ addlinef(bp, "Command exited abnormally with code %d " ++ "at %s", status, timestr); ++ } else ++ addlinef(bp, "Subshell killed by signal %d at %s", ++ WTERMSIG(ret), timestr); ++ ++ bp->b_dotp = bfirstlp(bp); ++ bp->b_modes[0] = name_mode("fundamental"); ++ bp->b_modes[1] = name_mode("compile"); ++ bp->b_nmodes = 1; ++ ++ compile_buffer = bp; ++ ++ if (chdir(cwd) == -1) { ++ dobeep(); ++ ewprintf("Can't change dir back to %s", cwd); ++ return (NULL); ++ } ++ return (bp); ++} ++ ++/* ARGSUSED */ ++static int ++compile_goto_error(int f, int n) ++{ ++ struct buffer *bp; ++ struct mgwin *wp; ++ char *fname, *line, *lp, *ln; ++ int lineno; ++ char *adjf, path[NFILEN]; ++ const char *errstr; ++ struct line *last; ++ ++ compile_win = curwp; ++ compile_buffer = curbp; ++ last = blastlp(compile_buffer); ++ ++ retry: ++ /* last line is compilation result */ ++ if (curwp->w_dotp == last) ++ return (FALSE); ++ ++ if ((line = linetostr(curwp->w_dotp)) == NULL) ++ return (FALSE); ++ lp = line; ++ if ((fname = strsep(&lp, ":")) == NULL || *fname == '\0') ++ goto fail; ++ if ((ln = strsep(&lp, ":")) == NULL || *ln == '\0') ++ goto fail; ++ lineno = (int)strtonum(ln, INT_MIN, INT_MAX, &errstr); ++ if (errstr) ++ goto fail; ++ ++ if (fname && fname[0] != '/') { ++ if (getbufcwd(path, sizeof(path)) == FALSE) ++ goto fail; ++ if (strlcat(path, fname, sizeof(path)) >= sizeof(path)) ++ goto fail; ++ adjf = path; ++ } else { ++ adjf = adjustname(fname, TRUE); ++ } ++ free(line); ++ ++ if (adjf == NULL) ++ return (FALSE); ++ ++ if ((bp = findbuffer(adjf)) == NULL) ++ return (FALSE); ++ if ((wp = popbuf(bp, WNONE)) == NULL) ++ return (FALSE); ++ curbp = bp; ++ curwp = wp; ++ if (bp->b_fname[0] == '\0') ++ readin(adjf); ++ gotoline(FFARG, lineno); ++ return (TRUE); ++fail: ++ free(line); ++ if (curwp->w_dotp != blastlp(curbp)) { ++ curwp->w_dotp = lforw(curwp->w_dotp); ++ curwp->w_rflag |= WFMOVE; ++ goto retry; ++ } ++ dobeep(); ++ ewprintf("No more hits"); ++ return (FALSE); ++} ++ ++/* ARGSUSED */ ++int ++next_error(int f, int n) ++{ ++ if (compile_win == NULL || compile_buffer == NULL) { ++ dobeep(); ++ ewprintf("No compilation active"); ++ return (FALSE); ++ } ++ curwp = compile_win; ++ curbp = compile_buffer; ++ if (curwp->w_dotp == blastlp(curbp)) { ++ dobeep(); ++ ewprintf("No more hits"); ++ return (FALSE); ++ } ++ curwp->w_dotp = lforw(curwp->w_dotp); ++ curwp->w_rflag |= WFMOVE; ++ ++ return (compile_goto_error(f, n)); ++} ++ ++/* ++ * Since we don't have variables (we probably should) these are command ++ * processors for changing the values of mode flags. ++ */ ++/* ARGSUSED */ ++int ++globalwdtoggle(int f, int n) ++{ ++ if (f & FFARG) ++ globalwd = n > 0; ++ else ++ globalwd = !globalwd; ++ ++ sgarbf = TRUE; ++ ++ return (TRUE); ++} diff -Naur a/main.c b/main.c ---- a/main.c 2020-02-01 21:23:32.000000000 +0000 -+++ b/main.c 2020-02-01 21:34:42.000000000 +0000 +--- a/main.c 2020-04-20 21:09:41.000000000 +0100 ++++ b/main.c 2020-04-20 21:26:10.000000000 +0100 @@ -16,6 +16,9 @@ #include #include @@ -267,8 +2089,8 @@ diff -Naur a/main.c b/main.c #include "kbd.h" #include "funmap.h" diff -Naur a/paragraph.c b/paragraph.c ---- a/paragraph.c 2020-02-01 21:23:32.000000000 +0000 -+++ b/paragraph.c 2020-02-01 21:34:49.000000000 +0000 +--- a/paragraph.c 2020-04-20 21:09:41.000000000 +0100 ++++ b/paragraph.c 2020-04-20 21:26:10.000000000 +0100 @@ -14,6 +14,9 @@ #include #include @@ -279,9 +2101,554 @@ diff -Naur a/paragraph.c b/paragraph.c #include "def.h" static int fillcol = 70; +diff -Naur a/paragraph.c.orig b/paragraph.c.orig +--- a/paragraph.c.orig 1970-01-01 01:00:00.000000000 +0100 ++++ b/paragraph.c.orig 2020-04-20 21:26:06.000000000 +0100 +@@ -0,0 +1,499 @@ ++/* $OpenBSD: paragraph.c,v 1.46 2018/11/17 09:52:34 lum Exp $ */ ++ ++/* This file is in the public domain. */ ++ ++/* ++ * Code for dealing with paragraphs and filling. Adapted from MicroEMACS 3.6 ++ * and GNU-ified by mwm@ucbvax. Several bug fixes by blarson@usc-oberon. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "def.h" ++ ++static int fillcol = 70; ++ ++#define MAXWORD 256 ++ ++static int findpara(void); ++static int do_gotoeop(int, int, int *); ++ ++/* ++ * Move to start of paragraph. ++ * Move backwards by line, checking from the 1st character forwards for the ++ * existence a non-space. If a non-space character is found, move to the ++ * preceding line. Keep doing this until a line with only spaces is found or ++ * the start of buffer. ++ */ ++/* ARGSUSED */ ++int ++gotobop(int f, int n) ++{ ++ int col, nospace; ++ ++ /* the other way... */ ++ if (n < 0) ++ return (gotoeop(f, -n)); ++ ++ while (n-- > 0) { ++ nospace = 0; ++ while (lback(curwp->w_dotp) != curbp->b_headp) { ++ curwp->w_doto = 0; ++ col = 0; ++ ++ while (col < llength(curwp->w_dotp) && ++ (isspace(lgetc(curwp->w_dotp, col)))) ++ col++; ++ ++ if (col >= llength(curwp->w_dotp)) { ++ if (nospace) ++ break; ++ } else ++ nospace = 1; ++ ++ curwp->w_dotline--; ++ curwp->w_dotp = lback(curwp->w_dotp); ++ } ++ } ++ /* force screen update */ ++ curwp->w_rflag |= WFMOVE; ++ return (TRUE); ++} ++ ++/* ++ * Move to end of paragraph. ++ * See comments for gotobop(). Same, but moving forwards. ++ */ ++/* ARGSUSED */ ++int ++gotoeop(int f, int n) ++{ ++ int i; ++ ++ return(do_gotoeop(f, n, &i)); ++} ++ ++int ++do_gotoeop(int f, int n, int *i) ++{ ++ int col, nospace, j = 0; ++ ++ /* the other way... */ ++ if (n < 0) ++ return (gotobop(f, -n)); ++ ++ /* for each one asked for */ ++ while (n-- > 0) { ++ *i = ++j; ++ nospace = 0; ++ while (lforw(curwp->w_dotp) != curbp->b_headp) { ++ col = 0; ++ curwp->w_doto = 0; ++ ++ while (col < llength(curwp->w_dotp) && ++ (isspace(lgetc(curwp->w_dotp, col)))) ++ col++; ++ ++ if (col >= llength(curwp->w_dotp)) { ++ if (nospace) ++ break; ++ } else ++ nospace = 1; ++ ++ curwp->w_dotp = lforw(curwp->w_dotp); ++ curwp->w_dotline++; ++ ++ } ++ } ++ /* do not continue after end of buffer */ ++ if (lforw(curwp->w_dotp) == curbp->b_headp) { ++ gotoeol(FFRAND, 1); ++ curwp->w_rflag |= WFMOVE; ++ return (FALSE); ++ } ++ ++ /* force screen update */ ++ curwp->w_rflag |= WFMOVE; ++ return (TRUE); ++} ++ ++/* ++ * Justify a paragraph. Fill the current paragraph according to the current ++ * fill column. ++ */ ++/* ARGSUSED */ ++int ++fillpara(int f, int n) ++{ ++ int c; /* current char during scan */ ++ int wordlen; /* length of current word */ ++ int clength; /* position on line during fill */ ++ int i; /* index during word copy */ ++ int eopflag; /* Are we at the End-Of-Paragraph? */ ++ int firstflag; /* first word? (needs no space) */ ++ int newlength; /* tentative new line length */ ++ int eolflag; /* was at end of line */ ++ int retval; /* return value */ ++ struct line *eopline; /* pointer to line just past EOP */ ++ char wbuf[MAXWORD]; /* buffer for current word */ ++ ++ if (n == 0) ++ return (TRUE); ++ ++ undo_boundary_enable(FFRAND, 0); ++ ++ /* record the pointer to the line just past the EOP */ ++ (void)gotoeop(FFRAND, 1); ++ if (curwp->w_doto != 0) { ++ /* paragraph ends at end of buffer */ ++ (void)lnewline(); ++ eopline = lforw(curwp->w_dotp); ++ } else ++ eopline = curwp->w_dotp; ++ ++ /* and back top the beginning of the paragraph */ ++ (void)gotobop(FFRAND, 1); ++ ++ /* initialize various info */ ++ while (inword() == 0 && forwchar(FFRAND, 1)); ++ ++ clength = curwp->w_doto; ++ wordlen = 0; ++ ++ /* scan through lines, filling words */ ++ firstflag = TRUE; ++ eopflag = FALSE; ++ while (!eopflag) { ++ ++ /* get the next character in the paragraph */ ++ if ((eolflag = (curwp->w_doto == llength(curwp->w_dotp)))) { ++ c = ' '; ++ if (lforw(curwp->w_dotp) == eopline) ++ eopflag = TRUE; ++ } else ++ c = lgetc(curwp->w_dotp, curwp->w_doto); ++ ++ /* and then delete it */ ++ if (ldelete((RSIZE) 1, KNONE) == FALSE && !eopflag) { ++ retval = FALSE; ++ goto cleanup; ++ } ++ ++ /* if not a separator, just add it in */ ++ if (c != ' ' && c != '\t') { ++ if (wordlen < MAXWORD - 1) ++ wbuf[wordlen++] = c; ++ else { ++ /* ++ * You lose chars beyond MAXWORD if the word ++ * is too long. I'm too lazy to fix it now; it ++ * just silently truncated the word before, ++ * so I get to feel smug. ++ */ ++ ewprintf("Word too long!"); ++ } ++ } else if (wordlen) { ++ ++ /* calculate tentative new length with word added */ ++ newlength = clength + 1 + wordlen; ++ ++ /* ++ * if at end of line or at doublespace and previous ++ * character was one of '.','?','!' doublespace here. ++ * behave the same way if a ')' is preceded by a ++ * [.?!] and followed by a doublespace. ++ */ ++ if (dblspace && (!eopflag && ((eolflag || ++ curwp->w_doto == llength(curwp->w_dotp) || ++ (c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ' ++ || c == '\t') && (ISEOSP(wbuf[wordlen - 1]) || ++ (wbuf[wordlen - 1] == ')' && wordlen >= 2 && ++ ISEOSP(wbuf[wordlen - 2])))) && ++ wordlen < MAXWORD - 1)) ++ wbuf[wordlen++] = ' '; ++ ++ /* at a word break with a word waiting */ ++ if (newlength <= fillcol) { ++ /* add word to current line */ ++ if (!firstflag) { ++ (void)linsert(1, ' '); ++ ++clength; ++ } ++ firstflag = FALSE; ++ } else { ++ if (curwp->w_doto > 0 && ++ lgetc(curwp->w_dotp, curwp->w_doto - 1) == ' ') { ++ curwp->w_doto -= 1; ++ (void)ldelete((RSIZE) 1, KNONE); ++ } ++ /* start a new line */ ++ (void)lnewline(); ++ clength = 0; ++ } ++ ++ /* and add the word in in either case */ ++ for (i = 0; i < wordlen; i++) { ++ (void)linsert(1, wbuf[i]); ++ ++clength; ++ } ++ wordlen = 0; ++ } ++ } ++ /* and add a last newline for the end of our new paragraph */ ++ (void)lnewline(); ++ ++ /* ++ * We really should wind up where we started, (which is hard to keep ++ * track of) but I think the end of the last line is better than the ++ * beginning of the blank line. ++ */ ++ (void)backchar(FFRAND, 1); ++ retval = TRUE; ++cleanup: ++ undo_boundary_enable(FFRAND, 1); ++ return (retval); ++} ++ ++/* ++ * Delete n paragraphs. Move to the beginning of the current paragraph, or if ++ * the cursor is on an empty line, move down the buffer to the first line with ++ * non-space characters. Then mark n paragraphs and delete. ++ */ ++/* ARGSUSED */ ++int ++killpara(int f, int n) ++{ ++ int lineno, status; ++ ++ if (n == 0) ++ return (TRUE); ++ ++ if (findpara() == FALSE) ++ return (TRUE); ++ ++ /* go to the beginning of the paragraph */ ++ (void)gotobop(FFRAND, 1); ++ ++ /* take a note of the line number for after deletions and set mark */ ++ lineno = curwp->w_dotline; ++ curwp->w_markp = curwp->w_dotp; ++ curwp->w_marko = curwp->w_doto; ++ ++ (void)gotoeop(FFRAND, n); ++ ++ if ((status = killregion(FFRAND, 1)) != TRUE) ++ return (status); ++ ++ curwp->w_dotline = lineno; ++ return (TRUE); ++} ++ ++/* ++ * Mark n paragraphs starting with the n'th and working our way backwards. ++ * This leaves the cursor at the beginning of the paragraph where markpara() ++ * was invoked. ++ */ ++/* ARGSUSED */ ++int ++markpara(int f, int n) ++{ ++ int i = 0; ++ ++ if (n == 0) ++ return (TRUE); ++ ++ clearmark(FFARG, 0); ++ ++ if (findpara() == FALSE) ++ return (TRUE); ++ ++ (void)do_gotoeop(FFRAND, n, &i); ++ ++ /* set the mark here */ ++ curwp->w_markp = curwp->w_dotp; ++ curwp->w_marko = curwp->w_doto; ++ ++ (void)gotobop(FFRAND, i); ++ ++ return (TRUE); ++} ++ ++/* ++ * Transpose the current paragraph with the following paragraph. If invoked ++ * multiple times, transpose to the n'th paragraph. If invoked between ++ * paragraphs, move to the previous paragraph, then continue. ++ */ ++/* ARGSUSED */ ++int ++transposepara(int f, int n) ++{ ++ int i = 0, status; ++ char flg; ++ ++ if (n == 0) ++ return (TRUE); ++ ++ undo_boundary_enable(FFRAND, 0); ++ ++ /* find a paragraph, set mark, then goto the end */ ++ gotobop(FFRAND, 1); ++ curwp->w_markp = curwp->w_dotp; ++ curwp->w_marko = curwp->w_doto; ++ (void)gotoeop(FFRAND, 1); ++ ++ /* take a note of buffer flags - we may need them */ ++ flg = curbp->b_flag; ++ ++ /* clean out kill buffer then kill region */ ++ kdelete(); ++ if ((status = killregion(FFRAND, 1)) != TRUE) ++ return (status); ++ ++ /* ++ * Now step through n paragraphs. If we reach the end of buffer, ++ * stop and paste the killed region back, then display a message. ++ */ ++ if (do_gotoeop(FFRAND, n, &i) == FALSE) { ++ ewprintf("Cannot transpose paragraph, end of buffer reached."); ++ (void)gotobop(FFRAND, i); ++ (void)yank(FFRAND, 1); ++ curbp->b_flag = flg; ++ return (FALSE); ++ } ++ (void)yank(FFRAND, 1); ++ ++ undo_boundary_enable(FFRAND, 1); ++ ++ return (TRUE); ++} ++ ++/* ++ * Go down the buffer until we find a line with non-space characters. ++ */ ++int ++findpara(void) ++{ ++ int col, nospace = 0; ++ ++ /* we move forward to find a para to mark */ ++ do { ++ curwp->w_doto = 0; ++ col = 0; ++ ++ /* check if we are on a blank line */ ++ while (col < llength(curwp->w_dotp)) { ++ if (!isspace(lgetc(curwp->w_dotp, col))) ++ nospace = 1; ++ col++; ++ } ++ if (nospace) ++ break; ++ ++ if (lforw(curwp->w_dotp) == curbp->b_headp) ++ return (FALSE); ++ ++ curwp->w_dotp = lforw(curwp->w_dotp); ++ curwp->w_dotline++; ++ } while (1); ++ ++ return (TRUE); ++} ++ ++/* ++ * Insert char with work wrap. Check to see if we're past fillcol, and if so, ++ * justify this line. As a last step, justify the line. ++ */ ++/* ARGSUSED */ ++int ++fillword(int f, int n) ++{ ++ char c; ++ int col, i, nce; ++ ++ for (i = col = 0; col <= fillcol; ++i, ++col) { ++ if (i == curwp->w_doto) ++ return selfinsert(f, n); ++ c = lgetc(curwp->w_dotp, i); ++ if (c == '\t' ++#ifdef NOTAB ++ && !(curbp->b_flag & BFNOTAB) ++#endif ++ ) ++ col |= 0x07; ++ else if (ISCTRL(c) != FALSE) ++ ++col; ++ } ++ if (curwp->w_doto != llength(curwp->w_dotp)) { ++ (void)selfinsert(f, n); ++ nce = llength(curwp->w_dotp) - curwp->w_doto; ++ } else ++ nce = 0; ++ curwp->w_doto = i; ++ ++ if ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' && c != '\t') ++ do { ++ (void)backchar(FFRAND, 1); ++ } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' && ++ c != '\t' && curwp->w_doto > 0); ++ ++ if (curwp->w_doto == 0) ++ do { ++ (void)forwchar(FFRAND, 1); ++ } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' && ++ c != '\t' && curwp->w_doto < llength(curwp->w_dotp)); ++ ++ (void)delwhite(FFRAND, 1); ++ (void)lnewline(); ++ i = llength(curwp->w_dotp) - nce; ++ curwp->w_doto = i > 0 ? i : 0; ++ curwp->w_rflag |= WFMOVE; ++ if (nce == 0 && curwp->w_doto != 0) ++ return (fillword(f, n)); ++ return (TRUE); ++} ++ ++/* ++ * Set fill column to n for justify. ++ */ ++int ++setfillcol(int f, int n) ++{ ++ char buf[32], *rep; ++ const char *es; ++ int nfill; ++ ++ if ((f & FFARG) != 0) { ++ fillcol = n; ++ } else { ++ if ((rep = eread("Set fill-column: ", buf, sizeof(buf), ++ EFNEW | EFCR)) == NULL) ++ return (ABORT); ++ else if (rep[0] == '\0') ++ return (FALSE); ++ nfill = strtonum(rep, 0, INT_MAX, &es); ++ if (es != NULL) { ++ dobeep(); ++ ewprintf("Invalid fill column: %s", rep); ++ return (FALSE); ++ } ++ fillcol = nfill; ++ ewprintf("Fill column set to %d", fillcol); ++ } ++ return (TRUE); ++} ++ ++int ++sentencespace(int f, int n) ++{ ++ if (f & FFARG) ++ dblspace = n > 1; ++ else ++ dblspace = !dblspace; ++ ++ return (TRUE); ++} +diff -Naur a/reallocarray.c b/reallocarray.c +--- a/reallocarray.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/reallocarray.c 2020-04-20 21:26:10.000000000 +0100 +@@ -0,0 +1,38 @@ ++/* $OpenBSD: reallocarray.c,v 1.3 2015/09/13 08:31:47 guenther Exp $ */ ++/* ++ * Copyright (c) 2008 Otto Moerbeek ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++#include ++#include ++ ++/* ++ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX ++ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW ++ */ ++#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) ++ ++void * ++reallocarray(void *optr, size_t nmemb, size_t size) ++{ ++ if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && ++ nmemb > 0 && SIZE_MAX / nmemb < size) { ++ errno = ENOMEM; ++ return NULL; ++ } ++ return realloc(optr, size * nmemb); ++} diff -Naur a/strtonum.c b/strtonum.c --- a/strtonum.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/strtonum.c 2020-02-01 21:55:24.000000000 +0000 ++++ b/strtonum.c 2020-04-20 21:26:10.000000000 +0100 @@ -0,0 +1,65 @@ +/* $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $ */ + @@ -349,8 +2716,8 @@ diff -Naur a/strtonum.c b/strtonum.c + return (ll); +} diff -Naur a/tags.c b/tags.c ---- a/tags.c 2020-02-01 21:23:32.000000000 +0000 -+++ b/tags.c 2020-02-01 21:27:56.000000000 +0000 +--- a/tags.c 2020-04-20 21:09:41.000000000 +0100 ++++ b/tags.c 2020-04-20 21:26:10.000000000 +0100 @@ -8,7 +8,11 @@ #include @@ -392,7 +2759,7 @@ diff -Naur a/tags.c b/tags.c struct tagpos { diff -Naur a/tree.h b/tree.h --- a/tree.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/tree.h 2020-02-01 21:25:11.000000000 +0000 ++++ b/tree.h 2020-04-20 21:26:10.000000000 +0100 @@ -0,0 +1,1006 @@ +/* $OpenBSD: tree.h,v 1.29 2017/07/30 19:27:20 deraadt Exp $ */ +/* diff --git a/pkgs/applications/editors/mg/default.nix b/pkgs/applications/editors/mg/default.nix index f97e34aff8d..e019baaf727 100644 --- a/pkgs/applications/editors/mg/default.nix +++ b/pkgs/applications/editors/mg/default.nix @@ -1,12 +1,14 @@ -{ stdenv, fetchurl, pkgconfig, ncurses, buildPackages, libbsd }: +{ stdenv, fetchFromGitHub, pkgconfig, ncurses, buildPackages, libbsd }: stdenv.mkDerivation rec { pname = "mg"; - version = "20180927"; + version = "20200215"; - src = fetchurl { - url = "https://github.com/hboetes/mg/archive/${version}.tar.gz"; - sha256 = "fbb09729ea00fe42dcdbc96ac7fc1d2b89eac651dec49e4e7af52fad4f5788f6"; + src = fetchFromGitHub { + owner = "hboetes"; + repo = "mg"; + rev = "20200215"; + sha256 = "1rss7d43hbq43n63gxfvx4b2vh2km58cchwzdf2ssqhaz3qj40m6"; }; enableParallelBuilding = true; From fcedd9f78e8072b629a5ff1da4f538f7e655f091 Mon Sep 17 00:00:00 2001 From: "D. Guthrie" Date: Tue, 21 Apr 2020 19:04:51 +0100 Subject: [PATCH 06/81] Fix the patch: when converting it to the new version (20200215), forgot to remove temporary files --- .../editors/mg/darwin_no_libbsd.patch | 2379 +---------------- 1 file changed, 18 insertions(+), 2361 deletions(-) diff --git a/pkgs/applications/editors/mg/darwin_no_libbsd.patch b/pkgs/applications/editors/mg/darwin_no_libbsd.patch index 2484c03255b..1863f2952b2 100644 --- a/pkgs/applications/editors/mg/darwin_no_libbsd.patch +++ b/pkgs/applications/editors/mg/darwin_no_libbsd.patch @@ -1,6 +1,6 @@ diff -Naur a/GNUmakefile b/GNUmakefile --- a/GNUmakefile 2020-04-20 21:09:41.000000000 +0100 -+++ b/GNUmakefile 2020-04-20 21:31:19.000000000 +0100 ++++ b/GNUmakefile 2020-04-21 19:01:59.000000000 +0100 @@ -18,7 +18,7 @@ STRIP= /usr/bin/strip @@ -10,7 +10,7 @@ diff -Naur a/GNUmakefile b/GNUmakefile BSD_CPPFLAGS:= BSD_LIBS:= -lutil else -@@ -38,24 +38,21 @@ +@@ -38,10 +38,6 @@ $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.) endif @@ -21,11 +21,7 @@ diff -Naur a/GNUmakefile b/GNUmakefile CC?= gcc CFLAGS?= -O2 -pipe CFLAGS+= -g -Wall - CPPFLAGS= -DREGEX - CPPFLAGS+= -D_GNU_SOURCE --CPPFLAGS+= $(BSD_CPPFLAGS) -+CPPFLAGS+= $(BSD_CPPFLAGS) -D__dead=__dead2 - LIBS= $(CURSES_LIBS) $(BSD_LIBS) +@@ -52,10 +48,11 @@ OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \ @@ -41,109 +37,9 @@ diff -Naur a/GNUmakefile b/GNUmakefile OBJS+= cmode.o cscope.o dired.o grep.o tags.o -diff -Naur a/GNUmakefile~ b/GNUmakefile~ ---- a/GNUmakefile~ 1970-01-01 01:00:00.000000000 +0100 -+++ b/GNUmakefile~ 2020-04-20 21:27:39.000000000 +0100 -@@ -0,0 +1,96 @@ -+# Makefile for mg -+ -+# This Makefile has been written by Han Boetes -+# and is released in Public Domain. -+ -+# *sigh* Those debian folks are really tidy on their licenses. -+ -+name= mg -+ -+prefix= /usr/local -+bindir= $(prefix)/bin -+libdir= $(prefix)/lib -+includedir= $(prefix)/include -+mandir= $(prefix)/man -+ -+PKG_CONFIG= /usr/bin/pkg-config --silence-errors -+INSTALL= /usr/bin/install -+STRIP= /usr/bin/strip -+ -+UNAME:= $(shell uname) -+ifeq ($(UNAME),FreeBSD) -+ BSD_CPPFLAGS:= -+ BSD_LIBS:= -lutil -+else -+ BSD_CPPFLAGS:= $(shell $(PKG_CONFIG) --cflags libbsd-overlay) -+ BSD_LIBS:= $(shell $(PKG_CONFIG) --libs libbsd-overlay) -+endif -+ -+# Test is some required libraries are installed. Rather bummer that -+# they are also required to run make clean or uninstall. Oh well... Who -+# does that? -+ifeq ($(BSD_LIBS),) -+ $(error You probably need to install "libbsd-dev" or "libbsd-devel" or something like that.) -+endif -+ -+CURSES_LIBS:= $(shell $(PKG_CONFIG) --libs ncurses) -+ifeq ($(CURSES_LIBS),) -+ $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.) -+endif -+ -+ifdef STATIC -+ LDFLAGS=-static -static-libgcc -+endif -+ -+CC?= gcc -+CFLAGS?= -O2 -pipe -+CFLAGS+= -g -Wall -+CPPFLAGS= -DREGEX -+CPPFLAGS+= -D_GNU_SOURCE -+CPPFLAGS+= $(BSD_CPPFLAGS) -+LIBS= $(CURSES_LIBS) $(BSD_LIBS) -+ -+ -+OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \ -+ echo.o extend.o file.o fileio.o funmap.o interpreter.o help.o \ -+ kbd.o keymap.o line.o macro.o main.o match.o modes.o paragraph.o \ -+ re_search.o region.o search.o spawn.o tty.o ttyio.o ttykbd.o \ -+ undo.o util.o version.o window.o word.o yank.o -+OBJS+= cmode.o cscope.o dired.o grep.o tags.o -+ -+ -+# Portability stuff. -+CFLAGS+= -Wno-strict-aliasing -Wno-deprecated-declarations -+EXE_EXT= -+ -+.c.o: -+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -+ -+all: $(name) -+ -+$(name): $(OBJS) -+ $(CC) $(LDFLAGS) $(OBJS) -o $(name) $(LIBS) -+ -+distclean: clean -+ -rm -f *.core core.* -+ -+clean: -+ -rm -f *.o $(name)$(EXE_EXT) -+ -+ -+install: $(name) $(name).1 -+ $(INSTALL) -d $(DESTDIR)$(bindir) -+ $(INSTALL) -d $(DESTDIR)$(mandir)/man1 -+ $(INSTALL) -m 755 $(name) $(DESTDIR)$(bindir)/$(name) -+ $(INSTALL) -m 444 $(name).1 $(DESTDIR)$(mandir)/man1/$(name).1 -+ -+install-strip: install -+ $(STRIP) $(DESTDIR)$(bindir)/$(name) -+ -+uninstall: -+ rm -f \ -+ $(DESTDIR)$(bindir)/$(name)$(EXE_EXT) \ -+ $(DESTDIR)$(mandir)/man1/$(name).1 -+ -+rebuild: -+ make clean all diff -Naur a/_null.h b/_null.h --- a/_null.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/_null.h 2020-04-20 21:26:10.000000000 +0100 ++++ b/_null.h 2020-04-21 19:01:59.000000000 +0100 @@ -0,0 +1,18 @@ +/* $OpenBSD: _null.h,v 1.2 2016/09/09 22:07:58 millert Exp $ */ + @@ -165,7 +61,7 @@ diff -Naur a/_null.h b/_null.h +#endif diff -Naur a/apple.h b/apple.h --- a/apple.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/apple.h 2020-04-20 21:26:10.000000000 +0100 ++++ b/apple.h 2020-04-21 19:01:59.000000000 +0100 @@ -0,0 +1,27 @@ +/* + * Mac OS X-specific support. @@ -196,7 +92,7 @@ diff -Naur a/apple.h b/apple.h +extern int futimens(int, const struct timespec[2]); diff -Naur a/autoexec.c b/autoexec.c --- a/autoexec.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/autoexec.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/autoexec.c 2020-04-21 19:01:59.000000000 +0100 @@ -9,6 +9,9 @@ #include #include @@ -209,7 +105,7 @@ diff -Naur a/autoexec.c b/autoexec.c diff -Naur a/basic.c b/basic.c --- a/basic.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/basic.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/basic.c 2020-04-21 19:01:59.000000000 +0100 @@ -19,6 +19,9 @@ #include #include @@ -220,614 +116,9 @@ diff -Naur a/basic.c b/basic.c #include "def.h" #define percint(n1, n2) ((n1 * (int) n2) * 0.1) -diff -Naur a/basic.c.orig b/basic.c.orig ---- a/basic.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ b/basic.c.orig 2020-04-20 21:26:06.000000000 +0100 -@@ -0,0 +1,601 @@ -+/* $OpenBSD: basic.c,v 1.49 2019/06/17 11:39:26 lum Exp $ */ -+ -+/* This file is in the public domain */ -+ -+/* -+ * Basic cursor motion commands. -+ * -+ * The routines in this file are the basic -+ * command functions for moving the cursor around on -+ * the screen, setting mark, and swapping dot with -+ * mark. Only moves between lines, which might make the -+ * current buffer framing bad, are hard. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "def.h" -+ -+#define percint(n1, n2) ((n1 * (int) n2) * 0.1) -+ -+/* -+ * Go to beginning of line. -+ */ -+/* ARGSUSED */ -+int -+gotobol(int f, int n) -+{ -+ if (n == 0) -+ return (TRUE); -+ -+ curwp->w_doto = 0; -+ return (TRUE); -+} -+ -+/* -+ * Move cursor backwards. Do the -+ * right thing if the count is less than -+ * 0. Error if you try to move back from -+ * the beginning of the buffer. -+ */ -+/* ARGSUSED */ -+int -+backchar(int f, int n) -+{ -+ struct line *lp; -+ -+ if (n < 0) -+ return (forwchar(f, -n)); -+ while (n--) { -+ if (curwp->w_doto == 0) { -+ if ((lp = lback(curwp->w_dotp)) == curbp->b_headp) { -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("Beginning of buffer"); -+ } -+ return (FALSE); -+ } -+ curwp->w_dotp = lp; -+ curwp->w_doto = llength(lp); -+ curwp->w_rflag |= WFMOVE; -+ curwp->w_dotline--; -+ } else -+ curwp->w_doto--; -+ } -+ return (TRUE); -+} -+ -+/* -+ * Go to end of line. -+ */ -+/* ARGSUSED */ -+int -+gotoeol(int f, int n) -+{ -+ if (n == 0) -+ return (TRUE); -+ -+ curwp->w_doto = llength(curwp->w_dotp); -+ return (TRUE); -+} -+ -+/* -+ * Move cursor forwards. Do the -+ * right thing if the count is less than -+ * 0. Error if you try to move forward -+ * from the end of the buffer. -+ */ -+/* ARGSUSED */ -+int -+forwchar(int f, int n) -+{ -+ if (n < 0) -+ return (backchar(f, -n)); -+ while (n--) { -+ if (curwp->w_doto == llength(curwp->w_dotp)) { -+ curwp->w_dotp = lforw(curwp->w_dotp); -+ if (curwp->w_dotp == curbp->b_headp) { -+ curwp->w_dotp = lback(curwp->w_dotp); -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("End of buffer"); -+ } -+ return (FALSE); -+ } -+ curwp->w_doto = 0; -+ curwp->w_dotline++; -+ curwp->w_rflag |= WFMOVE; -+ } else -+ curwp->w_doto++; -+ } -+ return (TRUE); -+} -+ -+/* -+ * Go to the beginning of the buffer. Setting WFFULL is conservative, -+ * but almost always the case. A universal argument of higher than 9 -+ * puts the cursor back to the end of buffer. -+ */ -+int -+gotobob(int f, int n) -+{ -+ if (!curwp->w_markp) -+ (void) setmark(f, n); -+ curwp->w_dotp = bfirstlp(curbp); -+ curwp->w_doto = 0; -+ curwp->w_rflag |= WFFULL; -+ curwp->w_dotline = 1; -+ if (f & FFOTHARG && n > 0) { -+ if (n > 9) -+ gotoeob(0, 0); -+ else -+ forwline(f, percint(curwp->w_bufp->b_lines, n) - 1); -+ } -+ return (TRUE); -+} -+ -+/* -+ * Go to the end of the buffer. Leave dot 3 lines from the bottom of the -+ * window if buffer length is longer than window length; same as emacs. -+ * Setting WFFULL is conservative, but almost always the case. A universal -+ * argument of higher than 9 puts the cursor back to the start of buffer. -+ */ -+int -+gotoeob(int f, int n) -+{ -+ int ln; -+ struct line *lp; -+ -+ if (!curwp->w_markp) -+ (void) setmark(f, n); -+ curwp->w_dotp = blastlp(curbp); -+ curwp->w_doto = llength(curwp->w_dotp); -+ curwp->w_dotline = curwp->w_bufp->b_lines; -+ -+ lp = curwp->w_dotp; -+ ln = curwp->w_ntrows - 3; -+ -+ if (ln < curwp->w_bufp->b_lines && ln >= 3) { -+ while (ln--) -+ curwp->w_dotp = lback(curwp->w_dotp); -+ -+ curwp->w_linep = curwp->w_dotp; -+ curwp->w_dotp = lp; -+ } -+ if (f & FFOTHARG && n > 0) { -+ if (n > 9) -+ gotobob(0, 0); -+ else -+ backline(f, percint(curwp->w_bufp->b_lines, n)); -+ } -+ -+ curwp->w_rflag |= WFFULL; -+ return (TRUE); -+} -+ -+/* -+ * Move forward by full lines. -+ * If the number of lines to move is less -+ * than zero, call the backward line function to -+ * actually do it. The last command controls how -+ * the goal column is set. -+ */ -+/* ARGSUSED */ -+int -+forwline(int f, int n) -+{ -+ struct line *dlp; -+ -+ if (n < 0) -+ return (backline(f | FFRAND, -n)); -+ if ((dlp = curwp->w_dotp) == curbp->b_headp) { -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("End of buffer"); -+ } -+ return(TRUE); -+ } -+ if ((lastflag & CFCPCN) == 0) /* Fix goal. */ -+ setgoal(); -+ thisflag |= CFCPCN; -+ if (n == 0) -+ return (TRUE); -+ while (n--) { -+ dlp = lforw(dlp); -+ if (dlp == curbp->b_headp) { -+ curwp->w_dotp = lback(dlp); -+ curwp->w_doto = llength(curwp->w_dotp); -+ curwp->w_rflag |= WFMOVE; -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("End of buffer"); -+ } -+ return (TRUE); -+ } -+ curwp->w_dotline++; -+ } -+ curwp->w_rflag |= WFMOVE; -+ curwp->w_dotp = dlp; -+ curwp->w_doto = getgoal(dlp); -+ -+ return (TRUE); -+} -+ -+/* -+ * This function is like "forwline", but -+ * goes backwards. The scheme is exactly the same. -+ * Check for arguments that are less than zero and -+ * call your alternate. Figure out the new line and -+ * call "movedot" to perform the motion. -+ */ -+/* ARGSUSED */ -+int -+backline(int f, int n) -+{ -+ struct line *dlp; -+ -+ if (n < 0) -+ return (forwline(f | FFRAND, -n)); -+ if ((lastflag & CFCPCN) == 0) /* Fix goal. */ -+ setgoal(); -+ thisflag |= CFCPCN; -+ dlp = curwp->w_dotp; -+ if (lback(dlp) == curbp->b_headp) { -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("Beginning of buffer"); -+ } -+ return(TRUE); -+ } -+ while (n-- && lback(dlp) != curbp->b_headp) { -+ dlp = lback(dlp); -+ curwp->w_dotline--; -+ } -+ if (n > 0 && !(f & FFRAND)) { -+ dobeep(); -+ ewprintf("Beginning of buffer"); -+ } -+ curwp->w_dotp = dlp; -+ curwp->w_doto = getgoal(dlp); -+ curwp->w_rflag |= WFMOVE; -+ return (TRUE); -+} -+ -+/* -+ * Set the current goal column, which is saved in the external variable -+ * "curgoal", to the current cursor column. The column is never off -+ * the edge of the screen; it's more like display then show position. -+ */ -+void -+setgoal(void) -+{ -+ curgoal = getcolpos(curwp); /* Get the position. */ -+ /* we can now display past end of display, don't chop! */ -+} -+ -+/* -+ * This routine looks at a line (pointed -+ * to by the LINE pointer "dlp") and the current -+ * vertical motion goal column (set by the "setgoal" -+ * routine above) and returns the best offset to use -+ * when a vertical motion is made into the line. -+ */ -+int -+getgoal(struct line *dlp) -+{ -+ int c, i, col = 0; -+ char tmp[5]; -+ -+ -+ for (i = 0; i < llength(dlp); i++) { -+ c = lgetc(dlp, i); -+ if (c == '\t' -+#ifdef NOTAB -+ && !(curbp->b_flag & BFNOTAB) -+#endif -+ ) { -+ col |= 0x07; -+ col++; -+ } else if (ISCTRL(c) != FALSE) { -+ col += 2; -+ } else if (isprint(c)) -+ col++; -+ else { -+ col += snprintf(tmp, sizeof(tmp), "\\%o", c); -+ } -+ if (col > curgoal) -+ break; -+ } -+ return (i); -+} -+ -+/* -+ * Scroll forward by a specified number -+ * of lines, or by a full page if no argument. -+ * The "2" is the window overlap (this is the default -+ * value from ITS EMACS). Because the top line in -+ * the window is zapped, we have to do a hard -+ * update and get it back. -+ */ -+/* ARGSUSED */ -+int -+forwpage(int f, int n) -+{ -+ struct line *lp; -+ -+ if (!(f & FFARG)) { -+ n = curwp->w_ntrows - 2; /* Default scroll. */ -+ if (n <= 0) /* Forget the overlap */ -+ n = 1; /* if tiny window. */ -+ } else if (n < 0) -+ return (backpage(f | FFRAND, -n)); -+ -+ lp = curwp->w_linep; -+ while (n--) -+ if ((lp = lforw(lp)) == curbp->b_headp) { -+ dobeep(); -+ ewprintf("End of buffer"); -+ return(TRUE); -+ } -+ -+ curwp->w_linep = lp; -+ curwp->w_rflag |= WFFULL; -+ -+ /* if in current window, don't move dot */ -+ for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) -+ if (lp == curwp->w_dotp) -+ return (TRUE); -+ -+ /* Advance the dot the slow way, for line nos */ -+ while (curwp->w_dotp != curwp->w_linep) { -+ curwp->w_dotp = lforw(curwp->w_dotp); -+ curwp->w_dotline++; -+ } -+ curwp->w_doto = 0; -+ return (TRUE); -+} -+ -+/* -+ * This command is like "forwpage", -+ * but it goes backwards. The "2", like above, -+ * is the overlap between the two windows. The -+ * value is from the ITS EMACS manual. The -+ * hard update is done because the top line in -+ * the window is zapped. -+ */ -+/* ARGSUSED */ -+int -+backpage(int f, int n) -+{ -+ struct line *lp, *lp2; -+ -+ if (!(f & FFARG)) { -+ n = curwp->w_ntrows - 2; /* Default scroll. */ -+ if (n <= 0) /* Don't blow up if the */ -+ return (backline(f, 1));/* window is tiny. */ -+ } else if (n < 0) -+ return (forwpage(f | FFRAND, -n)); -+ -+ lp = lp2 = curwp->w_linep; -+ -+ while (n-- && lback(lp) != curbp->b_headp) { -+ lp = lback(lp); -+ } -+ if (lp == curwp->w_linep) { -+ dobeep(); -+ ewprintf("Beginning of buffer"); -+ } -+ curwp->w_linep = lp; -+ curwp->w_rflag |= WFFULL; -+ -+ /* if in current window, don't move dot */ -+ for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) -+ if (lp == curwp->w_dotp) -+ return (TRUE); -+ -+ lp2 = lforw(lp2); -+ -+ /* Move the dot the slow way, for line nos */ -+ while (curwp->w_dotp != lp2) { -+ if (curwp->w_dotline <= curwp->w_ntrows) -+ goto out; -+ curwp->w_dotp = lback(curwp->w_dotp); -+ curwp->w_dotline--; -+ } -+out: -+ curwp->w_doto = 0; -+ return (TRUE); -+} -+ -+/* -+ * These functions are provided for compatibility with Gosling's Emacs. They -+ * are used to scroll the display up (or down) one line at a time. -+ */ -+int -+forw1page(int f, int n) -+{ -+ if (!(f & FFARG)) { -+ n = 1; -+ f = FFUNIV; -+ } -+ forwpage(f | FFRAND, n); -+ return (TRUE); -+} -+ -+int -+back1page(int f, int n) -+{ -+ if (!(f & FFARG)) { -+ n = 1; -+ f = FFUNIV; -+ } -+ backpage(f | FFRAND, n); -+ return (TRUE); -+} -+ -+/* -+ * Page the other window. Check to make sure it exists, then -+ * nextwind, forwpage and restore window pointers. -+ */ -+int -+pagenext(int f, int n) -+{ -+ struct mgwin *wp; -+ -+ if (wheadp->w_wndp == NULL) { -+ dobeep(); -+ ewprintf("No other window"); -+ return (FALSE); -+ } -+ wp = curwp; -+ (void) nextwind(f, n); -+ (void) forwpage(f, n); -+ curwp = wp; -+ curbp = wp->w_bufp; -+ return (TRUE); -+} -+ -+/* -+ * Internal set mark routine, used by other functions (daveb). -+ */ -+void -+isetmark(void) -+{ -+ curwp->w_markp = curwp->w_dotp; -+ curwp->w_marko = curwp->w_doto; -+ curwp->w_markline = curwp->w_dotline; -+} -+ -+/* -+ * Set the mark in the current window -+ * to the value of dot. A message is written to -+ * the echo line. (ewprintf knows about macros) -+ */ -+/* ARGSUSED */ -+int -+setmark(int f, int n) -+{ -+ isetmark(); -+ ewprintf("Mark set"); -+ return (TRUE); -+} -+ -+/* Clear the mark, if set. */ -+/* ARGSUSED */ -+int -+clearmark(int f, int n) -+{ -+ if (!curwp->w_markp) -+ return (FALSE); -+ -+ curwp->w_markp = NULL; -+ curwp->w_marko = 0; -+ curwp->w_markline = 0; -+ -+ return (TRUE); -+} -+ -+/* -+ * Swap the values of "dot" and "mark" in -+ * the current window. This is pretty easy, because -+ * all of the hard work gets done by the standard routine -+ * that moves the mark about. The only possible -+ * error is "no mark". -+ */ -+/* ARGSUSED */ -+int -+swapmark(int f, int n) -+{ -+ struct line *odotp; -+ int odoto, odotline; -+ -+ if (curwp->w_markp == NULL) { -+ dobeep(); -+ ewprintf("No mark in this window"); -+ return (FALSE); -+ } -+ odotp = curwp->w_dotp; -+ odoto = curwp->w_doto; -+ odotline = curwp->w_dotline; -+ curwp->w_dotp = curwp->w_markp; -+ curwp->w_doto = curwp->w_marko; -+ curwp->w_dotline = curwp->w_markline; -+ curwp->w_markp = odotp; -+ curwp->w_marko = odoto; -+ curwp->w_markline = odotline; -+ curwp->w_rflag |= WFMOVE; -+ return (TRUE); -+} -+ -+/* -+ * Go to a specific line, mostly for -+ * looking up errors in C programs, which give the -+ * error a line number. If an argument is present, then -+ * it is the line number, else prompt for a line number -+ * to use. -+ */ -+/* ARGSUSED */ -+int -+gotoline(int f, int n) -+{ -+ char buf[32], *bufp; -+ const char *err; -+ -+ if (!(f & FFARG)) { -+ if ((bufp = eread("Goto line: ", buf, sizeof(buf), -+ EFNUL | EFNEW | EFCR)) == NULL) -+ return (ABORT); -+ if (bufp[0] == '\0') -+ return (ABORT); -+ n = (int)strtonum(buf, INT_MIN, INT_MAX, &err); -+ if (err) { -+ dobeep(); -+ ewprintf("Line number %s", err); -+ return (FALSE); -+ } -+ } -+ return(setlineno(n)); -+} -+ -+/* -+ * Set the line number and switch to it. -+ */ -+int -+setlineno(int n) -+{ -+ struct line *clp; -+ -+ if (n >= 0) { -+ if (n == 0) -+ n++; -+ curwp->w_dotline = n; -+ clp = lforw(curbp->b_headp); /* "clp" is first line */ -+ while (--n > 0) { -+ if (lforw(clp) == curbp->b_headp) { -+ curwp->w_dotline = curwp->w_bufp->b_lines; -+ break; -+ } -+ clp = lforw(clp); -+ } -+ } else { -+ curwp->w_dotline = curwp->w_bufp->b_lines + n; -+ clp = lback(curbp->b_headp); /* "clp" is last line */ -+ while (n < 0) { -+ if (lback(clp) == curbp->b_headp) { -+ curwp->w_dotline = 1; -+ break; -+ } -+ clp = lback(clp); -+ n++; -+ } -+ } -+ curwp->w_dotp = clp; -+ curwp->w_doto = 0; -+ curwp->w_rflag |= WFMOVE; -+ return (TRUE); -+} diff -Naur a/cscope.c b/cscope.c --- a/cscope.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/cscope.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/cscope.c 2020-04-21 19:01:59.000000000 +0100 @@ -20,6 +20,9 @@ #include #include @@ -840,7 +131,7 @@ diff -Naur a/cscope.c b/cscope.c #define CSSYMBOL 0 diff -Naur a/display.c b/display.c --- a/display.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/display.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/display.c 2020-04-21 19:01:59.000000000 +0100 @@ -19,6 +19,9 @@ #include #include @@ -853,7 +144,7 @@ diff -Naur a/display.c b/display.c diff -Naur a/fileio.c b/fileio.c --- a/fileio.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/fileio.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/fileio.c 2020-04-21 19:01:59.000000000 +0100 @@ -22,19 +22,13 @@ #include #include @@ -913,774 +204,9 @@ diff -Naur a/fileio.c b/fileio.c ewprintf("Path too long"); return (NULL); } -diff -Naur a/fileio.c.orig b/fileio.c.orig ---- a/fileio.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ b/fileio.c.orig 2020-04-20 21:26:06.000000000 +0100 -@@ -0,0 +1,761 @@ -+/* $OpenBSD: fileio.c,v 1.106 2019/06/22 10:21:57 lum Exp $ */ -+ -+/* This file is in the public domain. */ -+ -+/* -+ * POSIX fileio.c -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "def.h" -+#include "kbd.h" -+#include "pathnames.h" -+ -+#ifndef MAXNAMLEN -+#define MAXNAMLEN 255 -+#endif -+ -+#ifndef DEFFILEMODE -+#define DEFFILEMODE 0666 -+#endif -+ -+static char *bkuplocation(const char *); -+static int bkupleavetmp(const char *); -+ -+static char *bkupdir; -+static int leavetmp = 0; /* 1 = leave any '~' files in tmp dir */ -+ -+/* -+ * Open a file for reading. -+ */ -+int -+ffropen(FILE ** ffp, const char *fn, struct buffer *bp) -+{ -+ if ((*ffp = fopen(fn, "r")) == NULL) { -+ if (errno == ENOENT) -+ return (FIOFNF); -+ return (FIOERR); -+ } -+ -+ /* If 'fn' is a directory open it with dired. */ -+ if (fisdir(fn) == TRUE) -+ return (FIODIR); -+ -+ ffstat(*ffp, bp); -+ -+ return (FIOSUC); -+} -+ -+/* -+ * Update stat/dirty info -+ */ -+void -+ffstat(FILE *ffp, struct buffer *bp) -+{ -+ struct stat sb; -+ -+ if (bp && fstat(fileno(ffp), &sb) == 0) { -+ /* set highorder bit to make sure this isn't all zero */ -+ bp->b_fi.fi_mode = sb.st_mode | 0x8000; -+ bp->b_fi.fi_uid = sb.st_uid; -+ bp->b_fi.fi_gid = sb.st_gid; -+ /* bp->b_fi.fi_mtime = sb.st_mtimespec; */ -+ bp->b_fi.fi_mtime.tv_sec = sb.st_mtime; -+ bp->b_fi.fi_mtime.tv_nsec = 0; -+ /* Clear the ignore flag */ -+ bp->b_flag &= ~(BFIGNDIRTY | BFDIRTY); -+ } -+} -+ -+/* -+ * Update the status/dirty info. If there is an error, -+ * there's not a lot we can do. -+ */ -+int -+fupdstat(struct buffer *bp) -+{ -+ FILE *ffp; -+ -+ if ((ffp = fopen(bp->b_fname, "r")) == NULL) { -+ if (errno == ENOENT) -+ return (FIOFNF); -+ return (FIOERR); -+ } -+ ffstat(ffp, bp); -+ (void)ffclose(ffp, bp); -+ return (FIOSUC); -+} -+ -+/* -+ * Open a file for writing. -+ */ -+int -+ffwopen(FILE ** ffp, const char *fn, struct buffer *bp) -+{ -+ int fd; -+ mode_t fmode = DEFFILEMODE; -+ -+ if (bp && bp->b_fi.fi_mode) -+ fmode = bp->b_fi.fi_mode & 07777; -+ -+ fd = open(fn, O_RDWR | O_CREAT | O_TRUNC, fmode); -+ if (fd == -1) { -+ ffp = NULL; -+ dobeep(); -+ ewprintf("Cannot open file for writing : %s", strerror(errno)); -+ return (FIOERR); -+ } -+ -+ if ((*ffp = fdopen(fd, "w")) == NULL) { -+ dobeep(); -+ ewprintf("Cannot open file for writing : %s", strerror(errno)); -+ close(fd); -+ return (FIOERR); -+ } -+ -+ /* -+ * If we have file information, use it. We don't bother to check for -+ * errors, because there's no a lot we can do about it. Certainly -+ * trying to change ownership will fail if we aren't root. That's -+ * probably OK. If we don't have info, no need to get it, since any -+ * future writes will do the same thing. -+ */ -+ if (bp && bp->b_fi.fi_mode) { -+ fchmod(fd, bp->b_fi.fi_mode & 07777); -+ fchown(fd, bp->b_fi.fi_uid, bp->b_fi.fi_gid); -+ } -+ return (FIOSUC); -+} -+ -+/* -+ * Close a file. -+ */ -+/* ARGSUSED */ -+int -+ffclose(FILE *ffp, struct buffer *bp) -+{ -+ if (fclose(ffp) == 0) -+ return (FIOSUC); -+ return (FIOERR); -+} -+ -+/* -+ * Write a buffer to the already opened file. bp points to the -+ * buffer. Return the status. -+ */ -+int -+ffputbuf(FILE *ffp, struct buffer *bp, int eobnl) -+{ -+ struct line *lp, *lpend; -+ -+ lpend = bp->b_headp; -+ -+ for (lp = lforw(lpend); lp != lpend; lp = lforw(lp)) { -+ if (fwrite(ltext(lp), 1, llength(lp), ffp) != llength(lp)) { -+ dobeep(); -+ ewprintf("Write I/O error"); -+ return (FIOERR); -+ } -+ if (lforw(lp) != lpend) /* no implied \n on last line */ -+ putc('\n', ffp); -+ } -+ if (eobnl) { -+ lnewline_at(lback(lpend), llength(lback(lpend))); -+ putc('\n', ffp); -+ } -+ return (FIOSUC); -+} -+ -+/* -+ * Read a line from a file, and store the bytes -+ * in the supplied buffer. Stop on end of file or end of -+ * line. When FIOEOF is returned, there is a valid line -+ * of data without the normally implied \n. -+ * If the line length exceeds nbuf, FIOLONG is returned. -+ */ -+int -+ffgetline(FILE *ffp, char *buf, int nbuf, int *nbytes) -+{ -+ int c, i; -+ -+ i = 0; -+ while ((c = getc(ffp)) != EOF && c != '\n') { -+ buf[i++] = c; -+ if (i >= nbuf) -+ return (FIOLONG); -+ } -+ if (c == EOF && ferror(ffp) != FALSE) { -+ dobeep(); -+ ewprintf("File read error"); -+ return (FIOERR); -+ } -+ *nbytes = i; -+ return (c == EOF ? FIOEOF : FIOSUC); -+} -+ -+/* -+ * Make a backup copy of "fname". On Unix the backup has the same -+ * name as the original file, with a "~" on the end; this seems to -+ * be newest of the new-speak. The error handling is all in "file.c". -+ * We do a copy instead of a rename since otherwise another process -+ * with an open fd will get the backup, not the new file. This is -+ * a problem when using mg with things like crontab and vipw. -+ */ -+int -+fbackupfile(const char *fn) -+{ -+ struct stat sb; -+ struct timespec new_times[2]; -+ int from, to, serrno; -+ ssize_t nread; -+ char buf[BUFSIZ]; -+ char *nname, *tname, *bkpth; -+ -+ if (stat(fn, &sb) == -1) { -+ dobeep(); -+ ewprintf("Can't stat %s : %s", fn, strerror(errno)); -+ return (FALSE); -+ } -+ -+ if ((bkpth = bkuplocation(fn)) == NULL) -+ return (FALSE); -+ -+ if (asprintf(&nname, "%s~", bkpth) == -1) { -+ dobeep(); -+ ewprintf("Can't allocate backup file name : %s", strerror(errno)); -+ free(bkpth); -+ return (ABORT); -+ } -+ if (asprintf(&tname, "%s.XXXXXXXXXX", bkpth) == -1) { -+ dobeep(); -+ ewprintf("Can't allocate temp file name : %s", strerror(errno)); -+ free(bkpth); -+ free(nname); -+ return (ABORT); -+ } -+ free(bkpth); -+ -+ if ((from = open(fn, O_RDONLY)) == -1) { -+ free(nname); -+ free(tname); -+ return (FALSE); -+ } -+ to = mkstemp(tname); -+ if (to == -1) { -+ serrno = errno; -+ close(from); -+ free(nname); -+ free(tname); -+ errno = serrno; -+ return (FALSE); -+ } -+ while ((nread = read(from, buf, sizeof(buf))) > 0) { -+ if (write(to, buf, (size_t)nread) != nread) { -+ nread = -1; -+ break; -+ } -+ } -+ serrno = errno; -+ (void) fchmod(to, (sb.st_mode & 0777)); -+ -+ /* copy the mtime to the backupfile */ -+ new_times[0] = sb.st_atim; -+ new_times[1] = sb.st_mtim; -+ futimens(to, new_times); -+ -+ close(from); -+ close(to); -+ if (nread == -1) { -+ if (unlink(tname) == -1) -+ ewprintf("Can't unlink temp : %s", strerror(errno)); -+ } else { -+ if (rename(tname, nname) == -1) { -+ ewprintf("Can't rename temp : %s", strerror(errno)); -+ (void) unlink(tname); -+ nread = -1; -+ } -+ } -+ free(nname); -+ free(tname); -+ errno = serrno; -+ -+ return (nread == -1 ? FALSE : TRUE); -+} -+ -+/* -+ * Convert "fn" to a canonicalized absolute filename, replacing -+ * a leading ~/ with the user's home dir, following symlinks, and -+ * remove all occurrences of /./ and /../ -+ */ -+char * -+adjustname(const char *fn, int slashslash) -+{ -+ static char fnb[PATH_MAX]; -+ const char *cp, *ep = NULL; -+ char *path; -+ -+ if (slashslash == TRUE) { -+ cp = fn + strlen(fn) - 1; -+ for (; cp >= fn; cp--) { -+ if (ep && (*cp == '/')) { -+ fn = ep; -+ break; -+ } -+ if (*cp == '/' || *cp == '~') -+ ep = cp; -+ else -+ ep = NULL; -+ } -+ } -+ if ((path = expandtilde(fn)) == NULL) -+ return (NULL); -+ -+ if (realpath(path, fnb) == NULL) -+ (void)strlcpy(fnb, path, sizeof(fnb)); -+ -+ free(path); -+ return (fnb); -+} -+ -+/* -+ * Find a startup file for the user and return its name. As a service -+ * to other pieces of code that may want to find a startup file (like -+ * the terminal driver in particular), accepts a suffix to be appended -+ * to the startup file name. -+ */ -+char * -+startupfile(char *suffix) -+{ -+ static char file[NFILEN]; -+ char *home; -+ int ret; -+ -+ if ((home = getenv("HOME")) == NULL || *home == '\0') -+ goto nohome; -+ -+ if (suffix == NULL) { -+ ret = snprintf(file, sizeof(file), _PATH_MG_STARTUP, home); -+ if (ret < 0 || ret >= sizeof(file)) -+ return (NULL); -+ } else { -+ ret = snprintf(file, sizeof(file), _PATH_MG_TERM, home, suffix); -+ if (ret < 0 || ret >= sizeof(file)) -+ return (NULL); -+ } -+ -+ if (access(file, R_OK) == 0) -+ return (file); -+nohome: -+#ifdef STARTUPFILE -+ if (suffix == NULL) { -+ ret = snprintf(file, sizeof(file), "%s", STARTUPFILE); -+ if (ret < 0 || ret >= sizeof(file)) -+ return (NULL); -+ } else { -+ ret = snprintf(file, sizeof(file), "%s%s", STARTUPFILE, -+ suffix); -+ if (ret < 0 || ret >= sizeof(file)) -+ return (NULL); -+ } -+ -+ if (access(file, R_OK) == 0) -+ return (file); -+#endif /* STARTUPFILE */ -+ return (NULL); -+} -+ -+int -+copy(char *frname, char *toname) -+{ -+ int ifd, ofd; -+ char buf[BUFSIZ]; -+ mode_t fmode = DEFFILEMODE; /* XXX?? */ -+ struct stat orig; -+ ssize_t sr; -+ -+ if ((ifd = open(frname, O_RDONLY)) == -1) -+ return (FALSE); -+ if (fstat(ifd, &orig) == -1) { -+ dobeep(); -+ ewprintf("fstat: %s", strerror(errno)); -+ close(ifd); -+ return (FALSE); -+ } -+ -+ if ((ofd = open(toname, O_WRONLY|O_CREAT|O_TRUNC, fmode)) == -1) { -+ close(ifd); -+ return (FALSE); -+ } -+ while ((sr = read(ifd, buf, sizeof(buf))) > 0) { -+ if (write(ofd, buf, (size_t)sr) != sr) { -+ ewprintf("write error : %s", strerror(errno)); -+ break; -+ } -+ } -+ if (fchmod(ofd, orig.st_mode) == -1) -+ ewprintf("Cannot set original mode : %s", strerror(errno)); -+ -+ if (sr == -1) { -+ ewprintf("Read error : %s", strerror(errno)); -+ close(ifd); -+ close(ofd); -+ return (FALSE); -+ } -+ /* -+ * It is "normal" for this to fail since we can't guarantee that -+ * we will be running as root. -+ */ -+ if (fchown(ofd, orig.st_uid, orig.st_gid) && errno != EPERM) -+ ewprintf("Cannot set owner : %s", strerror(errno)); -+ -+ (void) close(ifd); -+ (void) close(ofd); -+ -+ return (TRUE); -+} -+ -+/* -+ * return list of file names that match the name in buf. -+ */ -+struct list * -+make_file_list(char *buf) -+{ -+ char *dir, *file, *cp; -+ size_t len, preflen; -+ int ret; -+ DIR *dirp; -+ struct dirent *dent; -+ struct list *last, *current; -+ char fl_name[NFILEN + 2]; -+ char prefixx[NFILEN + 1]; -+ -+ /* -+ * We need three different strings: -+ -+ * dir - the name of the directory containing what the user typed. -+ * Must be a real unix file name, e.g. no ~user, etc.. -+ * Must not end in /. -+ * prefix - the portion of what the user typed that is before the -+ * names we are going to find in the directory. Must have a -+ * trailing / if the user typed it. -+ * names from the directory - We open dir, and return prefix -+ * concatenated with names. -+ */ -+ -+ /* first we get a directory name we can look up */ -+ /* -+ * Names ending in . are potentially odd, because adjustname will -+ * treat foo/bar/.. as a foo/, whereas we are -+ * interested in names starting with .. -+ */ -+ len = strlen(buf); -+ if (len && buf[len - 1] == '.') { -+ buf[len - 1] = 'x'; -+ dir = adjustname(buf, TRUE); -+ buf[len - 1] = '.'; -+ } else -+ dir = adjustname(buf, TRUE); -+ if (dir == NULL) -+ return (NULL); -+ /* -+ * If the user typed a trailing / or the empty string -+ * he wants us to use his file spec as a directory name. -+ */ -+ if (len && buf[len - 1] != '/') { -+ file = strrchr(dir, '/'); -+ if (file) { -+ *file = '\0'; -+ if (*dir == '\0') -+ dir = "/"; -+ } else -+ return (NULL); -+ } -+ /* Now we get the prefix of the name the user typed. */ -+ if (strlcpy(prefixx, buf, sizeof(prefixx)) >= sizeof(prefixx)) -+ return (NULL); -+ cp = strrchr(prefixx, '/'); -+ if (cp == NULL) -+ prefixx[0] = '\0'; -+ else -+ cp[1] = '\0'; -+ -+ preflen = strlen(prefixx); -+ /* cp is the tail of buf that really needs to be compared. */ -+ cp = buf + preflen; -+ len = strlen(cp); -+ -+ /* -+ * Now make sure that file names will fit in the buffers allocated. -+ * SV files are fairly short. For BSD, something more general would -+ * be required. -+ */ -+ if (preflen > NFILEN - MAXNAMLEN) -+ return (NULL); -+ -+ /* loop over the specified directory, making up the list of files */ -+ -+ /* -+ * Note that it is worth our time to filter out names that don't -+ * match, even though our caller is going to do so again, and to -+ * avoid doing the stat if completion is being done, because stat'ing -+ * every file in the directory is relatively expensive. -+ */ -+ -+ dirp = opendir(dir); -+ if (dirp == NULL) -+ return (NULL); -+ last = NULL; -+ -+ while ((dent = readdir(dirp)) != NULL) { -+ int isdir; -+ if (strncmp(cp, dent->d_name, len) != 0) -+ continue; -+ isdir = 0; -+ if (dent->d_type == DT_DIR) { -+ isdir = 1; -+ } else if (dent->d_type == DT_LNK || -+ dent->d_type == DT_UNKNOWN) { -+ struct stat statbuf; -+ -+ if (fstatat(dirfd(dirp), dent->d_name, &statbuf, 0) < 0) -+ continue; -+ if (S_ISDIR(statbuf.st_mode)) -+ isdir = 1; -+ } -+ -+ if ((current = malloc(sizeof(struct list))) == NULL) { -+ free_file_list(last); -+ closedir(dirp); -+ return (NULL); -+ } -+ ret = snprintf(fl_name, sizeof(fl_name), -+ "%s%s%s", prefixx, dent->d_name, isdir ? "/" : ""); -+ if (ret < 0 || ret >= sizeof(fl_name)) { -+ free(current); -+ continue; -+ } -+ current->l_next = last; -+ current->l_name = strdup(fl_name); -+ last = current; -+ } -+ closedir(dirp); -+ -+ return (last); -+} -+ -+/* -+ * Test if a supplied filename refers to a directory -+ * Returns ABORT on error, TRUE if directory. FALSE otherwise -+ */ -+int -+fisdir(const char *fname) -+{ -+ struct stat statbuf; -+ -+ if (stat(fname, &statbuf) != 0) -+ return (ABORT); -+ -+ if (S_ISDIR(statbuf.st_mode)) -+ return (TRUE); -+ -+ return (FALSE); -+} -+ -+/* -+ * Check the mtime of the supplied filename. -+ * Return TRUE if last mtime matches, FALSE if not, -+ * If the stat fails, return TRUE and try the save anyway -+ */ -+int -+fchecktime(struct buffer *bp) -+{ -+ struct stat sb; -+ -+ if (stat(bp->b_fname, &sb) == -1) -+ return (TRUE); -+ -+ /* if (bp->b_fi.fi_mtime.tv_sec != sb.st_mtimespec.tv_sec || -+ bp->b_fi.fi_mtime.tv_nsec != sb.st_mtimespec.tv_nsec) */ -+ if (bp->b_fi.fi_mtime.tv_sec != sb.st_mtime) -+ return (FALSE); -+ -+ return (TRUE); -+ -+} -+ -+/* -+ * Location of backup file. This function creates the correct path. -+ */ -+static char * -+bkuplocation(const char *fn) -+{ -+ struct stat sb; -+ char *ret; -+ -+ if (bkupdir != NULL && (stat(bkupdir, &sb) == 0) && -+ S_ISDIR(sb.st_mode) && !bkupleavetmp(fn)) { -+ char fname[NFILEN]; -+ const char *c; -+ int i = 0, len; -+ -+ c = fn; -+ len = strlen(bkupdir); -+ -+ while (*c != '\0') { -+ /* Make sure we don't go over combined: -+ * strlen(bkupdir + '/' + fname + '\0') -+ */ -+ if (i >= NFILEN - len - 1) -+ return (NULL); -+ if (*c == '/') { -+ fname[i] = '!'; -+ } else if (*c == '!') { -+ if (i >= NFILEN - len - 2) -+ return (NULL); -+ fname[i++] = '!'; -+ fname[i] = '!'; -+ } else -+ fname[i] = *c; -+ i++; -+ c++; -+ } -+ fname[i] = '\0'; -+ if (asprintf(&ret, "%s/%s", bkupdir, fname) == -1) -+ return (NULL); -+ -+ } else if ((ret = strndup(fn, NFILEN)) == NULL) -+ return (NULL); -+ -+ return (ret); -+} -+ -+int -+backuptohomedir(int f, int n) -+{ -+ const char *c = _PATH_MG_DIR; -+ char *p; -+ -+ if (bkupdir == NULL) { -+ p = adjustname(c, TRUE); -+ bkupdir = strndup(p, NFILEN); -+ if (bkupdir == NULL) -+ return(FALSE); -+ -+ if (mkdir(bkupdir, 0700) == -1 && errno != EEXIST) { -+ free(bkupdir); -+ bkupdir = NULL; -+ } -+ } else { -+ free(bkupdir); -+ bkupdir = NULL; -+ } -+ -+ return (TRUE); -+} -+ -+/* -+ * For applications that use mg as the editor and have a desire to keep -+ * '~' files in /tmp, toggle the location: /tmp | ~/.mg.d -+ */ -+int -+toggleleavetmp(int f, int n) -+{ -+ leavetmp = !leavetmp; -+ -+ return (TRUE); -+} -+ -+/* -+ * Returns TRUE if fn is located in the temp directory and we want to save -+ * those backups there. -+ */ -+int -+bkupleavetmp(const char *fn) -+{ -+ if (!leavetmp) -+ return(FALSE); -+ -+ if (strncmp(fn, "/tmp", 4) == 0) -+ return (TRUE); -+ -+ return (FALSE); -+} -+ -+/* -+ * Expand file names beginning with '~' if appropriate: -+ * 1, if ./~fn exists, continue without expanding tilde. -+ * 2, else, if username 'fn' exists, expand tilde with home directory path. -+ * 3, otherwise, continue and create new buffer called ~fn. -+ */ -+char * -+expandtilde(const char *fn) -+{ -+ struct passwd *pw; -+ struct stat statbuf; -+ const char *cp; -+ char user[LOGIN_NAME_MAX], path[NFILEN]; -+ char *ret; -+ size_t ulen, plen; -+ -+ path[0] = '\0'; -+ -+ if (fn[0] != '~' || stat(fn, &statbuf) == 0) { -+ if ((ret = strndup(fn, NFILEN)) == NULL) -+ return (NULL); -+ return(ret); -+ } -+ cp = strchr(fn, '/'); -+ if (cp == NULL) -+ cp = fn + strlen(fn); /* point to the NUL byte */ -+ ulen = cp - &fn[1]; -+ if (ulen >= sizeof(user)) { -+ if ((ret = strndup(fn, NFILEN)) == NULL) -+ return (NULL); -+ return(ret); -+ } -+ if (ulen == 0) /* ~/ or ~ */ -+ pw = getpwuid(geteuid()); -+ else { /* ~user/ or ~user */ -+ memcpy(user, &fn[1], ulen); -+ user[ulen] = '\0'; -+ pw = getpwnam(user); -+ } -+ if (pw != NULL) { -+ plen = strlcpy(path, pw->pw_dir, sizeof(path)); -+ if (plen == 0 || path[plen - 1] != '/') { -+ if (strlcat(path, "/", sizeof(path)) >= sizeof(path)) { -+ dobeep(); -+ ewprintf("Path too long"); -+ return (NULL); -+ } -+ } -+ fn = cp; -+ if (*fn == '/') -+ fn++; -+ } -+ if (strlcat(path, fn, sizeof(path)) >= sizeof(path)) { -+ dobeep(); -+ ewprintf("Path too long"); -+ return (NULL); -+ } -+ if ((ret = strndup(path, NFILEN)) == NULL) -+ return (NULL); -+ -+ return (ret); -+} diff -Naur a/futimens.c b/futimens.c --- a/futimens.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/futimens.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/futimens.c 2020-04-21 19:01:59.000000000 +0100 @@ -0,0 +1,14 @@ +/* This file is in the public domain. */ + @@ -1698,7 +224,7 @@ diff -Naur a/futimens.c b/futimens.c +} diff -Naur a/grep.c b/grep.c --- a/grep.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/grep.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/grep.c 2020-04-21 19:01:59.000000000 +0100 @@ -15,6 +15,9 @@ #include #include @@ -1709,375 +235,9 @@ diff -Naur a/grep.c b/grep.c #include "def.h" #include "kbd.h" #include "funmap.h" -diff -Naur a/grep.c.orig b/grep.c.orig ---- a/grep.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ b/grep.c.orig 2020-04-20 21:26:06.000000000 +0100 -@@ -0,0 +1,362 @@ -+/* $OpenBSD: grep.c,v 1.48 2019/07/11 18:20:18 lum Exp $ */ -+ -+/* This file is in the public domain */ -+ -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "def.h" -+#include "kbd.h" -+#include "funmap.h" -+ -+int globalwd = FALSE; -+static int compile_goto_error(int, int); -+int next_error(int, int); -+static int grep(int, int); -+static int gid(int, int); -+static struct buffer *compile_mode(const char *, const char *); -+void grep_init(void); -+ -+static char compile_last_command[NFILEN] = "make "; -+ -+/* -+ * Hints for next-error -+ * -+ * XXX - need some kind of callback to find out when those get killed. -+ */ -+struct mgwin *compile_win; -+struct buffer *compile_buffer; -+ -+static PF compile_pf[] = { -+ compile_goto_error -+}; -+ -+static struct KEYMAPE (1) compilemap = { -+ 1, -+ 1, -+ rescan, -+ { -+ { CCHR('M'), CCHR('M'), compile_pf, NULL } -+ } -+}; -+ -+void -+grep_init(void) -+{ -+ funmap_add(compile_goto_error, "compile-goto-error", 0); -+ funmap_add(next_error, "next-error", 0); -+ funmap_add(grep, "grep", 1); -+ funmap_add(compile, "compile", 0); -+ funmap_add(gid, "gid", 1); -+ maps_add((KEYMAP *)&compilemap, "compile"); -+} -+ -+/* ARGSUSED */ -+static int -+grep(int f, int n) -+{ -+ char cprompt[NFILEN], *bufp; -+ struct buffer *bp; -+ struct mgwin *wp; -+ -+ (void)strlcpy(cprompt, "grep -n ", sizeof(cprompt)); -+ if ((bufp = eread("Run grep: ", cprompt, NFILEN, -+ EFDEF | EFNEW | EFCR)) == NULL) -+ return (ABORT); -+ else if (bufp[0] == '\0') -+ return (FALSE); -+ if (strlcat(cprompt, " /dev/null", sizeof(cprompt)) >= sizeof(cprompt)) -+ return (FALSE); -+ -+ if ((bp = compile_mode("*grep*", cprompt)) == NULL) -+ return (FALSE); -+ if ((wp = popbuf(bp, WNONE)) == NULL) -+ return (FALSE); -+ curbp = bp; -+ compile_win = curwp = wp; -+ return (TRUE); -+} -+ -+/* ARGSUSED */ -+int -+compile(int f, int n) -+{ -+ char cprompt[NFILEN], *bufp; -+ struct buffer *bp; -+ struct mgwin *wp; -+ -+ (void)strlcpy(cprompt, compile_last_command, sizeof(cprompt)); -+ if ((bufp = eread("Compile command: ", cprompt, NFILEN, -+ EFDEF | EFNEW | EFCR)) == NULL) -+ return (ABORT); -+ else if (bufp[0] == '\0') -+ return (FALSE); -+ if (savebuffers(f, n) == ABORT) -+ return (ABORT); -+ (void)strlcpy(compile_last_command, bufp, sizeof(compile_last_command)); -+ -+ if ((bp = compile_mode("*compile*", cprompt)) == NULL) -+ return (FALSE); -+ if ((wp = popbuf(bp, WNONE)) == NULL) -+ return (FALSE); -+ curbp = bp; -+ compile_win = curwp = wp; -+ gotoline(FFARG, 0); -+ return (TRUE); -+} -+ -+/* id-utils foo. */ -+/* ARGSUSED */ -+static int -+gid(int f, int n) -+{ -+ char command[NFILEN]; -+ char cprompt[NFILEN], *bufp; -+ int c; -+ struct buffer *bp; -+ struct mgwin *wp; -+ int i, j, len; -+ -+ /* catch ([^\s(){}]+)[\s(){}]* */ -+ -+ i = curwp->w_doto; -+ /* Skip backwards over delimiters we are currently on */ -+ while (i > 0) { -+ c = lgetc(curwp->w_dotp, i); -+ if (isalnum(c) || c == '_') -+ break; -+ -+ i--; -+ } -+ -+ /* Skip the symbol itself */ -+ for (; i > 0; i--) { -+ c = lgetc(curwp->w_dotp, i - 1); -+ if (!isalnum(c) && c != '_') -+ break; -+ } -+ /* Fill the symbol in cprompt[] */ -+ for (j = 0; j < sizeof(cprompt) - 1 && i < llength(curwp->w_dotp); -+ j++, i++) { -+ c = lgetc(curwp->w_dotp, i); -+ if (!isalnum(c) && c != '_') -+ break; -+ cprompt[j] = c; -+ } -+ cprompt[j] = '\0'; -+ -+ if ((bufp = eread("Run gid (with args): ", cprompt, NFILEN, -+ (j ? EFDEF : 0) | EFNEW | EFCR)) == NULL) -+ return (ABORT); -+ else if (bufp[0] == '\0') -+ return (FALSE); -+ len = snprintf(command, sizeof(command), "gid %s", cprompt); -+ if (len < 0 || len >= sizeof(command)) -+ return (FALSE); -+ -+ if ((bp = compile_mode("*gid*", command)) == NULL) -+ return (FALSE); -+ if ((wp = popbuf(bp, WNONE)) == NULL) -+ return (FALSE); -+ curbp = bp; -+ compile_win = curwp = wp; -+ return (TRUE); -+} -+ -+struct buffer * -+compile_mode(const char *name, const char *command) -+{ -+ struct buffer *bp; -+ FILE *fpipe; -+ char *buf; -+ size_t sz; -+ ssize_t len; -+ int ret, n, status; -+ char cwd[NFILEN], qcmd[NFILEN]; -+ char timestr[NTIME]; -+ time_t t; -+ -+ buf = NULL; -+ sz = 0; -+ -+ n = snprintf(qcmd, sizeof(qcmd), "%s 2>&1", command); -+ if (n < 0 || n >= sizeof(qcmd)) -+ return (NULL); -+ -+ bp = bfind(name, TRUE); -+ if (bclear(bp) != TRUE) -+ return (NULL); -+ -+ if (getbufcwd(bp->b_cwd, sizeof(bp->b_cwd)) != TRUE) -+ return (NULL); -+ addlinef(bp, "cd %s", bp->b_cwd); -+ addline(bp, qcmd); -+ addline(bp, ""); -+ -+ if (getcwd(cwd, sizeof(cwd)) == NULL) -+ panic("Can't get current directory!"); -+ if (chdir(bp->b_cwd) == -1) { -+ dobeep(); -+ ewprintf("Can't change dir to %s", bp->b_cwd); -+ return (NULL); -+ } -+ if ((fpipe = popen(qcmd, "r")) == NULL) { -+ dobeep(); -+ ewprintf("Problem opening pipe"); -+ return (NULL); -+ } -+ while ((len = getline(&buf, &sz, fpipe)) != -1) { -+ if (buf[len - 1] == '\n') -+ buf[len - 1] = '\0'; -+ addline(bp, buf); -+ } -+ free(buf); -+ if (ferror(fpipe)) -+ ewprintf("Problem reading pipe"); -+ ret = pclose(fpipe); -+ t = time(NULL); -+ strftime(timestr, sizeof(timestr), "%a %b %e %T %Y", localtime(&t)); -+ addline(bp, ""); -+ if (WIFEXITED(ret)) { -+ status = WEXITSTATUS(ret); -+ if (status == 0) -+ addlinef(bp, "Command finished at %s", timestr); -+ else -+ addlinef(bp, "Command exited abnormally with code %d " -+ "at %s", status, timestr); -+ } else -+ addlinef(bp, "Subshell killed by signal %d at %s", -+ WTERMSIG(ret), timestr); -+ -+ bp->b_dotp = bfirstlp(bp); -+ bp->b_modes[0] = name_mode("fundamental"); -+ bp->b_modes[1] = name_mode("compile"); -+ bp->b_nmodes = 1; -+ -+ compile_buffer = bp; -+ -+ if (chdir(cwd) == -1) { -+ dobeep(); -+ ewprintf("Can't change dir back to %s", cwd); -+ return (NULL); -+ } -+ return (bp); -+} -+ -+/* ARGSUSED */ -+static int -+compile_goto_error(int f, int n) -+{ -+ struct buffer *bp; -+ struct mgwin *wp; -+ char *fname, *line, *lp, *ln; -+ int lineno; -+ char *adjf, path[NFILEN]; -+ const char *errstr; -+ struct line *last; -+ -+ compile_win = curwp; -+ compile_buffer = curbp; -+ last = blastlp(compile_buffer); -+ -+ retry: -+ /* last line is compilation result */ -+ if (curwp->w_dotp == last) -+ return (FALSE); -+ -+ if ((line = linetostr(curwp->w_dotp)) == NULL) -+ return (FALSE); -+ lp = line; -+ if ((fname = strsep(&lp, ":")) == NULL || *fname == '\0') -+ goto fail; -+ if ((ln = strsep(&lp, ":")) == NULL || *ln == '\0') -+ goto fail; -+ lineno = (int)strtonum(ln, INT_MIN, INT_MAX, &errstr); -+ if (errstr) -+ goto fail; -+ -+ if (fname && fname[0] != '/') { -+ if (getbufcwd(path, sizeof(path)) == FALSE) -+ goto fail; -+ if (strlcat(path, fname, sizeof(path)) >= sizeof(path)) -+ goto fail; -+ adjf = path; -+ } else { -+ adjf = adjustname(fname, TRUE); -+ } -+ free(line); -+ -+ if (adjf == NULL) -+ return (FALSE); -+ -+ if ((bp = findbuffer(adjf)) == NULL) -+ return (FALSE); -+ if ((wp = popbuf(bp, WNONE)) == NULL) -+ return (FALSE); -+ curbp = bp; -+ curwp = wp; -+ if (bp->b_fname[0] == '\0') -+ readin(adjf); -+ gotoline(FFARG, lineno); -+ return (TRUE); -+fail: -+ free(line); -+ if (curwp->w_dotp != blastlp(curbp)) { -+ curwp->w_dotp = lforw(curwp->w_dotp); -+ curwp->w_rflag |= WFMOVE; -+ goto retry; -+ } -+ dobeep(); -+ ewprintf("No more hits"); -+ return (FALSE); -+} -+ -+/* ARGSUSED */ -+int -+next_error(int f, int n) -+{ -+ if (compile_win == NULL || compile_buffer == NULL) { -+ dobeep(); -+ ewprintf("No compilation active"); -+ return (FALSE); -+ } -+ curwp = compile_win; -+ curbp = compile_buffer; -+ if (curwp->w_dotp == blastlp(curbp)) { -+ dobeep(); -+ ewprintf("No more hits"); -+ return (FALSE); -+ } -+ curwp->w_dotp = lforw(curwp->w_dotp); -+ curwp->w_rflag |= WFMOVE; -+ -+ return (compile_goto_error(f, n)); -+} -+ -+/* -+ * Since we don't have variables (we probably should) these are command -+ * processors for changing the values of mode flags. -+ */ -+/* ARGSUSED */ -+int -+globalwdtoggle(int f, int n) -+{ -+ if (f & FFARG) -+ globalwd = n > 0; -+ else -+ globalwd = !globalwd; -+ -+ sgarbf = TRUE; -+ -+ return (TRUE); -+} diff -Naur a/main.c b/main.c --- a/main.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/main.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/main.c 2020-04-21 19:01:59.000000000 +0100 @@ -16,6 +16,9 @@ #include #include @@ -2090,7 +250,7 @@ diff -Naur a/main.c b/main.c #include "funmap.h" diff -Naur a/paragraph.c b/paragraph.c --- a/paragraph.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/paragraph.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/paragraph.c 2020-04-21 19:01:59.000000000 +0100 @@ -14,6 +14,9 @@ #include #include @@ -2101,512 +261,9 @@ diff -Naur a/paragraph.c b/paragraph.c #include "def.h" static int fillcol = 70; -diff -Naur a/paragraph.c.orig b/paragraph.c.orig ---- a/paragraph.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ b/paragraph.c.orig 2020-04-20 21:26:06.000000000 +0100 -@@ -0,0 +1,499 @@ -+/* $OpenBSD: paragraph.c,v 1.46 2018/11/17 09:52:34 lum Exp $ */ -+ -+/* This file is in the public domain. */ -+ -+/* -+ * Code for dealing with paragraphs and filling. Adapted from MicroEMACS 3.6 -+ * and GNU-ified by mwm@ucbvax. Several bug fixes by blarson@usc-oberon. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "def.h" -+ -+static int fillcol = 70; -+ -+#define MAXWORD 256 -+ -+static int findpara(void); -+static int do_gotoeop(int, int, int *); -+ -+/* -+ * Move to start of paragraph. -+ * Move backwards by line, checking from the 1st character forwards for the -+ * existence a non-space. If a non-space character is found, move to the -+ * preceding line. Keep doing this until a line with only spaces is found or -+ * the start of buffer. -+ */ -+/* ARGSUSED */ -+int -+gotobop(int f, int n) -+{ -+ int col, nospace; -+ -+ /* the other way... */ -+ if (n < 0) -+ return (gotoeop(f, -n)); -+ -+ while (n-- > 0) { -+ nospace = 0; -+ while (lback(curwp->w_dotp) != curbp->b_headp) { -+ curwp->w_doto = 0; -+ col = 0; -+ -+ while (col < llength(curwp->w_dotp) && -+ (isspace(lgetc(curwp->w_dotp, col)))) -+ col++; -+ -+ if (col >= llength(curwp->w_dotp)) { -+ if (nospace) -+ break; -+ } else -+ nospace = 1; -+ -+ curwp->w_dotline--; -+ curwp->w_dotp = lback(curwp->w_dotp); -+ } -+ } -+ /* force screen update */ -+ curwp->w_rflag |= WFMOVE; -+ return (TRUE); -+} -+ -+/* -+ * Move to end of paragraph. -+ * See comments for gotobop(). Same, but moving forwards. -+ */ -+/* ARGSUSED */ -+int -+gotoeop(int f, int n) -+{ -+ int i; -+ -+ return(do_gotoeop(f, n, &i)); -+} -+ -+int -+do_gotoeop(int f, int n, int *i) -+{ -+ int col, nospace, j = 0; -+ -+ /* the other way... */ -+ if (n < 0) -+ return (gotobop(f, -n)); -+ -+ /* for each one asked for */ -+ while (n-- > 0) { -+ *i = ++j; -+ nospace = 0; -+ while (lforw(curwp->w_dotp) != curbp->b_headp) { -+ col = 0; -+ curwp->w_doto = 0; -+ -+ while (col < llength(curwp->w_dotp) && -+ (isspace(lgetc(curwp->w_dotp, col)))) -+ col++; -+ -+ if (col >= llength(curwp->w_dotp)) { -+ if (nospace) -+ break; -+ } else -+ nospace = 1; -+ -+ curwp->w_dotp = lforw(curwp->w_dotp); -+ curwp->w_dotline++; -+ -+ } -+ } -+ /* do not continue after end of buffer */ -+ if (lforw(curwp->w_dotp) == curbp->b_headp) { -+ gotoeol(FFRAND, 1); -+ curwp->w_rflag |= WFMOVE; -+ return (FALSE); -+ } -+ -+ /* force screen update */ -+ curwp->w_rflag |= WFMOVE; -+ return (TRUE); -+} -+ -+/* -+ * Justify a paragraph. Fill the current paragraph according to the current -+ * fill column. -+ */ -+/* ARGSUSED */ -+int -+fillpara(int f, int n) -+{ -+ int c; /* current char during scan */ -+ int wordlen; /* length of current word */ -+ int clength; /* position on line during fill */ -+ int i; /* index during word copy */ -+ int eopflag; /* Are we at the End-Of-Paragraph? */ -+ int firstflag; /* first word? (needs no space) */ -+ int newlength; /* tentative new line length */ -+ int eolflag; /* was at end of line */ -+ int retval; /* return value */ -+ struct line *eopline; /* pointer to line just past EOP */ -+ char wbuf[MAXWORD]; /* buffer for current word */ -+ -+ if (n == 0) -+ return (TRUE); -+ -+ undo_boundary_enable(FFRAND, 0); -+ -+ /* record the pointer to the line just past the EOP */ -+ (void)gotoeop(FFRAND, 1); -+ if (curwp->w_doto != 0) { -+ /* paragraph ends at end of buffer */ -+ (void)lnewline(); -+ eopline = lforw(curwp->w_dotp); -+ } else -+ eopline = curwp->w_dotp; -+ -+ /* and back top the beginning of the paragraph */ -+ (void)gotobop(FFRAND, 1); -+ -+ /* initialize various info */ -+ while (inword() == 0 && forwchar(FFRAND, 1)); -+ -+ clength = curwp->w_doto; -+ wordlen = 0; -+ -+ /* scan through lines, filling words */ -+ firstflag = TRUE; -+ eopflag = FALSE; -+ while (!eopflag) { -+ -+ /* get the next character in the paragraph */ -+ if ((eolflag = (curwp->w_doto == llength(curwp->w_dotp)))) { -+ c = ' '; -+ if (lforw(curwp->w_dotp) == eopline) -+ eopflag = TRUE; -+ } else -+ c = lgetc(curwp->w_dotp, curwp->w_doto); -+ -+ /* and then delete it */ -+ if (ldelete((RSIZE) 1, KNONE) == FALSE && !eopflag) { -+ retval = FALSE; -+ goto cleanup; -+ } -+ -+ /* if not a separator, just add it in */ -+ if (c != ' ' && c != '\t') { -+ if (wordlen < MAXWORD - 1) -+ wbuf[wordlen++] = c; -+ else { -+ /* -+ * You lose chars beyond MAXWORD if the word -+ * is too long. I'm too lazy to fix it now; it -+ * just silently truncated the word before, -+ * so I get to feel smug. -+ */ -+ ewprintf("Word too long!"); -+ } -+ } else if (wordlen) { -+ -+ /* calculate tentative new length with word added */ -+ newlength = clength + 1 + wordlen; -+ -+ /* -+ * if at end of line or at doublespace and previous -+ * character was one of '.','?','!' doublespace here. -+ * behave the same way if a ')' is preceded by a -+ * [.?!] and followed by a doublespace. -+ */ -+ if (dblspace && (!eopflag && ((eolflag || -+ curwp->w_doto == llength(curwp->w_dotp) || -+ (c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ' -+ || c == '\t') && (ISEOSP(wbuf[wordlen - 1]) || -+ (wbuf[wordlen - 1] == ')' && wordlen >= 2 && -+ ISEOSP(wbuf[wordlen - 2])))) && -+ wordlen < MAXWORD - 1)) -+ wbuf[wordlen++] = ' '; -+ -+ /* at a word break with a word waiting */ -+ if (newlength <= fillcol) { -+ /* add word to current line */ -+ if (!firstflag) { -+ (void)linsert(1, ' '); -+ ++clength; -+ } -+ firstflag = FALSE; -+ } else { -+ if (curwp->w_doto > 0 && -+ lgetc(curwp->w_dotp, curwp->w_doto - 1) == ' ') { -+ curwp->w_doto -= 1; -+ (void)ldelete((RSIZE) 1, KNONE); -+ } -+ /* start a new line */ -+ (void)lnewline(); -+ clength = 0; -+ } -+ -+ /* and add the word in in either case */ -+ for (i = 0; i < wordlen; i++) { -+ (void)linsert(1, wbuf[i]); -+ ++clength; -+ } -+ wordlen = 0; -+ } -+ } -+ /* and add a last newline for the end of our new paragraph */ -+ (void)lnewline(); -+ -+ /* -+ * We really should wind up where we started, (which is hard to keep -+ * track of) but I think the end of the last line is better than the -+ * beginning of the blank line. -+ */ -+ (void)backchar(FFRAND, 1); -+ retval = TRUE; -+cleanup: -+ undo_boundary_enable(FFRAND, 1); -+ return (retval); -+} -+ -+/* -+ * Delete n paragraphs. Move to the beginning of the current paragraph, or if -+ * the cursor is on an empty line, move down the buffer to the first line with -+ * non-space characters. Then mark n paragraphs and delete. -+ */ -+/* ARGSUSED */ -+int -+killpara(int f, int n) -+{ -+ int lineno, status; -+ -+ if (n == 0) -+ return (TRUE); -+ -+ if (findpara() == FALSE) -+ return (TRUE); -+ -+ /* go to the beginning of the paragraph */ -+ (void)gotobop(FFRAND, 1); -+ -+ /* take a note of the line number for after deletions and set mark */ -+ lineno = curwp->w_dotline; -+ curwp->w_markp = curwp->w_dotp; -+ curwp->w_marko = curwp->w_doto; -+ -+ (void)gotoeop(FFRAND, n); -+ -+ if ((status = killregion(FFRAND, 1)) != TRUE) -+ return (status); -+ -+ curwp->w_dotline = lineno; -+ return (TRUE); -+} -+ -+/* -+ * Mark n paragraphs starting with the n'th and working our way backwards. -+ * This leaves the cursor at the beginning of the paragraph where markpara() -+ * was invoked. -+ */ -+/* ARGSUSED */ -+int -+markpara(int f, int n) -+{ -+ int i = 0; -+ -+ if (n == 0) -+ return (TRUE); -+ -+ clearmark(FFARG, 0); -+ -+ if (findpara() == FALSE) -+ return (TRUE); -+ -+ (void)do_gotoeop(FFRAND, n, &i); -+ -+ /* set the mark here */ -+ curwp->w_markp = curwp->w_dotp; -+ curwp->w_marko = curwp->w_doto; -+ -+ (void)gotobop(FFRAND, i); -+ -+ return (TRUE); -+} -+ -+/* -+ * Transpose the current paragraph with the following paragraph. If invoked -+ * multiple times, transpose to the n'th paragraph. If invoked between -+ * paragraphs, move to the previous paragraph, then continue. -+ */ -+/* ARGSUSED */ -+int -+transposepara(int f, int n) -+{ -+ int i = 0, status; -+ char flg; -+ -+ if (n == 0) -+ return (TRUE); -+ -+ undo_boundary_enable(FFRAND, 0); -+ -+ /* find a paragraph, set mark, then goto the end */ -+ gotobop(FFRAND, 1); -+ curwp->w_markp = curwp->w_dotp; -+ curwp->w_marko = curwp->w_doto; -+ (void)gotoeop(FFRAND, 1); -+ -+ /* take a note of buffer flags - we may need them */ -+ flg = curbp->b_flag; -+ -+ /* clean out kill buffer then kill region */ -+ kdelete(); -+ if ((status = killregion(FFRAND, 1)) != TRUE) -+ return (status); -+ -+ /* -+ * Now step through n paragraphs. If we reach the end of buffer, -+ * stop and paste the killed region back, then display a message. -+ */ -+ if (do_gotoeop(FFRAND, n, &i) == FALSE) { -+ ewprintf("Cannot transpose paragraph, end of buffer reached."); -+ (void)gotobop(FFRAND, i); -+ (void)yank(FFRAND, 1); -+ curbp->b_flag = flg; -+ return (FALSE); -+ } -+ (void)yank(FFRAND, 1); -+ -+ undo_boundary_enable(FFRAND, 1); -+ -+ return (TRUE); -+} -+ -+/* -+ * Go down the buffer until we find a line with non-space characters. -+ */ -+int -+findpara(void) -+{ -+ int col, nospace = 0; -+ -+ /* we move forward to find a para to mark */ -+ do { -+ curwp->w_doto = 0; -+ col = 0; -+ -+ /* check if we are on a blank line */ -+ while (col < llength(curwp->w_dotp)) { -+ if (!isspace(lgetc(curwp->w_dotp, col))) -+ nospace = 1; -+ col++; -+ } -+ if (nospace) -+ break; -+ -+ if (lforw(curwp->w_dotp) == curbp->b_headp) -+ return (FALSE); -+ -+ curwp->w_dotp = lforw(curwp->w_dotp); -+ curwp->w_dotline++; -+ } while (1); -+ -+ return (TRUE); -+} -+ -+/* -+ * Insert char with work wrap. Check to see if we're past fillcol, and if so, -+ * justify this line. As a last step, justify the line. -+ */ -+/* ARGSUSED */ -+int -+fillword(int f, int n) -+{ -+ char c; -+ int col, i, nce; -+ -+ for (i = col = 0; col <= fillcol; ++i, ++col) { -+ if (i == curwp->w_doto) -+ return selfinsert(f, n); -+ c = lgetc(curwp->w_dotp, i); -+ if (c == '\t' -+#ifdef NOTAB -+ && !(curbp->b_flag & BFNOTAB) -+#endif -+ ) -+ col |= 0x07; -+ else if (ISCTRL(c) != FALSE) -+ ++col; -+ } -+ if (curwp->w_doto != llength(curwp->w_dotp)) { -+ (void)selfinsert(f, n); -+ nce = llength(curwp->w_dotp) - curwp->w_doto; -+ } else -+ nce = 0; -+ curwp->w_doto = i; -+ -+ if ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' && c != '\t') -+ do { -+ (void)backchar(FFRAND, 1); -+ } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' && -+ c != '\t' && curwp->w_doto > 0); -+ -+ if (curwp->w_doto == 0) -+ do { -+ (void)forwchar(FFRAND, 1); -+ } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' && -+ c != '\t' && curwp->w_doto < llength(curwp->w_dotp)); -+ -+ (void)delwhite(FFRAND, 1); -+ (void)lnewline(); -+ i = llength(curwp->w_dotp) - nce; -+ curwp->w_doto = i > 0 ? i : 0; -+ curwp->w_rflag |= WFMOVE; -+ if (nce == 0 && curwp->w_doto != 0) -+ return (fillword(f, n)); -+ return (TRUE); -+} -+ -+/* -+ * Set fill column to n for justify. -+ */ -+int -+setfillcol(int f, int n) -+{ -+ char buf[32], *rep; -+ const char *es; -+ int nfill; -+ -+ if ((f & FFARG) != 0) { -+ fillcol = n; -+ } else { -+ if ((rep = eread("Set fill-column: ", buf, sizeof(buf), -+ EFNEW | EFCR)) == NULL) -+ return (ABORT); -+ else if (rep[0] == '\0') -+ return (FALSE); -+ nfill = strtonum(rep, 0, INT_MAX, &es); -+ if (es != NULL) { -+ dobeep(); -+ ewprintf("Invalid fill column: %s", rep); -+ return (FALSE); -+ } -+ fillcol = nfill; -+ ewprintf("Fill column set to %d", fillcol); -+ } -+ return (TRUE); -+} -+ -+int -+sentencespace(int f, int n) -+{ -+ if (f & FFARG) -+ dblspace = n > 1; -+ else -+ dblspace = !dblspace; -+ -+ return (TRUE); -+} diff -Naur a/reallocarray.c b/reallocarray.c --- a/reallocarray.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/reallocarray.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/reallocarray.c 2020-04-21 19:01:59.000000000 +0100 @@ -0,0 +1,38 @@ +/* $OpenBSD: reallocarray.c,v 1.3 2015/09/13 08:31:47 guenther Exp $ */ +/* @@ -2648,7 +305,7 @@ diff -Naur a/reallocarray.c b/reallocarray.c +} diff -Naur a/strtonum.c b/strtonum.c --- a/strtonum.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/strtonum.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/strtonum.c 2020-04-21 19:01:59.000000000 +0100 @@ -0,0 +1,65 @@ +/* $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $ */ + @@ -2717,7 +374,7 @@ diff -Naur a/strtonum.c b/strtonum.c +} diff -Naur a/tags.c b/tags.c --- a/tags.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/tags.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/tags.c 2020-04-21 19:01:59.000000000 +0100 @@ -8,7 +8,11 @@ #include @@ -2759,7 +416,7 @@ diff -Naur a/tags.c b/tags.c struct tagpos { diff -Naur a/tree.h b/tree.h --- a/tree.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/tree.h 2020-04-20 21:26:10.000000000 +0100 ++++ b/tree.h 2020-04-21 19:01:59.000000000 +0100 @@ -0,0 +1,1006 @@ +/* $OpenBSD: tree.h,v 1.29 2017/07/30 19:27:20 deraadt Exp $ */ +/* From 30328c3c3327d41b813cc4fd4f7e4eaaded8bc6e Mon Sep 17 00:00:00 2001 From: ryneeverett Date: Fri, 24 Apr 2020 19:02:31 +0000 Subject: [PATCH 07/81] ycmd: typescript completion support Link the already-packaged typescript package so that ycmd will support completions for javascript and typescript filetypes. The structure of these installation directories is "documented" here: . I don't completely understand why the language support is passed as optional attrs Is it because folks want to build leaner packages and pass null or because they want to target particular dependencies? At any rate I followed the pattern. --- pkgs/development/tools/misc/ycmd/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/tools/misc/ycmd/default.nix b/pkgs/development/tools/misc/ycmd/default.nix index aee7af17730..02298d93b8a 100644 --- a/pkgs/development/tools/misc/ycmd/default.nix +++ b/pkgs/development/tools/misc/ycmd/default.nix @@ -2,6 +2,7 @@ , gocode ? null , godef ? null , gotools ? null +, nodePackages ? null , rustracerd ? null , fixDarwinDylibNames, Cocoa ? null }: @@ -69,6 +70,9 @@ stdenv.mkDerivation { TARGET=$out/lib/ycmd/third_party/go/src/golang.org/x/tools/cmd/gopls mkdir -p $TARGET ln -sf ${gotools}/bin/gopls $TARGET + '' + lib.optionalString (nodePackages != null) '' + TARGET=$out/lib/ycmd/third_party/tsserver + ln -sf ${nodePackages.typescript} $TARGET '' + lib.optionalString (rustracerd != null) '' TARGET=$out/lib/ycmd/third_party/racerd/target/release mkdir -p $TARGET From aa0574e394136b2e154438b64b3019c8338de757 Mon Sep 17 00:00:00 2001 From: Eugene Shatsky Date: Sun, 3 May 2020 00:14:28 +0300 Subject: [PATCH 08/81] plasma5.kwin: add mesa dependency mesa provides libgbm required to build kwin_wayland drm backend with hw accel (compositing&clients) --- pkgs/desktops/plasma-5/kwin/default.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/desktops/plasma-5/kwin/default.nix b/pkgs/desktops/plasma-5/kwin/default.nix index 0e1709d8245..c3e9e2b9c24 100644 --- a/pkgs/desktops/plasma-5/kwin/default.nix +++ b/pkgs/desktops/plasma-5/kwin/default.nix @@ -11,11 +11,10 @@ kcoreaddons, kcrash, kdeclarative, kdecoration, kglobalaccel, ki18n, kiconthemes, kidletime, kinit, kio, knewstuff, knotifications, kpackage, kscreenlocker, kservice, kwayland, kwidgetsaddons, kwindowsystem, kxmlgui, - plasma-framework, qtsensors, libcap, libdrm + plasma-framework, qtsensors, libcap, libdrm, mesa }: # TODO (ttuegel): investigate qmlplugindump failure -# TODO (ttuegel): investigate gbm dependency mkDerivation { name = "kwin"; @@ -30,7 +29,7 @@ mkDerivation { kcoreaddons kcrash kdeclarative kdecoration kglobalaccel ki18n kiconthemes kidletime kinit kio knewstuff knotifications kpackage kscreenlocker kservice kwayland kwidgetsaddons kwindowsystem kxmlgui plasma-framework - libcap libdrm + libcap libdrm mesa ]; outputs = [ "bin" "dev" "out" ]; patches = [ From 4d988ff0d0fa772f0297b5227c343a62391cbe1c Mon Sep 17 00:00:00 2001 From: Izorkin Date: Sat, 25 Apr 2020 16:54:33 +0300 Subject: [PATCH 09/81] nixos/nginx: change log and cache directories --- .../services/web-servers/nginx/default.nix | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index 8d49dc66eb1..1e9cda7e478 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -187,7 +187,7 @@ let then "/etc/nginx/nginx.conf" else configFile; - execCommand = "${cfg.package}/bin/nginx -c '${configPath}' -p '${cfg.stateDir}'"; + execCommand = "${cfg.package}/bin/nginx -c '${configPath}'"; vhosts = concatStringsSep "\n" (mapAttrsToList (vhostName: vhost: let @@ -463,13 +463,6 @@ in ''; }; - stateDir = mkOption { - default = "/var/spool/nginx"; - description = " - Directory holding all state for nginx to run. - "; - }; - user = mkOption { type = types.str; default = "nginx"; @@ -636,6 +629,13 @@ in }; }; + imports = [ + (mkRemovedOptionModule [ "services" "nginx" "stateDir" ] '' + The Nginx log directory has been moved to /var/log/nginx, the cache directory + to /var/cache/nginx. The option services.nginx.stateDir has been removed. + '') + ]; + config = mkIf cfg.enable { # TODO: test user supplied config file pases syntax test @@ -680,12 +680,6 @@ in } ]; - systemd.tmpfiles.rules = [ - "d '${cfg.stateDir}' 0750 ${cfg.user} ${cfg.group} - -" - "d '${cfg.stateDir}/logs' 0750 ${cfg.user} ${cfg.group} - -" - "Z '${cfg.stateDir}' - ${cfg.user} ${cfg.group} - -" - ]; - systemd.services.nginx = { description = "Nginx Web Server"; wantedBy = [ "multi-user.target" ]; @@ -708,6 +702,12 @@ in # Runtime directory and mode RuntimeDirectory = "nginx"; RuntimeDirectoryMode = "0750"; + # Cache directory and mode + CacheDirectory = "nginx"; + CacheDirectoryMode = "0750"; + # Logs directory and mode + LogsDirectory = "nginx"; + LogsDirectoryMode = "0750"; # Capabilities AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" "CAP_SYS_RESOURCE" ]; }; From a19800fb48b52079c55d88c9f6137f58e8d97918 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Sat, 25 Apr 2020 17:02:23 +0300 Subject: [PATCH 10/81] nginx: change logs path --- pkgs/servers/http/nginx/generic.nix | 42 ++++++++++++------- .../http/nginx/nix-skip-check-logs-path.patch | 27 ++++++++++++ pkgs/servers/http/openresty/default.nix | 7 ++-- 3 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 pkgs/servers/http/nginx/nix-skip-check-logs-path.patch diff --git a/pkgs/servers/http/nginx/generic.nix b/pkgs/servers/http/nginx/generic.nix index 67a914b6a98..80bc1458ad7 100644 --- a/pkgs/servers/http/nginx/generic.nix +++ b/pkgs/servers/http/nginx/generic.nix @@ -68,6 +68,14 @@ stdenv.mkDerivation { "--with-http_stub_status_module" "--with-threads" "--with-pcre-jit" + "--http-log-path=/var/log/nginx/access.log" + "--error-log-path=/var/log/nginx/error.log" + "--pid-path=/var/log/nginx/nginx.pid" + "--http-client-body-temp-path=/var/cache/nginx/client_body" + "--http-proxy-temp-path=/var/cache/nginx/proxy" + "--http-fastcgi-temp-path=/var/cache/nginx/fastcgi" + "--http-uwsgi-temp-path=/var/cache/nginx/uwsgi" + "--http-scgi-temp-path=/var/cache/nginx/scgi" ] ++ optionals withDebug [ "--with-debug" ] ++ optionals withStream [ @@ -99,26 +107,28 @@ stdenv.mkDerivation { preConfigure = preConfigure + concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules; - patches = map fixPatch - (singleton (substituteAll { + patches = map fixPatch ([ + (substituteAll { src = ./nix-etag-1.15.4.patch; preInstall = '' export nixStoreDir="$NIX_STORE" nixStoreDirLen="''${#NIX_STORE}" ''; - }) ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - (fetchpatch { - url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/102-sizeof_test_fix.patch"; - sha256 = "0i2k30ac8d7inj9l6bl0684kjglam2f68z8lf3xggcc2i5wzhh8a"; - }) - (fetchpatch { - url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/101-feature_test_fix.patch"; - sha256 = "0v6890a85aqmw60pgj3mm7g8nkaphgq65dj4v9c6h58wdsrc6f0y"; - }) - (fetchpatch { - url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/103-sys_nerr.patch"; - sha256 = "0s497x6mkz947aw29wdy073k8dyjq8j99lax1a1mzpikzr4rxlmd"; - }) - ] ++ mapModules "patches"); + }) + ./nix-skip-check-logs-path.patch + ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + (fetchpatch { + url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/102-sizeof_test_fix.patch"; + sha256 = "0i2k30ac8d7inj9l6bl0684kjglam2f68z8lf3xggcc2i5wzhh8a"; + }) + (fetchpatch { + url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/101-feature_test_fix.patch"; + sha256 = "0v6890a85aqmw60pgj3mm7g8nkaphgq65dj4v9c6h58wdsrc6f0y"; + }) + (fetchpatch { + url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/103-sys_nerr.patch"; + sha256 = "0s497x6mkz947aw29wdy073k8dyjq8j99lax1a1mzpikzr4rxlmd"; + }) + ] ++ mapModules "patches"); hardeningEnable = optional (!stdenv.isDarwin) "pie"; diff --git a/pkgs/servers/http/nginx/nix-skip-check-logs-path.patch b/pkgs/servers/http/nginx/nix-skip-check-logs-path.patch new file mode 100644 index 00000000000..a823660cc32 --- /dev/null +++ b/pkgs/servers/http/nginx/nix-skip-check-logs-path.patch @@ -0,0 +1,27 @@ +diff --git a/auto/install b/auto/install +index d884487..dccc411 100644 +--- a/auto/install ++++ b/auto/install +@@ -148,12 +148,6 @@ install: build $NGX_INSTALL_PERL_MODULES + || cp conf/nginx.conf '\$(DESTDIR)$NGX_CONF_PATH' + cp conf/nginx.conf '\$(DESTDIR)$NGX_CONF_PREFIX/nginx.conf.default' + +- test -d '\$(DESTDIR)`dirname "$NGX_PID_PATH"`' \\ +- || mkdir -p '\$(DESTDIR)`dirname "$NGX_PID_PATH"`' +- +- test -d '\$(DESTDIR)`dirname "$NGX_HTTP_LOG_PATH"`' \\ +- || mkdir -p '\$(DESTDIR)`dirname "$NGX_HTTP_LOG_PATH"`' +- + test -d '\$(DESTDIR)$NGX_PREFIX/html' \\ + || cp -R $NGX_HTML '\$(DESTDIR)$NGX_PREFIX' + END +@@ -161,9 +155,6 @@ END + + if test -n "$NGX_ERROR_LOG_PATH"; then + cat << END >> $NGX_MAKEFILE +- +- test -d '\$(DESTDIR)`dirname "$NGX_ERROR_LOG_PATH"`' \\ +- || mkdir -p '\$(DESTDIR)`dirname "$NGX_ERROR_LOG_PATH"`' + END + + fi diff --git a/pkgs/servers/http/openresty/default.nix b/pkgs/servers/http/openresty/default.nix index 0e87b971985..9c01cfb19e1 100644 --- a/pkgs/servers/http/openresty/default.nix +++ b/pkgs/servers/http/openresty/default.nix @@ -16,10 +16,11 @@ callPackage ../nginx/generic.nix args rec { sha256 = "1a1la7vszv1parsnhphydblz64ffhycazncn3ividnvqg2mg735n"; }; - fixPatch = patch: - runCommand "openresty-${patch.name}" { src = patch; } '' + fixPatch = patch: let name = patch.name or (builtins.baseNameOf patch); in + runCommand "openresty-${name}" { src = patch; } '' substitute $src $out \ - --replace "src/" "bundle/nginx-${nginxVersion}/src/" + --replace "a/" "a/bundle/nginx-${nginxVersion}/" \ + --replace "b/" "b/bundle/nginx-${nginxVersion}/" ''; buildInputs = [ postgresql ]; From 1d71150c73bd3ee3a427950b4c8f29b5a7be060f Mon Sep 17 00:00:00 2001 From: Izorkin Date: Sat, 25 Apr 2020 17:02:57 +0300 Subject: [PATCH 11/81] tengine: add ETag patch --- pkgs/servers/http/tengine/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/http/tengine/default.nix b/pkgs/servers/http/tengine/default.nix index 1593ad0c06f..41a913bd61e 100644 --- a/pkgs/servers/http/tengine/default.nix +++ b/pkgs/servers/http/tengine/default.nix @@ -1,5 +1,5 @@ { stdenv, fetchFromGitHub, openssl, zlib, pcre, libxml2, libxslt -, gd, geoip, gperftools, jemalloc +, substituteAll, gd, geoip, gperftools, jemalloc , withDebug ? false , withMail ? false , withStream ? false @@ -24,7 +24,12 @@ stdenv.mkDerivation rec { [ openssl zlib pcre libxml2 libxslt gd geoip gperftools jemalloc ] ++ concatMap (mod: mod.inputs or []) modules; - patches = [ + patches = singleton (substituteAll { + src = ../nginx/nix-etag-1.15.4.patch; + preInstall = '' + export nixStoreDir="$NIX_STORE" nixStoreDirLen="''${#NIX_STORE}" + ''; + }) ++ [ ./check-resolv-conf.patch ]; From 98e0cba4690d8034e4846ee5f36d2ddf68bb4ea3 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Sat, 25 Apr 2020 17:05:01 +0300 Subject: [PATCH 12/81] tengine: change logs path --- pkgs/servers/http/tengine/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/servers/http/tengine/default.nix b/pkgs/servers/http/tengine/default.nix index 41a913bd61e..f3cae597ef9 100644 --- a/pkgs/servers/http/tengine/default.nix +++ b/pkgs/servers/http/tengine/default.nix @@ -31,6 +31,7 @@ stdenv.mkDerivation rec { ''; }) ++ [ ./check-resolv-conf.patch + ../nginx/nix-skip-check-logs-path.patch ]; configureFlags = [ @@ -58,6 +59,14 @@ stdenv.mkDerivation rec { "--with-poll_module" "--with-google_perftools_module" "--with-jemalloc" + "--http-log-path=/var/log/nginx/access.log" + "--error-log-path=/var/log/nginx/error.log" + "--pid-path=/var/log/nginx/nginx.pid" + "--http-client-body-temp-path=/var/cache/nginx/client_body" + "--http-proxy-temp-path=/var/cache/nginx/proxy" + "--http-fastcgi-temp-path=/var/cache/nginx/fastcgi" + "--http-uwsgi-temp-path=/var/cache/nginx/uwsgi" + "--http-scgi-temp-path=/var/cache/nginx/scgi" ] ++ optionals withDebug [ "--with-debug" ] ++ optionals withMail [ From 9f099143bc025ec962c64bda651f85728643f0a2 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Mon, 27 Apr 2020 21:54:20 +0300 Subject: [PATCH 13/81] nixos/awstats: change path to nginx logs --- nixos/modules/services/logging/awstats.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/logging/awstats.nix b/nixos/modules/services/logging/awstats.nix index 5939d7808f7..896f52302ff 100644 --- a/nixos/modules/services/logging/awstats.nix +++ b/nixos/modules/services/logging/awstats.nix @@ -24,7 +24,7 @@ let logFile = mkOption { type = types.str; - example = "/var/spool/nginx/logs/access.log"; + example = "/var/log/nginx/access.log"; description = '' The log file to be scanned. @@ -110,7 +110,7 @@ in { "mysite" = { domain = "example.com"; - logFile = "/var/spool/nginx/logs/access.log"; + logFile = "/var/log/nginx/access.log"; }; } ''; From 7b368b30727d3970bc26f1d598eda8261f962d83 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Mon, 27 Apr 2020 22:07:13 +0300 Subject: [PATCH 14/81] nixos/tests/service-runner: change paths to nginx logs and cache --- nixos/tests/service-runner.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/tests/service-runner.nix b/nixos/tests/service-runner.nix index adb3fcd36d7..39ae66fe111 100644 --- a/nixos/tests/service-runner.nix +++ b/nixos/tests/service-runner.nix @@ -23,7 +23,7 @@ import ./make-test-python.nix ({ pkgs, ... }: { machine.fail(f"curl {url}") machine.succeed( """ - mkdir -p /run/nginx /var/spool/nginx/logs + mkdir -p /run/nginx /var/log/nginx /var/cache/nginx ${nodes.machine.config.systemd.services.nginx.runner} & echo $!>my-nginx.pid """ From 2d8d8415c0c780307bcff62d1ba63f7ada46d1cb Mon Sep 17 00:00:00 2001 From: Izorkin Date: Mon, 27 Apr 2020 22:16:14 +0300 Subject: [PATCH 15/81] nixos/nginx: add release notes --- nixos/doc/manual/release-notes/rl-2009.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2009.xml b/nixos/doc/manual/release-notes/rl-2009.xml index c6a766cc045..d9f26f668f8 100644 --- a/nixos/doc/manual/release-notes/rl-2009.xml +++ b/nixos/doc/manual/release-notes/rl-2009.xml @@ -277,6 +277,13 @@ php.override { + + + The Nginx log directory has been moved to /var/log/nginx, the cache directory + to /var/cache/nginx. The option services.nginx.stateDir has + been removed. + + The httpd web server previously started its main process as root From 57e6799d907995242575d94bd37178c59cb3cc9a Mon Sep 17 00:00:00 2001 From: Ambroz Bizjak Date: Sun, 12 Jan 2020 23:36:15 +0100 Subject: [PATCH 16/81] kdegraphics-thumbnailers: Add patch for thumbnail.so hang. https://bugs.kde.org/show_bug.cgi?id=404652 https://phabricator.kde.org/D26635 --- pkgs/applications/kde/kdegraphics-thumbnailers.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/kde/kdegraphics-thumbnailers.nix b/pkgs/applications/kde/kdegraphics-thumbnailers.nix index 6ae45057f19..d98f2013339 100644 --- a/pkgs/applications/kde/kdegraphics-thumbnailers.nix +++ b/pkgs/applications/kde/kdegraphics-thumbnailers.nix @@ -1,5 +1,5 @@ { - mkDerivation, lib, + mkDerivation, lib, fetchpatch, extra-cmake-modules, karchive, kio, libkexiv2, libkdcraw }: @@ -9,6 +9,14 @@ mkDerivation { license = [ lib.licenses.lgpl21 ]; maintainers = [ lib.maintainers.ttuegel ]; }; + patches = [ + # Fix a bug with thumbnail.so processes hanging: + # https://bugs.kde.org/show_bug.cgi?id=404652 + (fetchpatch { + url = "https://phabricator.kde.org/file/data/tnk4b6roouixzifi6vre/PHID-FILE-qkkedevt7svx7lv56ea5/D26635.diff"; + sha256 = "0fq85zhymmrq8vl0y6vgh87qf4c6fhcq704p4kpkaq7y0isxj4h1"; + }) + ]; nativeBuildInputs = [ extra-cmake-modules ]; buildInputs = [ karchive kio libkexiv2 libkdcraw ]; } From 18a1b153ac9039b3cad1b69b5b437ffd56478b30 Mon Sep 17 00:00:00 2001 From: Evils Date: Mon, 30 Mar 2020 06:13:59 +0200 Subject: [PATCH 17/81] kicad: expose base and libraries attributes --- .../science/electronics/kicad/base.nix | 13 +++++------ .../science/electronics/kicad/default.nix | 23 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix index 6bc66596229..b3e4bf92f7b 100644 --- a/pkgs/applications/science/electronics/kicad/base.nix +++ b/pkgs/applications/science/electronics/kicad/base.nix @@ -2,7 +2,6 @@ , libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig , doxygen, pcre, libpthreadstubs, libXdmcp, fetchpatch, lndir, callPackages -, pname ? "kicad" , stable ? true , baseName ? "kicad" , versions ? { } @@ -20,26 +19,26 @@ with lib; let versionConfig = versions.${baseName}; - baseVersion = "${versions.${baseName}.kicadVersion.version}"; # oce on aarch64 fails a test withOCE = oceSupport && !stdenv.isAarch64; withOCC = (withOCCT && !withOCE) || (oceSupport && stdenv.isAarch64); - kicad-libraries = callPackages ./libraries.nix versionConfig.libVersion; + libraries = callPackages ./libraries.nix versionConfig.libVersion; in stdenv.mkDerivation rec { - inherit pname; - version = "base-${baseVersion}"; + i18n = libraries.i18n; + + pname = "kicad-base"; + version = "${versions.${baseName}.kicadVersion.version}"; src = fetchFromGitLab ( { group = "kicad"; owner = "code"; repo = "kicad"; - rev = baseVersion; } // versionConfig.kicadVersion.src ); @@ -113,7 +112,7 @@ stdenv.mkDerivation rec { postInstall = optional (withI18n) '' mkdir -p $out/share - lndir ${kicad-libraries.i18n}/share $out/share + lndir ${i18n}/share $out/share ''; meta = { diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index f03a0a0ccef..221dbaf9287 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -35,17 +35,16 @@ let python = python3; wxPython = python3Packages.wxPython_4_0; - libraries = callPackages ./libraries.nix versionConfig.libVersion; +in +stdenv.mkDerivation rec { + + passthru.libraries = callPackages ./libraries.nix versionConfig.libVersion; base = callPackage ./base.nix { - pname = baseName; inherit versions stable baseName; inherit wxGTK python wxPython; inherit debug withI18n withOCCT oceSupport ngspiceSupport scriptingSupport; }; -in -stdenv.mkDerivation rec { - inherit pname; version = versions.${baseName}.kicadVersion.version; @@ -63,7 +62,7 @@ stdenv.mkDerivation rec { # wrapGAppsHook added the equivalent to ${base}/share # though i noticed no difference without it - makeWrapperArgs = [ + makeWrapperArgs = with passthru.libraries; [ "--prefix XDG_DATA_DIRS : ${base}/share" "--prefix XDG_DATA_DIRS : ${hicolor-icon-theme}/share" "--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share" @@ -73,13 +72,13 @@ stdenv.mkDerivation rec { "--prefix XDG_DATA_DIRS : ${cups}/share" "--prefix GIO_EXTRA_MODULES : ${gnome3.dconf}/lib/gio/modules" - "--set KISYSMOD ${libraries.footprints}/share/kicad/modules" - "--set KICAD_SYMBOL_DIR ${libraries.symbols}/share/kicad/library" - "--set KICAD_TEMPLATE_DIR ${libraries.templates}/share/kicad/template" - "--prefix KICAD_TEMPLATE_DIR : ${libraries.symbols}/share/kicad/template" - "--prefix KICAD_TEMPLATE_DIR : ${libraries.footprints}/share/kicad/template" + "--set KISYSMOD ${footprints}/share/kicad/modules" + "--set KICAD_SYMBOL_DIR ${symbols}/share/kicad/library" + "--set KICAD_TEMPLATE_DIR ${templates}/share/kicad/template" + "--prefix KICAD_TEMPLATE_DIR : ${symbols}/share/kicad/template" + "--prefix KICAD_TEMPLATE_DIR : ${footprints}/share/kicad/template" ] - ++ optionals (with3d) [ "--set KISYS3DMOD ${libraries.packages3d}/share/kicad/modules/packages3d" ] + ++ optionals (with3d) [ "--set KISYS3DMOD ${packages3d}/share/kicad/modules/packages3d" ] ++ optionals (ngspiceSupport) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ] # infinisil's workaround for #39493 From 95e4e33bdfd03adce366f09b5cd7db4ee9e86a91 Mon Sep 17 00:00:00 2001 From: Evils Date: Sat, 28 Mar 2020 01:39:57 +0100 Subject: [PATCH 18/81] kicad-unstable-small: init to make kicad-unstable the -small packages depend on all hydra buildable dependencies the non-small ones depend on packages3d which exceeds hydra's limit set platforms to all (kicad is cross-platform) clarify package differences in the description set maintainers on just the top level derivation switch -unstable to not save debug symbols indicate patch in version string note broken dependencies --- .../science/electronics/kicad/base.nix | 7 ++-- .../science/electronics/kicad/default.nix | 33 ++++++++++------ .../science/electronics/kicad/libraries.nix | 39 ++++++++++++------- pkgs/top-level/all-packages.nix | 9 ++++- 4 files changed, 57 insertions(+), 31 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix index b3e4bf92f7b..9fc1111c7b9 100644 --- a/pkgs/applications/science/electronics/kicad/base.nix +++ b/pkgs/applications/science/electronics/kicad/base.nix @@ -56,9 +56,11 @@ stdenv.mkDerivation rec { # tagged releases don't have "unknown" # kicad nightlies use git describe --dirty # nix removes .git, so its approximated here + # "-1" appended to indicate we're adding a patch postPatch = '' substituteInPlace CMakeModules/KiCadVersion.cmake \ - --replace "unknown" ${builtins.substring 0 10 src.rev} + --replace "unknown" "${builtins.substring 0 10 src.rev}-1" \ + --replace "${version}" "${version}-1" ''; makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ]; @@ -123,7 +125,6 @@ stdenv.mkDerivation rec { ''; homepage = "https://www.kicad-pcb.org/"; license = licenses.agpl3; - maintainers = with maintainers; [ evils kiwi berce ]; - platforms = with platforms; linux; + platforms = platforms.all; }; } diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index 221dbaf9287..51ec1dad8aa 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -4,6 +4,7 @@ , librsvg, cups , pname ? "kicad" +, stable ? true , oceSupport ? false, opencascade , withOCCT ? true, opencascade-occt , ngspiceSupport ? true, libngspice @@ -18,7 +19,6 @@ assert ngspiceSupport -> libngspice != null; with lib; let - stable = pname != "kicad-unstable"; baseName = if (stable) then "kicad" else "kicad-unstable"; versions = import ./versions.nix; @@ -122,10 +122,11 @@ stdenv.mkDerivation rec { # and can't git commit if this could be running in parallel with other scripts passthru.updateScript = [ ./update.sh "all" ]; - meta = { - description = if (stable) - then "Open Source Electronics Design Automation Suite" - else "Open Source EDA Suite, Development Build"; + meta = rec { + description = (if (stable) + then "Open Source Electronics Design Automation suite" + else "Open Source EDA suite, development build") + + (if (!with3d) then ", without 3D models" else ""); homepage = "https://www.kicad-pcb.org/"; longDescription = '' KiCad is an open source software suite for Electronic Design Automation. @@ -133,12 +134,20 @@ stdenv.mkDerivation rec { ''; license = licenses.agpl3; # berce seems inactive... - maintainers = with maintainers; [ evils kiwi berce ]; - # kicad's cross-platform, not sure what to fill in here - platforms = with platforms; linux; - } // optionalAttrs with3d { - # We can't download the 3d models on Hydra - they are a ~1 GiB download and - # they occupy ~5 GiB in store. - hydraPlatforms = []; + maintainers = with stdenv.lib.maintainers; [ evils kiwi berce ]; + # kicad is cross platform + platforms = stdenv.lib.platforms.all; + # despite that, nipkgs' wxGTK for darwin is "wxmac" + # and wxPython_4_0 does not account for this + # adjusting this package to downgrade to python2Packages.wxPython (wxPython 3), + # seems like more trouble than fixing wxPython_4_0 would be + # additionally, libngspice is marked as linux only, though it should support darwin + + hydraPlatforms = if (with3d) then [ ] else platforms; + # We can't download the 3d models on Hydra, + # they are a ~1 GiB download and they occupy ~5 GiB in store. + # as long as the base and libraries (minus 3d) are build, + # this wrapper does not need to get built + # the kicad-*small "packages" cause this to happen }; } diff --git a/pkgs/applications/science/electronics/kicad/libraries.nix b/pkgs/applications/science/electronics/kicad/libraries.nix index 7cdf9373e08..4dde2a0a122 100644 --- a/pkgs/applications/science/electronics/kicad/libraries.nix +++ b/pkgs/applications/science/electronics/kicad/libraries.nix @@ -13,21 +13,27 @@ with lib; let mkLib = name: - stdenv.mkDerivation - { - pname = "kicad-${name}"; - version = "${version}"; - src = fetchFromGitHub ( - { - owner = "KiCad"; - repo = "kicad-${name}"; - rev = version; - inherit name; - } // (libSources.${name} or { }) - ); - nativeBuildInputs = [ cmake ]; - meta.license = licenses.cc-by-sa-40; + stdenv.mkDerivation { + pname = "kicad-${name}"; + version = "${version}"; + src = fetchFromGitHub ( + { + owner = "KiCad"; + repo = "kicad-${name}"; + rev = version; + inherit name; + } // (libSources.${name} or { }) + ); + nativeBuildInputs = [ cmake ]; + + meta = rec { + license = licenses.cc-by-sa-40; + platforms = stdenv.lib.platforms.all; + # the 3d models are a ~1 GiB download and occupy ~5 GiB in store. + # this would exceed the hydra output limit + hydraPlatforms = if (name == "packages3d" ) then [ ] else platforms; }; + }; in { symbols = mkLib "symbols"; @@ -56,6 +62,9 @@ in ); buildInputs = [ gettext ]; nativeBuildInputs = [ cmake ]; - meta.license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 + meta = { + license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 + platforms = stdenv.lib.platforms.all; + }; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2e8eb8461ee..269d5b577ab 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -24894,9 +24894,16 @@ in fped = callPackage ../applications/science/electronics/fped { }; + # this is a wrapper for kicad.base and kicad.libraries kicad = callPackage ../applications/science/electronics/kicad { }; kicad-small = kicad.override { pname = "kicad-small"; with3d = false; }; - kicad-unstable = kicad.override { pname = "kicad-unstable"; debug = true; }; + kicad-unstable = kicad.override { pname = "kicad-unstable"; stable = false; }; + # mostly here so the kicad-unstable components (except packages3d) get built + kicad-unstable-small = kicad.override { + pname = "kicad-unstable-small"; + stable = false; + with3d = false; + }; librepcb = libsForQt5.callPackage ../applications/science/electronics/librepcb { }; From 1059fdf1433bc4964faaa2010bfde54d8c8c687f Mon Sep 17 00:00:00 2001 From: Evils Date: Sun, 5 Apr 2020 21:23:36 +0200 Subject: [PATCH 19/81] kicad: link utils; clean up wrapper installPhase --- .../science/electronics/kicad/default.nix | 47 ++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index 51ec1dad8aa..2aa2686a29a 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -85,34 +85,27 @@ stdenv.mkDerivation rec { ++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ] ; - # dunno why i have to add $makeWrapperArgs manually... + # why does $makeWrapperArgs have to be added explicitly? # $out and $program_PYTHONPATH don't exist when makeWrapperArgs gets set? - # not sure if anything has to be done with the other stuff in base/bin - # dxf2idf, idf2vrml, idfcyl, idfrect, kicad2step, kicad-ogltest - installPhase = - optionalString (scriptingSupport) '' buildPythonPath "${base} $pythonPath" - '' + - '' makeWrapper ${base}/bin/kicad $out/bin/kicad $makeWrapperArgs '' - + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" - '' + - '' makeWrapper ${base}/bin/pcbnew $out/bin/pcbnew $makeWrapperArgs '' - + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" - '' + - '' makeWrapper ${base}/bin/eeschema $out/bin/eeschema $makeWrapperArgs '' - + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" - '' + - '' makeWrapper ${base}/bin/gerbview $out/bin/gerbview $makeWrapperArgs '' - + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" - '' + - '' makeWrapper ${base}/bin/pcb_calculator $out/bin/pcb_calculator $makeWrapperArgs '' - + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" - '' + - '' makeWrapper ${base}/bin/pl_editor $out/bin/pl_editor $makeWrapperArgs '' - + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" - '' + - '' makeWrapper ${base}/bin/bitmap2component $out/bin/bitmap2component $makeWrapperArgs '' - + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" - '' + # kicad-ogltest's source seems to indicate that crashing is expected behaviour... + installPhase = with lib; + let + tools = [ "kicad" "pcbnew" "eeschema" "gerbview" "pcb_calculator" "pl_editor" "bitmap2component" ]; + utils = [ "dxf2idf" "idf2vrml" "idfcyl" "idfrect" "kicad2step" "kicad-ogltest" ]; + in + ( concatStringsSep "\n" + ( flatten [ + ( optionalString (scriptingSupport) "buildPythonPath \"${base} $pythonPath\" \n" ) + + # wrap each of the directly usable tools + ( map ( tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs" + + optionalString (scriptingSupport) " --set PYTHONPATH \"$program_PYTHONPATH\"" + ) tools ) + + # link in the CLI utils + ( map ( util: "ln -s ${base}/bin/${util} $out/bin/${util}" ) utils ) + ]) + ) ; # can't run this for each pname From 2d3d8c4d6676e353d73d0028ec52217a01070e88 Mon Sep 17 00:00:00 2001 From: Evils Date: Sat, 2 May 2020 13:22:57 +0200 Subject: [PATCH 20/81] kicad-unstable: 2020-04-25 -> 2020-05-06 --- .../science/electronics/kicad/versions.nix | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/versions.nix b/pkgs/applications/science/electronics/kicad/versions.nix index 174532d6962..2b7c91751e5 100644 --- a/pkgs/applications/science/electronics/kicad/versions.nix +++ b/pkgs/applications/science/electronics/kicad/versions.nix @@ -27,25 +27,25 @@ }; "kicad-unstable" = { kicadVersion = { - version = "2020-04-25"; + version = "2020-05-06"; src = { - rev = "3759799d1e03b2da6a0dcd72273e4978880fc8f1"; - sha256 = "0ba14fla8m5zli68wfjkfc4ymvj4j8z92y3jigxs8hys0450bybi"; + rev = "c92181621e2e51dc8aae1bd9f4483bb3301ffaa5"; + sha256 = "0s50xn5gbjy7yxnp9yiynxvxi2mkcrp6yghgdzclpm40rnfyi0v5"; }; }; libVersion = { - version = "2020-04-25"; + version = "2020-05-06"; libSources = { - i18n.rev = "fc14baa52ca56a58b0048ab860bf31887d3cf8eb"; - i18n.sha256 = "05nayab7dkjyq7g3i9q7k55hcckpc0cmq4bbklmxx16rx4rbhzc6"; - symbols.rev = "0f9ff2d17237f90bb649bf0a52b6d454f68197e8"; - symbols.sha256 = "1a54428syn2xksc00n2bvh1alrx2vrqmp7cg7d2rn8nlq8yk4qd5"; + i18n.rev = "f29cab831eb823165fa2c5efab5d9c9b443e62e2"; + i18n.sha256 = "0cc0zvpml75yxphay3281f762ls08fzvv538cd5hmkr8xqlj3vbi"; + symbols.rev = "d4245ae8cf633095a0994ab01492bd56cd124112"; + symbols.sha256 = "11pynjgji3skw42q5mryz98f8z418k43jy6s2k90w6jv638z3cb0"; templates.rev = "7db8d4d0ea0711f1961d117853547fb3edbc3857"; templates.sha256 = "1hppcsrkn4dk6ggby6ckh0q65qxkywrbyxa4lwpaf7pxjyv498xg"; - footprints.rev = "61df6d8853b4c68cca0ac87784c0a33cff9394d3"; - footprints.sha256 = "0blmhk8pwd4mi6rlsr4lf4lq7j01h6xbpbvr3pm8pmw8zylhi54v"; - packages3d.rev = "88bcf2e817fe000bb2c05e14489afc3b1a4e10ed"; - packages3d.sha256 = "0z9p1fn5xbz940kr5jz2ibzf09hpdi1c9izmabkffvrnfy6408x6"; + footprints.rev = "3bff23ee339bc48490bb39deba5d8b2f1f42733e"; + footprints.sha256 = "0430r8k49ib6w1sjr8fx42szbz960yhlzg4w80jl5bwasq67nqwd"; + packages3d.rev = "889a3dd550233ec51baed4a04a01d4cc64a8d747"; + packages3d.sha256 = "152zv4j51v8skqlvrabblpcqpbn5yf3grisjj8vnwf7kdd41chb2"; }; }; }; From c54d37598a27941621228c7b4bb1eebb2dfaafdd Mon Sep 17 00:00:00 2001 From: "D. Guthrie" Date: Thu, 7 May 2020 17:37:53 +0100 Subject: [PATCH 21/81] Set upstream to https://github.com/ibara/mg As per reasonable suggestion, instead of extensively patching the hboetes version of mg to work on MacOS using bits from ibara's mg, just set upstream to ibara's mg. This also removes the dependency on libbsd, although I'm not sure if this is a good or bad thing. --- .../editors/mg/darwin_no_libbsd.patch | 1426 ----------------- pkgs/applications/editors/mg/default.nix | 16 +- 2 files changed, 7 insertions(+), 1435 deletions(-) delete mode 100644 pkgs/applications/editors/mg/darwin_no_libbsd.patch diff --git a/pkgs/applications/editors/mg/darwin_no_libbsd.patch b/pkgs/applications/editors/mg/darwin_no_libbsd.patch deleted file mode 100644 index 1863f2952b2..00000000000 --- a/pkgs/applications/editors/mg/darwin_no_libbsd.patch +++ /dev/null @@ -1,1426 +0,0 @@ -diff -Naur a/GNUmakefile b/GNUmakefile ---- a/GNUmakefile 2020-04-20 21:09:41.000000000 +0100 -+++ b/GNUmakefile 2020-04-21 19:01:59.000000000 +0100 -@@ -18,7 +18,7 @@ - STRIP= /usr/bin/strip - - UNAME:= $(shell uname) --ifeq ($(UNAME),FreeBSD) -+ifeq ($(UNAME),Darwin) - BSD_CPPFLAGS:= - BSD_LIBS:= -lutil - else -@@ -38,10 +38,6 @@ - $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.) - endif - --ifdef STATIC -- LDFLAGS=-static -static-libgcc --endif -- - CC?= gcc - CFLAGS?= -O2 -pipe - CFLAGS+= -g -Wall -@@ -52,10 +48,11 @@ - - - OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \ -- echo.o extend.o file.o fileio.o funmap.o interpreter.o help.o \ -- kbd.o keymap.o line.o macro.o main.o match.o modes.o paragraph.o \ -- re_search.o region.o search.o spawn.o tty.o ttyio.o ttykbd.o \ -- undo.o util.o version.o window.o word.o yank.o -+ echo.o extend.o file.o fileio.o funmap.o futimens.o interpreter.o \ -+ help.o kbd.o keymap.o line.o macro.o main.o match.o modes.o \ -+ paragraph.o re_search.o reallocarray.o region.o search.o spawn.o \ -+ strtonum.o tty.o ttyio.o ttykbd.o undo.o util.o version.o window.o \ -+ word.o yank.o - OBJS+= cmode.o cscope.o dired.o grep.o tags.o - - -diff -Naur a/_null.h b/_null.h ---- a/_null.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/_null.h 2020-04-21 19:01:59.000000000 +0100 -@@ -0,0 +1,18 @@ -+/* $OpenBSD: _null.h,v 1.2 2016/09/09 22:07:58 millert Exp $ */ -+ -+/* -+ * Written by Todd C. Miller, September 9, 2016 -+ * Public domain. -+ */ -+ -+#ifndef NULL -+#if !defined(__cplusplus) -+#define NULL ((void *)0) -+#elif __cplusplus >= 201103L -+#define NULL nullptr -+#elif defined(__GNUG__) -+#define NULL __null -+#else -+#define NULL 0L -+#endif -+#endif -diff -Naur a/apple.h b/apple.h ---- a/apple.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/apple.h 2020-04-21 19:01:59.000000000 +0100 -@@ -0,0 +1,27 @@ -+/* -+ * Mac OS X-specific support. -+ */ -+ -+#include -+#include -+ -+#include -+#include -+ -+/* -+ * fparseln() specific operation flags. -+ */ -+#define FPARSELN_UNESCESC 0x01 -+#define FPARSELN_UNESCCONT 0x02 -+#define FPARSELN_UNESCCOMM 0x04 -+#define FPARSELN_UNESCREST 0x08 -+#define FPARSELN_UNESCALL 0x0f -+ -+/* struct stat compatibilty */ -+#define st_atim st_atimespec -+#define st_mtim st_mtimespec -+#define st_ctim st_ctimespec -+ -+extern long long strtonum(const char *, long long, long long, const char **); -+extern void *reallocarray(void *, size_t, size_t); -+extern int futimens(int, const struct timespec[2]); -diff -Naur a/autoexec.c b/autoexec.c ---- a/autoexec.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/autoexec.c 2020-04-21 19:01:59.000000000 +0100 -@@ -9,6 +9,9 @@ - #include - #include - -+#if defined(__APPLE__) -+# include "apple.h" -+#endif - #include "def.h" - #include "funmap.h" - -diff -Naur a/basic.c b/basic.c ---- a/basic.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/basic.c 2020-04-21 19:01:59.000000000 +0100 -@@ -19,6 +19,9 @@ - #include - #include - -+#if defined(__APPLE__) -+# include "apple.h" -+#endif - #include "def.h" - - #define percint(n1, n2) ((n1 * (int) n2) * 0.1) -diff -Naur a/cscope.c b/cscope.c ---- a/cscope.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/cscope.c 2020-04-21 19:01:59.000000000 +0100 -@@ -20,6 +20,9 @@ - #include - #include - -+#if defined(__APPLE__) -+# include "apple.h" -+#endif - #include "def.h" - - #define CSSYMBOL 0 -diff -Naur a/display.c b/display.c ---- a/display.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/display.c 2020-04-21 19:01:59.000000000 +0100 -@@ -19,6 +19,9 @@ - #include - #include - -+#if defined(__APPLE__) -+# include "apple.h" -+#endif - #include "def.h" - #include "kbd.h" - -diff -Naur a/fileio.c b/fileio.c ---- a/fileio.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/fileio.c 2020-04-21 19:01:59.000000000 +0100 -@@ -22,19 +22,13 @@ - #include - #include - #include -- -+#if defined(__APPLE__) -+# include "apple.h" -+#endif - #include "def.h" - #include "kbd.h" - #include "pathnames.h" - --#ifndef MAXNAMLEN --#define MAXNAMLEN 255 --#endif -- --#ifndef DEFFILEMODE --#define DEFFILEMODE 0666 --#endif -- - static char *bkuplocation(const char *); - static int bkupleavetmp(const char *); - -@@ -710,7 +704,7 @@ - struct stat statbuf; - const char *cp; - char user[LOGIN_NAME_MAX], path[NFILEN]; -- char *ret; -+ char *un, *ret; - size_t ulen, plen; - - path[0] = '\0'; -@@ -729,18 +723,21 @@ - return (NULL); - return(ret); - } -- if (ulen == 0) /* ~/ or ~ */ -- pw = getpwuid(geteuid()); -- else { /* ~user/ or ~user */ -+ if (ulen == 0) { /* ~/ or ~ */ -+ if ((un = getlogin()) != NULL) -+ (void)strlcpy(user, un, sizeof(user)); -+ else -+ user[0] = '\0'; -+ } else { /* ~user/ or ~user */ - memcpy(user, &fn[1], ulen); - user[ulen] = '\0'; -- pw = getpwnam(user); - } -+ pw = getpwnam(user); - if (pw != NULL) { - plen = strlcpy(path, pw->pw_dir, sizeof(path)); - if (plen == 0 || path[plen - 1] != '/') { - if (strlcat(path, "/", sizeof(path)) >= sizeof(path)) { -- dobeep(); -+ dobeep(); - ewprintf("Path too long"); - return (NULL); - } -diff -Naur a/futimens.c b/futimens.c ---- a/futimens.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/futimens.c 2020-04-21 19:01:59.000000000 +0100 -@@ -0,0 +1,14 @@ -+/* This file is in the public domain. */ -+ -+#include -+ -+#include -+ -+int -+futimens(int fildes, const struct timespec times[2]) -+{ -+ struct timeval timevals[2]; -+ TIMESPEC_TO_TIMEVAL(&timevals[0], ×[0]); -+ TIMESPEC_TO_TIMEVAL(&timevals[1], ×[1]); -+ return futimes(fildes, timevals); -+} -diff -Naur a/grep.c b/grep.c ---- a/grep.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/grep.c 2020-04-21 19:01:59.000000000 +0100 -@@ -15,6 +15,9 @@ - #include - #include - -+#if defined(__APPLE__) -+# include "apple.h" -+#endif - #include "def.h" - #include "kbd.h" - #include "funmap.h" -diff -Naur a/main.c b/main.c ---- a/main.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/main.c 2020-04-21 19:01:59.000000000 +0100 -@@ -16,6 +16,9 @@ - #include - #include - -+#if defined(__APPLE__) -+# include "apple.h" -+#endif - #include "def.h" - #include "kbd.h" - #include "funmap.h" -diff -Naur a/paragraph.c b/paragraph.c ---- a/paragraph.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/paragraph.c 2020-04-21 19:01:59.000000000 +0100 -@@ -14,6 +14,9 @@ - #include - #include - -+#if defined(__APPLE__) -+# include "apple.h" -+#endif - #include "def.h" - - static int fillcol = 70; -diff -Naur a/reallocarray.c b/reallocarray.c ---- a/reallocarray.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/reallocarray.c 2020-04-21 19:01:59.000000000 +0100 -@@ -0,0 +1,38 @@ -+/* $OpenBSD: reallocarray.c,v 1.3 2015/09/13 08:31:47 guenther Exp $ */ -+/* -+ * Copyright (c) 2008 Otto Moerbeek -+ * -+ * Permission to use, copy, modify, and distribute this software for any -+ * purpose with or without fee is hereby granted, provided that the above -+ * copyright notice and this permission notice appear in all copies. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -+ */ -+ -+#include -+#include -+#include -+#include -+ -+/* -+ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX -+ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW -+ */ -+#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) -+ -+void * -+reallocarray(void *optr, size_t nmemb, size_t size) -+{ -+ if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && -+ nmemb > 0 && SIZE_MAX / nmemb < size) { -+ errno = ENOMEM; -+ return NULL; -+ } -+ return realloc(optr, size * nmemb); -+} -diff -Naur a/strtonum.c b/strtonum.c ---- a/strtonum.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/strtonum.c 2020-04-21 19:01:59.000000000 +0100 -@@ -0,0 +1,65 @@ -+/* $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $ */ -+ -+/* -+ * Copyright (c) 2004 Ted Unangst and Todd Miller -+ * All rights reserved. -+ * -+ * Permission to use, copy, modify, and distribute this software for any -+ * purpose with or without fee is hereby granted, provided that the above -+ * copyright notice and this permission notice appear in all copies. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -+ */ -+ -+#include -+#include -+#include -+ -+#define INVALID 1 -+#define TOOSMALL 2 -+#define TOOLARGE 3 -+ -+long long -+strtonum(const char *numstr, long long minval, long long maxval, -+ const char **errstrp) -+{ -+ long long ll = 0; -+ int error = 0; -+ char *ep; -+ struct errval { -+ const char *errstr; -+ int err; -+ } ev[4] = { -+ { NULL, 0 }, -+ { "invalid", EINVAL }, -+ { "too small", ERANGE }, -+ { "too large", ERANGE }, -+ }; -+ -+ ev[0].err = errno; -+ errno = 0; -+ if (minval > maxval) { -+ error = INVALID; -+ } else { -+ ll = strtoll(numstr, &ep, 10); -+ if (numstr == ep || *ep != '\0') -+ error = INVALID; -+ else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval) -+ error = TOOSMALL; -+ else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval) -+ error = TOOLARGE; -+ } -+ if (errstrp != NULL) -+ *errstrp = ev[error].errstr; -+ errno = ev[error].err; -+ if (error) -+ ll = 0; -+ -+ return (ll); -+} -diff -Naur a/tags.c b/tags.c ---- a/tags.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/tags.c 2020-04-21 19:01:59.000000000 +0100 -@@ -8,7 +8,11 @@ - - #include - #include --#include -+#if defined(LIBBSD_OVERLAY) -+# include -+#else -+# include "tree.h" -+#endif - #include - #include - #include -@@ -18,11 +22,14 @@ - #include - #include - #include --#if defined(LIBBSD_OVERLAY) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__GLIBC__) -+#if defined(LIBBSD_OVERLAY) || defined(__FreeBSD__) || defined(__GLIBC__) || defined(__APPLE__) - # include - #else - #include - #endif -+#if defined(__APPLE__) -+# include "apple.h" -+#endif - - #include "def.h" - -@@ -53,9 +60,6 @@ - char *pat; - }; - RB_HEAD(tagtree, ctag) tags = RB_INITIALIZER(&tags); --#ifdef __DragonFly__ --RB_PROTOTYPE(tagtree, ctag, entry, ctagcmp); --#endif - RB_GENERATE(tagtree, ctag, entry, ctagcmp); - - struct tagpos { -diff -Naur a/tree.h b/tree.h ---- a/tree.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/tree.h 2020-04-21 19:01:59.000000000 +0100 -@@ -0,0 +1,1006 @@ -+/* $OpenBSD: tree.h,v 1.29 2017/07/30 19:27:20 deraadt Exp $ */ -+/* -+ * Copyright 2002 Niels Provos -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in the -+ * documentation and/or other materials provided with the distribution. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ */ -+ -+#ifndef _SYS_TREE_H_ -+#define _SYS_TREE_H_ -+ -+#include "_null.h" -+ -+/* -+ * This file defines data structures for different types of trees: -+ * splay trees and red-black trees. -+ * -+ * A splay tree is a self-organizing data structure. Every operation -+ * on the tree causes a splay to happen. The splay moves the requested -+ * node to the root of the tree and partly rebalances it. -+ * -+ * This has the benefit that request locality causes faster lookups as -+ * the requested nodes move to the top of the tree. On the other hand, -+ * every lookup causes memory writes. -+ * -+ * The Balance Theorem bounds the total access time for m operations -+ * and n inserts on an initially empty tree as O((m + n)lg n). The -+ * amortized cost for a sequence of m accesses to a splay tree is O(lg n); -+ * -+ * A red-black tree is a binary search tree with the node color as an -+ * extra attribute. It fulfills a set of conditions: -+ * - every search path from the root to a leaf consists of the -+ * same number of black nodes, -+ * - each red node (except for the root) has a black parent, -+ * - each leaf node is black. -+ * -+ * Every operation on a red-black tree is bounded as O(lg n). -+ * The maximum height of a red-black tree is 2lg (n+1). -+ */ -+ -+#define SPLAY_HEAD(name, type) \ -+struct name { \ -+ struct type *sph_root; /* root of the tree */ \ -+} -+ -+#define SPLAY_INITIALIZER(root) \ -+ { NULL } -+ -+#define SPLAY_INIT(root) do { \ -+ (root)->sph_root = NULL; \ -+} while (0) -+ -+#define SPLAY_ENTRY(type) \ -+struct { \ -+ struct type *spe_left; /* left element */ \ -+ struct type *spe_right; /* right element */ \ -+} -+ -+#define SPLAY_LEFT(elm, field) (elm)->field.spe_left -+#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right -+#define SPLAY_ROOT(head) (head)->sph_root -+#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) -+ -+/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -+#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ -+ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ -+ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ -+ (head)->sph_root = tmp; \ -+} while (0) -+ -+#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ -+ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ -+ SPLAY_LEFT(tmp, field) = (head)->sph_root; \ -+ (head)->sph_root = tmp; \ -+} while (0) -+ -+#define SPLAY_LINKLEFT(head, tmp, field) do { \ -+ SPLAY_LEFT(tmp, field) = (head)->sph_root; \ -+ tmp = (head)->sph_root; \ -+ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ -+} while (0) -+ -+#define SPLAY_LINKRIGHT(head, tmp, field) do { \ -+ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ -+ tmp = (head)->sph_root; \ -+ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ -+} while (0) -+ -+#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ -+ SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ -+ SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ -+ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ -+ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ -+} while (0) -+ -+/* Generates prototypes and inline functions */ -+ -+#define SPLAY_PROTOTYPE(name, type, field, cmp) \ -+void name##_SPLAY(struct name *, struct type *); \ -+void name##_SPLAY_MINMAX(struct name *, int); \ -+struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ -+struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ -+ \ -+/* Finds the node with the same key as elm */ \ -+static __unused __inline struct type * \ -+name##_SPLAY_FIND(struct name *head, struct type *elm) \ -+{ \ -+ if (SPLAY_EMPTY(head)) \ -+ return(NULL); \ -+ name##_SPLAY(head, elm); \ -+ if ((cmp)(elm, (head)->sph_root) == 0) \ -+ return (head->sph_root); \ -+ return (NULL); \ -+} \ -+ \ -+static __unused __inline struct type * \ -+name##_SPLAY_NEXT(struct name *head, struct type *elm) \ -+{ \ -+ name##_SPLAY(head, elm); \ -+ if (SPLAY_RIGHT(elm, field) != NULL) { \ -+ elm = SPLAY_RIGHT(elm, field); \ -+ while (SPLAY_LEFT(elm, field) != NULL) { \ -+ elm = SPLAY_LEFT(elm, field); \ -+ } \ -+ } else \ -+ elm = NULL; \ -+ return (elm); \ -+} \ -+ \ -+static __unused __inline struct type * \ -+name##_SPLAY_MIN_MAX(struct name *head, int val) \ -+{ \ -+ name##_SPLAY_MINMAX(head, val); \ -+ return (SPLAY_ROOT(head)); \ -+} -+ -+/* Main splay operation. -+ * Moves node close to the key of elm to top -+ */ -+#define SPLAY_GENERATE(name, type, field, cmp) \ -+struct type * \ -+name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -+{ \ -+ if (SPLAY_EMPTY(head)) { \ -+ SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ -+ } else { \ -+ int __comp; \ -+ name##_SPLAY(head, elm); \ -+ __comp = (cmp)(elm, (head)->sph_root); \ -+ if(__comp < 0) { \ -+ SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ -+ SPLAY_RIGHT(elm, field) = (head)->sph_root; \ -+ SPLAY_LEFT((head)->sph_root, field) = NULL; \ -+ } else if (__comp > 0) { \ -+ SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ -+ SPLAY_LEFT(elm, field) = (head)->sph_root; \ -+ SPLAY_RIGHT((head)->sph_root, field) = NULL; \ -+ } else \ -+ return ((head)->sph_root); \ -+ } \ -+ (head)->sph_root = (elm); \ -+ return (NULL); \ -+} \ -+ \ -+struct type * \ -+name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -+{ \ -+ struct type *__tmp; \ -+ if (SPLAY_EMPTY(head)) \ -+ return (NULL); \ -+ name##_SPLAY(head, elm); \ -+ if ((cmp)(elm, (head)->sph_root) == 0) { \ -+ if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ -+ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ -+ } else { \ -+ __tmp = SPLAY_RIGHT((head)->sph_root, field); \ -+ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ -+ name##_SPLAY(head, elm); \ -+ SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ -+ } \ -+ return (elm); \ -+ } \ -+ return (NULL); \ -+} \ -+ \ -+void \ -+name##_SPLAY(struct name *head, struct type *elm) \ -+{ \ -+ struct type __node, *__left, *__right, *__tmp; \ -+ int __comp; \ -+\ -+ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ -+ __left = __right = &__node; \ -+\ -+ while ((__comp = (cmp)(elm, (head)->sph_root))) { \ -+ if (__comp < 0) { \ -+ __tmp = SPLAY_LEFT((head)->sph_root, field); \ -+ if (__tmp == NULL) \ -+ break; \ -+ if ((cmp)(elm, __tmp) < 0){ \ -+ SPLAY_ROTATE_RIGHT(head, __tmp, field); \ -+ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ -+ break; \ -+ } \ -+ SPLAY_LINKLEFT(head, __right, field); \ -+ } else if (__comp > 0) { \ -+ __tmp = SPLAY_RIGHT((head)->sph_root, field); \ -+ if (__tmp == NULL) \ -+ break; \ -+ if ((cmp)(elm, __tmp) > 0){ \ -+ SPLAY_ROTATE_LEFT(head, __tmp, field); \ -+ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ -+ break; \ -+ } \ -+ SPLAY_LINKRIGHT(head, __left, field); \ -+ } \ -+ } \ -+ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -+} \ -+ \ -+/* Splay with either the minimum or the maximum element \ -+ * Used to find minimum or maximum element in tree. \ -+ */ \ -+void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -+{ \ -+ struct type __node, *__left, *__right, *__tmp; \ -+\ -+ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ -+ __left = __right = &__node; \ -+\ -+ while (1) { \ -+ if (__comp < 0) { \ -+ __tmp = SPLAY_LEFT((head)->sph_root, field); \ -+ if (__tmp == NULL) \ -+ break; \ -+ if (__comp < 0){ \ -+ SPLAY_ROTATE_RIGHT(head, __tmp, field); \ -+ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ -+ break; \ -+ } \ -+ SPLAY_LINKLEFT(head, __right, field); \ -+ } else if (__comp > 0) { \ -+ __tmp = SPLAY_RIGHT((head)->sph_root, field); \ -+ if (__tmp == NULL) \ -+ break; \ -+ if (__comp > 0) { \ -+ SPLAY_ROTATE_LEFT(head, __tmp, field); \ -+ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ -+ break; \ -+ } \ -+ SPLAY_LINKRIGHT(head, __left, field); \ -+ } \ -+ } \ -+ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -+} -+ -+#define SPLAY_NEGINF -1 -+#define SPLAY_INF 1 -+ -+#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) -+#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) -+#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) -+#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) -+#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ -+ : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -+#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ -+ : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) -+ -+#define SPLAY_FOREACH(x, name, head) \ -+ for ((x) = SPLAY_MIN(name, head); \ -+ (x) != NULL; \ -+ (x) = SPLAY_NEXT(name, head, x)) -+ -+/* Macros that define a red-black tree */ -+#define RB_HEAD(name, type) \ -+struct name { \ -+ struct type *rbh_root; /* root of the tree */ \ -+} -+ -+#define RB_INITIALIZER(root) \ -+ { NULL } -+ -+#define RB_INIT(root) do { \ -+ (root)->rbh_root = NULL; \ -+} while (0) -+ -+#define RB_BLACK 0 -+#define RB_RED 1 -+#define RB_ENTRY(type) \ -+struct { \ -+ struct type *rbe_left; /* left element */ \ -+ struct type *rbe_right; /* right element */ \ -+ struct type *rbe_parent; /* parent element */ \ -+ int rbe_color; /* node color */ \ -+} -+ -+#define RB_LEFT(elm, field) (elm)->field.rbe_left -+#define RB_RIGHT(elm, field) (elm)->field.rbe_right -+#define RB_PARENT(elm, field) (elm)->field.rbe_parent -+#define RB_COLOR(elm, field) (elm)->field.rbe_color -+#define RB_ROOT(head) (head)->rbh_root -+#define RB_EMPTY(head) (RB_ROOT(head) == NULL) -+ -+#define RB_SET(elm, parent, field) do { \ -+ RB_PARENT(elm, field) = parent; \ -+ RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ -+ RB_COLOR(elm, field) = RB_RED; \ -+} while (0) -+ -+#define RB_SET_BLACKRED(black, red, field) do { \ -+ RB_COLOR(black, field) = RB_BLACK; \ -+ RB_COLOR(red, field) = RB_RED; \ -+} while (0) -+ -+#ifndef RB_AUGMENT -+#define RB_AUGMENT(x) do {} while (0) -+#endif -+ -+#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ -+ (tmp) = RB_RIGHT(elm, field); \ -+ if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field))) { \ -+ RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ -+ } \ -+ RB_AUGMENT(elm); \ -+ if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ -+ if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ -+ RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ -+ else \ -+ RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ -+ } else \ -+ (head)->rbh_root = (tmp); \ -+ RB_LEFT(tmp, field) = (elm); \ -+ RB_PARENT(elm, field) = (tmp); \ -+ RB_AUGMENT(tmp); \ -+ if ((RB_PARENT(tmp, field))) \ -+ RB_AUGMENT(RB_PARENT(tmp, field)); \ -+} while (0) -+ -+#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ -+ (tmp) = RB_LEFT(elm, field); \ -+ if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field))) { \ -+ RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ -+ } \ -+ RB_AUGMENT(elm); \ -+ if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ -+ if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ -+ RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ -+ else \ -+ RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ -+ } else \ -+ (head)->rbh_root = (tmp); \ -+ RB_RIGHT(tmp, field) = (elm); \ -+ RB_PARENT(elm, field) = (tmp); \ -+ RB_AUGMENT(tmp); \ -+ if ((RB_PARENT(tmp, field))) \ -+ RB_AUGMENT(RB_PARENT(tmp, field)); \ -+} while (0) -+ -+/* Generates prototypes and inline functions */ -+#define RB_PROTOTYPE(name, type, field, cmp) \ -+ RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) -+#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ -+ RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static) -+#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ -+attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ -+attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ -+attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ -+attr struct type *name##_RB_INSERT(struct name *, struct type *); \ -+attr struct type *name##_RB_FIND(struct name *, struct type *); \ -+attr struct type *name##_RB_NFIND(struct name *, struct type *); \ -+attr struct type *name##_RB_NEXT(struct type *); \ -+attr struct type *name##_RB_PREV(struct type *); \ -+attr struct type *name##_RB_MINMAX(struct name *, int); \ -+ \ -+ -+/* Main rb operation. -+ * Moves node close to the key of elm to top -+ */ -+#define RB_GENERATE(name, type, field, cmp) \ -+ RB_GENERATE_INTERNAL(name, type, field, cmp,) -+#define RB_GENERATE_STATIC(name, type, field, cmp) \ -+ RB_GENERATE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static) -+#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ -+attr void \ -+name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ -+{ \ -+ struct type *parent, *gparent, *tmp; \ -+ while ((parent = RB_PARENT(elm, field)) && \ -+ RB_COLOR(parent, field) == RB_RED) { \ -+ gparent = RB_PARENT(parent, field); \ -+ if (parent == RB_LEFT(gparent, field)) { \ -+ tmp = RB_RIGHT(gparent, field); \ -+ if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ -+ RB_COLOR(tmp, field) = RB_BLACK; \ -+ RB_SET_BLACKRED(parent, gparent, field);\ -+ elm = gparent; \ -+ continue; \ -+ } \ -+ if (RB_RIGHT(parent, field) == elm) { \ -+ RB_ROTATE_LEFT(head, parent, tmp, field);\ -+ tmp = parent; \ -+ parent = elm; \ -+ elm = tmp; \ -+ } \ -+ RB_SET_BLACKRED(parent, gparent, field); \ -+ RB_ROTATE_RIGHT(head, gparent, tmp, field); \ -+ } else { \ -+ tmp = RB_LEFT(gparent, field); \ -+ if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ -+ RB_COLOR(tmp, field) = RB_BLACK; \ -+ RB_SET_BLACKRED(parent, gparent, field);\ -+ elm = gparent; \ -+ continue; \ -+ } \ -+ if (RB_LEFT(parent, field) == elm) { \ -+ RB_ROTATE_RIGHT(head, parent, tmp, field);\ -+ tmp = parent; \ -+ parent = elm; \ -+ elm = tmp; \ -+ } \ -+ RB_SET_BLACKRED(parent, gparent, field); \ -+ RB_ROTATE_LEFT(head, gparent, tmp, field); \ -+ } \ -+ } \ -+ RB_COLOR(head->rbh_root, field) = RB_BLACK; \ -+} \ -+ \ -+attr void \ -+name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ -+{ \ -+ struct type *tmp; \ -+ while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ -+ elm != RB_ROOT(head)) { \ -+ if (RB_LEFT(parent, field) == elm) { \ -+ tmp = RB_RIGHT(parent, field); \ -+ if (RB_COLOR(tmp, field) == RB_RED) { \ -+ RB_SET_BLACKRED(tmp, parent, field); \ -+ RB_ROTATE_LEFT(head, parent, tmp, field);\ -+ tmp = RB_RIGHT(parent, field); \ -+ } \ -+ if ((RB_LEFT(tmp, field) == NULL || \ -+ RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ -+ (RB_RIGHT(tmp, field) == NULL || \ -+ RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ -+ RB_COLOR(tmp, field) = RB_RED; \ -+ elm = parent; \ -+ parent = RB_PARENT(elm, field); \ -+ } else { \ -+ if (RB_RIGHT(tmp, field) == NULL || \ -+ RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ -+ struct type *oleft; \ -+ if ((oleft = RB_LEFT(tmp, field)))\ -+ RB_COLOR(oleft, field) = RB_BLACK;\ -+ RB_COLOR(tmp, field) = RB_RED; \ -+ RB_ROTATE_RIGHT(head, tmp, oleft, field);\ -+ tmp = RB_RIGHT(parent, field); \ -+ } \ -+ RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ -+ RB_COLOR(parent, field) = RB_BLACK; \ -+ if (RB_RIGHT(tmp, field)) \ -+ RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\ -+ RB_ROTATE_LEFT(head, parent, tmp, field);\ -+ elm = RB_ROOT(head); \ -+ break; \ -+ } \ -+ } else { \ -+ tmp = RB_LEFT(parent, field); \ -+ if (RB_COLOR(tmp, field) == RB_RED) { \ -+ RB_SET_BLACKRED(tmp, parent, field); \ -+ RB_ROTATE_RIGHT(head, parent, tmp, field);\ -+ tmp = RB_LEFT(parent, field); \ -+ } \ -+ if ((RB_LEFT(tmp, field) == NULL || \ -+ RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ -+ (RB_RIGHT(tmp, field) == NULL || \ -+ RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ -+ RB_COLOR(tmp, field) = RB_RED; \ -+ elm = parent; \ -+ parent = RB_PARENT(elm, field); \ -+ } else { \ -+ if (RB_LEFT(tmp, field) == NULL || \ -+ RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ -+ struct type *oright; \ -+ if ((oright = RB_RIGHT(tmp, field)))\ -+ RB_COLOR(oright, field) = RB_BLACK;\ -+ RB_COLOR(tmp, field) = RB_RED; \ -+ RB_ROTATE_LEFT(head, tmp, oright, field);\ -+ tmp = RB_LEFT(parent, field); \ -+ } \ -+ RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ -+ RB_COLOR(parent, field) = RB_BLACK; \ -+ if (RB_LEFT(tmp, field)) \ -+ RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\ -+ RB_ROTATE_RIGHT(head, parent, tmp, field);\ -+ elm = RB_ROOT(head); \ -+ break; \ -+ } \ -+ } \ -+ } \ -+ if (elm) \ -+ RB_COLOR(elm, field) = RB_BLACK; \ -+} \ -+ \ -+attr struct type * \ -+name##_RB_REMOVE(struct name *head, struct type *elm) \ -+{ \ -+ struct type *child, *parent, *old = elm; \ -+ int color; \ -+ if (RB_LEFT(elm, field) == NULL) \ -+ child = RB_RIGHT(elm, field); \ -+ else if (RB_RIGHT(elm, field) == NULL) \ -+ child = RB_LEFT(elm, field); \ -+ else { \ -+ struct type *left; \ -+ elm = RB_RIGHT(elm, field); \ -+ while ((left = RB_LEFT(elm, field))) \ -+ elm = left; \ -+ child = RB_RIGHT(elm, field); \ -+ parent = RB_PARENT(elm, field); \ -+ color = RB_COLOR(elm, field); \ -+ if (child) \ -+ RB_PARENT(child, field) = parent; \ -+ if (parent) { \ -+ if (RB_LEFT(parent, field) == elm) \ -+ RB_LEFT(parent, field) = child; \ -+ else \ -+ RB_RIGHT(parent, field) = child; \ -+ RB_AUGMENT(parent); \ -+ } else \ -+ RB_ROOT(head) = child; \ -+ if (RB_PARENT(elm, field) == old) \ -+ parent = elm; \ -+ (elm)->field = (old)->field; \ -+ if (RB_PARENT(old, field)) { \ -+ if (RB_LEFT(RB_PARENT(old, field), field) == old)\ -+ RB_LEFT(RB_PARENT(old, field), field) = elm;\ -+ else \ -+ RB_RIGHT(RB_PARENT(old, field), field) = elm;\ -+ RB_AUGMENT(RB_PARENT(old, field)); \ -+ } else \ -+ RB_ROOT(head) = elm; \ -+ RB_PARENT(RB_LEFT(old, field), field) = elm; \ -+ if (RB_RIGHT(old, field)) \ -+ RB_PARENT(RB_RIGHT(old, field), field) = elm; \ -+ if (parent) { \ -+ left = parent; \ -+ do { \ -+ RB_AUGMENT(left); \ -+ } while ((left = RB_PARENT(left, field))); \ -+ } \ -+ goto color; \ -+ } \ -+ parent = RB_PARENT(elm, field); \ -+ color = RB_COLOR(elm, field); \ -+ if (child) \ -+ RB_PARENT(child, field) = parent; \ -+ if (parent) { \ -+ if (RB_LEFT(parent, field) == elm) \ -+ RB_LEFT(parent, field) = child; \ -+ else \ -+ RB_RIGHT(parent, field) = child; \ -+ RB_AUGMENT(parent); \ -+ } else \ -+ RB_ROOT(head) = child; \ -+color: \ -+ if (color == RB_BLACK) \ -+ name##_RB_REMOVE_COLOR(head, parent, child); \ -+ return (old); \ -+} \ -+ \ -+/* Inserts a node into the RB tree */ \ -+attr struct type * \ -+name##_RB_INSERT(struct name *head, struct type *elm) \ -+{ \ -+ struct type *tmp; \ -+ struct type *parent = NULL; \ -+ int comp = 0; \ -+ tmp = RB_ROOT(head); \ -+ while (tmp) { \ -+ parent = tmp; \ -+ comp = (cmp)(elm, parent); \ -+ if (comp < 0) \ -+ tmp = RB_LEFT(tmp, field); \ -+ else if (comp > 0) \ -+ tmp = RB_RIGHT(tmp, field); \ -+ else \ -+ return (tmp); \ -+ } \ -+ RB_SET(elm, parent, field); \ -+ if (parent != NULL) { \ -+ if (comp < 0) \ -+ RB_LEFT(parent, field) = elm; \ -+ else \ -+ RB_RIGHT(parent, field) = elm; \ -+ RB_AUGMENT(parent); \ -+ } else \ -+ RB_ROOT(head) = elm; \ -+ name##_RB_INSERT_COLOR(head, elm); \ -+ return (NULL); \ -+} \ -+ \ -+/* Finds the node with the same key as elm */ \ -+attr struct type * \ -+name##_RB_FIND(struct name *head, struct type *elm) \ -+{ \ -+ struct type *tmp = RB_ROOT(head); \ -+ int comp; \ -+ while (tmp) { \ -+ comp = cmp(elm, tmp); \ -+ if (comp < 0) \ -+ tmp = RB_LEFT(tmp, field); \ -+ else if (comp > 0) \ -+ tmp = RB_RIGHT(tmp, field); \ -+ else \ -+ return (tmp); \ -+ } \ -+ return (NULL); \ -+} \ -+ \ -+/* Finds the first node greater than or equal to the search key */ \ -+attr struct type * \ -+name##_RB_NFIND(struct name *head, struct type *elm) \ -+{ \ -+ struct type *tmp = RB_ROOT(head); \ -+ struct type *res = NULL; \ -+ int comp; \ -+ while (tmp) { \ -+ comp = cmp(elm, tmp); \ -+ if (comp < 0) { \ -+ res = tmp; \ -+ tmp = RB_LEFT(tmp, field); \ -+ } \ -+ else if (comp > 0) \ -+ tmp = RB_RIGHT(tmp, field); \ -+ else \ -+ return (tmp); \ -+ } \ -+ return (res); \ -+} \ -+ \ -+/* ARGSUSED */ \ -+attr struct type * \ -+name##_RB_NEXT(struct type *elm) \ -+{ \ -+ if (RB_RIGHT(elm, field)) { \ -+ elm = RB_RIGHT(elm, field); \ -+ while (RB_LEFT(elm, field)) \ -+ elm = RB_LEFT(elm, field); \ -+ } else { \ -+ if (RB_PARENT(elm, field) && \ -+ (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ -+ elm = RB_PARENT(elm, field); \ -+ else { \ -+ while (RB_PARENT(elm, field) && \ -+ (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ -+ elm = RB_PARENT(elm, field); \ -+ elm = RB_PARENT(elm, field); \ -+ } \ -+ } \ -+ return (elm); \ -+} \ -+ \ -+/* ARGSUSED */ \ -+attr struct type * \ -+name##_RB_PREV(struct type *elm) \ -+{ \ -+ if (RB_LEFT(elm, field)) { \ -+ elm = RB_LEFT(elm, field); \ -+ while (RB_RIGHT(elm, field)) \ -+ elm = RB_RIGHT(elm, field); \ -+ } else { \ -+ if (RB_PARENT(elm, field) && \ -+ (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ -+ elm = RB_PARENT(elm, field); \ -+ else { \ -+ while (RB_PARENT(elm, field) && \ -+ (elm == RB_LEFT(RB_PARENT(elm, field), field)))\ -+ elm = RB_PARENT(elm, field); \ -+ elm = RB_PARENT(elm, field); \ -+ } \ -+ } \ -+ return (elm); \ -+} \ -+ \ -+attr struct type * \ -+name##_RB_MINMAX(struct name *head, int val) \ -+{ \ -+ struct type *tmp = RB_ROOT(head); \ -+ struct type *parent = NULL; \ -+ while (tmp) { \ -+ parent = tmp; \ -+ if (val < 0) \ -+ tmp = RB_LEFT(tmp, field); \ -+ else \ -+ tmp = RB_RIGHT(tmp, field); \ -+ } \ -+ return (parent); \ -+} -+ -+#define RB_NEGINF -1 -+#define RB_INF 1 -+ -+#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) -+#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) -+#define RB_FIND(name, x, y) name##_RB_FIND(x, y) -+#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) -+#define RB_NEXT(name, x, y) name##_RB_NEXT(y) -+#define RB_PREV(name, x, y) name##_RB_PREV(y) -+#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) -+#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) -+ -+#define RB_FOREACH(x, name, head) \ -+ for ((x) = RB_MIN(name, head); \ -+ (x) != NULL; \ -+ (x) = name##_RB_NEXT(x)) -+ -+#define RB_FOREACH_SAFE(x, name, head, y) \ -+ for ((x) = RB_MIN(name, head); \ -+ ((x) != NULL) && ((y) = name##_RB_NEXT(x), 1); \ -+ (x) = (y)) -+ -+#define RB_FOREACH_REVERSE(x, name, head) \ -+ for ((x) = RB_MAX(name, head); \ -+ (x) != NULL; \ -+ (x) = name##_RB_PREV(x)) -+ -+#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ -+ for ((x) = RB_MAX(name, head); \ -+ ((x) != NULL) && ((y) = name##_RB_PREV(x), 1); \ -+ (x) = (y)) -+ -+ -+/* -+ * Copyright (c) 2016 David Gwynne -+ * -+ * Permission to use, copy, modify, and distribute this software for any -+ * purpose with or without fee is hereby granted, provided that the above -+ * copyright notice and this permission notice appear in all copies. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -+ */ -+ -+struct rb_type { -+ int (*t_compare)(const void *, const void *); -+ void (*t_augment)(void *); -+ unsigned int t_offset; /* offset of rb_entry in type */ -+}; -+ -+struct rb_tree { -+ struct rb_entry *rbt_root; -+}; -+ -+struct rb_entry { -+ struct rb_entry *rbt_parent; -+ struct rb_entry *rbt_left; -+ struct rb_entry *rbt_right; -+ unsigned int rbt_color; -+}; -+ -+#define RBT_HEAD(_name, _type) \ -+struct _name { \ -+ struct rb_tree rbh_root; \ -+} -+ -+#define RBT_ENTRY(_type) struct rb_entry -+ -+static inline void -+_rb_init(struct rb_tree *rbt) -+{ -+ rbt->rbt_root = NULL; -+} -+ -+static inline int -+_rb_empty(struct rb_tree *rbt) -+{ -+ return (rbt->rbt_root == NULL); -+} -+ -+void *_rb_insert(const struct rb_type *, struct rb_tree *, void *); -+void *_rb_remove(const struct rb_type *, struct rb_tree *, void *); -+void *_rb_find(const struct rb_type *, struct rb_tree *, const void *); -+void *_rb_nfind(const struct rb_type *, struct rb_tree *, const void *); -+void *_rb_root(const struct rb_type *, struct rb_tree *); -+void *_rb_min(const struct rb_type *, struct rb_tree *); -+void *_rb_max(const struct rb_type *, struct rb_tree *); -+void *_rb_next(const struct rb_type *, void *); -+void *_rb_prev(const struct rb_type *, void *); -+void *_rb_left(const struct rb_type *, void *); -+void *_rb_right(const struct rb_type *, void *); -+void *_rb_parent(const struct rb_type *, void *); -+void _rb_set_left(const struct rb_type *, void *, void *); -+void _rb_set_right(const struct rb_type *, void *, void *); -+void _rb_set_parent(const struct rb_type *, void *, void *); -+void _rb_poison(const struct rb_type *, void *, unsigned long); -+int _rb_check(const struct rb_type *, void *, unsigned long); -+ -+#define RBT_INITIALIZER(_head) { { NULL } } -+ -+#define RBT_PROTOTYPE(_name, _type, _field, _cmp) \ -+extern const struct rb_type *const _name##_RBT_TYPE; \ -+ \ -+__unused static inline void \ -+_name##_RBT_INIT(struct _name *head) \ -+{ \ -+ _rb_init(&head->rbh_root); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_INSERT(struct _name *head, struct _type *elm) \ -+{ \ -+ return _rb_insert(_name##_RBT_TYPE, &head->rbh_root, elm); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_REMOVE(struct _name *head, struct _type *elm) \ -+{ \ -+ return _rb_remove(_name##_RBT_TYPE, &head->rbh_root, elm); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_FIND(struct _name *head, const struct _type *key) \ -+{ \ -+ return _rb_find(_name##_RBT_TYPE, &head->rbh_root, key); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_NFIND(struct _name *head, const struct _type *key) \ -+{ \ -+ return _rb_nfind(_name##_RBT_TYPE, &head->rbh_root, key); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_ROOT(struct _name *head) \ -+{ \ -+ return _rb_root(_name##_RBT_TYPE, &head->rbh_root); \ -+} \ -+ \ -+__unused static inline int \ -+_name##_RBT_EMPTY(struct _name *head) \ -+{ \ -+ return _rb_empty(&head->rbh_root); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_MIN(struct _name *head) \ -+{ \ -+ return _rb_min(_name##_RBT_TYPE, &head->rbh_root); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_MAX(struct _name *head) \ -+{ \ -+ return _rb_max(_name##_RBT_TYPE, &head->rbh_root); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_NEXT(struct _type *elm) \ -+{ \ -+ return _rb_next(_name##_RBT_TYPE, elm); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_PREV(struct _type *elm) \ -+{ \ -+ return _rb_prev(_name##_RBT_TYPE, elm); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_LEFT(struct _type *elm) \ -+{ \ -+ return _rb_left(_name##_RBT_TYPE, elm); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_RIGHT(struct _type *elm) \ -+{ \ -+ return _rb_right(_name##_RBT_TYPE, elm); \ -+} \ -+ \ -+__unused static inline struct _type * \ -+_name##_RBT_PARENT(struct _type *elm) \ -+{ \ -+ return _rb_parent(_name##_RBT_TYPE, elm); \ -+} \ -+ \ -+__unused static inline void \ -+_name##_RBT_SET_LEFT(struct _type *elm, struct _type *left) \ -+{ \ -+ return _rb_set_left(_name##_RBT_TYPE, elm, left); \ -+} \ -+ \ -+__unused static inline void \ -+_name##_RBT_SET_RIGHT(struct _type *elm, struct _type *right) \ -+{ \ -+ return _rb_set_right(_name##_RBT_TYPE, elm, right); \ -+} \ -+ \ -+__unused static inline void \ -+_name##_RBT_SET_PARENT(struct _type *elm, struct _type *parent) \ -+{ \ -+ return _rb_set_parent(_name##_RBT_TYPE, elm, parent); \ -+} \ -+ \ -+__unused static inline void \ -+_name##_RBT_POISON(struct _type *elm, unsigned long poison) \ -+{ \ -+ return _rb_poison(_name##_RBT_TYPE, elm, poison); \ -+} \ -+ \ -+__unused static inline int \ -+_name##_RBT_CHECK(struct _type *elm, unsigned long poison) \ -+{ \ -+ return _rb_check(_name##_RBT_TYPE, elm, poison); \ -+} -+ -+#define RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug) \ -+static int \ -+_name##_RBT_COMPARE(const void *lptr, const void *rptr) \ -+{ \ -+ const struct _type *l = lptr, *r = rptr; \ -+ return _cmp(l, r); \ -+} \ -+static const struct rb_type _name##_RBT_INFO = { \ -+ _name##_RBT_COMPARE, \ -+ _aug, \ -+ offsetof(struct _type, _field), \ -+}; \ -+const struct rb_type *const _name##_RBT_TYPE = &_name##_RBT_INFO -+ -+#define RBT_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug) \ -+static void \ -+_name##_RBT_AUGMENT(void *ptr) \ -+{ \ -+ struct _type *p = ptr; \ -+ return _aug(p); \ -+} \ -+RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RBT_AUGMENT) -+ -+#define RBT_GENERATE(_name, _type, _field, _cmp) \ -+ RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL) -+ -+#define RBT_INIT(_name, _head) _name##_RBT_INIT(_head) -+#define RBT_INSERT(_name, _head, _elm) _name##_RBT_INSERT(_head, _elm) -+#define RBT_REMOVE(_name, _head, _elm) _name##_RBT_REMOVE(_head, _elm) -+#define RBT_FIND(_name, _head, _key) _name##_RBT_FIND(_head, _key) -+#define RBT_NFIND(_name, _head, _key) _name##_RBT_NFIND(_head, _key) -+#define RBT_ROOT(_name, _head) _name##_RBT_ROOT(_head) -+#define RBT_EMPTY(_name, _head) _name##_RBT_EMPTY(_head) -+#define RBT_MIN(_name, _head) _name##_RBT_MIN(_head) -+#define RBT_MAX(_name, _head) _name##_RBT_MAX(_head) -+#define RBT_NEXT(_name, _elm) _name##_RBT_NEXT(_elm) -+#define RBT_PREV(_name, _elm) _name##_RBT_PREV(_elm) -+#define RBT_LEFT(_name, _elm) _name##_RBT_LEFT(_elm) -+#define RBT_RIGHT(_name, _elm) _name##_RBT_RIGHT(_elm) -+#define RBT_PARENT(_name, _elm) _name##_RBT_PARENT(_elm) -+#define RBT_SET_LEFT(_name, _elm, _l) _name##_RBT_SET_LEFT(_elm, _l) -+#define RBT_SET_RIGHT(_name, _elm, _r) _name##_RBT_SET_RIGHT(_elm, _r) -+#define RBT_SET_PARENT(_name, _elm, _p) _name##_RBT_SET_PARENT(_elm, _p) -+#define RBT_POISON(_name, _elm, _p) _name##_RBT_POISON(_elm, _p) -+#define RBT_CHECK(_name, _elm, _p) _name##_RBT_CHECK(_elm, _p) -+ -+#define RBT_FOREACH(_e, _name, _head) \ -+ for ((_e) = RBT_MIN(_name, (_head)); \ -+ (_e) != NULL; \ -+ (_e) = RBT_NEXT(_name, (_e))) -+ -+#define RBT_FOREACH_SAFE(_e, _name, _head, _n) \ -+ for ((_e) = RBT_MIN(_name, (_head)); \ -+ (_e) != NULL && ((_n) = RBT_NEXT(_name, (_e)), 1); \ -+ (_e) = (_n)) -+ -+#define RBT_FOREACH_REVERSE(_e, _name, _head) \ -+ for ((_e) = RBT_MAX(_name, (_head)); \ -+ (_e) != NULL; \ -+ (_e) = RBT_PREV(_name, (_e))) -+ -+#define RBT_FOREACH_REVERSE_SAFE(_e, _name, _head, _n) \ -+ for ((_e) = RBT_MAX(_name, (_head)); \ -+ (_e) != NULL && ((_n) = RBT_PREV(_name, (_e)), 1); \ -+ (_e) = (_n)) -+ -+#endif /* _SYS_TREE_H_ */ diff --git a/pkgs/applications/editors/mg/default.nix b/pkgs/applications/editors/mg/default.nix index e019baaf727..612cdcc7f88 100644 --- a/pkgs/applications/editors/mg/default.nix +++ b/pkgs/applications/editors/mg/default.nix @@ -1,14 +1,14 @@ -{ stdenv, fetchFromGitHub, pkgconfig, ncurses, buildPackages, libbsd }: +{ stdenv, fetchFromGitHub, pkgconfig, ncurses, buildPackages }: stdenv.mkDerivation rec { pname = "mg"; - version = "20200215"; + version = "6.7"; src = fetchFromGitHub { - owner = "hboetes"; + owner = "ibara"; repo = "mg"; - rev = "20200215"; - sha256 = "1rss7d43hbq43n63gxfvx4b2vh2km58cchwzdf2ssqhaz3qj40m6"; + rev = "mg-6.7"; + sha256 = "15adwibq6xrfxbrxzk765g9250iyfn4wbcxd7kcsabiwn6apm0ai"; }; enableParallelBuilding = true; @@ -21,13 +21,11 @@ stdenv.mkDerivation rec { ''; nativeBuildInputs = [ pkgconfig ]; - patches = ./darwin_no_libbsd.patch; - - buildInputs = [ ncurses ] ++ stdenv.lib.optional (!stdenv.isDarwin) libbsd; + buildInputs = [ ncurses ]; meta = with stdenv.lib; { description = "Micro GNU/emacs, a portable version of the mg maintained by the OpenBSD team"; - homepage = "https://homepage.boetes.org/software/mg"; + homepage = "https://man.openbsd.org/OpenBSD-current/man1/mg.1"; license = licenses.publicDomain; platforms = platforms.all; }; From 4cad49dc1a7e15335e401ed39ae42c98b06391a7 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 3 May 2020 02:04:54 +0100 Subject: [PATCH 22/81] python3Packages.PyGithub: 1.47 -> 1.51 --- pkgs/development/python-modules/pyGithub/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/pyGithub/default.nix b/pkgs/development/python-modules/pyGithub/default.nix index 2102554face..cf0784024f1 100644 --- a/pkgs/development/python-modules/pyGithub/default.nix +++ b/pkgs/development/python-modules/pyGithub/default.nix @@ -12,14 +12,14 @@ buildPythonPackage rec { pname = "PyGithub"; - version = "1.47"; + version = "1.51"; disabled = !isPy3k; src = fetchFromGitHub { owner = "PyGithub"; repo = "PyGithub"; rev = "v${version}"; - sha256 = "0zvp1gib2lryw698vxkbdv40n3lsmdlhwp7vdcg41dqqa5nfryhn"; + hash = "sha256-8uQCFiw1ByPOX8ZRUlSLYPIibjmd19r/JtTnmQdz5cM="; }; checkInputs = [ httpretty parameterized pytestCheckHook ]; From 83c4ac2eb3ac2aacfc917e96b1a12091889fdfae Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 26 Apr 2020 19:28:24 +0100 Subject: [PATCH 23/81] linux/update-hardened.py: reformat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit $ isort --multi-line=3 --trailing-comma --force-grid-wrap=0 --use-parentheses … $ black --line-length=80 … (per the black documentation) --- .../linux/kernel/update-hardened.py | 138 ++++++++++-------- 1 file changed, 80 insertions(+), 58 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/update-hardened.py b/pkgs/os-specific/linux/kernel/update-hardened.py index 7f6949653af..49a6228fb97 100755 --- a/pkgs/os-specific/linux/kernel/update-hardened.py +++ b/pkgs/os-specific/linux/kernel/update-hardened.py @@ -3,60 +3,68 @@ # This is automatically called by ./update.sh. -import re import json -import sys import os.path -from glob import glob +import re import subprocess +import sys +from glob import glob from tempfile import TemporaryDirectory from github import Github HERE = os.path.dirname(os.path.realpath(__file__)) -HARDENED_GITHUB_REPO = 'anthraxx/linux-hardened' -HARDENED_TRUSTED_KEY = os.path.join(HERE, 'anthraxx.asc') -HARDENED_PATCHES_PATH = os.path.join(HERE, 'hardened-patches.json') +HARDENED_GITHUB_REPO = "anthraxx/linux-hardened" +HARDENED_TRUSTED_KEY = os.path.join(HERE, "anthraxx.asc") +HARDENED_PATCHES_PATH = os.path.join(HERE, "hardened-patches.json") MIN_KERNEL_VERSION = [4, 14] + def run(*args, **kwargs): try: return subprocess.run( - args, **kwargs, - check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + args, + **kwargs, + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, ) except subprocess.CalledProcessError as err: print( - f'error: `{err.cmd}` failed unexpectedly\n' - f'status code: {err.returncode}\n' + f"error: `{err.cmd}` failed unexpectedly\n" + f"status code: {err.returncode}\n" f'stdout:\n{err.stdout.decode("utf-8").strip()}\n' f'stderr:\n{err.stderr.decode("utf-8").strip()}', file=sys.stderr, ) sys.exit(1) + def nix_prefetch_url(url): - output = run('nix-prefetch-url', '--print-path', url).stdout - return output.decode('utf-8').strip().split('\n') + output = run("nix-prefetch-url", "--print-path", url).stdout + return output.decode("utf-8").strip().split("\n") + def verify_openpgp_signature(*, name, trusted_key, sig_path, data_path): - with TemporaryDirectory(suffix='.nixpkgs-gnupg-home') as gnupg_home: - run('gpg', '--homedir', gnupg_home, '--import', trusted_key) - keyring = os.path.join(gnupg_home, 'pubring.kbx') + with TemporaryDirectory(suffix=".nixpkgs-gnupg-home") as gnupg_home: + run("gpg", "--homedir", gnupg_home, "--import", trusted_key) + keyring = os.path.join(gnupg_home, "pubring.kbx") try: subprocess.run( - ('gpgv', '--keyring', keyring, sig_path, data_path), - check=True, stderr=subprocess.PIPE, + ("gpgv", "--keyring", keyring, sig_path, data_path), + check=True, + stderr=subprocess.PIPE, ) return True except subprocess.CalledProcessError as err: print( - f'error: signature for {name} failed to verify!', + f"error: signature for {name} failed to verify!", file=sys.stderr, ) - print(err.stderr.decode('utf-8'), file=sys.stderr, end='') + print(err.stderr.decode("utf-8"), file=sys.stderr, end="") return False + def fetch_patch(*, name, release): def find_asset(filename): try: @@ -68,12 +76,12 @@ def fetch_patch(*, name, release): except StopIteration: raise KeyError(filename) - patch_filename = f'{name}.patch' + patch_filename = f"{name}.patch" try: patch_url = find_asset(patch_filename) - sig_url = find_asset(patch_filename + '.sig') + sig_url = find_asset(patch_filename + ".sig") except KeyError: - print(f'error: {patch_filename}{{,.sig}} not present', file=sys.stderr) + print(f"error: {patch_filename}{{,.sig}} not present", file=sys.stderr) return None sha256, patch_path = nix_prefetch_url(patch_url) @@ -88,59 +96,71 @@ def fetch_patch(*, name, release): return None return { - 'name': patch_filename, - 'url': patch_url, - 'sha256': sha256, + "name": patch_filename, + "url": patch_url, + "sha256": sha256, } + def parse_version(version_str): version = [] - for component in version_str.split('.'): + for component in version_str.split("."): try: version.append(int(component)) except ValueError: version.append(component) return version + def version_string(version): - return '.'.join(str(component) for component in version) + return ".".join(str(component) for component in version) + def major_kernel_version_key(kernel_version): return version_string(kernel_version[:-1]) + def commit_patches(*, kernel_key, message): - with open(HARDENED_PATCHES_PATH + '.new', 'w') as new_patches_file: + with open(HARDENED_PATCHES_PATH + ".new", "w") as new_patches_file: json.dump(patches, new_patches_file, indent=4, sort_keys=True) - new_patches_file.write('\n') - os.rename(HARDENED_PATCHES_PATH + '.new', HARDENED_PATCHES_PATH) - message = f'linux/hardened-patches/{kernel_key}: {message}' + new_patches_file.write("\n") + os.rename(HARDENED_PATCHES_PATH + ".new", HARDENED_PATCHES_PATH) + message = f"linux/hardened-patches/{kernel_key}: {message}" print(message) - if os.environ.get('COMMIT'): + if os.environ.get("COMMIT"): run( - 'git', '-C', HERE, 'commit', f'--message={message}', - 'hardened-patches.json', + "git", + "-C", + HERE, + "commit", + f"--message={message}", + "hardened-patches.json", ) + # Load the existing patches. with open(HARDENED_PATCHES_PATH) as patches_file: patches = json.load(patches_file) -NIX_VERSION_RE = re.compile(r''' - \s* version \s* = - \s* " (?P [^"]*) " - \s* ; \s* \n -''', re.VERBOSE) +NIX_VERSION_RE = re.compile( + r""" + \s* version \s* = + \s* " (?P [^"]*) " + \s* ; \s* \n + """, + re.VERBOSE, +) # Get the set of currently packaged kernel versions. kernel_versions = {} for filename in os.listdir(HERE): - filename_match = re.fullmatch(r'linux-(\d+)\.(\d+)\.nix', filename) + filename_match = re.fullmatch(r"linux-(\d+)\.(\d+)\.nix", filename) if filename_match: with open(os.path.join(HERE, filename)) as nix_file: for nix_line in nix_file: match = NIX_VERSION_RE.fullmatch(nix_line) if match: - kernel_version = parse_version(match.group('version')) + kernel_version = parse_version(match.group("version")) if kernel_version < MIN_KERNEL_VERSION: continue kernel_key = major_kernel_version_key(kernel_version) @@ -148,9 +168,9 @@ for filename in os.listdir(HERE): # Remove patches for unpackaged kernel versions. for kernel_key in sorted(patches.keys() - kernel_versions.keys()): - commit_patches(kernel_key=kernel_key, message='remove') + commit_patches(kernel_key=kernel_key, message="remove") -g = Github(os.environ.get('GITHUB_TOKEN')) +g = Github(os.environ.get("GITHUB_TOKEN")) repo = g.get_repo(HARDENED_GITHUB_REPO) failures = False @@ -171,8 +191,8 @@ for release in repo.get_releases(): continue release_info = { - 'version': version, - 'release': release, + "version": version, + "release": release, } if kernel_version == packaged_kernel_version: @@ -182,22 +202,24 @@ for release in repo.get_releases(): # skipping patches for kernels newer than the packaged one. if kernel_version > packaged_kernel_version: continue - elif (kernel_key not in releases or - releases[kernel_key]['version'] < version): + elif ( + kernel_key not in releases + or releases[kernel_key]["version"] < version + ): releases[kernel_key] = release_info # Update hardened-patches.json for each release. for kernel_key, release_info in releases.items(): - release = release_info['release'] - version = release_info['version'] + release = release_info["release"] + version = release_info["version"] version_str = release.tag_name - name = f'linux-hardened-{version_str}' + name = f"linux-hardened-{version_str}" try: - old_filename = patches[kernel_key]['name'] - old_version_str = (old_filename - .replace('linux-hardened-', '') - .replace('.patch', '')) + old_filename = patches[kernel_key]["name"] + old_version_str = old_filename.replace("linux-hardened-", "").replace( + ".patch", "" + ) old_version = parse_version(old_version_str) update = old_version < version except KeyError: @@ -211,17 +233,17 @@ for kernel_key, release_info in releases.items(): else: patches[kernel_key] = patch if old_version: - message = f'{old_version_str} -> {version_str}' + message = f"{old_version_str} -> {version_str}" else: - message = f'init at {version_str}' + message = f"init at {version_str}" commit_patches(kernel_key=kernel_key, message=message) missing_kernel_versions = kernel_versions.keys() - patches.keys() if missing_kernel_versions: print( - f'warning: no patches for kernel versions ' + - ', '.join(missing_kernel_versions), + f"warning: no patches for kernel versions " + + ", ".join(missing_kernel_versions), file=sys.stderr, ) From abe4bef033a8d6b1a82c84d2cd71f50a1624a389 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 26 Apr 2020 04:06:11 +0100 Subject: [PATCH 24/81] linux/update-hardened.py: use pathlib --- .../linux/kernel/update-hardened.py | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/update-hardened.py b/pkgs/os-specific/linux/kernel/update-hardened.py index 49a6228fb97..bc9110578d6 100755 --- a/pkgs/os-specific/linux/kernel/update-hardened.py +++ b/pkgs/os-specific/linux/kernel/update-hardened.py @@ -4,19 +4,19 @@ # This is automatically called by ./update.sh. import json -import os.path +import os import re import subprocess import sys -from glob import glob +from pathlib import Path from tempfile import TemporaryDirectory from github import Github -HERE = os.path.dirname(os.path.realpath(__file__)) +HERE = Path(__file__).resolve().parent HARDENED_GITHUB_REPO = "anthraxx/linux-hardened" -HARDENED_TRUSTED_KEY = os.path.join(HERE, "anthraxx.asc") -HARDENED_PATCHES_PATH = os.path.join(HERE, "hardened-patches.json") +HARDENED_TRUSTED_KEY = HERE / "anthraxx.asc" +HARDENED_PATCHES_PATH = HERE / "hardened-patches.json" MIN_KERNEL_VERSION = [4, 14] @@ -42,13 +42,15 @@ def run(*args, **kwargs): def nix_prefetch_url(url): output = run("nix-prefetch-url", "--print-path", url).stdout - return output.decode("utf-8").strip().split("\n") + sha256, path = output.decode("utf-8").strip().split("\n") + return sha256, Path(path) def verify_openpgp_signature(*, name, trusted_key, sig_path, data_path): - with TemporaryDirectory(suffix=".nixpkgs-gnupg-home") as gnupg_home: + with TemporaryDirectory(suffix=".nixpkgs-gnupg-home") as gnupg_home_str: + gnupg_home = Path(gnupg_home_str) run("gpg", "--homedir", gnupg_home, "--import", trusted_key) - keyring = os.path.join(gnupg_home, "pubring.kbx") + keyring = gnupg_home / "pubring.kbx" try: subprocess.run( ("gpgv", "--keyring", keyring, sig_path, data_path), @@ -121,10 +123,11 @@ def major_kernel_version_key(kernel_version): def commit_patches(*, kernel_key, message): - with open(HARDENED_PATCHES_PATH + ".new", "w") as new_patches_file: + new_patches_path = HARDENED_PATCHES_PATH.with_suffix(".new") + with open(new_patches_path, "w") as new_patches_file: json.dump(patches, new_patches_file, indent=4, sort_keys=True) new_patches_file.write("\n") - os.rename(HARDENED_PATCHES_PATH + ".new", HARDENED_PATCHES_PATH) + os.rename(new_patches_path, HARDENED_PATCHES_PATH) message = f"linux/hardened-patches/{kernel_key}: {message}" print(message) if os.environ.get("COMMIT"): @@ -156,7 +159,7 @@ kernel_versions = {} for filename in os.listdir(HERE): filename_match = re.fullmatch(r"linux-(\d+)\.(\d+)\.nix", filename) if filename_match: - with open(os.path.join(HERE, filename)) as nix_file: + with open(HERE / filename) as nix_file: for nix_line in nix_file: match = NIX_VERSION_RE.fullmatch(nix_line) if match: From d6fe0a4e2dc2711480f87fe8c9fa9b66323e4c25 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 26 Apr 2020 18:19:02 +0100 Subject: [PATCH 25/81] linux/hardened: move files into directory --- lib/kernel.nix | 2 +- .../linux/kernel/{ => hardened}/anthraxx.asc | 0 .../{hardened-config.nix => hardened/config.nix} | 0 .../patches.json} | 0 .../kernel/{ => hardened}/tag-hardened.patch | 0 .../{update-hardened.py => hardened/update.py} | 16 +++++++++------- pkgs/os-specific/linux/kernel/patches.nix | 4 ++-- pkgs/os-specific/linux/kernel/update.sh | 2 +- pkgs/top-level/all-packages.nix | 2 +- 9 files changed, 14 insertions(+), 12 deletions(-) rename pkgs/os-specific/linux/kernel/{ => hardened}/anthraxx.asc (100%) rename pkgs/os-specific/linux/kernel/{hardened-config.nix => hardened/config.nix} (100%) rename pkgs/os-specific/linux/kernel/{hardened-patches.json => hardened/patches.json} (100%) rename pkgs/os-specific/linux/kernel/{ => hardened}/tag-hardened.patch (100%) rename pkgs/os-specific/linux/kernel/{update-hardened.py => hardened/update.py} (94%) diff --git a/lib/kernel.nix b/lib/kernel.nix index 2ce19f8cb68..8045a228d05 100644 --- a/lib/kernel.nix +++ b/lib/kernel.nix @@ -14,7 +14,7 @@ with lib; freeform = x: { freeform = x; }; /* - Common patterns/legacy used in common-config/hardened-config.nix + Common patterns/legacy used in common-config/hardened/config.nix */ whenHelpers = version: { whenAtLeast = ver: mkIf (versionAtLeast version ver); diff --git a/pkgs/os-specific/linux/kernel/anthraxx.asc b/pkgs/os-specific/linux/kernel/hardened/anthraxx.asc similarity index 100% rename from pkgs/os-specific/linux/kernel/anthraxx.asc rename to pkgs/os-specific/linux/kernel/hardened/anthraxx.asc diff --git a/pkgs/os-specific/linux/kernel/hardened-config.nix b/pkgs/os-specific/linux/kernel/hardened/config.nix similarity index 100% rename from pkgs/os-specific/linux/kernel/hardened-config.nix rename to pkgs/os-specific/linux/kernel/hardened/config.nix diff --git a/pkgs/os-specific/linux/kernel/hardened-patches.json b/pkgs/os-specific/linux/kernel/hardened/patches.json similarity index 100% rename from pkgs/os-specific/linux/kernel/hardened-patches.json rename to pkgs/os-specific/linux/kernel/hardened/patches.json diff --git a/pkgs/os-specific/linux/kernel/tag-hardened.patch b/pkgs/os-specific/linux/kernel/hardened/tag-hardened.patch similarity index 100% rename from pkgs/os-specific/linux/kernel/tag-hardened.patch rename to pkgs/os-specific/linux/kernel/hardened/tag-hardened.patch diff --git a/pkgs/os-specific/linux/kernel/update-hardened.py b/pkgs/os-specific/linux/kernel/hardened/update.py similarity index 94% rename from pkgs/os-specific/linux/kernel/update-hardened.py rename to pkgs/os-specific/linux/kernel/hardened/update.py index bc9110578d6..1ef5acd3eb0 100755 --- a/pkgs/os-specific/linux/kernel/update-hardened.py +++ b/pkgs/os-specific/linux/kernel/hardened/update.py @@ -1,7 +1,7 @@ #! /usr/bin/env nix-shell #! nix-shell -i python -p "python3.withPackages (ps: [ps.PyGithub])" git gnupg -# This is automatically called by ./update.sh. +# This is automatically called by ../update.sh. import json import os @@ -14,9 +14,11 @@ from tempfile import TemporaryDirectory from github import Github HERE = Path(__file__).resolve().parent +NIXPKGS_KERNEL_PATH = HERE.parent +NIXPKGS_PATH = HERE.parents[4] HARDENED_GITHUB_REPO = "anthraxx/linux-hardened" HARDENED_TRUSTED_KEY = HERE / "anthraxx.asc" -HARDENED_PATCHES_PATH = HERE / "hardened-patches.json" +HARDENED_PATCHES_PATH = HERE / "patches.json" MIN_KERNEL_VERSION = [4, 14] @@ -128,16 +130,16 @@ def commit_patches(*, kernel_key, message): json.dump(patches, new_patches_file, indent=4, sort_keys=True) new_patches_file.write("\n") os.rename(new_patches_path, HARDENED_PATCHES_PATH) - message = f"linux/hardened-patches/{kernel_key}: {message}" + message = f"linux/hardened/patches/{kernel_key}: {message}" print(message) if os.environ.get("COMMIT"): run( "git", "-C", - HERE, + NIXPKGS_PATH, "commit", f"--message={message}", - "hardened-patches.json", + HARDENED_PATCHES_PATH, ) @@ -156,10 +158,10 @@ NIX_VERSION_RE = re.compile( # Get the set of currently packaged kernel versions. kernel_versions = {} -for filename in os.listdir(HERE): +for filename in os.listdir(NIXPKGS_KERNEL_PATH): filename_match = re.fullmatch(r"linux-(\d+)\.(\d+)\.nix", filename) if filename_match: - with open(HERE / filename) as nix_file: + with open(NIXPKGS_KERNEL_PATH / filename) as nix_file: for nix_line in nix_file: match = NIX_VERSION_RE.fullmatch(nix_line) if match: diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix index 1c4af8c32a6..8ce1ac2b587 100644 --- a/pkgs/os-specific/linux/kernel/patches.nix +++ b/pkgs/os-specific/linux/kernel/patches.nix @@ -35,7 +35,7 @@ tag_hardened = { name = "tag-hardened"; - patch = ./tag-hardened.patch; + patch = ./hardened/tag-hardened.patch; }; hardened = let @@ -43,7 +43,7 @@ name = lib.removeSuffix ".patch" src.name; patch = fetchurl src; }; - patches = builtins.fromJSON (builtins.readFile ./hardened-patches.json); + patches = builtins.fromJSON (builtins.readFile ./hardened/patches.json); in lib.mapAttrs mkPatch patches; # https://bugzilla.kernel.org/show_bug.cgi?id=197591#c6 diff --git a/pkgs/os-specific/linux/kernel/update.sh b/pkgs/os-specific/linux/kernel/update.sh index c483661b6f5..55fdce06c97 100755 --- a/pkgs/os-specific/linux/kernel/update.sh +++ b/pkgs/os-specific/linux/kernel/update.sh @@ -62,4 +62,4 @@ done COMMIT=1 $NIXPKGS/pkgs/os-specific/linux/kernel/update-libre.sh # Update linux-hardened -COMMIT=1 $NIXPKGS/pkgs/os-specific/linux/kernel/update-hardened.py +COMMIT=1 $NIXPKGS/pkgs/os-specific/linux/kernel/hardened/update.py diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 349bc242ee1..f6419394b2d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17014,7 +17014,7 @@ in # Hardened linux hardenedLinuxPackagesFor = kernel: linuxPackagesFor (kernel.override { - structuredExtraConfig = import ../os-specific/linux/kernel/hardened-config.nix { + structuredExtraConfig = import ../os-specific/linux/kernel/hardened/config.nix { inherit stdenv; inherit (kernel) version; }; From e77d174fcdba9c12468553c895ce235e9ea6bb77 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 26 Apr 2020 04:06:11 +0100 Subject: [PATCH 26/81] linux/hardened/update.py: add type annotations --- .../linux/kernel/hardened/update.py | 86 ++++++++++++------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/hardened/update.py b/pkgs/os-specific/linux/kernel/hardened/update.py index 1ef5acd3eb0..116dd616891 100755 --- a/pkgs/os-specific/linux/kernel/hardened/update.py +++ b/pkgs/os-specific/linux/kernel/hardened/update.py @@ -1,17 +1,44 @@ #! /usr/bin/env nix-shell -#! nix-shell -i python -p "python3.withPackages (ps: [ps.PyGithub])" git gnupg +#! nix-shell -i python -p "python38.withPackages (ps: [ps.PyGithub])" git gnupg # This is automatically called by ../update.sh. +from __future__ import annotations + import json import os import re import subprocess import sys +from dataclasses import dataclass from pathlib import Path from tempfile import TemporaryDirectory +from typing import ( + Dict, + Iterator, + List, + Optional, + Sequence, + Tuple, + TypedDict, + Union, +) from github import Github +from github.GitRelease import GitRelease + +VersionComponent = Union[int, str] +Version = List[VersionComponent] + + +Patch = TypedDict("Patch", {"name": str, "url": str, "sha256": str}) + + +@dataclass +class ReleaseInfo: + version: Version + release: GitRelease + HERE = Path(__file__).resolve().parent NIXPKGS_KERNEL_PATH = HERE.parent @@ -19,17 +46,13 @@ NIXPKGS_PATH = HERE.parents[4] HARDENED_GITHUB_REPO = "anthraxx/linux-hardened" HARDENED_TRUSTED_KEY = HERE / "anthraxx.asc" HARDENED_PATCHES_PATH = HERE / "patches.json" -MIN_KERNEL_VERSION = [4, 14] +MIN_KERNEL_VERSION: Version = [4, 14] -def run(*args, **kwargs): +def run(*args: Union[str, Path]) -> subprocess.CompletedProcess[bytes]: try: return subprocess.run( - args, - **kwargs, - check=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + args, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) except subprocess.CalledProcessError as err: print( @@ -42,13 +65,15 @@ def run(*args, **kwargs): sys.exit(1) -def nix_prefetch_url(url): +def nix_prefetch_url(url: str) -> Tuple[str, Path]: output = run("nix-prefetch-url", "--print-path", url).stdout sha256, path = output.decode("utf-8").strip().split("\n") return sha256, Path(path) -def verify_openpgp_signature(*, name, trusted_key, sig_path, data_path): +def verify_openpgp_signature( + *, name: str, trusted_key: Path, sig_path: Path, data_path: Path, +) -> bool: with TemporaryDirectory(suffix=".nixpkgs-gnupg-home") as gnupg_home_str: gnupg_home = Path(gnupg_home_str) run("gpg", "--homedir", gnupg_home, "--import", trusted_key) @@ -69,14 +94,15 @@ def verify_openpgp_signature(*, name, trusted_key, sig_path, data_path): return False -def fetch_patch(*, name, release): - def find_asset(filename): +def fetch_patch(*, name: str, release: GitRelease) -> Optional[Patch]: + def find_asset(filename: str) -> str: try: - return next( + it: Iterator[str] = ( asset.browser_download_url for asset in release.get_assets() if asset.name == filename ) + return next(it) except StopIteration: raise KeyError(filename) @@ -99,15 +125,11 @@ def fetch_patch(*, name, release): if not sig_ok: return None - return { - "name": patch_filename, - "url": patch_url, - "sha256": sha256, - } + return Patch(name=patch_filename, url=patch_url, sha256=sha256) -def parse_version(version_str): - version = [] +def parse_version(version_str: str) -> Version: + version: Version = [] for component in version_str.split("."): try: version.append(int(component)) @@ -116,15 +138,15 @@ def parse_version(version_str): return version -def version_string(version): +def version_string(version: Version) -> str: return ".".join(str(component) for component in version) -def major_kernel_version_key(kernel_version): +def major_kernel_version_key(kernel_version: Version) -> str: return version_string(kernel_version[:-1]) -def commit_patches(*, kernel_key, message): +def commit_patches(*, kernel_key: str, message: str) -> None: new_patches_path = HARDENED_PATCHES_PATH.with_suffix(".new") with open(new_patches_path, "w") as new_patches_file: json.dump(patches, new_patches_file, indent=4, sort_keys=True) @@ -144,6 +166,7 @@ def commit_patches(*, kernel_key, message): # Load the existing patches. +patches: Dict[str, Patch] with open(HARDENED_PATCHES_PATH) as patches_file: patches = json.load(patches_file) @@ -177,7 +200,6 @@ for kernel_key in sorted(patches.keys() - kernel_versions.keys()): g = Github(os.environ.get("GITHUB_TOKEN")) repo = g.get_repo(HARDENED_GITHUB_REPO) - failures = False # Match each kernel version with the best patch version. @@ -195,10 +217,7 @@ for release in repo.get_releases(): except KeyError: continue - release_info = { - "version": version, - "release": release, - } + release_info = ReleaseInfo(version=version, release=release) if kernel_version == packaged_kernel_version: releases[kernel_key] = release_info @@ -208,18 +227,20 @@ for release in repo.get_releases(): if kernel_version > packaged_kernel_version: continue elif ( - kernel_key not in releases - or releases[kernel_key]["version"] < version + kernel_key not in releases or releases[kernel_key].version < version ): releases[kernel_key] = release_info # Update hardened-patches.json for each release. for kernel_key, release_info in releases.items(): - release = release_info["release"] - version = release_info["version"] + release = release_info.release + version = release_info.version version_str = release.tag_name name = f"linux-hardened-{version_str}" + old_version: Optional[Version] = None + old_version_str: Optional[str] = None + update: bool try: old_filename = patches[kernel_key]["name"] old_version_str = old_filename.replace("linux-hardened-", "").replace( @@ -229,7 +250,6 @@ for kernel_key, release_info in releases.items(): update = old_version < version except KeyError: update = True - old_version = None if update: patch = fetch_patch(name=name, release=release) From 88486c4e767cb92b0a51d9c41f4e40121c6e3bf1 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 26 Apr 2020 18:12:14 +0100 Subject: [PATCH 27/81] linux/hardened/update.py: get versions with nix(1) --- .../linux/kernel/hardened/update.py | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/hardened/update.py b/pkgs/os-specific/linux/kernel/hardened/update.py index 116dd616891..7960f1264f8 100755 --- a/pkgs/os-specific/linux/kernel/hardened/update.py +++ b/pkgs/os-specific/linux/kernel/hardened/update.py @@ -170,29 +170,24 @@ patches: Dict[str, Patch] with open(HARDENED_PATCHES_PATH) as patches_file: patches = json.load(patches_file) -NIX_VERSION_RE = re.compile( - r""" - \s* version \s* = - \s* " (?P [^"]*) " - \s* ; \s* \n - """, - re.VERBOSE, -) - # Get the set of currently packaged kernel versions. kernel_versions = {} for filename in os.listdir(NIXPKGS_KERNEL_PATH): filename_match = re.fullmatch(r"linux-(\d+)\.(\d+)\.nix", filename) if filename_match: - with open(NIXPKGS_KERNEL_PATH / filename) as nix_file: - for nix_line in nix_file: - match = NIX_VERSION_RE.fullmatch(nix_line) - if match: - kernel_version = parse_version(match.group("version")) - if kernel_version < MIN_KERNEL_VERSION: - continue - kernel_key = major_kernel_version_key(kernel_version) - kernel_versions[kernel_key] = kernel_version + nix_version_expr = f""" + with import {NIXPKGS_PATH} {{}}; + (callPackage {NIXPKGS_KERNEL_PATH / filename} {{}}).version + """ + kernel_version = parse_version( + run( + "nix", "eval", "--impure", "--raw", "--expr", nix_version_expr, + ).stdout.decode("utf-8") + ) + if kernel_version < MIN_KERNEL_VERSION: + continue + kernel_key = major_kernel_version_key(kernel_version) + kernel_versions[kernel_key] = kernel_version # Remove patches for unpackaged kernel versions. for kernel_key in sorted(patches.keys() - kernel_versions.keys()): From b2ad58536c7ed0f0a0d5434d63067011f531e0c5 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 26 Apr 2020 20:09:37 +0100 Subject: [PATCH 28/81] linux/hardened/update.py: commit updates in order --- pkgs/os-specific/linux/kernel/hardened/update.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/kernel/hardened/update.py b/pkgs/os-specific/linux/kernel/hardened/update.py index 7960f1264f8..be955efbb53 100755 --- a/pkgs/os-specific/linux/kernel/hardened/update.py +++ b/pkgs/os-specific/linux/kernel/hardened/update.py @@ -227,7 +227,8 @@ for release in repo.get_releases(): releases[kernel_key] = release_info # Update hardened-patches.json for each release. -for kernel_key, release_info in releases.items(): +for kernel_key in sorted(releases.keys()): + release_info = releases[kernel_key] release = release_info.release version = release_info.version version_str = release.tag_name From 5a5a2d0342ee6610f14a7024c6b01ab6261749f9 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 3 May 2020 12:54:11 +0100 Subject: [PATCH 29/81] linux/hardened/update.py: pass encoding to subprocess --- .../os-specific/linux/kernel/hardened/update.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/hardened/update.py b/pkgs/os-specific/linux/kernel/hardened/update.py index be955efbb53..3958c85fe20 100755 --- a/pkgs/os-specific/linux/kernel/hardened/update.py +++ b/pkgs/os-specific/linux/kernel/hardened/update.py @@ -52,14 +52,18 @@ MIN_KERNEL_VERSION: Version = [4, 14] def run(*args: Union[str, Path]) -> subprocess.CompletedProcess[bytes]: try: return subprocess.run( - args, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + args, + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf-8", ) except subprocess.CalledProcessError as err: print( f"error: `{err.cmd}` failed unexpectedly\n" f"status code: {err.returncode}\n" - f'stdout:\n{err.stdout.decode("utf-8").strip()}\n' - f'stderr:\n{err.stderr.decode("utf-8").strip()}', + f"stdout:\n{err.stdout.strip()}\n" + f"stderr:\n{err.stderr.strip()}", file=sys.stderr, ) sys.exit(1) @@ -67,7 +71,7 @@ def run(*args: Union[str, Path]) -> subprocess.CompletedProcess[bytes]: def nix_prefetch_url(url: str) -> Tuple[str, Path]: output = run("nix-prefetch-url", "--print-path", url).stdout - sha256, path = output.decode("utf-8").strip().split("\n") + sha256, path = output.strip().split("\n") return sha256, Path(path) @@ -83,6 +87,7 @@ def verify_openpgp_signature( ("gpgv", "--keyring", keyring, sig_path, data_path), check=True, stderr=subprocess.PIPE, + encoding="utf-8", ) return True except subprocess.CalledProcessError as err: @@ -90,7 +95,7 @@ def verify_openpgp_signature( f"error: signature for {name} failed to verify!", file=sys.stderr, ) - print(err.stderr.decode("utf-8"), file=sys.stderr, end="") + print(err.stderr, file=sys.stderr, end="") return False @@ -182,7 +187,7 @@ for filename in os.listdir(NIXPKGS_KERNEL_PATH): kernel_version = parse_version( run( "nix", "eval", "--impure", "--raw", "--expr", nix_version_expr, - ).stdout.decode("utf-8") + ).stdout ) if kernel_version < MIN_KERNEL_VERSION: continue From 751a27020e733f064339eab208327b85c23e3c42 Mon Sep 17 00:00:00 2001 From: Chuck Date: Sat, 9 May 2020 10:32:42 -0700 Subject: [PATCH 30/81] nixos/test-driver: Specify /bin/sh shell when running a bourne shell script as the user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test harness provides the commands it wishes to run in Bourne syntax. This fails if the user uses a different shell. For example, with fish: machine.wait_for_unit("graphical-session.target", "alice") machine # fish: Unsupported use of '='. To run '-u`' with a modified environment, please use 'env XDG_RUNTIME_DIR=/run/user/`id -u`…' machine # XDG_RUNTIME_DIR=/run/user/`id -u` systemctl --user --no-pager show "graphical-session.target" machine # ^ machine # [ 16.329957] su[1077]: pam_unix(su:session): session closed for user alice error: retrieving systemctl info for unit "graphical-session.target" under user "alice" failed with exit code 127 --- nixos/lib/test-driver/test-driver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py index 84661a4a758..bf46d0df97f 100644 --- a/nixos/lib/test-driver/test-driver.py +++ b/nixos/lib/test-driver/test-driver.py @@ -369,7 +369,7 @@ class Machine: q = q.replace("'", "\\'") return self.execute( ( - "su -l {} -c " + "su -l {} --shell /bin/sh -c " "$'XDG_RUNTIME_DIR=/run/user/`id -u` " "systemctl --user {}'" ).format(user, q) From d91d2bdf77d4db115ce6a7acaf622100d7225668 Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Sun, 10 May 2020 03:50:19 +0900 Subject: [PATCH 31/81] compiler-rt: fix build on armv7l --- .../llvm/10/compiler-rt-armv7l.patch | 32 ++++++++++++++++ .../compilers/llvm/10/compiler-rt.nix | 1 + .../compilers/llvm/5/compiler-rt-armv7l.patch | 23 +++++++++++ .../compilers/llvm/5/compiler-rt.nix | 1 + .../compilers/llvm/6/compiler-rt-armv7l.patch | 32 ++++++++++++++++ .../compilers/llvm/6/compiler-rt.nix | 1 + .../compilers/llvm/7/compiler-rt-armv7l.patch | 38 +++++++++++++++++++ .../compilers/llvm/7/compiler-rt.nix | 1 + .../compilers/llvm/8/compiler-rt-armv7l.patch | 38 +++++++++++++++++++ .../compilers/llvm/8/compiler-rt.nix | 1 + .../compilers/llvm/9/compiler-rt-armv7l.patch | 38 +++++++++++++++++++ .../compilers/llvm/9/compiler-rt.nix | 1 + 12 files changed, 207 insertions(+) create mode 100644 pkgs/development/compilers/llvm/10/compiler-rt-armv7l.patch create mode 100644 pkgs/development/compilers/llvm/5/compiler-rt-armv7l.patch create mode 100644 pkgs/development/compilers/llvm/6/compiler-rt-armv7l.patch create mode 100644 pkgs/development/compilers/llvm/7/compiler-rt-armv7l.patch create mode 100644 pkgs/development/compilers/llvm/8/compiler-rt-armv7l.patch create mode 100644 pkgs/development/compilers/llvm/9/compiler-rt-armv7l.patch diff --git a/pkgs/development/compilers/llvm/10/compiler-rt-armv7l.patch b/pkgs/development/compilers/llvm/10/compiler-rt-armv7l.patch new file mode 100644 index 00000000000..120cfe6feb2 --- /dev/null +++ b/pkgs/development/compilers/llvm/10/compiler-rt-armv7l.patch @@ -0,0 +1,32 @@ +diff -ur compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake +--- compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake 2020-03-24 00:01:02.000000000 +0900 ++++ compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake 2020-05-10 03:42:00.883450706 +0900 +@@ -24,7 +24,7 @@ + + + set(ARM64 aarch64) +-set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k) ++set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l) + set(HEXAGON hexagon) + set(X86 i386) + set(X86_64 x86_64) +diff -ur compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt +--- compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt 2020-03-24 00:01:02.000000000 +0900 ++++ compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt 2020-05-10 03:44:49.468579650 +0900 +@@ -474,6 +474,7 @@ + set(armv7_SOURCES ${arm_SOURCES}) + set(armv7s_SOURCES ${arm_SOURCES}) + set(armv7k_SOURCES ${arm_SOURCES}) ++set(armv7l_SOURCES ${arm_SOURCES}) + set(arm64_SOURCES ${aarch64_SOURCES}) + + # macho_embedded archs +@@ -595,7 +596,7 @@ + foreach (arch ${BUILTIN_SUPPORTED_ARCH}) + if (CAN_TARGET_${arch}) + # For ARM archs, exclude any VFP builtins if VFP is not supported +- if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") ++ if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") + string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}") + check_compile_definition(__VFP_FP__ "${CMAKE_C_FLAGS} ${_TARGET_${arch}_CFLAGS}" COMPILER_RT_HAS_${arch}_VFP) + if(NOT COMPILER_RT_HAS_${arch}_VFP) diff --git a/pkgs/development/compilers/llvm/10/compiler-rt.nix b/pkgs/development/compilers/llvm/10/compiler-rt.nix index c0ea436ae27..dbcbc495460 100644 --- a/pkgs/development/compilers/llvm/10/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/10/compiler-rt.nix @@ -48,6 +48,7 @@ stdenv.mkDerivation rec { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory ./find-darwin-sdk-version.patch # don't test for macOS being >= 10.15 + ./compiler-rt-armv7l.patch ];# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks diff --git a/pkgs/development/compilers/llvm/5/compiler-rt-armv7l.patch b/pkgs/development/compilers/llvm/5/compiler-rt-armv7l.patch new file mode 100644 index 00000000000..77bf2640c47 --- /dev/null +++ b/pkgs/development/compilers/llvm/5/compiler-rt-armv7l.patch @@ -0,0 +1,23 @@ +diff -ur compiler-rt-5.0.2.src/cmake/builtin-config-ix.cmake compiler-rt-5.0.2.src-patched/cmake/builtin-config-ix.cmake +--- compiler-rt-5.0.2.src/cmake/builtin-config-ix.cmake 2017-05-25 00:53:24.000000000 +0900 ++++ compiler-rt-5.0.2.src-patched/cmake/builtin-config-ix.cmake 2020-05-10 03:24:24.937433155 +0900 +@@ -24,7 +24,7 @@ + + + set(ARM64 aarch64) +-set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k) ++set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l) + set(X86 i386 i686) + set(X86_64 x86_64) + set(MIPS32 mips mipsel) +diff -ur compiler-rt-5.0.2.src/lib/builtins/CMakeLists.txt compiler-rt-5.0.2.src-patched/lib/builtins/CMakeLists.txt +--- compiler-rt-5.0.2.src/lib/builtins/CMakeLists.txt 2017-07-13 04:33:30.000000000 +0900 ++++ compiler-rt-5.0.2.src-patched/lib/builtins/CMakeLists.txt 2020-05-10 03:24:45.945075423 +0900 +@@ -444,6 +444,7 @@ + set(armv7_SOURCES ${arm_SOURCES}) + set(armv7s_SOURCES ${arm_SOURCES}) + set(armv7k_SOURCES ${arm_SOURCES}) ++set(armv7l_SOURCES ${arm_SOURCES}) + set(arm64_SOURCES ${aarch64_SOURCES}) + + # macho_embedded archs diff --git a/pkgs/development/compilers/llvm/5/compiler-rt.nix b/pkgs/development/compilers/llvm/5/compiler-rt.nix index 55f4eb94e92..179fc033ffc 100644 --- a/pkgs/development/compilers/llvm/5/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/5/compiler-rt.nix @@ -47,6 +47,7 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ./compiler-rt-armv7l.patch ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "glibc") ./compiler-rt-sys-ustat.patch; diff --git a/pkgs/development/compilers/llvm/6/compiler-rt-armv7l.patch b/pkgs/development/compilers/llvm/6/compiler-rt-armv7l.patch new file mode 100644 index 00000000000..ca2ed632faa --- /dev/null +++ b/pkgs/development/compilers/llvm/6/compiler-rt-armv7l.patch @@ -0,0 +1,32 @@ +diff -ur compiler-rt-6.0.1.src/cmake/builtin-config-ix.cmake compiler-rt-6.0.1.src-patched/cmake/builtin-config-ix.cmake +--- compiler-rt-6.0.1.src/cmake/builtin-config-ix.cmake 2017-12-01 06:04:11.000000000 +0900 ++++ compiler-rt-6.0.1.src-patched/cmake/builtin-config-ix.cmake 2020-05-10 03:30:01.939694303 +0900 +@@ -24,7 +24,7 @@ + + + set(ARM64 aarch64) +-set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k) ++set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l) + set(X86 i386) + set(X86_64 x86_64) + set(MIPS32 mips mipsel) +diff -ur compiler-rt-6.0.1.src/lib/builtins/CMakeLists.txt compiler-rt-6.0.1.src-patched/lib/builtins/CMakeLists.txt +--- compiler-rt-6.0.1.src/lib/builtins/CMakeLists.txt 2017-12-25 06:11:32.000000000 +0900 ++++ compiler-rt-6.0.1.src-patched/lib/builtins/CMakeLists.txt 2020-05-10 03:30:44.814964156 +0900 +@@ -452,6 +452,7 @@ + set(armv7_SOURCES ${arm_SOURCES}) + set(armv7s_SOURCES ${arm_SOURCES}) + set(armv7k_SOURCES ${arm_SOURCES}) ++set(armv7l_SOURCES ${arm_SOURCES}) + set(arm64_SOURCES ${aarch64_SOURCES}) + + # macho_embedded archs +@@ -521,7 +522,7 @@ + set(_arch ${arch}) + if("${arch}" STREQUAL "armv6m") + set(_arch "arm|armv6m") +- elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") ++ elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") + set(_arch "arm") + endif() + diff --git a/pkgs/development/compilers/llvm/6/compiler-rt.nix b/pkgs/development/compilers/llvm/6/compiler-rt.nix index abb6796e3c7..89fca56f32c 100644 --- a/pkgs/development/compilers/llvm/6/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/6/compiler-rt.nix @@ -47,6 +47,7 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ./compiler-rt-armv7l.patch ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch; # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks diff --git a/pkgs/development/compilers/llvm/7/compiler-rt-armv7l.patch b/pkgs/development/compilers/llvm/7/compiler-rt-armv7l.patch new file mode 100644 index 00000000000..89d7f1aec91 --- /dev/null +++ b/pkgs/development/compilers/llvm/7/compiler-rt-armv7l.patch @@ -0,0 +1,38 @@ +diff -ur compiler-rt-7.1.0.src/cmake/builtin-config-ix.cmake compiler-rt-7.1.0.src-patched/cmake/builtin-config-ix.cmake +--- compiler-rt-7.1.0.src/cmake/builtin-config-ix.cmake 2018-05-25 06:36:27.000000000 +0900 ++++ compiler-rt-7.1.0.src-patched/cmake/builtin-config-ix.cmake 2020-05-09 20:26:33.030608692 +0900 +@@ -24,7 +24,7 @@ + + + set(ARM64 aarch64) +-set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k) ++set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l) + set(HEXAGON hexagon) + set(X86 i386) + set(X86_64 x86_64) +diff -ur compiler-rt-7.1.0.src/lib/builtins/CMakeLists.txt compiler-rt-7.1.0.src-patched/lib/builtins/CMakeLists.txt +--- compiler-rt-7.1.0.src/lib/builtins/CMakeLists.txt 2018-07-31 03:18:59.000000000 +0900 ++++ compiler-rt-7.1.0.src-patched/lib/builtins/CMakeLists.txt 2020-05-09 20:27:38.893409318 +0900 +@@ -453,6 +453,7 @@ + set(armv7_SOURCES ${arm_SOURCES}) + set(armv7s_SOURCES ${arm_SOURCES}) + set(armv7k_SOURCES ${arm_SOURCES}) ++set(armv7l_SOURCES ${arm_SOURCES}) + set(arm64_SOURCES ${aarch64_SOURCES}) + + # macho_embedded archs +@@ -563,12 +564,12 @@ + set(_arch ${arch}) + if("${arch}" STREQUAL "armv6m") + set(_arch "arm|armv6m") +- elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") ++ elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") + set(_arch "arm") + endif() + + # For ARM archs, exclude any VFP builtins if VFP is not supported +- if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") ++ if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") + string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}") + check_compile_definition(__VFP_FP__ "${CMAKE_C_FLAGS} ${_TARGET_${arch}_CFLAGS}" COMPILER_RT_HAS_${arch}_VFP) + if(NOT COMPILER_RT_HAS_${arch}_VFP) diff --git a/pkgs/development/compilers/llvm/7/compiler-rt.nix b/pkgs/development/compilers/llvm/7/compiler-rt.nix index e83a4a3c26f..4066d6bc2c3 100644 --- a/pkgs/development/compilers/llvm/7/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/7/compiler-rt.nix @@ -47,6 +47,7 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ./compiler-rt-armv7l.patch ] ++ stdenv.lib.optional (useLLVM) ./crtbegin-and-end.patch ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch; diff --git a/pkgs/development/compilers/llvm/8/compiler-rt-armv7l.patch b/pkgs/development/compilers/llvm/8/compiler-rt-armv7l.patch new file mode 100644 index 00000000000..89d7f1aec91 --- /dev/null +++ b/pkgs/development/compilers/llvm/8/compiler-rt-armv7l.patch @@ -0,0 +1,38 @@ +diff -ur compiler-rt-7.1.0.src/cmake/builtin-config-ix.cmake compiler-rt-7.1.0.src-patched/cmake/builtin-config-ix.cmake +--- compiler-rt-7.1.0.src/cmake/builtin-config-ix.cmake 2018-05-25 06:36:27.000000000 +0900 ++++ compiler-rt-7.1.0.src-patched/cmake/builtin-config-ix.cmake 2020-05-09 20:26:33.030608692 +0900 +@@ -24,7 +24,7 @@ + + + set(ARM64 aarch64) +-set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k) ++set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l) + set(HEXAGON hexagon) + set(X86 i386) + set(X86_64 x86_64) +diff -ur compiler-rt-7.1.0.src/lib/builtins/CMakeLists.txt compiler-rt-7.1.0.src-patched/lib/builtins/CMakeLists.txt +--- compiler-rt-7.1.0.src/lib/builtins/CMakeLists.txt 2018-07-31 03:18:59.000000000 +0900 ++++ compiler-rt-7.1.0.src-patched/lib/builtins/CMakeLists.txt 2020-05-09 20:27:38.893409318 +0900 +@@ -453,6 +453,7 @@ + set(armv7_SOURCES ${arm_SOURCES}) + set(armv7s_SOURCES ${arm_SOURCES}) + set(armv7k_SOURCES ${arm_SOURCES}) ++set(armv7l_SOURCES ${arm_SOURCES}) + set(arm64_SOURCES ${aarch64_SOURCES}) + + # macho_embedded archs +@@ -563,12 +564,12 @@ + set(_arch ${arch}) + if("${arch}" STREQUAL "armv6m") + set(_arch "arm|armv6m") +- elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") ++ elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") + set(_arch "arm") + endif() + + # For ARM archs, exclude any VFP builtins if VFP is not supported +- if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") ++ if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") + string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}") + check_compile_definition(__VFP_FP__ "${CMAKE_C_FLAGS} ${_TARGET_${arch}_CFLAGS}" COMPILER_RT_HAS_${arch}_VFP) + if(NOT COMPILER_RT_HAS_${arch}_VFP) diff --git a/pkgs/development/compilers/llvm/8/compiler-rt.nix b/pkgs/development/compilers/llvm/8/compiler-rt.nix index b11659a78cc..fb69373125c 100644 --- a/pkgs/development/compilers/llvm/8/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/8/compiler-rt.nix @@ -47,6 +47,7 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ./compiler-rt-armv7l.patch ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch ++ stdenv.lib.optional (useLLVM) ./crtbegin-and-end.patch; diff --git a/pkgs/development/compilers/llvm/9/compiler-rt-armv7l.patch b/pkgs/development/compilers/llvm/9/compiler-rt-armv7l.patch new file mode 100644 index 00000000000..89d7f1aec91 --- /dev/null +++ b/pkgs/development/compilers/llvm/9/compiler-rt-armv7l.patch @@ -0,0 +1,38 @@ +diff -ur compiler-rt-7.1.0.src/cmake/builtin-config-ix.cmake compiler-rt-7.1.0.src-patched/cmake/builtin-config-ix.cmake +--- compiler-rt-7.1.0.src/cmake/builtin-config-ix.cmake 2018-05-25 06:36:27.000000000 +0900 ++++ compiler-rt-7.1.0.src-patched/cmake/builtin-config-ix.cmake 2020-05-09 20:26:33.030608692 +0900 +@@ -24,7 +24,7 @@ + + + set(ARM64 aarch64) +-set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k) ++set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l) + set(HEXAGON hexagon) + set(X86 i386) + set(X86_64 x86_64) +diff -ur compiler-rt-7.1.0.src/lib/builtins/CMakeLists.txt compiler-rt-7.1.0.src-patched/lib/builtins/CMakeLists.txt +--- compiler-rt-7.1.0.src/lib/builtins/CMakeLists.txt 2018-07-31 03:18:59.000000000 +0900 ++++ compiler-rt-7.1.0.src-patched/lib/builtins/CMakeLists.txt 2020-05-09 20:27:38.893409318 +0900 +@@ -453,6 +453,7 @@ + set(armv7_SOURCES ${arm_SOURCES}) + set(armv7s_SOURCES ${arm_SOURCES}) + set(armv7k_SOURCES ${arm_SOURCES}) ++set(armv7l_SOURCES ${arm_SOURCES}) + set(arm64_SOURCES ${aarch64_SOURCES}) + + # macho_embedded archs +@@ -563,12 +564,12 @@ + set(_arch ${arch}) + if("${arch}" STREQUAL "armv6m") + set(_arch "arm|armv6m") +- elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") ++ elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") + set(_arch "arm") + endif() + + # For ARM archs, exclude any VFP builtins if VFP is not supported +- if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") ++ if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") + string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}") + check_compile_definition(__VFP_FP__ "${CMAKE_C_FLAGS} ${_TARGET_${arch}_CFLAGS}" COMPILER_RT_HAS_${arch}_VFP) + if(NOT COMPILER_RT_HAS_${arch}_VFP) diff --git a/pkgs/development/compilers/llvm/9/compiler-rt.nix b/pkgs/development/compilers/llvm/9/compiler-rt.nix index 7d712017eae..581cab902ee 100644 --- a/pkgs/development/compilers/llvm/9/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/9/compiler-rt.nix @@ -47,6 +47,7 @@ stdenv.mkDerivation rec { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ./compiler-rt-armv7l.patch ];# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks From d616ae8c6de5294cbd7db2431325f6b5387a4262 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 9 May 2020 21:30:52 +0200 Subject: [PATCH 32/81] llvm/compiler-rt: only apply armv7l patches on aarch32 No need for rebuilds on other platforms --- pkgs/development/compilers/llvm/10/compiler-rt.nix | 5 +++-- pkgs/development/compilers/llvm/5/compiler-rt.nix | 4 ++-- pkgs/development/compilers/llvm/6/compiler-rt.nix | 4 ++-- pkgs/development/compilers/llvm/7/compiler-rt.nix | 4 ++-- pkgs/development/compilers/llvm/8/compiler-rt.nix | 4 ++-- pkgs/development/compilers/llvm/9/compiler-rt.nix | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pkgs/development/compilers/llvm/10/compiler-rt.nix b/pkgs/development/compilers/llvm/10/compiler-rt.nix index dbcbc495460..68f64ef4256 100644 --- a/pkgs/development/compilers/llvm/10/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/10/compiler-rt.nix @@ -48,8 +48,9 @@ stdenv.mkDerivation rec { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory ./find-darwin-sdk-version.patch # don't test for macOS being >= 10.15 - ./compiler-rt-armv7l.patch - ];# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch + ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch + ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch; + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra diff --git a/pkgs/development/compilers/llvm/5/compiler-rt.nix b/pkgs/development/compilers/llvm/5/compiler-rt.nix index 179fc033ffc..624034b5228 100644 --- a/pkgs/development/compilers/llvm/5/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/5/compiler-rt.nix @@ -47,9 +47,9 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory - ./compiler-rt-armv7l.patch ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch - ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "glibc") ./compiler-rt-sys-ustat.patch; + ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "glibc") ./compiler-rt-sys-ustat.patch + ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch; # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra diff --git a/pkgs/development/compilers/llvm/6/compiler-rt.nix b/pkgs/development/compilers/llvm/6/compiler-rt.nix index 89fca56f32c..5ae8bb01f05 100644 --- a/pkgs/development/compilers/llvm/6/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/6/compiler-rt.nix @@ -47,8 +47,8 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory - ./compiler-rt-armv7l.patch - ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch; + ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch + ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch; # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra diff --git a/pkgs/development/compilers/llvm/7/compiler-rt.nix b/pkgs/development/compilers/llvm/7/compiler-rt.nix index 4066d6bc2c3..e9853c58ca5 100644 --- a/pkgs/development/compilers/llvm/7/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/7/compiler-rt.nix @@ -47,9 +47,9 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory - ./compiler-rt-armv7l.patch ] ++ stdenv.lib.optional (useLLVM) ./crtbegin-and-end.patch - ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch; + ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch + ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch; # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra diff --git a/pkgs/development/compilers/llvm/8/compiler-rt.nix b/pkgs/development/compilers/llvm/8/compiler-rt.nix index fb69373125c..1f58cb98e3d 100644 --- a/pkgs/development/compilers/llvm/8/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/8/compiler-rt.nix @@ -47,9 +47,9 @@ stdenv.mkDerivation { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory - ./compiler-rt-armv7l.patch ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch - ++ stdenv.lib.optional (useLLVM) ./crtbegin-and-end.patch; + ++ stdenv.lib.optional (useLLVM) ./crtbegin-and-end.patch + ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch; # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra diff --git a/pkgs/development/compilers/llvm/9/compiler-rt.nix b/pkgs/development/compilers/llvm/9/compiler-rt.nix index 581cab902ee..3b92264ad69 100644 --- a/pkgs/development/compilers/llvm/9/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/9/compiler-rt.nix @@ -47,8 +47,8 @@ stdenv.mkDerivation rec { patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory - ./compiler-rt-armv7l.patch - ];# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch + ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch + ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch; # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra From 53df8b1a2750ef5da3a911163a80c6b5d660c551 Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sun, 10 May 2020 19:02:26 +0200 Subject: [PATCH 33/81] python3Packages.trimesh: init at 3.6.36 --- .../python-modules/trimesh/default.nix | 24 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 pkgs/development/python-modules/trimesh/default.nix diff --git a/pkgs/development/python-modules/trimesh/default.nix b/pkgs/development/python-modules/trimesh/default.nix new file mode 100644 index 00000000000..a65ea1e98ba --- /dev/null +++ b/pkgs/development/python-modules/trimesh/default.nix @@ -0,0 +1,24 @@ +{ lib, buildPythonPackage, fetchPypi, numpy }: + +buildPythonPackage rec { + pname = "trimesh"; + version = "3.6.36"; + + src = fetchPypi { + inherit pname version; + sha256 = "1m8dqqyzazrjk4d32cqn4d8gvbfcwgs2qbmgvpi2f2mi5vnp6d85"; + }; + + propagatedBuildInputs = [ numpy ]; + + # tests are not included in pypi distributions and would require lots of + # optional dependencies + doCheck = false; + + meta = with lib; { + description = "Python library for loading and using triangular meshes."; + homepage = "https://trimsh.org/"; + license = licenses.mit; + maintainers = with maintainers; [ gebner ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index e54a4e9fe45..c356700167e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1479,6 +1479,8 @@ in { transforms3d = callPackage ../development/python-modules/transforms3d { }; + trimesh = callPackage ../development/python-modules/trimesh {}; + sentinel = callPackage ../development/python-modules/sentinel { }; sentry-sdk = callPackage ../development/python-modules/sentry-sdk {}; From be985ba49e96f8e8e29ee0adf1dbd761f83167df Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sun, 10 May 2020 19:02:42 +0200 Subject: [PATCH 34/81] python3Packages.libsavitar: 4.5.0 -> 4.6.1 --- pkgs/development/python-modules/libsavitar/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/libsavitar/default.nix b/pkgs/development/python-modules/libsavitar/default.nix index c7b12e3daf5..32717e127fb 100644 --- a/pkgs/development/python-modules/libsavitar/default.nix +++ b/pkgs/development/python-modules/libsavitar/default.nix @@ -2,14 +2,14 @@ buildPythonPackage rec { pname = "libsavitar"; - version = "4.5.0"; + version = "4.6.1"; format = "other"; src = fetchFromGitHub { owner = "Ultimaker"; repo = "libSavitar"; rev = version; - sha256 = "1l3l8cgaxzqdk93880p2ijrabshdj5sq05cwj1i6jpmhlqc5b9rx"; + sha256 = "0nk8zl5b0b36wrrkj271ck4phzxsigkjsazndscjslc9nkldmnpq"; }; postPatch = '' From ddac66d6b892e900432ba039bb6049c0fd3ab9fe Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sun, 10 May 2020 19:03:06 +0200 Subject: [PATCH 35/81] python3Packages.libarcus: 4.5.0 -> 4.6.1 --- pkgs/development/python-modules/libarcus/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/libarcus/default.nix b/pkgs/development/python-modules/libarcus/default.nix index a3f795f254e..cd5f0aef648 100644 --- a/pkgs/development/python-modules/libarcus/default.nix +++ b/pkgs/development/python-modules/libarcus/default.nix @@ -3,7 +3,7 @@ buildPythonPackage rec { pname = "libarcus"; - version = "4.5.0"; + version = "4.6.1"; format = "other"; src = fetchFromGitHub { From 9f23ba56f1d4a3d9a9dcafb421c21a7c15c282cf Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sun, 10 May 2020 19:03:25 +0200 Subject: [PATCH 36/81] python3Packages.uranium: 4.5.0 -> 4.6.1 --- pkgs/development/python-modules/uranium/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/uranium/default.nix b/pkgs/development/python-modules/uranium/default.nix index 1ab67be5bdc..af13fa8d17a 100644 --- a/pkgs/development/python-modules/uranium/default.nix +++ b/pkgs/development/python-modules/uranium/default.nix @@ -2,7 +2,7 @@ , pyqt5, numpy, scipy, shapely, libarcus, doxygen, gettext, pythonOlder }: buildPythonPackage rec { - version = "4.5.0"; + version = "4.6.1"; pname = "uranium"; format = "other"; @@ -10,7 +10,7 @@ buildPythonPackage rec { owner = "Ultimaker"; repo = "Uranium"; rev = version; - sha256 = "1l8fwj521irla42bdbw298d3c5rjpn1nm9xhjnx7hidbqixr5d27"; + sha256 = "07pksjbgxs1ks2i6pgxkwfg9c56pcql7f9p89dnwaf2rcn7yhx6r"; }; disabled = pythonOlder "3.5.0"; From bc56fe5759c5a9424ad3d6502999cca2bec6ac5c Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sun, 10 May 2020 19:03:40 +0200 Subject: [PATCH 37/81] cura: 4.5.0 -> 4.6.1 --- pkgs/applications/misc/cura/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/misc/cura/default.nix b/pkgs/applications/misc/cura/default.nix index 4c4fe9b1abd..1b5c7c23956 100644 --- a/pkgs/applications/misc/cura/default.nix +++ b/pkgs/applications/misc/cura/default.nix @@ -2,25 +2,26 @@ mkDerivation rec { pname = "cura"; - version = "4.5.0"; + version = "4.6.1"; src = fetchFromGitHub { owner = "Ultimaker"; repo = "Cura"; rev = version; - sha256 = "0fm04s912sgmr66wyb55ly4jh39ijsj6lx4fx9wn7hchlqmw5jxi"; + sha256 = "0h1r9caa579d3gfpcmch54rdbkg5df64ds2v84iqsbxwjp0rmn4n"; }; materials = fetchFromGitHub { owner = "Ultimaker"; repo = "fdm_materials"; rev = version; - sha256 = "0fgkwz1anw49macq1jxjhjr79slhmx7g3zwij7g9fqyzzhrrmwqn"; + sha256 = "1k5c3qmixhpz3z2yi0fysxcyyf1yhcwmdlrcypkw827lhsialqp4"; }; buildInputs = [ qtbase qtquickcontrols2 qtgraphicaleffects ]; propagatedBuildInputs = with python3.pkgs; [ libsavitar numpy-stl pyserial requests uranium zeroconf + sentry-sdk trimesh ] ++ plugins; nativeBuildInputs = [ cmake python3.pkgs.wrapPython ]; From af238824f4e20395feee56e6644aa2c92c50d844 Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sun, 10 May 2020 19:04:27 +0200 Subject: [PATCH 38/81] curaPlugins.octoprint: 3.5.11 -> 3.5.12 --- pkgs/applications/misc/cura/plugins.nix | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/misc/cura/plugins.nix b/pkgs/applications/misc/cura/plugins.nix index 35d6c97fa0b..9fbe647046c 100644 --- a/pkgs/applications/misc/cura/plugins.nix +++ b/pkgs/applications/misc/cura/plugins.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchFromGitHub, fetchpatch, cmake, python3Packages }: +{ stdenv, fetchFromGitHub, fetchpatch, python3Packages }: let @@ -6,21 +6,24 @@ let octoprint = stdenv.mkDerivation rec { pname = "Cura-OctoPrintPlugin"; - version = "3.5.11"; + version = "3.5.12"; src = fetchFromGitHub { owner = "fieldOfView"; repo = pname; - rev = "3cef0a955ae7ccfa5c07d20d9d147c530cc9d6ec"; - sha256 = "0q9bkwgpsbfwkp1bfaxq3wm9pbwx5d7ji0jr7cwc4y5nizji81is"; + rev = "ad522c0b7ead5fbe28da686a3cc75e351274c2bc"; + sha256 = "0ln11ng32bh0smfsk54mv2j3sadh0gwf031nmm95zrvbj9cr6yc0"; }; - nativeBuildInputs = [ cmake ]; - propagatedBuildInputs = with python3Packages; [ netifaces ]; + installPhase = '' + mkdir -p $out/lib/cura/plugins/OctoPrintPlugin + cp -rv . $out/lib/cura/plugins/OctoPrintPlugin/ + ''; + meta = with stdenv.lib; { description = "Enables printing directly to OctoPrint and monitoring the process"; homepage = "https://github.com/fieldOfView/Cura-OctoPrintPlugin"; From d531e723977ed1c510b224bd908d3614cb34a213 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Sun, 3 May 2020 17:23:10 +0200 Subject: [PATCH 39/81] nix-direnv: init at 1.0.0 --- pkgs/tools/misc/nix-direnv/default.nix | 33 ++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 35 insertions(+) create mode 100644 pkgs/tools/misc/nix-direnv/default.nix diff --git a/pkgs/tools/misc/nix-direnv/default.nix b/pkgs/tools/misc/nix-direnv/default.nix new file mode 100644 index 00000000000..2d133795500 --- /dev/null +++ b/pkgs/tools/misc/nix-direnv/default.nix @@ -0,0 +1,33 @@ +{ lib, stdenv, fetchFromGitHub, gnugrep, nix }: + +stdenv.mkDerivation rec { + pname = "nix-direnv"; + version = "1.0.0"; + + src = fetchFromGitHub { + owner = "nix-community"; + repo = "nix-direnv"; + rev = "${version}"; + sha256 = "1lwmg6mn3lf7s0345v53zadxn9v0x8z6pcbj90v5dx3pgrq41gs8"; + }; + + # Substitute instead of wrapping because the resulting file is + # getting sourced, not executed: + postPatch = '' + substituteInPlace direnvrc \ + --replace "grep" "${gnugrep}/bin/grep" \ + --replace "nix-shell" "${nix}/bin/nix-shell" \ + --replace "nix-instantiate" "${nix}/bin/nix-instantiate" + ''; + + installPhase = '' + install -m500 -D direnvrc $out/share/nix-direnv/direnvrc + ''; + + meta = with stdenv.lib; { + description = "A fast, persistent use_nix implementation for direnv"; + homepage = "https://github.com/nix-community/nix-direnv"; + license = licenses.mit; + platforms = platforms.unix; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b7dda53484e..7a2043b4cf5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2058,6 +2058,8 @@ in nfstrace = callPackage ../tools/networking/nfstrace { }; + nix-direnv = callPackage ../tools/misc/nix-direnv { }; + nixpkgs-pytools = with python3.pkgs; toPythonApplication nixpkgs-pytools; noteshrink = callPackage ../tools/misc/noteshrink { }; From 596c8150e931bffba88dc08300e2022d1b9b70ec Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sun, 10 May 2020 20:37:42 +0000 Subject: [PATCH 40/81] uclibc: 1.0.32 -> 1.0.33 --- pkgs/os-specific/linux/uclibc/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/uclibc/default.nix b/pkgs/os-specific/linux/uclibc/default.nix index 5f401411074..c9da86b7898 100644 --- a/pkgs/os-specific/linux/uclibc/default.nix +++ b/pkgs/os-specific/linux/uclibc/default.nix @@ -48,7 +48,7 @@ let UCLIBC_HAS_FPU n ''; - version = "1.0.32"; + version = "1.0.33"; in stdenv.mkDerivation { @@ -58,7 +58,7 @@ stdenv.mkDerivation { src = fetchurl { url = "https://downloads.uclibc-ng.org/releases/${version}/uClibc-ng-${version}.tar.bz2"; # from "${url}.sha256"; - sha256 = "0cp4xf3k0ib76xaz6n6i7yybw7s92s607ak8svq1kakwk0d1jjbv"; + sha256 = "0qy9xsqacrhhrxd16azm26pqb2ks6c43wbrlq3i8xmq2917kw3xi"; }; # 'ftw' needed to build acl, a coreutils dependency From f5c0535213267164bf26145cfefb94f5ed58c38e Mon Sep 17 00:00:00 2001 From: "Markus S. Wamser" Date: Sun, 10 May 2020 22:04:39 +0200 Subject: [PATCH 41/81] libfm: fix duplicate inclusion of libfm-extra --- pkgs/development/libraries/libfm/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/libraries/libfm/default.nix b/pkgs/development/libraries/libfm/default.nix index 9145d8fd892..94476984de0 100644 --- a/pkgs/development/libraries/libfm/default.nix +++ b/pkgs/development/libraries/libfm/default.nix @@ -28,6 +28,11 @@ stdenv.mkDerivation rec { "sysconfdir=${placeholder "out"}/etc" ]; + # libfm-extra is pulled in by menu-cache and thus leads to a collision for libfm + postInstall = optional (!extraOnly) '' + rm $out/lib/libfm-extra.so $out/lib/libfm-extra.so.* $out/lib/libfm-extra.la $out/lib/pkgconfig/libfm-extra.pc + ''; + enableParallelBuilding = true; meta = with stdenv.lib; { From 33272d9e98275c0ea9528772ee11f2d28ce6630a Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Mon, 11 May 2020 01:36:12 +0000 Subject: [PATCH 42/81] xlog: 2.0.17 -> 2.0.19 --- pkgs/applications/radio/xlog/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/radio/xlog/default.nix b/pkgs/applications/radio/xlog/default.nix index 31bcfa463b9..e92c216466f 100644 --- a/pkgs/applications/radio/xlog/default.nix +++ b/pkgs/applications/radio/xlog/default.nix @@ -1,11 +1,11 @@ { stdenv, fetchurl, glib, gtk2, pkgconfig, hamlib }: stdenv.mkDerivation rec { pname = "xlog"; - version = "2.0.17"; + version = "2.0.19"; src = fetchurl { url = "https://download.savannah.gnu.org/releases/xlog/${pname}-${version}.tar.gz"; - sha256 = "0vmn8518zk7qk1mbp1h8dm0f8fx0z0jvmy42c1n15il714lj7vsl"; + sha256 = "0y38gkcm4mgv6wn31pjq6d5bm22m63rpwa55qjmrlywrmw76rppy"; }; # glib-2.62 deprecations From 0e0995d14cca692cd1ddd11fb4a725f7f82eee04 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Mon, 11 May 2020 03:04:49 +0000 Subject: [PATCH 43/81] yed: 3.19.1.1 -> 3.20 --- pkgs/applications/graphics/yed/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/graphics/yed/default.nix b/pkgs/applications/graphics/yed/default.nix index 96515a13724..9472f931246 100644 --- a/pkgs/applications/graphics/yed/default.nix +++ b/pkgs/applications/graphics/yed/default.nix @@ -2,11 +2,11 @@ stdenv.mkDerivation rec { pname = "yEd"; - version = "3.19.1.1"; + version = "3.20"; src = fetchzip { url = "https://www.yworks.com/resources/yed/demo/${pname}-${version}.zip"; - sha256 = "0px88rc1slf7n1n8lpk56hf29ppbnnd4lrqfyggihcr0pxmw157c"; + sha256 = "08j8lpn2nd41gavgrj03rlrxl04wcamq1y02f1x1569ykbhycb3m"; }; nativeBuildInputs = [ makeWrapper unzip ]; From 9d405dd370246059cf774c2af86438c2e6324240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 11 May 2020 06:49:23 +0100 Subject: [PATCH 44/81] nix-direnv: add preInstall/postInstall hooks --- pkgs/tools/misc/nix-direnv/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/tools/misc/nix-direnv/default.nix b/pkgs/tools/misc/nix-direnv/default.nix index 2d133795500..299550aa0cb 100644 --- a/pkgs/tools/misc/nix-direnv/default.nix +++ b/pkgs/tools/misc/nix-direnv/default.nix @@ -21,7 +21,9 @@ stdenv.mkDerivation rec { ''; installPhase = '' + runHook preInstall install -m500 -D direnvrc $out/share/nix-direnv/direnvrc + runHook postInstall ''; meta = with stdenv.lib; { From 886f9fc37e967826eefd6f9054fac1acc77088dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 11 May 2020 06:49:37 +0100 Subject: [PATCH 45/81] nix-direnv: add myself as maintainer --- pkgs/tools/misc/nix-direnv/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/tools/misc/nix-direnv/default.nix b/pkgs/tools/misc/nix-direnv/default.nix index 299550aa0cb..cff7df1801f 100644 --- a/pkgs/tools/misc/nix-direnv/default.nix +++ b/pkgs/tools/misc/nix-direnv/default.nix @@ -31,5 +31,6 @@ stdenv.mkDerivation rec { homepage = "https://github.com/nix-community/nix-direnv"; license = licenses.mit; platforms = platforms.unix; + maintainers = with maintainers; [ mic92 ]; }; } From 56531f45cd4d147530c3f1eae89dd6d78484861c Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko Date: Mon, 11 May 2020 08:51:43 +0000 Subject: [PATCH 46/81] ytop: 0.6.0 -> 0.6.1 --- pkgs/tools/system/ytop/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/system/ytop/default.nix b/pkgs/tools/system/ytop/default.nix index 562886ad57e..08e227d2454 100644 --- a/pkgs/tools/system/ytop/default.nix +++ b/pkgs/tools/system/ytop/default.nix @@ -4,18 +4,18 @@ assert stdenv.isDarwin -> IOKit != null; rustPlatform.buildRustPackage rec { pname = "ytop"; - version = "0.6.0"; + version = "0.6.1"; src = fetchFromGitHub { owner = "cjbassi"; repo = pname; rev = version; - sha256 = "1zajgzhhxigga5wc94bmbk8iwx7yc2jq3f0hqadfsa4f0wmpi0nf"; + sha256 = "1p746v9xrfm6avc6v9dvcnpckhvdizzf53pcg9bpcp0lw5sh85da"; }; buildInputs = stdenv.lib.optionals stdenv.isDarwin [ IOKit ]; - cargoSha256 = "1ka9d81ddzz52w75xdiwd2xkv1rlamyvvdax09wanb61zxxwm0i7"; + cargoSha256 = "15cpi0b5yqjwi1liry2q17sn9hpc4xf9gn33ri3rs6ls5qs7j7pa"; meta = with stdenv.lib; { description = "A TUI system monitor written in Rust"; From e7ab236cab9dd6e74526bee282caa001a3374c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20K=C3=A1n=C4=9B?= Date: Mon, 11 May 2020 12:11:58 +0200 Subject: [PATCH 47/81] monero: fix rcp.restricted option According to https://monerodocs.org/interacting/monerod-reference/#node-rpc-api the correct option is restricted-rpc, not restrict-rpc. --- nixos/modules/services/networking/monero.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/monero.nix b/nixos/modules/services/networking/monero.nix index b9536430868..97af2997839 100644 --- a/nixos/modules/services/networking/monero.nix +++ b/nixos/modules/services/networking/monero.nix @@ -26,7 +26,7 @@ let rpc-login=${rpc.user}:${rpc.password} ''} ${optionalString rpc.restricted '' - restrict-rpc=1 + restricted-rpc=1 ''} limit-rate-up=${toString limits.upload} From 088a9495a8f70201baf674cb7f2e7bc7764476d2 Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Mon, 11 May 2020 12:18:43 +0200 Subject: [PATCH 48/81] bemenu: 0.3.0 -> 0.4.1 --- pkgs/applications/misc/bemenu/default.nix | 31 ++++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/pkgs/applications/misc/bemenu/default.nix b/pkgs/applications/misc/bemenu/default.nix index 665198b3d1f..5c622d811eb 100644 --- a/pkgs/applications/misc/bemenu/default.nix +++ b/pkgs/applications/misc/bemenu/default.nix @@ -1,32 +1,33 @@ -{ stdenv, fetchFromGitHub, cairo, cmake, libxkbcommon +{ stdenv, lib, fetchFromGitHub, cairo, libxkbcommon , pango, fribidi, harfbuzz, pcre, pkgconfig , ncursesSupport ? true, ncurses ? null -, waylandSupport ? true, wayland ? null +, waylandSupport ? true, wayland ? null, wayland-protocols ? null , x11Support ? true, xlibs ? null, xorg ? null }: assert ncursesSupport -> ncurses != null; -assert waylandSupport -> wayland != null; +assert waylandSupport -> ! lib.elem null [wayland wayland-protocols]; assert x11Support -> xlibs != null && xorg != null; stdenv.mkDerivation rec { pname = "bemenu"; - version = "0.3.0"; + version = "0.4.1"; src = fetchFromGitHub { owner = "Cloudef"; repo = pname; rev = version; - sha256 = "03k8wijdgj5nwmvgjhsrlh918n719789fhs4dqm23pd00rapxipk"; + sha256 = "1fjcs9d3533ay3nz79cx3c0lmy2chgragr2lhsy0xl2ckr0iins0"; }; - nativeBuildInputs = [ cmake pkgconfig pcre ]; + nativeBuildInputs = [ pkgconfig pcre ]; - cmakeFlags = [ - "-DBEMENU_CURSES_RENDERER=${if ncursesSupport then "ON" else "OFF"}" - "-DBEMENU_WAYLAND_RENDERER=${if waylandSupport then "ON" else "OFF"}" - "-DBEMENU_X11_RENDERER=${if x11Support then "ON" else "OFF"}" - ]; + makeFlags = ["PREFIX=$(out)"]; + + buildFlags = ["clients"] + ++ lib.optional ncursesSupport "curses" + ++ lib.optional waylandSupport "wayland" + ++ lib.optional x11Support "x11"; buildInputs = with stdenv.lib; [ cairo @@ -34,18 +35,18 @@ stdenv.mkDerivation rec { harfbuzz libxkbcommon pango - ] ++ optionals ncursesSupport [ ncurses ] - ++ optionals waylandSupport [ wayland ] + ] ++ optional ncursesSupport ncurses + ++ optionals waylandSupport [ wayland wayland-protocols ] ++ optionals x11Support [ xlibs.libX11 xlibs.libXinerama xlibs.libXft xorg.libXdmcp xorg.libpthreadstubs xorg.libxcb ]; - meta = with stdenv.lib; { + meta = with lib; { homepage = "https://github.com/Cloudef/bemenu"; description = "Dynamic menu library and client program inspired by dmenu"; license = licenses.gpl3Plus; - maintainers = with maintainers; [ thiagokokada ]; + maintainers = with maintainers; [ thiagokokada lheckemann ]; platforms = with platforms; linux; }; } From b95d49d03435c22142790fdd6f978ce0212ddc33 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Mon, 11 May 2020 13:17:26 +0200 Subject: [PATCH 49/81] wireguard-tools: 1.0.20200319 -> 1.0.20200510 https://lists.zx2c4.com/pipermail/wireguard/2020-May/005415.html --- pkgs/tools/networking/wireguard-tools/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/networking/wireguard-tools/default.nix b/pkgs/tools/networking/wireguard-tools/default.nix index 4fac72f7d03..4b6e2aa9f18 100644 --- a/pkgs/tools/networking/wireguard-tools/default.nix +++ b/pkgs/tools/networking/wireguard-tools/default.nix @@ -13,11 +13,11 @@ with stdenv.lib; stdenv.mkDerivation rec { pname = "wireguard-tools"; - version = "1.0.20200319"; + version = "1.0.20200510"; src = fetchzip { url = "https://git.zx2c4.com/wireguard-tools/snapshot/wireguard-tools-${version}.tar.xz"; - sha256 = "0g9vlngg9dnh7qqfhaycw35fq8ij5hfz6p1cykh4ncjgr93i7rbx"; + sha256 = "0xqchidfn1j3jq5w7ck570aib12q9z0mfvwhmnyzqxx7d3qh76j6"; }; outputs = [ "out" "man" ]; From ad8238c483133e617fe6dfc8855449c029a3775a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Mon, 11 May 2020 14:14:34 +0200 Subject: [PATCH 50/81] genxword: init at 2.0.1 (#87477) --- pkgs/applications/misc/genxword/default.nix | 54 +++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 56 insertions(+) create mode 100644 pkgs/applications/misc/genxword/default.nix diff --git a/pkgs/applications/misc/genxword/default.nix b/pkgs/applications/misc/genxword/default.nix new file mode 100644 index 00000000000..215542003ad --- /dev/null +++ b/pkgs/applications/misc/genxword/default.nix @@ -0,0 +1,54 @@ +{ lib +, python3 +, fetchFromGitHub +, gettext +, gobject-introspection +, wrapGAppsHook +, pango +, gtksourceview3 +}: + +python3.pkgs.buildPythonApplication rec { + pname = "genxword"; + version = "2.0.1"; + + src = fetchFromGitHub { + owner = "riverrun"; + repo = pname; + rev = "v${version}"; + sha256 = "00czdvyb5wnrk3x0g529afisl8v4frfys9ih0nzf1fs4jkzjcijg"; + }; + + nativeBuildInputs = [ + gettext + gobject-introspection + wrapGAppsHook + ]; + + buildInputs = [ + gobject-introspection + pango + gtksourceview3 + ]; + + propagatedBuildInputs = with python3.pkgs; [ + pycairo + pygobject3 + ]; + + # to prevent double wrapping + dontWrapGApps = true; + preFixup = '' + makeWrapperArgs+=("''${gappsWrapperArgs[@]}") + ''; + + # there are no tests + doCheck = false; + + meta = with lib; { + inherit (src.meta) homepage; + description = "Crossword generator"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ dotlambda ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 17aabe58daa..57276594e77 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19387,6 +19387,8 @@ in geany = callPackage ../applications/editors/geany { }; geany-with-vte = callPackage ../applications/editors/geany/with-vte.nix { }; + genxword = callPackage ../applications/misc/genxword { }; + geoipupdate = callPackage ../applications/misc/geoipupdate/default.nix { }; ghostwriter = libsForQt5.callPackage ../applications/editors/ghostwriter { }; From 6d183ed8d86d2c60bc55e0676081b72bd31728bc Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Mon, 11 May 2020 08:42:38 -0400 Subject: [PATCH 51/81] linux: 4.14.179 -> 4.14.180 --- pkgs/os-specific/linux/kernel/linux-4.14.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-4.14.nix b/pkgs/os-specific/linux/kernel/linux-4.14.nix index b3dea589cd6..8629eb8cf72 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.14.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.14.nix @@ -3,7 +3,7 @@ with stdenv.lib; buildLinux (args // rec { - version = "4.14.179"; + version = "4.14.180"; # modDirVersion needs to be x.y.z, will automatically add .0 if needed modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; @@ -13,6 +13,6 @@ buildLinux (args // rec { src = fetchurl { url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; - sha256 = "10arrj3ppbxkn15yxqpxlz4k8yp2afzbfpp2nwfy6klhjiffp9sx"; + sha256 = "03pd4wpg526n391jwc0kbmbxi059mvq8d42a9qbym9mnv5rzjkj4"; }; } // (args.argsOverride or {})) From 36a1ca4daaa1838588ea43ab3eac7a29a3607928 Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Mon, 11 May 2020 08:42:49 -0400 Subject: [PATCH 52/81] linux: 4.19.121 -> 4.19.122 --- pkgs/os-specific/linux/kernel/linux-4.19.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-4.19.nix b/pkgs/os-specific/linux/kernel/linux-4.19.nix index 450c44f0aa0..577138542b3 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.19.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.19.nix @@ -3,7 +3,7 @@ with stdenv.lib; buildLinux (args // rec { - version = "4.19.121"; + version = "4.19.122"; # modDirVersion needs to be x.y.z, will automatically add .0 if needed modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; @@ -13,6 +13,6 @@ buildLinux (args // rec { src = fetchurl { url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; - sha256 = "11bhjdaihhc42xhf4qxdkkjznc0i6igh0ahjbzr3fb8bmq9sirgv"; + sha256 = "1980vza1vf6cl772dynn4m0rgdjazbn125kd6sb3s06gqn72cl2h"; }; } // (args.argsOverride or {})) From ddd1363bff8284600f5904fcf46c5f0d303bed93 Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Mon, 11 May 2020 08:42:56 -0400 Subject: [PATCH 53/81] linux: 4.4.222 -> 4.4.223 --- pkgs/os-specific/linux/kernel/linux-4.4.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-4.4.nix b/pkgs/os-specific/linux/kernel/linux-4.4.nix index 81b32a932e1..58131815e0f 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.4.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.4.nix @@ -1,11 +1,11 @@ { stdenv, buildPackages, fetchurl, perl, buildLinux, ... } @ args: buildLinux (args // rec { - version = "4.4.222"; + version = "4.4.223"; extraMeta.branch = "4.4"; src = fetchurl { url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; - sha256 = "02zxy5vjxgrqs0mkz5aj70v6pazhif7x5cm26rf8zh4idpmhk2zh"; + sha256 = "09fln0sdfif2zv2jifp24yiqi0vcyj8fqx2jz91g21zvsxk3x5nd"; }; } // (args.argsOverride or {})) From 39426327ce684e69c5bdbe831a984c20a83e8f4a Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Mon, 11 May 2020 08:43:06 -0400 Subject: [PATCH 54/81] linux: 4.9.222 -> 4.9.223 --- pkgs/os-specific/linux/kernel/linux-4.9.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-4.9.nix b/pkgs/os-specific/linux/kernel/linux-4.9.nix index a9757aa2f10..9f2c7659abb 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.9.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.9.nix @@ -1,11 +1,11 @@ { stdenv, buildPackages, fetchurl, perl, buildLinux, ... } @ args: buildLinux (args // rec { - version = "4.9.222"; + version = "4.9.223"; extraMeta.branch = "4.9"; src = fetchurl { url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; - sha256 = "0aajgflf96bj7chbd83rdmgcdwd025c6mz6li4cwbfx7xcb91kjc"; + sha256 = "1r9ag1fhy0g429q44qlqh0qkf42qkhzxa04gxlmnrinqypk00lyg"; }; } // (args.argsOverride or {})) From 98c79eb588b0d19dafa058a8d326cf2199039513 Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Mon, 11 May 2020 08:43:15 -0400 Subject: [PATCH 55/81] linux: 5.4.39 -> 5.4.40 --- pkgs/os-specific/linux/kernel/linux-5.4.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-5.4.nix b/pkgs/os-specific/linux/kernel/linux-5.4.nix index 5ca72d8a6a5..ffe59480915 100644 --- a/pkgs/os-specific/linux/kernel/linux-5.4.nix +++ b/pkgs/os-specific/linux/kernel/linux-5.4.nix @@ -3,7 +3,7 @@ with stdenv.lib; buildLinux (args // rec { - version = "5.4.39"; + version = "5.4.40"; # modDirVersion needs to be x.y.z, will automatically add .0 if needed modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; @@ -13,6 +13,6 @@ buildLinux (args // rec { src = fetchurl { url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz"; - sha256 = "1j35yf1nilb9z7lw8w2drpww7q2zy8zfr0ip8hwcbcd7c5d9chai"; + sha256 = "1ar001rljlr15rcl77la5y1cj3plaqhdblnh87xsmv47fq13yml3"; }; } // (args.argsOverride or {})) From 0010ae4960d35243e7abb046cd26ddda904a4c63 Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Mon, 11 May 2020 08:43:23 -0400 Subject: [PATCH 56/81] linux: 5.6.11 -> 5.6.12 --- pkgs/os-specific/linux/kernel/linux-5.6.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-5.6.nix b/pkgs/os-specific/linux/kernel/linux-5.6.nix index 7cd3987f87c..844fb18c21a 100644 --- a/pkgs/os-specific/linux/kernel/linux-5.6.nix +++ b/pkgs/os-specific/linux/kernel/linux-5.6.nix @@ -3,7 +3,7 @@ with stdenv.lib; buildLinux (args // rec { - version = "5.6.11"; + version = "5.6.12"; # modDirVersion needs to be x.y.z, will automatically add .0 if needed modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; @@ -13,6 +13,6 @@ buildLinux (args // rec { src = fetchurl { url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz"; - sha256 = "1ahv4a3mnszqs3qcnwmhbvjgis1jg37anj5jvn70i7s2k6z6rpfn"; + sha256 = "0892ar2irfhd612sb8jpx85w0wwh4n76jgsv8wb92fp6mim37sns"; }; } // (args.argsOverride or {})) From f565285e6ba9ff65e9db0c2c6bf7da06799e89d7 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Mon, 11 May 2020 08:04:59 -0700 Subject: [PATCH 57/81] amass: 3.5.5 -> 3.6.0 (#87578) --- pkgs/tools/networking/amass/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/networking/amass/default.nix b/pkgs/tools/networking/amass/default.nix index be6d05ef426..116b0b25306 100644 --- a/pkgs/tools/networking/amass/default.nix +++ b/pkgs/tools/networking/amass/default.nix @@ -5,16 +5,16 @@ buildGoModule rec { pname = "amass"; - version = "3.5.5"; + version = "3.6.0"; src = fetchFromGitHub { owner = "OWASP"; repo = "Amass"; rev = "v${version}"; - sha256 = "1w93ia9jr2afgkbaklx2rj0ccd0ghg1qbdg363aqqvyw40ccya1r"; + sha256 = "05rh61dx4f9kv5p8sahhwwiyivwq438fl30j9d97i4sagvb5jvvm"; }; - modSha256 = "051fxfh7lwrj3hzsgr2c2ga6hksz56673lg35y36sz4d93yldj6f"; + modSha256 = "1k7yd2lh6hwz3qm6ywrlr1qw0asqwdgrpj594v1gvav426yqyr6s"; outputs = [ "out" "wordlists" ]; From 5458f4326eca06ba8d6f21d9e47e0392b99c01ce Mon Sep 17 00:00:00 2001 From: Vincent Laporte Date: Mon, 4 May 2020 22:18:36 +0200 Subject: [PATCH 58/81] ocamlPackages.async: remove at 112.24.00 This is a legacy version for OCaml 4.02 --- .../ocaml-modules/async/default.nix | 23 ------------------- .../ocaml-modules/janestreet/async.nix | 16 ------------- pkgs/top-level/ocaml-packages.nix | 12 ---------- 3 files changed, 51 deletions(-) delete mode 100644 pkgs/development/ocaml-modules/async/default.nix delete mode 100644 pkgs/development/ocaml-modules/janestreet/async.nix diff --git a/pkgs/development/ocaml-modules/async/default.nix b/pkgs/development/ocaml-modules/async/default.nix deleted file mode 100644 index 230db8189de..00000000000 --- a/pkgs/development/ocaml-modules/async/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{stdenv, buildOcaml, fetchurl, async_kernel_p4, - async_unix_p4, async_extra_p4, pa_ounit}: - -buildOcaml rec { - name = "async"; - version = "112.24.00"; - - minimumSupportedOcamlVersion = "4.02"; - - src = fetchurl { - url = "https://github.com/janestreet/async/archive/${version}.tar.gz"; - sha256 = "ecc4ca939ab098e689332921b110dbaacd06d9f8d8bf697023dfff3ca37dc1e9"; - }; - - propagatedBuildInputs = [ async_kernel_p4 async_unix_p4 async_extra_p4 pa_ounit ]; - - meta = with stdenv.lib; { - homepage = "https://github.com/janestreet/async"; - description = "Jane Street Capital's asynchronous execution library"; - license = licenses.asl20; - maintainers = [ maintainers.ericbmerritt ]; - }; -} diff --git a/pkgs/development/ocaml-modules/janestreet/async.nix b/pkgs/development/ocaml-modules/janestreet/async.nix deleted file mode 100644 index 8f15531403a..00000000000 --- a/pkgs/development/ocaml-modules/janestreet/async.nix +++ /dev/null @@ -1,16 +0,0 @@ -{stdenv, buildOcamlJane, async_kernel, - async_unix, async_extra}: - -buildOcamlJane { - name = "async"; - version = "113.33.03"; - hash = "0wyspkp8k833fh03r3h016nbfn6kjfhvb2bg42cly6agcak59fmr"; - propagatedBuildInputs = [ async_kernel async_unix async_extra ]; - - meta = with stdenv.lib; { - homepage = "https://github.com/janestreet/async"; - description = "Jane Street Capital's asynchronous execution library"; - license = licenses.asl20; - maintainers = [ maintainers.maurer maintainers.ericbmerritt ]; - }; -} diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 44b90219606..aadd51e6294 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -42,11 +42,6 @@ let async_unix_p4 = callPackage ../development/ocaml-modules/async_unix { }; - async_p4 = - if lib.versionOlder "4.02" ocaml.version - then callPackage ../development/ocaml-modules/async { } - else null; - atd = callPackage ../development/ocaml-modules/atd { }; atdgen = callPackage ../development/ocaml-modules/atdgen { }; @@ -1213,13 +1208,6 @@ let then callPackage ../development/ocaml-modules/janestreet/async-extra.nix {} else async_extra_p4; - async = - if lib.versionOlder "4.03" ocaml.version - then janeStreet.async - else if lib.versionOlder "4.02" ocaml.version - then callPackage ../development/ocaml-modules/janestreet/async.nix {} - else async_p4; - # Apps / from all-packages ocamlnat = callPackage ../development/ocaml-modules/ocamlnat { }; From d2b532a0d92904ed90b3c89763a30435bb095a5e Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Mon, 11 May 2020 17:39:26 +0200 Subject: [PATCH 59/81] bemenu: remove @thiagokokada from maintainers on request --- pkgs/applications/misc/bemenu/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/misc/bemenu/default.nix b/pkgs/applications/misc/bemenu/default.nix index 5c622d811eb..8b17ecea3cb 100644 --- a/pkgs/applications/misc/bemenu/default.nix +++ b/pkgs/applications/misc/bemenu/default.nix @@ -46,7 +46,7 @@ stdenv.mkDerivation rec { homepage = "https://github.com/Cloudef/bemenu"; description = "Dynamic menu library and client program inspired by dmenu"; license = licenses.gpl3Plus; - maintainers = with maintainers; [ thiagokokada lheckemann ]; + maintainers = with maintainers; [ lheckemann ]; platforms = with platforms; linux; }; } From a8b8942c880f8aec5511664fd8f544570be608b7 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sun, 10 May 2020 02:21:08 +0000 Subject: [PATCH 60/81] python27Packages.xapp: 1.8.1 -> 2.0.1 --- pkgs/development/python-modules/xapp/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/xapp/default.nix b/pkgs/development/python-modules/xapp/default.nix index 440db343025..de779fc2c00 100644 --- a/pkgs/development/python-modules/xapp/default.nix +++ b/pkgs/development/python-modules/xapp/default.nix @@ -11,13 +11,13 @@ buildPythonPackage rec { pname = "xapp"; - version = "1.8.1"; + version = "2.0.1"; src = fetchFromGitHub { owner = "linuxmint"; repo = "python-xapp"; rev = version; - sha256 = "0vw3cn09nx75lv4d9idp5fdhd81xs279zhbyyilynq29cxxs2zil"; + sha256 = "1pp3z4q6ryxcc26kaq222j53ji110n2v7rx29c7vy1fbb8mq64im"; }; propagatedBuildInputs = [ From 88c4688c253facc62c0a59b245d0b6cbb45a9c29 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sun, 10 May 2020 15:41:44 +0200 Subject: [PATCH 61/81] jc: 1.10.7 -> 1.10.10 Tests were removed from the PyPi distribution, so we need to fetch from GitHub now. See https://github.com/kellyjonbrazil/jc/issues/58 --- pkgs/development/python-modules/jc/default.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/development/python-modules/jc/default.nix b/pkgs/development/python-modules/jc/default.nix index 190d469f836..7ab5d230782 100644 --- a/pkgs/development/python-modules/jc/default.nix +++ b/pkgs/development/python-modules/jc/default.nix @@ -1,6 +1,6 @@ { stdenv , buildPythonPackage -, fetchPypi +, fetchFromGitHub , ruamel_yaml , xmltodict , pygments @@ -9,12 +9,14 @@ buildPythonPackage rec { pname = "jc"; - version = "1.10.7"; + version = "1.10.10"; disabled = isPy27; - src = fetchPypi { - inherit pname version; - sha256 = "198vsnh6j0nv9d7msnvw6qr1bzf0nffjsz7clm11bs7fh3ri3qxp"; + src = fetchFromGitHub { + owner = "kellyjonbrazil"; + repo = "jc"; + rev = "v${version}"; + sha256 = "1rkgk1d1gijic6l6rsvz5mpfhdj8l7qc60aqafj27s4yi5bbqrc7"; }; propagatedBuildInputs = [ ruamel_yaml xmltodict pygments ]; From 4d66a37dd5c76996f8068b84ff4c32e75bb81cc8 Mon Sep 17 00:00:00 2001 From: Kira Bruneau Date: Mon, 11 May 2020 13:58:52 -0400 Subject: [PATCH 62/81] texlab: 2.0.0 -> 2.1.0 (#87565) --- pkgs/development/tools/misc/texlab/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/tools/misc/texlab/default.nix b/pkgs/development/tools/misc/texlab/default.nix index 5cc67cb5e17..0076884e2ed 100644 --- a/pkgs/development/tools/misc/texlab/default.nix +++ b/pkgs/development/tools/misc/texlab/default.nix @@ -6,16 +6,16 @@ rustPlatform.buildRustPackage rec { pname = "texlab"; - version = "2.0.0"; + version = "2.1.0"; src = fetchFromGitHub { owner = "latex-lsp"; repo = pname; rev = "v${version}"; - sha256 = "0y8cv8y92a4nqwrvqk2cxgs6nspqjk8jm4spr8rgkwlpfbrg74xn"; + sha256 = "0cmciadiknw6w573v71spzf5ydaz2xxm2snv3n1hks732nahlr56"; }; - cargoSha256 = "1qi1c4v5d5a4xcf1bjbdicrv35w6chl5swlm96c1h3pr9s09lqy7"; + cargoSha256 = "0dhbbni8ia0dkwjacx5jlr5rj7173nsbivm9gjsx9j8ais0f0hff"; buildInputs = stdenv.lib.optionals stdenv.isDarwin [ Security ]; From 113bd283a427a49591ffded3f5f457b9fe7700b4 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 21:43:48 +0000 Subject: [PATCH 63/81] python27Packages.testfixtures: 6.10.3 -> 6.14.1 --- pkgs/development/python-modules/testfixtures/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/testfixtures/default.nix b/pkgs/development/python-modules/testfixtures/default.nix index 0c0db60f2c0..b3db882c82b 100644 --- a/pkgs/development/python-modules/testfixtures/default.nix +++ b/pkgs/development/python-modules/testfixtures/default.nix @@ -3,11 +3,11 @@ buildPythonPackage rec { pname = "testfixtures"; - version = "6.10.3"; + version = "6.14.1"; src = fetchPypi { inherit pname version; - sha256 = "8f22100d4fb841b958f64e71c8820a32dc46f57d4d7e077777b932acd87b7327"; + sha256 = "0rh38zj8wywgqlsi5j75c7drpqhkrg50qknj1kdmvg4kdlab7ljq"; }; checkInputs = [ pytest mock sybil zope_component twisted ]; From 336361c258e8e5ba976d9d5c867da6ba3c916a60 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sun, 10 May 2020 05:06:11 +0000 Subject: [PATCH 64/81] python27Packages.yamllint: 1.21.0 -> 1.23.0 --- pkgs/development/python-modules/yamllint/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/yamllint/default.nix b/pkgs/development/python-modules/yamllint/default.nix index b883a3d2bc8..c01c862e2f4 100644 --- a/pkgs/development/python-modules/yamllint/default.nix +++ b/pkgs/development/python-modules/yamllint/default.nix @@ -3,11 +3,11 @@ buildPythonPackage rec { pname = "yamllint"; - version = "1.21.0"; + version = "1.23.0"; src = fetchPypi { inherit pname version; - sha256 = "14yijcnmanyd3s2ir38sxl07rzpxgpgw9s6b8sy68jrl7n5nj7ky"; + sha256 = "1agl80csxhiqglm0idwhw98iqfpp61c9inzcdaz4czsfyivzzwsr"; }; checkInputs = [ nose ]; From 518b577ce92606e0ee06f398de183f46fb68ca1e Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 21:23:58 +0000 Subject: [PATCH 65/81] python27Packages.pyudev: 0.21.0 -> 0.22.0 --- pkgs/development/python-modules/pyudev/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/pyudev/default.nix b/pkgs/development/python-modules/pyudev/default.nix index dedec796e65..c26f9bcabe6 100644 --- a/pkgs/development/python-modules/pyudev/default.nix +++ b/pkgs/development/python-modules/pyudev/default.nix @@ -4,11 +4,11 @@ buildPythonPackage rec { pname = "pyudev"; - version = "0.21.0"; + version = "0.22.0"; src = fetchPypi { inherit pname version; - sha256 = "0arz0dqp75sszsmgm6vhg92n1lsx91ihddx3m944f4ah0487ljq9"; + sha256 = "0xmj6l08iih2js9skjqpv4w7y0dhxyg91zmrs6v5aa65gbmipfv9"; }; postPatch = '' From 31a06c11a8f00c6699ae43112b3abba4aa4ff36b Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 21:03:02 +0000 Subject: [PATCH 66/81] python27Packages.rfc3986: 1.3.2 -> 1.4.0 --- pkgs/development/python-modules/rfc3986/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/rfc3986/default.nix b/pkgs/development/python-modules/rfc3986/default.nix index 7d8a44365c4..3af6d2f022b 100644 --- a/pkgs/development/python-modules/rfc3986/default.nix +++ b/pkgs/development/python-modules/rfc3986/default.nix @@ -3,11 +3,11 @@ buildPythonPackage rec { pname = "rfc3986"; - version = "1.3.2"; + version = "1.4.0"; src = fetchPypi { inherit pname version; - sha256 = "0344d0bd428126ce554e7ca2b61787b6a28d2bbd19fc70ed2dd85efe31176405"; + sha256 = "17dvx15m3r49bmif5zlli8kzjd6bys6psixzbp14sd5367d9h8qi"; }; checkInputs = [ pytest ]; From 9f1c6fe8e188fc9b148e2fbde06ca462b59f8128 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 20:55:46 +0000 Subject: [PATCH 67/81] python27Packages.subliminal: 2.0.5 -> 2.1.0 --- pkgs/development/python-modules/subliminal/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/subliminal/default.nix b/pkgs/development/python-modules/subliminal/default.nix index 4c8bf7f6ba6..25e20a44118 100644 --- a/pkgs/development/python-modules/subliminal/default.nix +++ b/pkgs/development/python-modules/subliminal/default.nix @@ -28,11 +28,11 @@ buildPythonPackage rec { pname = "subliminal"; - version = "2.0.5"; + version = "2.1.0"; src = fetchPypi { inherit pname version; - sha256 = "1dzv5csjcwgz69aimarx2c6606ckm2gbn4x2mzydcqnyai7sayhl"; + sha256 = "12v2clnbic8320fjsvkg3xfxfa7x8inhjk61z00pzwx46g3rqhy6"; }; propagatedBuildInputs = [ From 9d11fd8f5f5a3d09dbf96925a8efd2e8438405ab Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 19:43:15 +0000 Subject: [PATCH 68/81] python27Packages.snakeviz: 2.0.1 -> 2.1.0 --- pkgs/development/python-modules/snakeviz/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/snakeviz/default.nix b/pkgs/development/python-modules/snakeviz/default.nix index efb0a23a7c6..a34996b8734 100644 --- a/pkgs/development/python-modules/snakeviz/default.nix +++ b/pkgs/development/python-modules/snakeviz/default.nix @@ -2,11 +2,11 @@ buildPythonPackage rec { pname = "snakeviz"; - version = "2.0.1"; + version = "2.1.0"; src = fetchPypi { inherit pname version; - sha256 = "11a8cd4g98vq2x61i99ncl5w83clnndwg909ya4y1cdf0k1ckb40"; + sha256 = "0s6byw23hr2khqx2az36hpi52fk4v6bfm1bb7biaf0d2nrpqgbcj"; }; # Upstream doesn't run tests from setup.py From 24cf81696f3e61e7f48e469ba7430fd2a1e84c2d Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 17:19:04 +0000 Subject: [PATCH 69/81] python37Packages.starlette: 0.13.2 -> 0.13.4 --- pkgs/development/python-modules/starlette/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/starlette/default.nix b/pkgs/development/python-modules/starlette/default.nix index cad0aa79705..842622e56f8 100644 --- a/pkgs/development/python-modules/starlette/default.nix +++ b/pkgs/development/python-modules/starlette/default.nix @@ -26,14 +26,14 @@ buildPythonPackage rec { # https://github.com/tiangolo/fastapi/issues/683. Please update when # possible. FastAPI is currently Starlette's only dependent. - version = "0.13.2"; + version = "0.13.4"; disabled = isPy27; src = fetchFromGitHub { owner = "encode"; repo = pname; rev = version; - sha256 = "1ls8d121zyyhry5ji7gf7vjvhyqdpr4za3qx1llq48943fmaxxpq"; + sha256 = "1rk20rj62iigkkikb80bmalriyg1j3g28s25l8z2gijagv1v5c7l"; }; propagatedBuildInputs = [ From 37d3bd1af75a0e52a7e49262209b7762eb981832 Mon Sep 17 00:00:00 2001 From: Jonathan Ringer Date: Mon, 11 May 2020 11:43:40 -0700 Subject: [PATCH 70/81] python3Packages.fastapi: don't pin starlette --- pkgs/development/python-modules/fastapi/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/fastapi/default.nix b/pkgs/development/python-modules/fastapi/default.nix index 0ed9d42c3b0..3513f57cdbe 100644 --- a/pkgs/development/python-modules/fastapi/default.nix +++ b/pkgs/development/python-modules/fastapi/default.nix @@ -16,7 +16,7 @@ buildPythonPackage rec { pname = "fastapi"; - version = "0.54.0"; + version = "0.54.1"; format = "flit"; disabled = !isPy3k; @@ -24,9 +24,14 @@ buildPythonPackage rec { owner = "tiangolo"; repo = "fastapi"; rev = version; - sha256 = "17bicrpr801z71wrn9iimvh7qk6iwyxvr89ialf0s2rxxa2s0yb5"; + sha256 = "0k0lss8x6lzf0szcli48v28r269fsx1jdkr9q78liz47dz5x03d8"; }; + postPatch = '' + substituteInPlace pyproject.toml \ + --replace "starlette ==0.13.2" "starlette" + ''; + propagatedBuildInputs = [ uvicorn starlette From 013246780759b5d0a0b4ffd43e28947c792caed3 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 16:24:49 +0000 Subject: [PATCH 71/81] python27Packages.parver: 0.2.1 -> 0.3.0 --- pkgs/development/python-modules/parver/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/parver/default.nix b/pkgs/development/python-modules/parver/default.nix index c71e39ca111..a51f1c00327 100644 --- a/pkgs/development/python-modules/parver/default.nix +++ b/pkgs/development/python-modules/parver/default.nix @@ -11,11 +11,11 @@ buildPythonPackage rec { pname = "parver"; - version = "0.2.1"; + version = "0.3.0"; src = fetchPypi { inherit pname version; - sha256 = "0jzyylcmjxb0agc4fpdnzdnv2ajvp99rs9pz7qcklnhlmy8scdqv"; + sha256 = "0a6jp17c1ag6b9yp5xgy9wvznk3g0v2f8gpwkcwxpyc9ygk98zdm"; }; propagatedBuildInputs = [ six attrs arpeggio ]; From 0f89908eeef67ed23be412d187e872e48be50d11 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 16:45:39 +0000 Subject: [PATCH 72/81] python27Packages.rdflib: 4.2.2 -> 5.0.0 --- pkgs/development/python-modules/rdflib/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/rdflib/default.nix b/pkgs/development/python-modules/rdflib/default.nix index 87d99623057..261ba794e70 100644 --- a/pkgs/development/python-modules/rdflib/default.nix +++ b/pkgs/development/python-modules/rdflib/default.nix @@ -10,11 +10,11 @@ buildPythonPackage rec { pname = "rdflib"; - version = "4.2.2"; + version = "5.0.0"; src = fetchPypi { inherit pname version; - sha256 = "0398c714znnhaa2x7v51b269hk20iz073knq2mvmqp2ma92z27fs"; + sha256 = "0mdi7xh4zcr3ngqwlgqdqf0i5bxghwfddyxdng1zwpiqkpa9s53q"; }; propagatedBuildInputs = [isodate html5lib SPARQLWrapper ]; From 18218babe483778af3f50a97396cc0af7efd8691 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 16:31:21 +0000 Subject: [PATCH 73/81] python37Packages.pyenchant: 2.0.0 -> 3.0.1 --- pkgs/development/python-modules/pyenchant/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/pyenchant/default.nix b/pkgs/development/python-modules/pyenchant/default.nix index 472cdc7118d..b775a1a0157 100644 --- a/pkgs/development/python-modules/pyenchant/default.nix +++ b/pkgs/development/python-modules/pyenchant/default.nix @@ -6,11 +6,11 @@ buildPythonPackage rec { pname = "pyenchant"; - version = "2.0.0"; + version = "3.0.1"; src = fetchPypi { inherit pname version; - sha256 = "fc31cda72ace001da8fe5d42f11c26e514a91fa8c70468739216ddd8de64e2a0"; + sha256 = "0nfmckqm45fbfz795qw5hgvygdxgxchdiwp3kmm1k05z99j6mlhv"; }; propagatedBuildInputs = [ enchant2 ]; From c2e563d9785de2741a931cdf48af0bb3141e98f8 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 11 May 2020 11:55:14 -0700 Subject: [PATCH 74/81] python2Packages.pyenchant: disable python2 Abandoned upstream --- pkgs/development/python-modules/pyenchant/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/python-modules/pyenchant/default.nix b/pkgs/development/python-modules/pyenchant/default.nix index b775a1a0157..91626bd5e55 100644 --- a/pkgs/development/python-modules/pyenchant/default.nix +++ b/pkgs/development/python-modules/pyenchant/default.nix @@ -1,5 +1,6 @@ { stdenv , buildPythonPackage +, isPy27 , fetchPypi , enchant2 }: @@ -7,6 +8,7 @@ buildPythonPackage rec { pname = "pyenchant"; version = "3.0.1"; + disabled = isPy27; src = fetchPypi { inherit pname version; From 1d5390bee10e16a78c8180584f7d3472e0f5a216 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 15:57:36 +0000 Subject: [PATCH 75/81] python27Packages.ldap3: 2.6.1 -> 2.7 --- pkgs/development/python-modules/ldap3/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/ldap3/default.nix b/pkgs/development/python-modules/ldap3/default.nix index d9694633704..eb2d09d8d26 100644 --- a/pkgs/development/python-modules/ldap3/default.nix +++ b/pkgs/development/python-modules/ldap3/default.nix @@ -2,11 +2,11 @@ buildPythonPackage rec { pname = "ldap3"; - version = "2.6.1"; + version = "2.7"; src = fetchPypi { inherit pname version; - sha256 = "0ag5xqlki6pjk3f50b8ar8vynx2fmkna7rfampv3kdgwg8z6gjr7"; + sha256 = "1h1q8g1c2nkhx8p5n91bzkvjx5js5didi9xqbnmfrxqbnyc45w0p"; }; propagatedBuildInputs = [ pyasn1 ]; From 3a453bc6323cb45531edf503ffac741a6e780e21 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 16:11:37 +0000 Subject: [PATCH 76/81] python27Packages.plotly: 4.4.1 -> 4.6.0 --- pkgs/development/python-modules/plotly/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/plotly/default.nix b/pkgs/development/python-modules/plotly/default.nix index ecb5f7cc3ad..2d14488c4ee 100644 --- a/pkgs/development/python-modules/plotly/default.nix +++ b/pkgs/development/python-modules/plotly/default.nix @@ -11,11 +11,11 @@ buildPythonPackage rec { pname = "plotly"; - version = "4.4.1"; + version = "4.6.0"; src = fetchPypi { inherit pname version; - sha256 = "acc94f17452471ca3446c2ce491c4d1affb99b9ddd9eac4e05614ac4318f8780"; + sha256 = "0br996lqbyq1prq9hhrzkgpicz5fgvxamzjrrpms20a2y1alkwv1"; }; propagatedBuildInputs = [ From d020db4a44eb3cdc60aff19d21bd704f1f4d8768 Mon Sep 17 00:00:00 2001 From: Aiken Cairncross Date: Mon, 11 May 2020 19:46:44 +0100 Subject: [PATCH 77/81] onnx: 1.6.0 -> 1.7.0 --- .../python-modules/onnx/default.nix | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/pkgs/development/python-modules/onnx/default.nix b/pkgs/development/python-modules/onnx/default.nix index 3e2c8bd499d..6c0560bbaff 100644 --- a/pkgs/development/python-modules/onnx/default.nix +++ b/pkgs/development/python-modules/onnx/default.nix @@ -18,29 +18,18 @@ buildPythonPackage rec { pname = "onnx"; - version = "1.6.0"; + version = "1.7.0"; # Due to Protobuf packaging issues this build of Onnx with Python 2 gives - # errors on import + # errors on import. + # Also support for Python 2 will be deprecated from Onnx v1.8. disabled = isPy27; src = fetchPypi { inherit pname version; - sha256 = "0ig33jl3591041lyylxp52yi20rfrcqx3i030hd6al8iabzc721v"; + sha256 = "0j6rgfbhsw3a8id8pyg18y93k68lbjbj1kq6qia36h69f6pvlyjy"; }; - # Remove the unqualified requirement for the typing package for running the - # tests. typing is already required for the installation, where it is - # correctly qualified so as to only be required for sufficiently old Python - # versions. - # This patch should be in the next release (>1.6). - patches = [ - (fetchpatch { - url = "https://github.com/onnx/onnx/commit/c963586d0f8dd5740777b2fd06f04ec60816de9f.patch"; - sha256 = "1hl26cw5zckc91gmh0bdah87jyprccxiw0f4i5h1gwkq28hm6wbj"; - }) - ]; - nativeBuildInputs = [ cmake ]; propagatedBuildInputs = [ @@ -61,13 +50,17 @@ buildPythonPackage rec { patchShebangs tools/protoc-gen-mypy.py ''; + preBuild = '' + export MAX_JOBS=$NIX_BUILD_CORES + ''; + # The executables are just utility scripts that aren't too important postInstall = '' rm -r $out/bin ''; - # The setup.py does all the configuration (running CMake) - dontConfigure = true; + # The setup.py does all the configuration + dontUseCmakeConfigure = true; meta = { homepage = "http://onnx.ai"; From 9431a530cd0c3e6f93288854eae5431cf0f0742f Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sun, 10 May 2020 00:53:12 +0000 Subject: [PATCH 78/81] python27Packages.stripe: 2.44.0 -> 2.47.0 --- pkgs/development/python-modules/stripe/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/stripe/default.nix b/pkgs/development/python-modules/stripe/default.nix index ff520c5ffe3..109a5f6c769 100644 --- a/pkgs/development/python-modules/stripe/default.nix +++ b/pkgs/development/python-modules/stripe/default.nix @@ -2,7 +2,7 @@ buildPythonPackage rec { pname = "stripe"; - version = "2.44.0"; + version = "2.47.0"; # Tests require network connectivity and there's no easy way to disable # them. ~ C. @@ -10,7 +10,7 @@ buildPythonPackage rec { src = fetchPypi { inherit pname version; - sha256 = "0aaaf8dp989im2n0cdmslq0ys4ia970yl1irhxiwwqarmh6fap5i"; + sha256 = "14skddrf2nl25bvcyys0bgibjqkcivvfdywzldqjzyqvbwr4mkal"; }; propagatedBuildInputs = [ requests ]; From 15d4f7a83191bdadc82cba7d0adbedbdf45421f5 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 18:00:33 +0000 Subject: [PATCH 79/81] python37Packages.sparse: 0.8.0 -> 0.9.1 --- pkgs/development/python-modules/sparse/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/sparse/default.nix b/pkgs/development/python-modules/sparse/default.nix index 483fc12915f..355453ed26e 100644 --- a/pkgs/development/python-modules/sparse/default.nix +++ b/pkgs/development/python-modules/sparse/default.nix @@ -10,13 +10,13 @@ buildPythonPackage rec { pname = "sparse"; - version = "0.8.0"; + version = "0.9.1"; disabled = !isPy3k; src = fetchPypi { inherit pname version; - sha256 = "a3dc14ee5314caa2e64331b0b50c8f92e8999d7d275179a804a114e6cb1f8b81"; + sha256 = "04gfwm1y9knryx992biniqa3978n3chr38iy3y4i2b8wy52fzy3d"; }; checkInputs = [ pytest ]; From 84701d5f5a7ffbad95168fb9dda30bccc705b7c0 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 9 May 2020 19:50:06 +0000 Subject: [PATCH 80/81] python27Packages.pytest-metadata: 1.8.0 -> 1.9.0 --- pkgs/development/python-modules/pytest-metadata/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/pytest-metadata/default.nix b/pkgs/development/python-modules/pytest-metadata/default.nix index 369ddf2c476..9b25e2045e9 100644 --- a/pkgs/development/python-modules/pytest-metadata/default.nix +++ b/pkgs/development/python-modules/pytest-metadata/default.nix @@ -3,11 +3,11 @@ buildPythonPackage rec { pname = "pytest-metadata"; - version = "1.8.0"; + version = "1.9.0"; src = fetchPypi { inherit pname version; - sha256 = "1fk6icip2x1nh4kzhbc8cnqrs77avpqvj7ny3xadfh6yhn9aaw90"; + sha256 = "1711gippwsl7c1wi8pc2y75xqq5sn1sscpqvrxjvpjm8pcx2138n"; }; nativeBuildInputs = [ setuptools_scm ]; From 33a756f431c2bae404d1ebbe2bf457405d813566 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 1 Feb 2020 11:20:32 +0000 Subject: [PATCH 81/81] ocamlPackages.lablgtk3: 3.0.beta6 -> 3.1.0 --- pkgs/development/ocaml-modules/lablgtk3/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/ocaml-modules/lablgtk3/default.nix b/pkgs/development/ocaml-modules/lablgtk3/default.nix index d49208ede60..641f16f69b0 100644 --- a/pkgs/development/ocaml-modules/lablgtk3/default.nix +++ b/pkgs/development/ocaml-modules/lablgtk3/default.nix @@ -1,14 +1,14 @@ { lib, fetchurl, pkgconfig, buildDunePackage, gtk3, cairo2 }: buildDunePackage rec { - version = "3.0.beta6"; + version = "3.1.0"; pname = "lablgtk3"; minimumOCamlVersion = "4.05"; src = fetchurl { url = "https://github.com/garrigue/lablgtk/releases/download/${version}/lablgtk3-${version}.tbz"; - sha256 = "1jni5cbp54qs7y0dc5zkm28v2brpfwy5miighv7cy0nmmxrsq520"; + sha256 = "1fn04qwgkwc86jndlrnv4vxcmasjsp1mmcgfznahj1ccc7bv47sv"; }; nativeBuildInputs = [ pkgconfig ];