diff --git a/textproc/apache-solr/Makefile b/textproc/apache-solr/Makefile index 9cc3d200ef99..6c5eaa802342 100644 --- a/textproc/apache-solr/Makefile +++ b/textproc/apache-solr/Makefile @@ -1,73 +1,74 @@ PORTNAME= apache-solr PORTVERSION= 10.0.0 +PORTREVISION= 1 PORTEPOCH= 1 CATEGORIES= textproc java MASTER_SITES= https://archive.apache.org/dist/solr/solr/${PORTVERSION}/ DISTNAME= solr-${PORTVERSION} 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 java tar:tgz CPE_VENDOR= apache CPE_PRODUCT= solr JAVA_VERSION= 21+ USE_RC_SUBR= solr NO_ARCH= yes NO_BUILD= yes SUB_FILES= pkg-message USERS= solr GROUPS= ${USERS} CPE_PRODUCT= solr CPE_VENDOR= apache 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/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} '' >> ${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/server/solr-webapp/webapp/ui/composeResources/com.arkivanov.decompose.extensions_compose.generated.resources" >> ${TMPPLIST} @${ECHO_CMD} "@dir solr/server/solr-webapp/webapp/ui/composeResources/components.resources.library.generated.resources" >> ${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 diff --git a/textproc/apache-solr/files/patch-bin_solr b/textproc/apache-solr/files/patch-bin_solr old mode 100644 new mode 100755 index aac6e4e2d636..8ff1a720103f --- a/textproc/apache-solr/files/patch-bin_solr +++ b/textproc/apache-solr/files/patch-bin_solr @@ -1,33 +1,105 @@ ---- bin/solr.orig 2026-01-02 20:59:41 UTC -+++ bin/solr -@@ -1352,13 +1352,20 @@ function start_solr() { - fi +--- bin/solr.orig 2026-01-02 20:59:41.000000000 +0000 ++++ bin/solr 2026-03-22 17:27:21.259092000 +0000 +@@ -49,6 +49,13 @@ + SOLR_SCRIPT="$0" + verbose=false + THIS_OS=$(uname -s) ++ ++SOLR_PORT_PID_TOOL="" ++if [ "$THIS_OS" == "FreeBSD" ] && command -v sockstat > /dev/null 2>&1; then ++ SOLR_PORT_PID_TOOL="sockstat" ++elif command -v lsof > /dev/null 2>&1 && lsof -v 2>&1 | grep -q revision; then ++ SOLR_PORT_PID_TOOL="lsof" ++fi + + # What version of Java is required to run this version of Solr. + JAVA_VER_REQ=21 +@@ -475,15 +482,36 @@ + fi + } - # no lsof on cygwin though -+ check_command="" - if lsof -v 2>&1 | grep -q revision; then -+ check_command="lsof -t -PniTCP:$SOLR_PORT -sTCP:LISTEN" -+ elif which -s sockstat; then -+ check_command="sockstat -q46lp$SOLR_PORT" -+ fi +-# extract the value of the -Dsolr.port.listen parameter from a running Solr process ++# given a port, find the pid of a process that is actively listening on it ++function listening_pid_by_port() { ++ local the_port="$1" ++ local listening_pid="" ++ ++ if [ "$SOLR_PORT_PID_TOOL" == "sockstat" ]; then ++ listening_pid=$( ++ { ++ sockstat -4 -l -P tcp -p "$the_port" 2>/dev/null || : ++ sockstat -6 -l -P tcp -p "$the_port" 2>/dev/null || : ++ } | awk '$1 != "USER" { print $3; exit }' ++ ) ++ elif [ "$SOLR_PORT_PID_TOOL" == "lsof" ]; then ++ listening_pid=$(lsof -t -PniTCP:"$the_port" -sTCP:LISTEN 2>/dev/null | sed -n '1p' || :) ++ fi ++ ++ if [ -n "${listening_pid:-}" ]; then ++ echo "$listening_pid" ++ fi ++} + -+ if [[ "${check_command}" != "" ]]; then ++# extract the value of the listening port parameter from a running Solr process + function solr_port_listen() { + SOLR_PID="$1" +- SOLR_PROC=$(ps -fww -p "$SOLR_PID" | grep start\.jar | grep solr\.port\.listen) ++ SOLR_PROC=$(ps -fww -p "$SOLR_PID" | grep start\.jar | grep -E 'solr\.port\.listen|jetty\.port') + IFS=' ' read -a proc_args <<< "$SOLR_PROC" + for arg in "${proc_args[@]}" + do + IFS='=' read -a pair <<< "$arg" +- if [ "${pair[0]}" == "-Dsolr.port.listen" ]; then ++ if [ "${pair[0]}" == "-Dsolr.port.listen" ] || [ "${pair[0]}" == "-Djetty.port" ]; then + local solr_port="${pair[1]}" + break + fi +@@ -983,8 +1011,8 @@ + SOLR_PID=$(solr_pid_by_port "$SOLR_PORT_LISTEN") + + if [ -z "${SOLR_PID:-}" ]; then +- # not found using the pid file ... but use ps to ensure not found +- SOLR_PID=$(ps auxww | grep start\.jar | awk "/\-Dsolr\.port\.listen=$SOLR_PORT_LISTEN/"' {print $2}' | sort -r) ++ # not found using the pid file ... but check if any process is already listening on the port ++ SOLR_PID=$(listening_pid_by_port "$SOLR_PORT_LISTEN") + fi + + if [ -n "${SOLR_PID:-}" ]; then +@@ -1351,14 +1379,13 @@ + fi + fi + +- # no lsof on cygwin though +- if lsof -v 2>&1 | grep -q revision; then ++ if [ -n "$SOLR_PORT_PID_TOOL" ]; then echo -n "Waiting up to $SOLR_START_WAIT seconds to see Solr running on port $SOLR_PORT_LISTEN" # Launch in a subshell to show the spinner (loops=0 while true do - running=$(lsof -t -PniTCP:$SOLR_PORT_LISTEN -sTCP:LISTEN || :) -+ running=$(${check_command} || :) ++ running=$(listening_pid_by_port "$SOLR_PORT_LISTEN") if [ -z "${running:-}" ]; then slept=$((loops * 2)) if [ $slept -lt $SOLR_START_WAIT ]; then -@@ -1377,7 +1384,7 @@ function start_solr() { +@@ -1370,14 +1397,18 @@ + exit # subshell! + fi + else +- SOLR_PID=$(ps auxww | grep start\.jar | awk "/\-Dsolr\.port\.listen=$SOLR_PORT_LISTEN/"' {print $2}' | sort -r) ++ SOLR_PID="$running" + echo -e "\nStarted Solr server on port $SOLR_PORT_LISTEN (pid=$SOLR_PID). Happy searching!\n" + exit # subshell! + 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_LISTEN." -+ echo -e "NOTE: Please install lsof or sockstat as this script needs it to determine if Solr is listening on port $SOLR_PORT_LISTEN." ++ if [ "$THIS_OS" == "FreeBSD" ]; then ++ echo -e "NOTE: This script needs sockstat available in PATH to determine if Solr is listening on port $SOLR_PORT_LISTEN." ++ else ++ echo -e "NOTE: Please install lsof as this script needs it to determine if Solr is listening on port $SOLR_PORT_LISTEN." ++ fi sleep 10 SOLR_PID=$(ps auxww | grep start\.jar | awk "/\-Dsolr\.port\.listen=$SOLR_PORT_LISTEN/"' {print $2}' | sort -r) echo -e "\nStarted Solr server on port $SOLR_PORT_LISTEN (pid=$SOLR_PID). Happy searching!\n" diff --git a/textproc/apache-solr/files/solr.in b/textproc/apache-solr/files/solr.in index 306fe68c0654..68072763b9e5 100644 --- a/textproc/apache-solr/files/solr.in +++ b/textproc/apache-solr/files/solr.in @@ -1,68 +1,73 @@ #!/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_standalone:=YES} : ${solr_svcj_options:="net_basic"} solr_start () { - su -m solr -c "${command} start" + solr_mode_args="" + if checkyesno solr_standalone; then + solr_mode_args=" --user-managed" + fi + su -m solr -c "${command} start${solr_mode_args}" } 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"