public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: app-text/docbook-sgml-utils/files/, app-text/docbook-sgml-utils/
@ 2024-03-05  4:48 Sam James
  0 siblings, 0 replies; only message in thread
From: Sam James @ 2024-03-05  4:48 UTC (permalink / raw
  To: gentoo-commits

commit:     c540a31ca37a285140485fd37173120a97f4a56c
Author:     Eli Schwartz <eschwartz93 <AT> gmail <DOT> com>
AuthorDate: Mon Mar  4 23:43:06 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Mar  5 04:46:44 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c540a31c

app-text/docbook-sgml-utils: drop dependency on "which"

Patch it to use command -v instead. No upstream remaining to forward the
patch to.

Bug: https://bugs.gentoo.org/102464
Signed-off-by: Eli Schwartz <eschwartz93 <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../docbook-sgml-utils-0.6.14-r6.ebuild            | 76 ++++++++++++++++++
 ...m-1998-style-which-progname-lookup-to-com.patch | 90 ++++++++++++++++++++++
 2 files changed, 166 insertions(+)

diff --git a/app-text/docbook-sgml-utils/docbook-sgml-utils-0.6.14-r6.ebuild b/app-text/docbook-sgml-utils/docbook-sgml-utils-0.6.14-r6.ebuild
new file mode 100644
index 000000000000..8a3acfb1438d
--- /dev/null
+++ b/app-text/docbook-sgml-utils/docbook-sgml-utils-0.6.14-r6.ebuild
@@ -0,0 +1,76 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools prefix
+
+MY_P=${PN/-sgml/}-${PV}
+DESCRIPTION="Shell scripts to manage DocBook documents"
+HOMEPAGE="https://sourceware.org/docbook-tools/"
+SRC_URI="https://sourceware.org/pub/docbook-tools/new-trials/SOURCES/${MY_P}.tar.gz"
+S=${WORKDIR}/${MY_P}
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
+IUSE="jadetex"
+
+DEPEND=">=dev-lang/perl-5
+	app-text/docbook-dsssl-stylesheets
+	app-text/docbook-xml-dtd:4.2
+	app-text/openjade
+	app-text/xhtml1
+	dev-perl/SGMLSpm
+	~app-text/docbook-sgml-dtd-3.0
+	~app-text/docbook-sgml-dtd-3.1
+	~app-text/docbook-sgml-dtd-4.0
+	~app-text/docbook-sgml-dtd-4.1
+	~app-text/docbook-sgml-dtd-4.2
+	~app-text/docbook-sgml-dtd-4.4
+	~app-text/docbook-xml-simple-dtd-1.0
+	~app-text/docbook-xml-simple-dtd-4.1.2.4
+	jadetex? ( dev-texlive/texlive-formatsextra )
+	|| (
+		www-client/lynx
+		www-client/links
+		www-client/elinks
+		virtual/w3m
+	)"
+RDEPEND="${DEPEND}"
+
+# including both xml-simple-dtd 4.1.2.4 and 1.0, to ease
+# transition to simple-dtd 1.0, <obz@gentoo.org>
+
+PATCHES=(
+	"${FILESDIR}"/${MY_P}-elinks.patch
+	"${FILESDIR}"/${P}-grep-2.7.patch
+
+	# drop dependency on sys-apps/which
+	"${FILESDIR}"/0001-Migrate-from-1998-style-which-progname-lookup-to-com.patch
+)
+
+src_prepare() {
+	default
+	if use prefix; then
+		eapply "${FILESDIR}"/${MY_P}-prefix.patch
+		eprefixify doc/{man,HTML}/Makefile.am bin/jw.in backends/txt configure.in
+		eautoreconf
+	fi
+}
+
+src_install() {
+	make DESTDIR="${D}" \
+		htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
+		install
+
+	if ! use jadetex; then
+		local i
+		for i in dvi pdf ps; do
+			rm "${ED}"/usr/bin/docbook2${i} || die
+			rm "${ED}"/usr/share/sgml/docbook/utils-${PV}/backends/${i} || die
+			rm "${ED}"/usr/share/man/man1/docbook2${i}.1 || die
+		done
+	fi
+	einstalldocs
+}

diff --git a/app-text/docbook-sgml-utils/files/0001-Migrate-from-1998-style-which-progname-lookup-to-com.patch b/app-text/docbook-sgml-utils/files/0001-Migrate-from-1998-style-which-progname-lookup-to-com.patch
new file mode 100644
index 000000000000..764d06ad4d78
--- /dev/null
+++ b/app-text/docbook-sgml-utils/files/0001-Migrate-from-1998-style-which-progname-lookup-to-com.patch
@@ -0,0 +1,90 @@
+From a5956fccad44bed98b5de22a6169e0aa098d169f Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwartz93@gmail.com>
+Date: Mon, 4 Mar 2024 18:16:32 -0500
+Subject: [PATCH] Migrate from 1998 style "which progname" lookup to command -v
+
+The "which" utility is not guaranteed to be installed either, and if it
+is, its behavior is not portable either. This means that when sgml tools
+are installed, the `which` check will report a fatal error because the
+which tool did not exist and the shell returned a nonzero status when
+attempting to fork+exec. If it did exist, it might not be an
+implementation of `which` that returns nonzero when commands do not
+exist.
+
+The general scripting suggestion is to use the "command -v" shell
+builtin that is required to exist in all POSIX 2008 compliant shells,
+and is thus guaranteed to work everywhere.
+
+For some in-depth discussions on the topic, see:
+- https://mywiki.wooledge.org/BashFAQ/081
+- https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then/85250#85250
+
+Examples of open-source shells likely to be installed as /bin/sh on
+Linux, which implement the 15-year-old standard: ash, bash, busybox,
+dash, ksh, mksh and zsh.
+
+However, in this case there's a pretty good exuse for not using a 2008
+standard. The docbook-utils project is dead since 2004. So we patch it
+(and scratch our heads about where to try sending patches).
+
+Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
+---
+ bin/jw.in | 16 ++++++----------
+ 1 file changed, 6 insertions(+), 10 deletions(-)
+
+diff --git a/bin/jw.in b/bin/jw.in
+index 4bfb312..82bd497 100644
+--- a/bin/jw.in
++++ b/bin/jw.in
+@@ -58,8 +58,7 @@ SGML_ERRORS_LIST="\n\
+ \040 no-valid \t Do not require the document to be type-valid"
+ 
+ # Get name of main SGML configuration file
+-which sgmlwhich >/dev/null 2>/dev/null
+-if [ $? -eq 0 ]
++if command -v sgmlwhich >/dev/null
+ then
+   SGML_CONF=`sgmlwhich`
+ else
+@@ -296,10 +295,10 @@ fi
+ # Try to find the SGML normalizer
+ if [ -z "$SGML_NORM" ]
+ then
+-  SGML_NORM=`which sgmlnorm 2>/dev/null`
++  SGML_NORM=`command -v sgmlnorm`
+   if [ -z "SGML_NORM" ]
+   then
+-    SGML_NORM=`which osgmlnorm 2>/dev/null`
++    SGML_NORM=`command -v osgmlnorm`
+   fi
+ fi
+ 
+@@ -376,13 +375,11 @@ esac
+ # Choose a parser
+ if [ -z "$SGML_JADE" ]
+ then
+-  which jade >/dev/null 2>/dev/null
+-  if [ $? -eq 0 ]
++  if command -v jade >/dev/null
+   then
+     SGML_JADE="jade"
+   else
+-    which openjade >/dev/null 2>/dev/null
+-    if [ $? -eq 0 ]
++    if command -v openjade >/dev/null
+     then 
+       SGML_JADE="openjade"
+     else
+@@ -391,8 +388,7 @@ then
+     fi
+   fi
+ else
+-  which $SGML_JADE >/dev/null 2>/dev/null
+-  if [ $? -ne 0 ]
++  if ! command -v $SGML_JADE >/dev/null
+   then 
+     echo "`basename $0`: parser $SGML_JADE is not available" >&2
+     exit 6
+-- 
+2.43.0
+


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-05  4:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-05  4:48 [gentoo-commits] repo/gentoo:master commit in: app-text/docbook-sgml-utils/files/, app-text/docbook-sgml-utils/ Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox