git: 814f2b31f3b1 - main - textproc/saxon-he: Improve wrapper scripts

From: Matthias Andree <mandree_at_FreeBSD.org>
Date: Mon, 14 Jul 2025 11:38:26 UTC
The branch main has been updated by mandree:

URL: https://cgit.FreeBSD.org/ports/commit/?id=814f2b31f3b1bbbc86db6d29cfa58b65185f50fc

commit 814f2b31f3b1bbbc86db6d29cfa58b65185f50fc
Author:     Matthias Andree <mandree@FreeBSD.org>
AuthorDate: 2025-07-14 11:23:40 +0000
Commit:     Matthias Andree <mandree@FreeBSD.org>
CommitDate: 2025-07-14 11:38:18 +0000

    textproc/saxon-he: Improve wrapper scripts
    
    - make robust and put the literal string first in the script's
      IAM comparison so that in no case can it start with a dash
    - make efficient and use Makefile's :tsc (:ts:) transform to
      get classpath-ready colon-separated jars list without assembling
      it in the script each time.
        Else you could avoid adding the leading colon like so:
      SAXON_CLASSPATH="${SAXON_CLASSPATH}${SAXON_CLASSPATH:+:}${jarfile}"
    - install saxon-xquery as symlink instead of a copy
    - add saxon and saxon-xquery scripts to post-stage smoke test
    - bump PORTREVISION which was deferred from prior commit
    
    PR:             286764
---
 textproc/saxon-he/Makefile          | 10 ++++++----
 textproc/saxon-he/files/saxon.sh.in | 10 ++--------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/textproc/saxon-he/Makefile b/textproc/saxon-he/Makefile
index decab80302cb..b2ef13b8f515 100644
--- a/textproc/saxon-he/Makefile
+++ b/textproc/saxon-he/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	saxon-he
 DISTVERSION=	12-8
+PORTREVISION=	1
 CATEGORIES=	textproc java
 MASTER_SITES=	https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/releases/download/SaxonHE-${DISTVERSION}/
 DISTNAME=	SaxonHE${DISTVERSION}J
@@ -32,20 +33,21 @@ JARFILES2=	jline-2.14.6.jar \
 PLIST_FILES=	${JARFILES:S,^,%%JAVAJARDIR%%/,} ${SCRIPTFILES}
 
 SUB_FILES=	saxon.sh
-SUB_LIST=	SAXON_JARS="${JARFILES:S,^,${JAVAJARDIR}/,}"
+SUB_LIST=	SAXON_JARS="${JARFILES:S,^,${JAVAJARDIR}/,:ts:}"
 SCRIPTFILES=	bin/saxon bin/saxon-xquery
 
 do-install:
 	@${MKDIR} ${STAGEDIR}${JAVAJARDIR}
 	${INSTALL_DATA} ${JARFILES1:S,^,${WRKSRC}/,} ${STAGEDIR}${JAVAJARDIR}
 	${INSTALL_DATA} ${JARFILES2:S,^,${WRKSRC}/lib/,} ${STAGEDIR}${JAVAJARDIR}
-.for scriptfile in ${SCRIPTFILES}
-	${INSTALL_SCRIPT} ${WRKDIR}/saxon.sh ${STAGEDIR}${PREFIX}/${scriptfile}
-.endfor
+	${INSTALL_SCRIPT} ${WRKDIR}/saxon.sh ${STAGEDIR}${PREFIX}/bin/saxon
+	${RLN} ${STAGEDIR}${PREFIX}/bin/saxon ${STAGEDIR}${PREFIX}/bin/saxon-xquery
 
 post-stage:
 # smoke test so we're sure we can load all required classes
 # (12.0 and 12.6 didn't work with OpenJDK 8)
+	${STAGEDIR}${PREFIX}/bin/saxon-xquery -? 2>&1 | ${HEAD} -n1
+	${STAGEDIR}${PREFIX}/bin/saxon -? 2>&1 | ${HEAD} -n1
 	${JAVA} -cp '${STAGEDIR}${JAVAJARDIR}/*' net.sf.saxon.Transform -? 2>&1 \
 		| ${HEAD} -n1
 
diff --git a/textproc/saxon-he/files/saxon.sh.in b/textproc/saxon-he/files/saxon.sh.in
index 3cb3014693c0..8371776b80f2 100644
--- a/textproc/saxon-he/files/saxon.sh.in
+++ b/textproc/saxon-he/files/saxon.sh.in
@@ -2,17 +2,11 @@
 
 IAM="`basename "$0"`"
 
-if [ "${IAM}" = "saxon-xquery" ]
+if [ saxon-xquery = "${IAM}" ]
 then
 	LAUNCHER_CLASS="net.sf.saxon.Query"
 else
 	LAUNCHER_CLASS="net.sf.saxon.Transform"
 fi
 
-SAXON_CLASSPATH=""
-for jarfile in %%SAXON_JARS%%
-do
-	SAXON_CLASSPATH="${SAXON_CLASSPATH}:${jarfile}"
-done
-
-exec "%%LOCALBASE%%/bin/java" -classpath "${SAXON_CLASSPATH}" "${LAUNCHER_CLASS}" "$@"
+exec "%%LOCALBASE%%/bin/java" -classpath "%%SAXON_JARS%%" "${LAUNCHER_CLASS}" "$@"