about summary refs log tree commit diff
path: root/pkgs/sternenseemann
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-08-07 02:32:22 +0200
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-08-07 02:32:22 +0200
commite478fb8c7e7432572f7b9c9c50fd361fc90127a6 (patch)
treeebd19059be8d757866670b8ebd3ff623a356ff05 /pkgs/sternenseemann
parent264ad152cb130c94b8f8cd90f8162c721f7b2f57 (diff)
pkgs/sternenseemann/mandoc: sync repo and use ingo's patch
https://inbox.vuxu.org/mandoc-tech/c9932669-e9d4-1454-8708-7c8e36967e8e@systemli.org/T/#m445439360d5fbe71849001e39ce1e78a8a7d024f
Diffstat (limited to 'pkgs/sternenseemann')
-rw-r--r--pkgs/sternenseemann/default.nix4
-rw-r--r--pkgs/sternenseemann/patches/mandoc-nix-store.patch217
2 files changed, 126 insertions, 95 deletions
diff --git a/pkgs/sternenseemann/default.nix b/pkgs/sternenseemann/default.nix
index 87410e91..45296ad5 100644
--- a/pkgs/sternenseemann/default.nix
+++ b/pkgs/sternenseemann/default.nix
@@ -96,8 +96,8 @@ lib.fix (self: {
   # patched packages
   mandoc = pkgs.mandoc.overrideAttrs (old: rec {
     src = pkgs.fetchcvs {
-      sha256 = "19cqasw7fjsmhshs5khxrv8w3vdhf8xadls70l0gzqn7cyjmgsb9";
-      date = "2021-02-07";
+      sha256 = "13dz321f7fyqkz71xgyk42m4la9phqrijs9phn6icarnqrfi9fpr";
+      date = "2021-08-06";
       cvsRoot = "anoncvs@mandoc.bsd.lv:/cvs";
       module = "mandoc";
     };
diff --git a/pkgs/sternenseemann/patches/mandoc-nix-store.patch b/pkgs/sternenseemann/patches/mandoc-nix-store.patch
index d4d326d0..2e225241 100644
--- a/pkgs/sternenseemann/patches/mandoc-nix-store.patch
+++ b/pkgs/sternenseemann/patches/mandoc-nix-store.patch
@@ -1,102 +1,133 @@
 Index: configure
 ===================================================================
-RCS file: /cvs/mandoc/configure,v
+RCS file: /home/cvs/mandoc/mandoc/configure,v
 retrieving revision 1.77
-diff -r1.77 configure
-464c464,469
-< [ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
----
-> if [ -n "${HOMEBREWDIR}" ]; then
->   # support deprecated configuration variable HOMEBREWDIR
->   # by appending it to READ_ALLOWED_PATH
->   READ_ALLOWED_PATH="${READ_ALLOWED_PATH:+$READ_ALLOWED_PATH:}${HOMEBREWDIR}"
-> fi
-> [ -n "${READ_ALLOWED_PATH}" ] && echo "#define READ_ALLOWED_PATH \"${READ_ALLOWED_PATH}\""
+diff -u -p -r1.77 configure
+--- configure	20 Jul 2020 16:57:30 -0000	1.77
++++ configure	5 Aug 2021 11:42:59 -0000
+@@ -107,7 +107,7 @@ BIN_FROM_SBIN=
+ INCLUDEDIR=
+ LIBDIR=
+ MANDIR=
+-HOMEBREWDIR=
++READ_ALLOWED_PATH=
+ 
+ WWWPREFIX="/var/www"
+ HTDOCDIR=
+@@ -461,7 +461,8 @@ echo "#define MANPATH_DEFAULT \"${MANPAT
+ echo "#define OSENUM ${OSENUM}"
+ [ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
+ [ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
+-[ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
++[ -n "${READ_ALLOWED_PATH}" ] \
++	&& echo "#define READ_ALLOWED_PATH \"${READ_ALLOWED_PATH}\""
+ [ ${HAVE_ATTRIBUTE} -eq 0 ] && echo "#define __attribute__(x)"
+ [ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL"
+ [ ${HAVE_O_DIRECTORY} -eq 0 ] && echo "#define O_DIRECTORY 0"
 Index: configure.local.example
 ===================================================================
-RCS file: /cvs/mandoc/configure.local.example,v
+RCS file: /home/cvs/mandoc/mandoc/configure.local.example,v
 retrieving revision 1.39
-diff -r1.39 configure.local.example
-214,216c214,220
-< # into the manual trees.  To allow mandoc to follow such symlinks,
-< # you have to specify the physical location of the cellar as returned
-< # by realpath(3), for example:
----
-> # into the manual trees.  A similar situation arises on Linux
-> # distribution such as NixOS and Guix where all man pages are in a
-> # so-called “store” directory which are then symlinked into the man
-> # basedir. To allow mandoc to follow such symlinks, you have to specify
-> # the physical location of the cellar / store directory as returned by
-> # realpath(3) like in the following example. You can specify multiple
-> # locations by separating them with colons.
-219c223
-< HOMEBREWDIR="${PREFIX}/Cellar"
----
-> READ_ALLOWED_PATH="/nix/store:/gnu/store:${PREFIX}/Cellar"
+diff -u -p -r1.39 configure.local.example
+--- configure.local.example	20 Jul 2020 16:57:30 -0000	1.39
++++ configure.local.example	5 Aug 2021 11:43:00 -0000
+@@ -209,14 +209,28 @@ INSTALL_LIB="${INSTALL} -m 0444"
+ INSTALL_MAN="${INSTALL} -m 0444"
+ INSTALL_DATA="${INSTALL} -m 0444"
+ 
+-# When using the "homebrew" package manager on Mac OS X, the actual
+-# manuals are located in a so-called "cellar" and only symlinked
+-# into the manual trees.  To allow mandoc to follow such symlinks,
+-# you have to specify the physical location of the cellar as returned
+-# by realpath(3), for example:
++# By default, makewhatis(8) can only read from the paths passed on the
++# command line or configured in man.conf(5).
++# But some package managers on some operating systems store manual pages
++# in separate "cellar" or "store" directories and only symlink them
++# into the manual trees.
++# To support one or more such package managers, give makewhatis(8)
++# read access to the cellars and stores on your system, in the form
++# of a colon-separated path:
+ 
++# Homebrow package manager on Mac OS X:
+ PREFIX="/usr/local"
+-HOMEBREWDIR="${PREFIX}/Cellar"
++READ_ALLOWED_PATH="${PREFIX}/Cellar"
++
++# Nix package manager and/or NixOS Linux distibution:
++READ_ALLOWED_PATH="/nix/store"
++
++# GNU Guix package manager and/or GNU Guix Linux distibution:
++READ_ALLOWED_PATH="/gnu/store"
++
++# If multiple package managers are used concurrently:
++PREFIX="/usr/local"
++READ_ALLOWED_PATH="/nix/store:${PREFIX}/Cellar"
+ 
+ # --- user settings for the mandoc(3) library --------------------------
+ 
 Index: mandocdb.c
 ===================================================================
-RCS file: /cvs/mandoc/mandocdb.c,v
+RCS file: /home/cvs/mandoc/mandoc/mandocdb.c,v
 retrieving revision 1.267
-diff -r1.267 mandocdb.c
-167a168
-> static	ssize_t	 read_allowed(char *);
-614,618c615
-< 			if (strncmp(buf, basedir, basedir_len) != 0
-< #ifdef HOMEBREWDIR
-< 			    && strncmp(buf, HOMEBREWDIR, strlen(HOMEBREWDIR))
-< #endif
-< 			) {
----
-> 			if (read_allowed(buf) == -1) {
-788a786
-> 	ssize_t		 prefix_len;
-824,829c822,823
-< 	else if (strncmp(usefile, basedir, basedir_len) == 0)
-< 		start = usefile + basedir_len;
-< #ifdef HOMEBREWDIR
-< 	else if (strncmp(usefile, HOMEBREWDIR, strlen(HOMEBREWDIR)) == 0)
-< 		start = usefile;
-< #endif
----
-> 	else if ((prefix_len = read_allowed(usefile)) != -1)
-> 		start = usefile + prefix_len;
-1947a1942,1980
-> }
-> 
-> /*
->  * Checks if we may read from a given realpath when
->  * constructing a database. This checks if the given
->  * path is in the current set basedir or any directory
->  * in READ_ALLOWED_PATH if it is defined.
->  *
->  * Returns -1 if reading is not allowed, the length
->  * of the allowed directory part of the realpath if
->  * reading is allowed. Note that stripping a prefix of
->  * this length is only guaranteed to be a man dir if
->  * the file is in basedir.
->  */
-> static ssize_t
-> read_allowed(char *realpath)
-> {
-> 	// if we have no basedir, don't check
-> 	if(basedir_len == 0 || basedir == NULL || *basedir == '\0')
-> 		return basedir_len;
-> 
-> 	if(strncmp(realpath, basedir, basedir_len) == 0)
-> 		return basedir_len;
-> 
-> #ifdef READ_ALLOWED_PATH
-> 	const char *pb = READ_ALLOWED_PATH;
-> 
-> 	while (*pb != '\0') {
-> 		size_t len = strcspn(pb, ":");
-> 
-> 		if (len > 0 && strncmp(realpath, pb, len) == 0)
-> 			return len;
-> 
-> 		pb += len;
-> 		pb += strspn(pb, ":");
-> 	}
-> #endif
-> 
-> 	return -1;
+diff -u -p -r1.267 mandocdb.c
+--- mandocdb.c	3 Apr 2020 11:35:01 -0000	1.267
++++ mandocdb.c	5 Aug 2021 11:43:00 -0000
+@@ -165,6 +165,9 @@ static	void	 putkey(const struct mpage *
+ static	void	 putkeys(const struct mpage *, char *, size_t, uint64_t);
+ static	void	 putmdockey(const struct mpage *,
+ 			const struct roff_node *, uint64_t, int);
++#ifdef READ_ALLOWED_PATH
++static	int	 read_allowed(const char *);
++#endif
+ static	int	 render_string(char **, size_t *);
+ static	void	 say(const char *, const char *, ...)
+ 			__attribute__((__format__ (__printf__, 2, 3)));
+@@ -612,8 +615,8 @@ treescan(void)
+ 				continue;
+ 			}
+ 			if (strncmp(buf, basedir, basedir_len) != 0
+-#ifdef HOMEBREWDIR
+-			    && strncmp(buf, HOMEBREWDIR, strlen(HOMEBREWDIR))
++#ifdef READ_ALLOWED_PATH
++			    && !read_allowed(buf)
+ #endif
+ 			) {
+ 				if (warnings) say("",
+@@ -823,8 +826,8 @@ filescan(const char *infile)
+ 		start = usefile;
+ 	else if (strncmp(usefile, basedir, basedir_len) == 0)
+ 		start = usefile + basedir_len;
+-#ifdef HOMEBREWDIR
+-	else if (strncmp(usefile, HOMEBREWDIR, strlen(HOMEBREWDIR)) == 0)
++#ifdef READ_ALLOWED_PATH
++	else if (read_allowed(usefile))
+ 		start = usefile;
+ #endif
+ 	else {
+@@ -2380,6 +2383,25 @@ set_basedir(const char *targetdir, int r
+ 	}
+ 	return 1;
+ }
++
++#ifdef READ_ALLOWED_PATH
++static int
++read_allowed(const char *candidate)
++{
++	const char	*cp;
++	size_t		 len;
++
++	for (cp = READ_ALLOWED_PATH;; cp += len) {
++		while (*cp == ':')
++			cp++;
++		if (*cp == '\0')
++			return 0;
++		len = strcspn(cp, ":");
++		if (strncmp(candidate, cp, len) == 0)
++			return 1;
++	}
++}
++#endif
+ 
+ static void
+ say(const char *file, const char *format, ...)