git: d110fac03fba - main - deskutils/freeplane: Fix Unable to launch freeplane

From: Loïc Bartoletti <lbartoletti_at_FreeBSD.org>
Date: Mon, 10 Jan 2022 21:33:45 UTC
The branch main has been updated by lbartoletti:

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

commit d110fac03fba6114a8ad47a3ed45d9674afcc50e
Author:     Loïc Bartoletti <lbartoletti@FreeBSD.org>
AuthorDate: 2022-01-05 06:17:59 +0000
Commit:     Loïc Bartoletti <lbartoletti@FreeBSD.org>
CommitDate: 2022-01-10 20:32:39 +0000

    deskutils/freeplane: Fix Unable to launch freeplane
    
    Fix a typo in the launch script and add bash as a dependency.
    Create a new launch script.
    
    PR:             260753
    Reported by:    chris@crvintel.com
---
 deskutils/freeplane/Makefile                 | 15 ++++++-----
 deskutils/freeplane/files/freeplane.in       |  3 +++
 deskutils/freeplane/files/patch-freeplane.sh | 39 ++++++++++++++++++----------
 3 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/deskutils/freeplane/Makefile b/deskutils/freeplane/Makefile
index 9c419e217bc4..5c27da51e00c 100644
--- a/deskutils/freeplane/Makefile
+++ b/deskutils/freeplane/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	freeplane
 DISTVERSION=	1.9.12
+PORTREVISION=	1
 CATEGORIES=	deskutils editors java
 MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}%20stable/archive/${PORTVERSION}
 DISTNAME=	${PORTNAME}_bin-${PORTVERSION}
@@ -12,8 +13,10 @@ COMMENT=	Free mind mapping and knowledge management software
 LICENSE=	GPLv2+
 LICENSE_FILE=	${WRKSRC}/license.txt
 
-USES=		cpe zip
+RUN_DEPENDS=	bash:shells/bash
 
+USES=		cpe zip shebangfix
+SHEBANG_FILES=	${WRKSRC}/freeplane.sh
 USE_JAVA=	yes
 NO_ARCH=	yes
 NO_BUILD=	yes
@@ -23,10 +26,10 @@ WRKSRC=		${WRKDIR}/${PORTNAME}-${PORTVERSION}
 
 do-install:
 	cd ${WRKSRC} && ${COPYTREE_SHARE} . ${STAGEDIR}${DATADIR} \
-		"! ( -name freeplane\.sh* -or -name license\.txt -or -name *\.bat -or -name *\.exe )"
-# Install freeplane.sh with the right permission, link to it to bin/
-# and let it resolve the path to DATADIR automatically.
-	${INSTALL_SCRIPT} ${WRKSRC}/freeplane.sh ${STAGEDIR}${DATADIR}
-	${RLN} ${STAGEDIR}${DATADIR}/freeplane.sh ${STAGEDIR}${PREFIX}/bin/freeplane
+		"! ( -name license\.txt -or -name *\.bat -or -name *\.exe )"
+# Install freeplane.sh with the right permission
+	${SED} -e 's|%%DATADIR%%|${DATADIR}|' < ${FILESDIR}/freeplane.in > \
+		${WRKSRC}/freeplane
+	${INSTALL_SCRIPT} ${WRKSRC}/freeplane ${STAGEDIR}${PREFIX}/bin/
 
 .include <bsd.port.mk>
diff --git a/deskutils/freeplane/files/freeplane.in b/deskutils/freeplane/files/freeplane.in
new file mode 100644
index 000000000000..979424a424e4
--- /dev/null
+++ b/deskutils/freeplane/files/freeplane.in
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec /bin/sh %%DATADIR%%/freeplane.sh
diff --git a/deskutils/freeplane/files/patch-freeplane.sh b/deskutils/freeplane/files/patch-freeplane.sh
index 481f3fed5aa8..02e1cf4c65a2 100644
--- a/deskutils/freeplane/files/patch-freeplane.sh
+++ b/deskutils/freeplane/files/patch-freeplane.sh
@@ -1,17 +1,28 @@
---- freeplane.sh.orig	2018-01-07 18:16:56 UTC
+--- freeplane.sh.orig	2022-01-05 06:17:27 UTC
 +++ freeplane.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/bin/sh
+@@ -57,7 +57,7 @@ findjava() {
+ 		fi
+ 	fi
  
- # we only want to test the script, not Freeplane itself
- if ( echo "${DEBUG}" | grep -qe "script" ); then
-@@ -123,7 +123,7 @@ if [ -x $(which readlink) ] && [ "`echo $OSTYPE | cut 
- 	# if we have 'readlink' we can use it to get an absolute path
- 	# -m should be faster and link does always resolve, else this script
- 	# wouldn't be called, would it?
+-	JAVA_VERSION=$(${JAVACMD} -version |& grep -E "[[:alnum:]]+ version" | awk '{print $3}' | tr -d '"')
++	JAVA_VERSION=$(${JAVACMD} -version | grep -E "[[:alnum:]]+ version" | awk '{print $3}' | tr -d '"')
+ 	JAVA_MAJOR_VERSION=$(echo $JAVA_VERSION | awk -F. '{print $1}')
+ 	if [ $JAVA_MAJOR_VERSION -ge 16 ]; then
+ 		if [ -z "${FREEPLANE_USE_UNSUPPORTED_JAVA_VERSION}" ]; then
+@@ -142,15 +142,7 @@ fi
+ 
+ output_debug_info
+ 
+-if [ -x $(which readlink) ] && [ "`echo $OSTYPE | cut -b1-6`" != "darwin" ]; then
+-	# if we have 'readlink' we can use it to get an absolute path
+-	# -m should be faster and link does always resolve, else this script
+-	# wouldn't be called, would it?
 -	freefile=$(readlink -mn "$0")
-+	freefile=$(readlink -fn "$0")
- 	_debug "Link '$0' resolved to '${freefile}'."
- else
- 	freefile="$0"
+-	_debug "Link '$0' resolved to '${freefile}'."
+-else
+-	freefile="$0"
+-fi
++freefile="$0"
+ 
+ if [ "`echo $OSTYPE | cut -b1-6`" == "darwin" ]; then
+ 	xdockname='-Xdock:name=Freeplane'