Subject: [alpine-aports] [PATCH 1/3] main/mdocml: modernize abuild and explicitly set UTF8_LOCALE

From: Daniel Sabogal <[email-masked]>
Date: Tue, 1 Aug 2017 16:18:40 -0400

The configure script depends on the locale(1) utility to select a
UTF-8 encoding to test. This utility is not available.
---
 main/mdocml/APKBUILD | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/main/mdocml/APKBUILD b/main/mdocml/APKBUILD
index 9e5537a6dc..facc8a0eaf 100644
--- a/main/mdocml/APKBUILD
+++ b/main/mdocml/APKBUILD
@@ -1,13 +1,14 @@
 # Maintainer:  Natanael Copa <[email-masked]>
 pkgname=mdocml
 pkgver=1.14.1
-pkgrel=0
+pkgrel=1
 pkgdesc="mdoc/man compiler"
 url="http://mdocml.bsd.lv/"
 arch="all"
 license="BSD"
 depends=""
 makedepends="zlib-dev"
+checkdepends="perl"
 install="$pkgname.post-deinstall"
 triggers="$pkgname-apropos.trigger=/usr/share/man/*"
 subpackages="$pkgname-doc $pkgname-dev man::noarch $pkgname-apropos $pkgname-soelim"
@@ -18,32 +19,39 @@ source="http://mdocml.bsd.lv/snapshots/$pkgname-$pkgver.tar.gz
 	man.conf
 	"
 
-builddir="$srcdir"/$pkgname-$pkgver
+builddir="$srcdir/$pkgname-$pkgver"
 prepare() {
-	default_prepare || return 1
+	default_prepare
+
 	cd "$builddir"
 	cat >configure.local<<EOF
 PREFIX=/usr
 MANDIR=/usr/share/man
 LIBDIR=/usr/lib
 CFLAGS="$CFLAGS"
+UTF8_LOCALE="en_US.UTF-8"
 EOF
 }
 
 build() {
 	cd "$builddir"
-	./configure || return 1
-	make || return 1
+	./configure
+	make
+}
+
+check() {
+	cd "$builddir"
+	LD_LIBRARY_PATH="$builddir" make regress
 }
 
 package() {
 	cd "$builddir"
-	make -j1 DESTDIR="$pkgdir" base-install lib-install || return 1
-	install -Dm644 "$srcdir"/man.conf "$pkgdir"/etc/man.conf || return 1
+	make -j1 DESTDIR="$pkgdir" base-install lib-install
+	install -Dm644 "$srcdir"/man.conf "$pkgdir"/etc/man.conf
 	for X in usr/bin/apropos usr/bin/whatis usr/bin/man usr/sbin/makewhatis
 		do
-			rm -f "$pkgdir/$X" || return 1
-			ln -s /usr/bin/mandoc "$pkgdir/$X" || return 1
+			rm -f "$pkgdir/$X"
+			ln -s /usr/bin/mandoc "$pkgdir/$X"
 		done
 }
 
@@ -58,9 +66,9 @@ apropos() {
 	mkdir -p "$subpkgdir"/usr/sbin "$subpkgdir"/usr/bin
 	mv "$pkgdir"/usr/bin/apropos \
 		"$pkgdir"/usr/bin/whatis \
-		"$subpkgdir"/usr/bin/ || return 1
+		"$subpkgdir"/usr/bin/
 	mv "$pkgdir"/usr/sbin/makewhatis \
-		"$subpkgdir"/usr/sbin/ || return 1
+		"$subpkgdir"/usr/sbin/
 }
 
 soelim() {
@@ -68,7 +76,7 @@ soelim() {
 	depends=""
 	mkdir -p "$subpkgdir"/usr/bin
 	mv "$pkgdir"/usr/bin/soelim \
-		"$subpkgdir"/usr/bin/ || return 1
+		"$subpkgdir"/usr/bin/
 }
 
 sha512sums="90f00297d162faa404fe4e530f95422c210b8d23a0be5a115c2c8c17255d366e224444901842affb06ed8aaf8febd3e5c79966ff713fa7daf00e8c48b7a857c6  mdocml-1.14.1.tar.gz
-- 
2.13.3

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Daniel Sabogal <[email-masked]>
Date: Tue, 1 Aug 2017 16:18:41 -0400

Include upstream patch that fixes an out-of-bounds read.
This can be triggered with mount(8) from util-linux.
---
 main/mdocml/APKBUILD               | 15 +++++++++------
 main/mdocml/man_term-fix.patch     | 26 ++++++++++++++++++++++++++
 main/mdocml/shared-libmandoc.patch | 35 ++++++++++++++---------------------
 3 files changed, 49 insertions(+), 27 deletions(-)
 create mode 100644 main/mdocml/man_term-fix.patch

diff --git a/main/mdocml/APKBUILD b/main/mdocml/APKBUILD
index facc8a0eaf..90ffcc4911 100644
--- a/main/mdocml/APKBUILD
+++ b/main/mdocml/APKBUILD
@@ -1,7 +1,8 @@
 # Maintainer:  Natanael Copa <[email-masked]>
 pkgname=mdocml
-pkgver=1.14.1
-pkgrel=1
+_pkgname=mandoc
+pkgver=1.14.2
+pkgrel=0
 pkgdesc="mdoc/man compiler"
 url="http://mdocml.bsd.lv/"
 arch="all"
@@ -12,14 +13,15 @@ checkdepends="perl"
 install="$pkgname.post-deinstall"
 triggers="$pkgname-apropos.trigger=/usr/share/man/*"
 subpackages="$pkgname-doc $pkgname-dev man::noarch $pkgname-apropos $pkgname-soelim"
-source="http://mdocml.bsd.lv/snapshots/$pkgname-$pkgver.tar.gz
+source="http://mdocml.bsd.lv/snapshots/$_pkgname-$pkgver.tar.gz
 	shared-libmandoc.patch
 	pager.patch
+	man_term-fix.patch
 	mdocml-apropos.trigger
 	man.conf
 	"
 
-builddir="$srcdir/$pkgname-$pkgver"
+builddir="$srcdir/$_pkgname-$pkgver"
 prepare() {
 	default_prepare
 
@@ -79,8 +81,9 @@ soelim() {
 		"$subpkgdir"/usr/bin/
 }
 
-sha512sums="90f00297d162faa404fe4e530f95422c210b8d23a0be5a115c2c8c17255d366e224444901842affb06ed8aaf8febd3e5c79966ff713fa7daf00e8c48b7a857c6  mdocml-1.14.1.tar.gz
-ca0f68f6d3d67800eaae7649dacddd04b9159c636bc922840cdb30b741026e708a9527571af656b22642c83b2dc0f9cd9f0b83b43db7a64b0e15fb0654e935a6  shared-libmandoc.patch
+sha512sums="1691e4552b0417a30a3a546cff651665f8b4b3fbe2357c734546ca29c56eef9c971a6bd88daa170f4697fb50d14048138f4bc6f5ef55aa24a7ac03903d04c868  mandoc-1.14.2.tar.gz
+d127e635dfb54f9a88a28a8312f23495ec1e9356202e03ccfad1f7528f26f1cbfa7fc2c7b20c262523941d661fa7ba570a64a63c23f3e7fffc954d00bd5769c7  shared-libmandoc.patch
 04947a275df99298591c2a46fb81b74c7c3fcb9f3cf8fb718cf1e32eeae5409e90a3bca89e542f8aa1b30792e837fd3d716303a636d1a3ec165fbb9529546a64  pager.patch
+2d69ba396d05b2d1f0b91a3e31175f3a5bc306e334a341cd801b7b83a5cabf245a3f8228b5d7faded19e0c7d65bdfb31630613a9b780db49989599da0dbb3bfc  man_term-fix.patch
 704bc159acfc639e10c7d505372d303cb5784c8e9eb30084236ad89978978d4ba74f3127d4597d78594b64182c47a00c011f8bb3271d2b784f03a2a411ccb1d8  mdocml-apropos.trigger
 0723c32ab70e5b1c77768ca78d7437b26bed19b90b27876b10cc463359c41332befc0105fc1e23ceae48de5a892f1aa7ac60ef7eb0b6b8f1616726c4300632fe  man.conf"
diff --git a/main/mdocml/man_term-fix.patch b/main/mdocml/man_term-fix.patch
new file mode 100644
index 0000000000..0a5f435fb7
--- /dev/null
+++ b/main/mdocml/man_term-fix.patch
@@ -0,0 +1,26 @@
+--- mandoc-1.14.2/man_term.c.orig
++++ mandoc-1.14.2/man_term.c
+@@ -1,4 +1,4 @@
+-/*	$Id: man_term.c,v 1.208 2017/06/25 11:42:02 schwarze Exp $ */
++/*	$Id: man_term.c,v 1.209 2017/07/31 15:19:06 schwarze Exp $ */
+ /*
+  * Copyright (c) 2008-2012 Kristaps Dzonsons <[email-masked]>
+  * Copyright (c) 2010-2015, 2017 Ingo Schwarze <[email-masked]>
+@@ -673,7 +673,7 @@
+ 
+ 		do {
+ 			n = n->prev;
+-		} while (n != NULL && n->tok != TOKEN_NONE &&
++		} while (n != NULL && n->tok >= MAN_TH &&
+ 		    termacts[n->tok].flags & MAN_NOTEXT);
+ 		if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL))
+ 			break;
+@@ -735,7 +735,7 @@
+ 
+ 		do {
+ 			n = n->prev;
+-		} while (n != NULL && n->tok != TOKEN_NONE &&
++		} while (n != NULL && n->tok >= MAN_TH &&
+ 		    termacts[n->tok].flags & MAN_NOTEXT);
+ 		if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL))
+ 			break;
diff --git a/main/mdocml/shared-libmandoc.patch b/main/mdocml/shared-libmandoc.patch
index f01954fc94..819968ee6d 100644
--- a/main/mdocml/shared-libmandoc.patch
+++ b/main/mdocml/shared-libmandoc.patch
@@ -1,8 +1,8 @@
---- mdocml-1.14.1/Makefile.orig
-+++ mdocml-1.14.1/Makefile
-@@ -344,9 +344,13 @@
- WWW_OBJS	 = mdocml.tar.gz \
- 		   mdocml.sha256
+--- mandoc-1.14.2/Makefile.orig
++++ mandoc-1.14.2/Makefile
+@@ -347,9 +347,13 @@
+ 		   mdoc.h.html \
+ 		   roff.h.html
  
 +LIBMANDOC        = libmandoc.so
 +MANDOCLIB        = -L. -lmandoc
@@ -14,7 +14,7 @@
  
  # === DEPENDENCY HANDLING ==============================================
  
-@@ -369,7 +373,7 @@
+@@ -372,7 +376,7 @@
  	rm -f Makefile.local config.h config.h.old config.log config.log.old
  
  clean:
@@ -22,8 +22,8 @@
 +	rm -f $(LIBMANDOC) $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
  	rm -f mandoc $(MAIN_OBJS)
  	rm -f man.cgi $(CGI_OBJS)
- 	rm -f mandocd catman $(MANDOCD_OBJS)
-@@ -410,11 +414,11 @@
+ 	rm -f mandocd catman catman.o $(MANDOCD_OBJS)
+@@ -411,11 +415,11 @@
  	$(INSTALL_MAN) makewhatis.8 \
  		$(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
  
@@ -37,7 +37,7 @@
  	$(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
  		$(DESTDIR)$(INCLUDEDIR)
  	$(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
-@@ -487,26 +491,26 @@
+@@ -488,23 +492,23 @@
  	@echo "$@ is out of date; please run ./configure"
  	@exit 1
  
@@ -51,30 +51,23 @@
 +mandoc: $(MAIN_OBJS) $(LIBMANDOC)
 +	$(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) $(MANDOCLIB) $(LDADD)
  
--manpage: $(MANPAGE_OBJS) libmandoc.a
--	$(CC) -o $@ $(LDFLAGS) $(MANPAGE_OBJS) libmandoc.a $(LDADD)
-+manpage: $(MANPAGE_OBJS) $(LIBMANDOC)
-+	$(CC) -o $@ $(LDFLAGS) $(MANPAGE_OBJS) $(MANDOCLIB) $(LDADD)
- 
--man.cgi: $(CGI_OBJS) libmandoc.a
--	$(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
-+man.cgi: $(CGI_OBJS) $(LIBMANDOC)
-+	$(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) $(MANDOCLIB) $(LDADD)
+ man.cgi: $(CGI_OBJS) libmandoc.a
+ 	$(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
  
 -mandocd: $(MANDOCD_OBJS) libmandoc.a
 -	$(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
 +mandocd: $(MANDOCD_OBJS) $(LIBMANDOC)
-+	$(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) $(MANDOCLIB) $(LDADD)
++	$(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) $(LIBMANDOC) $(LDADD)
  
 -catman: catman.o libmandoc.a
 -	$(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
 +catman: catman.o $(LIBMANDOC)
-+	$(CC) -o $@ $(LDFLAGS) catman.o $(MANDOCLIB) $(LDADD)
++	$(CC) -o $@ $(LDFLAGS) catman.o $(LIBMANDOC) $(LDADD)
  
 -demandoc: $(DEMANDOC_OBJS) libmandoc.a
 -	$(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
 +demandoc: $(DEMANDOC_OBJS) $(LIBMANDOC)
-+	$(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) $(MANDOCLIB) $(LDADD)
++	$(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) $(LIBMANDOC) $(LDADD)
  
  soelim: $(SOELIM_OBJS)
  	$(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
-- 
2.13.3

---

---

From: Daniel Sabogal <[email-masked]>
Date: Tue, 1 Aug 2017 16:18:42 -0400

MANPATH_DEFAULT is recommended for operating system defaults.
man.conf is recommended for machine-specific defaults.

See http://mdocml.bsd.lv/NEWS
---
 main/mdocml/APKBUILD |  8 +++-----
 main/mdocml/man.conf | 55 ----------------------------------------------------
 2 files changed, 3 insertions(+), 60 deletions(-)
 delete mode 100644 main/mdocml/man.conf

diff --git a/main/mdocml/APKBUILD b/main/mdocml/APKBUILD
index 90ffcc4911..34da749486 100644
--- a/main/mdocml/APKBUILD
+++ b/main/mdocml/APKBUILD
@@ -2,7 +2,7 @@
 pkgname=mdocml
 _pkgname=mandoc
 pkgver=1.14.2
-pkgrel=0
+pkgrel=1
 pkgdesc="mdoc/man compiler"
 url="http://mdocml.bsd.lv/"
 arch="all"
@@ -18,7 +18,6 @@ source="http://mdocml.bsd.lv/snapshots/$_pkgname-$pkgver.tar.gz
 	pager.patch
 	man_term-fix.patch
 	mdocml-apropos.trigger
-	man.conf
 	"
 
 builddir="$srcdir/$_pkgname-$pkgver"
@@ -32,6 +31,7 @@ MANDIR=/usr/share/man
 LIBDIR=/usr/lib
 CFLAGS="$CFLAGS"
 UTF8_LOCALE="en_US.UTF-8"
+MANPATH_DEFAULT="/usr/share/man:/usr/local/man"
 EOF
 }
 
@@ -49,7 +49,6 @@ check() {
 package() {
 	cd "$builddir"
 	make -j1 DESTDIR="$pkgdir" base-install lib-install
-	install -Dm644 "$srcdir"/man.conf "$pkgdir"/etc/man.conf
 	for X in usr/bin/apropos usr/bin/whatis usr/bin/man usr/sbin/makewhatis
 		do
 			rm -f "$pkgdir/$X"
@@ -85,5 +84,4 @@ sha512sums="1691e4552b0417a30a3a546cff651665f8b4b3fbe2357c734546ca29c56eef9c971a
 d127e635dfb54f9a88a28a8312f23495ec1e9356202e03ccfad1f7528f26f1cbfa7fc2c7b20c262523941d661fa7ba570a64a63c23f3e7fffc954d00bd5769c7  shared-libmandoc.patch
 04947a275df99298591c2a46fb81b74c7c3fcb9f3cf8fb718cf1e32eeae5409e90a3bca89e542f8aa1b30792e837fd3d716303a636d1a3ec165fbb9529546a64  pager.patch
 2d69ba396d05b2d1f0b91a3e31175f3a5bc306e334a341cd801b7b83a5cabf245a3f8228b5d7faded19e0c7d65bdfb31630613a9b780db49989599da0dbb3bfc  man_term-fix.patch
-704bc159acfc639e10c7d505372d303cb5784c8e9eb30084236ad89978978d4ba74f3127d4597d78594b64182c47a00c011f8bb3271d2b784f03a2a411ccb1d8  mdocml-apropos.trigger
-0723c32ab70e5b1c77768ca78d7437b26bed19b90b27876b10cc463359c41332befc0105fc1e23ceae48de5a892f1aa7ac60ef7eb0b6b8f1616726c4300632fe  man.conf"
+704bc159acfc639e10c7d505372d303cb5784c8e9eb30084236ad89978978d4ba74f3127d4597d78594b64182c47a00c011f8bb3271d2b784f03a2a411ccb1d8  mdocml-apropos.trigger"
diff --git a/main/mdocml/man.conf b/main/mdocml/man.conf
deleted file mode 100644
index e96bb2f830..0000000000
--- a/main/mdocml/man.conf
+++ /dev/null
@@ -1,55 +0,0 @@
-#	$OpenBSD: man.conf,v 1.20 2014/02/24 20:11:53 espie Exp $
-
-# Sheer, raging paranoia...
-_version	BSD.2
-
-# The whatis/apropos database.
-_whatdb 	/usr/share/man/mandoc.db
-_whatdb 	/usr/local/share/man/mandoc.db
-
-# Subdirectories for paths ending in '/', IN SEARCH ORDER.
-_subdir		{cat,man}0p {cat,man}1 {cat,man}1p {cat,man}8 {cat,man}6 {cat,man}2 {cat,man}3 {cat,man}5 {cat,man}7 {cat,man}4 {cat,man}9 {cat,man}3p {cat,man}3f {cat,man}n
-
-# Files typed by suffix and their commands.
-_suffix		.0
-_build		.0.gz			/usr/bin/zcat %s
-_build		.[0-9n]			/usr/bin/mandoc -Tutf8 %s
-_build		.[0-9n].gz		/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
-_build		.[0-9][a-z]		/usr/bin/mandoc -Tutf8 %s
-_build		.[0-9][a-z].gz		/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
-_build		.[0-9][a-z][a-z]	/usr/bin/mandoc -Tutf8 %s
-_build		.[0-9][a-z][a-z].gz	/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
-_build		.[0-9][a-z][a-z][a-z]	/usr/bin/mandoc -Tutf8 %s
-_build		.[0-9][a-z][a-z][a-z].gz	/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
-_build		.tbl			/usr/bin/mandoc -Tutf8 %s
-_build		.tbl.gz			/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
-
-# Sections and their directories.
-# All paths ending in '/' are the equivalent of entries specifying that
-# directory with all of the subdirectories listed for the keyword _subdir.
-
-# default
-_default	/usr/{share,local/share}/man/
-
-# Other sections that represent complete man subdirectories.
-local		/usr/local/share/man/
-
-# Specific section/directory combinations.
-0p		/usr/{share,local/share}/man/{cat,man}0p
-1		/usr/{share,local/share}/man/{cat,man}1
-1p		/usr/{share,local/share}/man/{cat,man}1p
-2		/usr/{share,local/share}/man/{cat,man}2
-3		/usr/{share,local/share}/man/{cat,man}3
-3F		/usr/{share,local/share}/man/{cat,man}3f
-3f		/usr/{share,local/share}/man/{cat,man}3f
-3P		/usr/{share,local/share}/man/{cat,man}3p
-3p		/usr/{share,local/share}/man/{cat,man}3p
-3x		/usr/{share,local/share}/man/{cat,man}3
-3am		/usr/{share,local/share}/man/{cat,man}3
-4		/usr/{share,local/share}/man/{cat,man}4
-5		/usr/{share,local/share}/man/{cat,man}5
-6		/usr/{share,local/share}/man/{cat,man}6
-7		/usr/{share,local/share}/man/{cat,man}7
-8		/usr/{share,local/share}/man/{cat,man}8
-9		/usr/{share,local/share}/man/{cat,man}9
-n		/usr/{share,local/share}/man/{cat,man}n
-- 
2.13.3

---

---

From: Sören Tempel <[email-masked]>
Date: Thu, 3 Aug 2017 12:26:17 +0200

The patches have been applied. Thanks a lot!

Cheers,
Sören

---