summaryrefslogtreecommitdiff
path: root/system/mandoc
diff options
context:
space:
mode:
Diffstat (limited to 'system/mandoc')
-rw-r--r--system/mandoc/APKBUILD90
-rw-r--r--system/mandoc/cgi-adelie.patch62
-rw-r--r--system/mandoc/cgi-gz.patch77
-rw-r--r--system/mandoc/cgi-search.patch48
-rw-r--r--system/mandoc/configure.patch10
-rw-r--r--system/mandoc/doc.patch132
-rw-r--r--system/mandoc/less.patch45
-rw-r--r--system/mandoc/mandoc.post-deinstall3
-rw-r--r--system/mandoc/mandoc.trigger3
9 files changed, 470 insertions, 0 deletions
diff --git a/system/mandoc/APKBUILD b/system/mandoc/APKBUILD
new file mode 100644
index 000000000..88230079e
--- /dev/null
+++ b/system/mandoc/APKBUILD
@@ -0,0 +1,90 @@
+# Maintainer: Max Rees <maxcrees@me.com>
+pkgname=mandoc
+pkgver=1.14.6
+pkgrel=1
+pkgdesc="Manual page database, compiler, and viewer"
+url="https://mandoc.bsd.lv/"
+arch="all"
+license="ISC AND BSD-2-Clause AND BSD-3-Clause"
+replaces="man-db"
+depends="less"
+makedepends="zlib-dev"
+checkdepends="perl"
+subpackages="$pkgname-doc $pkgname-cgi"
+install="$pkgname.post-deinstall"
+triggers="$pkgname.trigger=/usr/share/man"
+source="https://mandoc.bsd.lv/snapshots/mandoc-$pkgver.tar.gz
+ configure.patch
+ less.patch
+ doc.patch
+ cgi-adelie.patch
+ cgi-gz.patch
+ cgi-search.patch
+ "
+
+prepare() {
+ default_prepare
+ cat >"configure.local" <<-EOF
+ PREFIX=/usr
+ MANDIR=/usr/share/man
+ WWWPREFIX=/var/lib/mandoc-cgi
+ # remove /usr/X11R6 from the following.
+ MANPATH_BASE=/usr/share/man
+ MANPATH_DEFAULT=/usr/share/man:/usr/local/share/man
+ # groff also provides a soelim.
+ BINM_SOELIM=mandoc-soelim
+
+ CFLAGS="$CFLAGS"
+ LDFLAGS="$LDFLAGS"
+ LN="ln -sf"
+ OSNAME="Adelie Linux"
+ UTF8_LOCALE=C.UTF-8
+
+ BUILD_CATMAN=1
+ BUILD_CGI=1
+ EOF
+
+ cat >"cgi.h" <<-EOF
+ #define SCRIPT_NAME ""
+ #define MAN_DIR "/var/lib/mandoc-cgi"
+ #define CSS_DIR ""
+ #define CUSTOMIZE_TITLE "Adelie Linux manual pages"
+ EOF
+}
+
+build() {
+ ./configure
+ make
+}
+
+check() {
+ make regress
+}
+
+package() {
+ make DESTDIR="$pkgdir" install
+ install -Dm644 -t "$pkgdir"/usr/share/man/man8 man.cgi.8
+
+ mkdir -p "$pkgdir"/etc
+ cat >"$pkgdir"/etc/man.conf <<-EOF
+ # See man.conf(5).
+ #manpath /usr/share/man
+ #manpath /usr/local/share/man
+ EOF
+}
+
+cgi() {
+ pkgdesc="$pkgdesc (web interface)"
+ depends="$pkgname=$pkgver-r$pkgrel"
+ mkdir -p "$subpkgdir"/var/lib
+ mv "$pkgdir"/var/lib/mandoc-cgi \
+ "$subpkgdir"/var/lib
+}
+
+sha512sums="54286070812a47b629f68757046d3c9a1bdd2b5d1c3b84a5c8e4cb92f1331afa745443f7238175835d8cfbe5b8dd442e00c75c3a5b5b8f8efd8d2ec8f636dad4 mandoc-1.14.6.tar.gz
+08d11f7f0ae66e1630796d928c3906914f4133906928f74b93a1b08207484d16d412577ed739a920cd87abcec720b69fe121da1338a59d2580b978feadeedf32 configure.patch
+dac7b07cff35899b004a334e2926662647da274f7a946ccbc5131e8dd81e32e14073dc93110410baa183da1ffcc53b653c415d89071a1bd941dbf0e88091dee0 less.patch
+c7e3afdf9c9a3c51237e860841902074e17e143433f314961b6f804b7b3a0f176855648180dd9a836848b1c54506344b09dab3577dea58e2ddf5bf5915196419 doc.patch
+098af21312c4acdec33b5817a60f3ed5e91685fc225ec051ad5326d8df3f5ab52a4725d30d52a3fef580de7e7d7ff16e8e7352b9d387edbea56dd816b04e3f19 cgi-adelie.patch
+957bbaef888fb2ea15f9b795b15952332e65aed70d2e70f3142305a4fb9313ade455eae6dfc923af3ef008834e771b1a85d71389b86cd0ff9a1c31e84fef861c cgi-gz.patch
+be7d734ceb436764ad9bd23ac8c4c4b486ad88521e54302524aeb3fc00b4f27939a19495c920ed1be1f82c58fcc72bbb930757a2ac5ad99532929b3e6b3d7d77 cgi-search.patch"
diff --git a/system/mandoc/cgi-adelie.patch b/system/mandoc/cgi-adelie.patch
new file mode 100644
index 000000000..fff862240
--- /dev/null
+++ b/system/mandoc/cgi-adelie.patch
@@ -0,0 +1,62 @@
+Adjustments for Adélie manual sections and architecture names.
+
+--- mandoc-1.14.5/cgi.c 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/cgi.c 2020-06-05 15:54:05.681060852 -0500
+@@ -101,38 +101,28 @@ static const char *scriptname = SCRIPT_
+
+ static const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9};
+ static const char *const sec_numbers[] = {
+- "0", "1", "2", "3", "3p", "4", "5", "6", "7", "8", "9"
++ "0", "0p", "1", "1p", "2", "3", "3p", "3pm", "4", "5", "6", "7", "8"
+ };
+ static const char *const sec_names[] = {
+ "All Sections",
++ "0p - POSIX C Headers",
+ "1 - General Commands",
++ "1p - POSIX Commands",
+ "2 - System Calls",
+ "3 - Library Functions",
+- "3p - Perl Library",
++ "3p - POSIX C Library Functions",
++ "3pm - Perl Library",
+ "4 - Device Drivers",
+- "5 - File Formats",
++ "5 - File formats and configuration files",
+ "6 - Games",
+- "7 - Miscellaneous Information",
+- "8 - System Manager\'s Manual",
+- "9 - Kernel Developer\'s Manual"
++ "7 - Overview, conventions, and miscellaneous",
++ "8 - System Administrator\'s Manual"
+ };
+ static const int sec_MAX = sizeof(sec_names) / sizeof(char *);
+
+ static const char *const arch_names[] = {
+- "amd64", "alpha", "armv7", "arm64",
+- "hppa", "i386", "landisk", "loongson",
+- "luna88k", "macppc", "mips64", "octeon",
+- "powerpc64", "riscv64", "sparc64",
+-
+- "amiga", "arc", "armish", "arm32",
+- "atari", "aviion", "beagle", "cats",
+- "hppa64", "hp300",
+- "ia64", "mac68k", "mvme68k", "mvme88k",
+- "mvmeppc", "palm", "pc532", "pegasos",
+- "pmax", "powerpc", "sgi", "socppc",
+- "solbourne", "sparc",
+- "sun3", "vax", "wgrisc", "x68k",
+- "zaurus"
++ "aarch64", "armv7", "pmmx",
++ "ppc", "ppc64", "x86_64",
+ };
+ static const int arch_MAX = sizeof(arch_names) / sizeof(char *);
+
+@@ -655,7 +661,7 @@ pg_searchres(const struct req *req, stru
+ == NULL) ? 3 :
+ ((archend = strchr(arch + 1, '/'))
+ == NULL) ? 0 :
+- strncmp(arch, "amd64/",
++ strncmp(arch, "ppc64/",
+ archend - arch) ? 2 : 1;
+ if (archprio < archpriouse) {
+ archpriouse = archprio;
diff --git a/system/mandoc/cgi-gz.patch b/system/mandoc/cgi-gz.patch
new file mode 100644
index 000000000..ac506b797
--- /dev/null
+++ b/system/mandoc/cgi-gz.patch
@@ -0,0 +1,77 @@
+Handle the case where some of the entries in the manpath are gzipped by
+removing the .gz extension and allowing mparse_open to add it back and
+mark the page as gzipped. This is part of the documented contract for
+mparse_open, see mandoc(3).
+
+--- mandoc-1.14.5/cgi.c 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/cgi.c 2020-06-05 15:54:05.681060852 -0500
+@@ -93,7 +93,7 @@ static void resp_searchform(const stru
+ static void resp_show(const struct req *, const char *);
+ static void set_query_attr(char **, char **);
+ static int validate_arch(const char *);
+-static int validate_filename(const char *);
++static int validate_filename(char *);
+ static int validate_manpath(const struct req *, const char *);
+ static int validate_urifrag(const char *);
+
+@@ -517,8 +509,13 @@ validate_arch(const char *arch)
+ }
+
+ static int
+-validate_filename(const char *file)
++validate_filename(char *file)
+ {
++ char *cp;
++
++ cp = strrchr(file, '.');
++ if (cp != NULL && ! strcmp(cp + 1, "gz"))
++ *cp = '\0';
+
+ if ('.' == file[0] && '/' == file[1])
+ file += 2;
+@@ -854,14 +862,15 @@ resp_format(const struct req *req, const
+ int fd;
+ int usepath;
+
+- if (-1 == (fd = open(file, O_RDONLY, 0))) {
+- puts("<p>You specified an invalid manual file.</p>");
+- return;
+- }
+-
+ mchars_alloc();
+ mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1 |
+ MPARSE_VALIDATE, MANDOC_OS_OTHER, req->q.manpath);
++
++ if (-1 == (fd = mparse_open(mp, file))) {
++ puts("<p>You specified an invalid manual file.</p>");
++ goto out;
++ }
++
+ mparse_readfd(mp, fd, file);
+ close(fd);
+ meta = mparse_result(mp);
+@@ -882,10 +891,11 @@ resp_format(const struct req *req, const
+ html_man(vp, meta);
+
+ html_free(vp);
+- mparse_free(mp);
+- mchars_free();
+ free(conf.man);
+ free(conf.style);
++out:
++ mparse_free(mp);
++ mchars_free();
+ }
+
+ static void
+@@ -904,8 +914,8 @@ resp_show(const struct req *req, const c
+ static void
+ pg_show(struct req *req, const char *fullpath)
+ {
+- char *manpath;
+- const char *file;
++ char *manpath;
++ char *file;
+
+ if ((file = strchr(fullpath, '/')) == NULL) {
+ pg_error_badrequest(
diff --git a/system/mandoc/cgi-search.patch b/system/mandoc/cgi-search.patch
new file mode 100644
index 000000000..387e25dbd
--- /dev/null
+++ b/system/mandoc/cgi-search.patch
@@ -0,0 +1,48 @@
+Don't exit immediately if mansearch returns some paths that man.cgi
+considers invalid, in particular translated manpages (e.g.
+./de/man1/chfn.1). Just mark them as invalid (section 10, see struct
+manpage in mansearch.h) and skip them later.
+
+--- mandoc-1.14.5/cgi.c 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/cgi.c 2020-06-05 15:54:05.681060852 -0500
+@@ -605,13 +602,20 @@ pg_searchres(const struct req *req, stru
+ size_t i, iuse;
+ int archprio, archpriouse;
+ int prio, priouse;
++ int results = 0;
+
+ for (i = 0; i < sz; i++) {
+- if (validate_filename(r[i].file))
++ if (validate_filename(r[i].file)) {
++ results = 1;
+ continue;
++ }
+ warnx("invalid filename %s in %s database",
+ r[i].file, req->q.manpath);
+- pg_error_internal();
++ r[i].sec = 10;
++ }
++
++ if (! results) {
++ pg_noresult(req, 404, "Not Found", "No results found.");
+ return;
+ }
+
+@@ -642,6 +646,8 @@ pg_searchres(const struct req *req, stru
+ priouse = 20;
+ archpriouse = 3;
+ for (i = 0; i < sz; i++) {
++ if (r[i].sec == 10)
++ continue;
+ sec = r[i].file;
+ sec += strcspn(sec, "123456789");
+ if (sec[0] == '\0')
+@@ -681,6 +687,8 @@ pg_searchres(const struct req *req, stru
+ if (sz > 1) {
+ puts("<table class=\"results\">");
+ for (i = 0; i < sz; i++) {
++ if (r[i].sec == 10)
++ continue;
+ printf(" <tr>\n"
+ " <td>"
+ "<a class=\"Xr\" href=\"/");
diff --git a/system/mandoc/configure.patch b/system/mandoc/configure.patch
new file mode 100644
index 000000000..ba26b53d5
--- /dev/null
+++ b/system/mandoc/configure.patch
@@ -0,0 +1,10 @@
+--- mandoc-1.14.5/test-recvmsg.c 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/test-recvmsg.c 2020-06-04 20:08:33.420299034 -0500
+@@ -4,5 +4,6 @@
+ int
+ main(void)
+ {
+- return recvmsg(-1, NULL, 0) != -1;
++ struct msghdr buf;
++ return recvmsg(-1, &buf, 0) != -1;
+ }
diff --git a/system/mandoc/doc.patch b/system/mandoc/doc.patch
new file mode 100644
index 000000000..09b1f93d9
--- /dev/null
+++ b/system/mandoc/doc.patch
@@ -0,0 +1,132 @@
+--- mandoc-1.14.5/mandoc.1 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/mandoc.1 2020-06-05 02:12:50.320533119 -0500
+@@ -1016,7 +1016,7 @@ An
+ When running with
+ .Fl W Cm base ,
+ the search is restricted to the base system, by default to
+-.Pa /usr/share/man : Ns Pa /usr/X11R6/man .
++.Pa /usr/share/man .
+ This path can be configured at compile time using the
+ .Dv MANPATH_BASE
+ preprocessor macro.
+--- mandoc-1.14.5/mandoc.db.5 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/mandoc.db.5 2020-06-05 02:14:48.380534383 -0500
+@@ -189,10 +189,6 @@ followed by the number 0.
+ .Bl -tag -width /usr/share/man/mandoc.db -compact
+ .It Pa /usr/share/man/mandoc.db
+ The manual page database for the base system.
+-.It Pa /usr/X11R6/man/mandoc.db
+-The same for the
+-.Xr X 7
+-Window System.
+ .It Pa /usr/local/man/mandoc.db
+ The same for
+ .Xr packages 7 .
+--- mandoc-1.14.5/man.conf.5 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/man.conf.5 2020-06-05 02:11:34.650532308 -0500
+@@ -117,7 +117,6 @@ installing it is equivalent to not havin
+ file at all.
+ .Bd -literal -offset indent
+ manpath /usr/share/man
+-manpath /usr/X11R6/man
+ manpath /usr/local/man
+ .Ed
+ .Sh SEE ALSO
+
+--- mandoc-1.14.5/man.1 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/man.1 2020-06-05 02:51:15.910557811 -0500
+@@ -174,28 +174,32 @@ Only select manuals from the specified
+ The currently available sections are:
+ .Pp
+ .Bl -tag -width "localXXX" -offset indent -compact
++.It 0p
++POSIX C headers.
+ .It 1
+ General commands
+ .Pq tools and utilities .
++.It 1p
++POSIX commands.
+ .It 2
+ System calls and error numbers.
+ .It 3
+ Library functions.
+ .It 3p
++POSIX C library functions.
++.It 3pm
+ .Xr perl 1
+ programmer's reference guide.
+ .It 4
+ Device drivers.
+ .It 5
+-File formats.
++File formats and configuration files.
+ .It 6
+ Games.
+ .It 7
+-Miscellaneous information.
++Overview, conventions, and miscellaneous information.
+ .It 8
+ System maintenance and operation commands.
+-.It 9
+-Kernel internals.
+ .El
+ .Pp
+ If not specified and a match is found in more than one section,
+--- mandoc-1.14.5/man.cgi.8 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/man.cgi.8 2020-06-05 16:26:12.541081488 -0500
+@@ -342,7 +342,7 @@ page to acquire the named parameters it
+ .El
+ .Sh FILES
+ .Bl -tag -width Ds
+-.It Pa /var/www
++.It Pa /var/lib/mandoc-cgi
+ Default web server
+ .Xr chroot 2
+ directory.
+@@ -366,13 +366,7 @@ This is part of the web server configura
+ A style sheet for
+ .Xr mandoc 1
+ HTML styling, referenced from each generated HTML page.
+-.It Pa /man
+-Default
+-.Nm
+-data directory containing all the manual trees.
+-Can be overridden by
+-.Dv MAN_DIR .
+-.It Pa /man/manpath.conf
++.It Pa /manpath.conf
+ The list of available manpaths, one per line.
+ If any of the lines in this file contains a slash
+ .Pq Sq /
+@@ -380,13 +374,13 @@ or any character not contained in the
+ .Sx Restricted character set ,
+ .Nm
+ reports an internal server error and exits without doing anything.
+-.It Pa /man/header.html
++.It Pa /header.html
+ An optional file containing static HTML code to be inserted right
+ after opening the <BODY> element.
+-.It Pa /man/footer.html
++.It Pa /footer.html
+ An optional file containing static HTML code to be inserted right
+ before closing the <BODY> element.
+-.It Pa /man/OpenBSD-current/man1/mandoc.1
++.It Pa /OpenBSD-current/man1/mandoc.1
+ An example
+ .Xr mdoc 7
+ source file located below the
+--- mandoc-1.14.5/soelim.1 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/soelim.1 2020-06-05 16:38:40.101089494 -0500
+@@ -25,10 +25,10 @@
+ .\" SUCH DAMAGE.
+ .\"
+ .Dd $Mdocdate: July 4 2017 $
+-.Dt SOELIM 1
++.Dt MANDOC-SOELIM 1
+ .Os
+ .Sh NAME
+-.Nm soelim
++.Nm mandoc-soelim
+ .Nd interpret .so requests in manpages
+ .Sh SYNOPSIS
+ .Nm
diff --git a/system/mandoc/less.patch b/system/mandoc/less.patch
new file mode 100644
index 000000000..51f79c453
--- /dev/null
+++ b/system/mandoc/less.patch
@@ -0,0 +1,45 @@
+Default to using less(1) instead of more(1) if MANPAGER and PAGER are
+unset, and also set a pretty prompt and smart case searching like man-db
+does if less is used as a pager.
+
+The name of the manpage is not available in the scope of the patched
+function - maybe add it at some point.
+
+--- mandoc-1.14.5/main.c 2019-03-10 04:56:43.000000000 -0500
++++ mandoc-1.14.5/main.c 2020-06-05 01:59:10.640524340 -0500
+@@ -1316,11 +1316,25 @@ spawn_pager(struct tag_files *tag_files)
+ /* For less(1), use the tag file. */
+
+ use_ofn = 1;
+-#if HAVE_LESS_T
+ if (*outst->tag_files->tfn != '\0' &&
+ (cmdlen = strlen(argv[0])) >= 4) {
+ cp = argv[0] + cmdlen - 4;
+ if (strcmp(cp, "less") == 0) {
++ /*
++ * Set a few options like man-db does.
++ * -i: smart case search
++ * -mPm: set prompt to following string terminated by $
++ */
++ argv[argc++] = "-imPm" \
++ " Manual page" \
++ /*
++ * print " (END)" if EOF, else % in file followed by % sign.
++ * ?X if X:else not X.
++ */
++ "?e (END):?pB %pB\\%.. " \
++ "(press h for help or q to quit)" \
++ "$";
++#if HAVE_LESS_T
+ argv[argc++] = mandoc_strdup("-T");
+ argv[argc++] = outst->tag_files->tfn;
+ if (tag_files->tagname != NULL) {
+@@ -1327,7 +1342,7 @@ spawn_pager(struct tag_files *tag_files)
+ argv[argc++] = tag_target;
+ use_ofn = 0;
+ }
++#endif
+ }
+ }
+-#endif
+ if (use_ofn) {
diff --git a/system/mandoc/mandoc.post-deinstall b/system/mandoc/mandoc.post-deinstall
new file mode 100644
index 000000000..0a8d5b9df
--- /dev/null
+++ b/system/mandoc/mandoc.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec rm -f /usr/share/man/mandoc.db 2>/dev/null
diff --git a/system/mandoc/mandoc.trigger b/system/mandoc/mandoc.trigger
new file mode 100644
index 000000000..d8ffe7102
--- /dev/null
+++ b/system/mandoc/mandoc.trigger
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec makewhatis -T utf8