git: 2b1e7456fbf4 - main - textproc/apache-solr9: make version 9 as extra port available

From: Matthias Fechner <mfechner_at_FreeBSD.org>
Date: Sun, 16 Oct 2022 07:13:09 UTC
The branch main has been updated by mfechner:

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

commit 2b1e7456fbf43223047cecdd2d95c5cf55926de5
Author:     Matthias Fechner <mfechner@FreeBSD.org>
AuthorDate: 2022-10-16 06:58:29 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2022-10-16 07:12:42 +0000

    textproc/apache-solr9: make version 9 as extra port available
    
    Version 9 has breaking changes which makes it impossible to do a simple
    upgrade.
    Using an extra ports makes sure to not break installation with
    solr version 8.
    Copied from b224cb40ad545da1f09dcf0d8bafb8baf0e1b110.
---
 textproc/Makefile                          |  1 +
 textproc/apache-solr9/Makefile             | 71 ++++++++++++++++++++++++++++++
 textproc/apache-solr9/distinfo             |  3 ++
 textproc/apache-solr9/files/patch-bin_solr | 31 +++++++++++++
 textproc/apache-solr9/files/pkg-message.in | 45 +++++++++++++++++++
 textproc/apache-solr9/files/solr.in        | 67 ++++++++++++++++++++++++++++
 textproc/apache-solr9/pkg-descr            |  5 +++
 7 files changed, 223 insertions(+)

diff --git a/textproc/Makefile b/textproc/Makefile
index 8f8304f24f79..b30b03c27b63 100644
--- a/textproc/Makefile
+++ b/textproc/Makefile
@@ -52,6 +52,7 @@
     SUBDIR += apache-commons-digester
     SUBDIR += apache-poi
     SUBDIR += apache-solr
+    SUBDIR += apache-solr9
     SUBDIR += apache-xmlbeans
     SUBDIR += apertium
     SUBDIR += apertium-eng
diff --git a/textproc/apache-solr9/Makefile b/textproc/apache-solr9/Makefile
new file mode 100644
index 000000000000..e2d00e49c750
--- /dev/null
+++ b/textproc/apache-solr9/Makefile
@@ -0,0 +1,71 @@
+PORTNAME=	apache-solr
+PORTVERSION=	9.0.0
+PORTREVISION=	0
+CATEGORIES=	textproc java
+MASTER_SITES=	https://archive.apache.org/dist/solr/solr/${PORTVERSION}/
+DISTNAME=	solr-${PORTVERSION}
+PKGNAMESUFFIX=	9
+
+MAINTAINER=	mfechner@FreeBSD.org
+COMMENT=	High performance search server built using Lucene Java
+WWW=		https://lucene.apache.org/solr/
+
+LICENSE=	APACHE20
+
+RUN_DEPENDS=	bash:shells/bash
+
+USES=		cpe tar:tgz
+CPE_VENDOR=	apache
+CPE_PRODUCT=	solr
+USE_JAVA=	yes
+JAVA_VERSION=	11+
+JAVA_RUN=	yes
+USE_RC_SUBR=	solr
+
+NO_ARCH=	yes
+NO_BUILD=	yes
+
+SUB_FILES=	pkg-message
+
+USERS=		solr
+GROUPS=		${USERS}
+
+PLIST_SUB+=	PORTVERSION="${PORTVERSION}"
+
+OPTIONS_DEFINE=	JTS
+OPTIONS_SUB=	yes
+
+JTS_DESC=	Enable support for JTS Topology Suite
+JTS_RUN_DEPENDS=	jts>0:math/jts
+
+do-install:
+	${FIND} ${WRKSRC} -name '*.orig' -delete
+	cd ${WRKSRC} && ${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/${CPE_PRODUCT}
+	${INSTALL_SCRIPT} ${WRKSRC}/bin/oom_solr.sh ${STAGEDIR}${PREFIX}/${CPE_PRODUCT}/bin
+	${INSTALL_SCRIPT} ${WRKSRC}/bin/post ${STAGEDIR}${PREFIX}/${CPE_PRODUCT}/bin
+	${INSTALL_SCRIPT} ${WRKSRC}/bin/postlogs ${STAGEDIR}${PREFIX}/${CPE_PRODUCT}/bin
+	${INSTALL_SCRIPT} ${WRKSRC}/bin/solr ${STAGEDIR}${PREFIX}/${CPE_PRODUCT}/bin
+	${INSTALL_DATA} ${WRKSRC}/bin/solr.in.sh ${STAGEDIR}${PREFIX}/etc/solr.in.sh.sample
+	${ECHO} 'SOLR_HOME="/var/db/solr"' >> ${STAGEDIR}${PREFIX}/etc/solr.in.sh.sample
+	${ECHO} '# LOG4J_PROPS="/var/db/solr/log4j2.xml"' >> ${STAGEDIR}${PREFIX}/etc/solr.in.sh.sample
+	${ECHO} 'SOLR_LOGS_DIR="/var/log/solr"' >> ${STAGEDIR}${PREFIX}/etc/solr.in.sh.sample
+	${ECHO} 'SOLR_PORT="8983"' >> ${STAGEDIR}${PREFIX}/etc/solr.in.sh.sample
+	${ECHO} 'SOLR_PID_DIR="/var/db/solr"' >> ${STAGEDIR}${PREFIX}/etc/solr.in.sh.sample
+	${ECHO} 'SOLR_OPTS="$$SOLR_OPTS -Djetty.host=localhost -Dlog4j2.formatMsgNoLookups=true"' >> ${STAGEDIR}${PREFIX}/etc/solr.in.sh.sample
+
+	${MKDIR} ${STAGEDIR}/var/db/solr
+	${MKDIR} ${STAGEDIR}/var/log/solr
+	${INSTALL_DATA} ${WRKSRC}/server/solr/solr.xml ${STAGEDIR}/var/db/solr/solr.xml.sample
+
+do-install-JTS-on:
+	${LN} -sf ${JAVALIBDIR}/jts-core.jar ${STAGEDIR}${PREFIX}/${CPE_PRODUCT}/server/solr-webapp/webapp/WEB-INF/lib/
+
+post-install:
+	${FIND} -s ${STAGEDIR}${PREFIX}/${CPE_PRODUCT} -not -type d | ${SORT} | \
+		${SED} -e 's#^${STAGEDIR}${PREFIX}/##' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dir(solr,solr) /var/db/solr" >> ${TMPPLIST}
+	@${ECHO_CMD} "@dir(solr,solr) /var/log/solr" >> ${TMPPLIST}
+	@${ECHO_CMD} "@sample etc/solr.in.sh.sample" >> ${TMPPLIST}
+	@${ECHO_CMD} "@sample(solr,solr) /var/db/solr/solr.xml.sample" >> ${TMPPLIST}
+
+.include <bsd.port.mk>
diff --git a/textproc/apache-solr9/distinfo b/textproc/apache-solr9/distinfo
new file mode 100644
index 000000000000..76634295a4da
--- /dev/null
+++ b/textproc/apache-solr9/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1665150331
+SHA256 (solr-9.0.0.tgz) = fd1ddf07e2a25fffee2f398926de7889275bdd2520e97b50402c12125d39581e
+SIZE (solr-9.0.0.tgz) = 223857836
diff --git a/textproc/apache-solr9/files/patch-bin_solr b/textproc/apache-solr9/files/patch-bin_solr
new file mode 100644
index 000000000000..1c15691df53e
--- /dev/null
+++ b/textproc/apache-solr9/files/patch-bin_solr
@@ -0,0 +1,31 @@
+--- bin/solr.orig	2022-04-25 20:37:26 UTC
++++ bin/solr
+@@ -2269,13 +2269,12 @@ function start_solr() {
+ 	echo ""
+     fi
+     # no lsof on cygwin though
+-    if lsof -v 2>&1 | grep -q revision; then
+       echo -n "Waiting up to $SOLR_START_WAIT seconds to see Solr running on port $SOLR_PORT"
+       # Launch in a subshell to show the spinner
+       (loops=0
+       while true
+       do
+-        running=$(lsof -t -PniTCP:$SOLR_PORT -sTCP:LISTEN || :)
++        running=$(sockstat -ls -P tcp -p $SOLR_PORT | grep LISTEN)
+         if [ -z "${running:-}" ]; then
+           slept=$((loops * 2))
+           if [ $slept -lt $SOLR_START_WAIT ]; then
+@@ -2293,13 +2292,6 @@ function start_solr() {
+         fi
+       done) &
+       spinner $!
+-    else
+-      echo -e "NOTE: Please install lsof as this script needs it to determine if Solr is listening on port $SOLR_PORT."
+-      sleep 10
+-      SOLR_PID=`ps auxww | grep start\.jar | awk "/\-Djetty\.port=$SOLR_PORT/"' {print $2}' | sort -r`
+-      echo -e "\nStarted Solr server on port $SOLR_PORT (pid=$SOLR_PID). Happy searching!\n"
+-      return;
+-    fi
+   fi
+ }
+ 
diff --git a/textproc/apache-solr9/files/pkg-message.in b/textproc/apache-solr9/files/pkg-message.in
new file mode 100644
index 000000000000..4ff8a03f0ec2
--- /dev/null
+++ b/textproc/apache-solr9/files/pkg-message.in
@@ -0,0 +1,45 @@
+[
+{ type: install
+  message: <<EOM
+Make sure to edit the following files to adapt to your setup:
+
+%%LOCALBASE%%/etc/solr.in.sh
+/var/db/solr/solr.xml
+
+All files are configured to have your solr instances running in
+/var/db/solr/<instancename>
+
+For more information how to configure solr check the manual:
+http://lucene.apache.org/solr/resources.html#documentation
+
+The port is configured to listen only on localhost, port 8983.
+
+To rotate solr log files include /var/log/solr/ to your log rotation
+configuration.
+
+To enable the port execute:
+sysrc solr_enable="YES"
+
+And start it with:
+service solr start
+EOM
+}
+{ type: upgrade
+  message: <<EOM
+If you update, make sure you update your %%LOCALBASE%%/etc/solr.in.sh
+The LOG4J_PROPS has changed.
+If you would like to change logging, copy:
+cp %%LOCALBASE%%/solr/server/resources/log4j2.xml /var/db/solr/
+Change it and make sure it is loaded in %%LOCALBASE%%/etc/solr.in.sh.
+
+Data Import Handler (DIH) has been removed from the base solr and is
+available as independent module which can be installed with solr
+package manager. The current repo is available at:
+https://github.com/rohitbemax/dataimporthandler
+
+Make also sure to always check the manual if you need to modify your
+configs or schemas:
+https://solr.apache.org/guide/9_0/solr-upgrade-notes.html
+EOM
+}
+]
diff --git a/textproc/apache-solr9/files/solr.in b/textproc/apache-solr9/files/solr.in
new file mode 100644
index 000000000000..9a73d64362ce
--- /dev/null
+++ b/textproc/apache-solr9/files/solr.in
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# Copyright (c) 2014, Radim Kolar
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice,
+#    this list of conditions and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+# DAMAGE.
+
+#
+# PROVIDE: solr
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name=solr
+rcvar=solr_enable
+load_rc_config $name
+
+: ${solr_enable:=NO}
+: ${solr_instance:=/var/db/solr}
+
+solr_start ()
+{
+	su -m solr -c "${command} start"
+}
+
+solr_stop ()
+{
+	su -m solr -c "${command} stop"
+}
+
+solr_status ()
+{
+	su -m solr -c "${command} status"
+}
+
+# add %%LOCALBASE%%/bin to path
+export PATH=$PATH:%%LOCALBASE%%/bin
+# let the start script read some custom settings
+export SOLR_INCLUDE=/usr/local/etc/solr.in.sh
+
+required_files="${solr_instance}/solr.xml /usr/local/etc/solr.in.sh"
+command=%%PREFIX%%/solr/bin/solr
+start_cmd=solr_start
+stop_cmd=solr_stop
+status_cmd=solr_status
+
+run_rc_command "$1"
diff --git a/textproc/apache-solr9/pkg-descr b/textproc/apache-solr9/pkg-descr
new file mode 100644
index 000000000000..ba1ba6e03733
--- /dev/null
+++ b/textproc/apache-solr9/pkg-descr
@@ -0,0 +1,5 @@
+Solr is an open source enterprise search server based on the Lucene
+Java search library, with XML/HTTP and JSON APIs, hit highlighting,
+faceted search, caching, replication, a web administration interface
+and many more features. It runs in a Java servlet container such as
+Tomcat.