From 2bdcabe499e97f6cc51daced7c29e2d0c463affb Mon Sep 17 00:00:00 2001
From: Herve Quiroz <hq@FreeBSD.org>
Date: Sat, 2 Apr 2005 22:14:50 +0000
Subject: Update to 2.1.7

PR:		79197
Submitted by:	maintainer
---
 www/cocoon/Makefile              |  15 ++--
 www/cocoon/Makefile.options      |  12 +--
 www/cocoon/Makefile.test-options |  85 +++++++++----------
 www/cocoon/distinfo              |   4 +-
 www/cocoon/files/cocoon.sh       |   2 +-
 www/cocoon/files/cocoonctl       | 174 ++++++++++++++++++++++++++++++++-------
 www/cocoon/files/pkg-deinstall   |   6 +-
 www/cocoon/files/pkg-install     |   4 +-
 8 files changed, 205 insertions(+), 97 deletions(-)

(limited to 'www/cocoon')

diff --git a/www/cocoon/Makefile b/www/cocoon/Makefile
index dadca8dbbb42..b8660cfff1fa 100644
--- a/www/cocoon/Makefile
+++ b/www/cocoon/Makefile
@@ -6,9 +6,10 @@
 #
 
 PORTNAME=	cocoon
-PORTVERSION=	2.1.6
+PORTVERSION=	2.1.7
 CATEGORIES=	www java
-MASTER_SITES=	${MASTER_SITE_APACHE:S,%SUBDIR%,${PORTNAME},}
+MASTER_SITES=	${MASTER_SITE_APACHE}
+MASTER_SITE_SUBDIR=	${PORTNAME}
 DISTNAME=	${PDISTNAME}-src
 
 MAINTAINER=	jb.quenot@caraldi.com
@@ -35,12 +36,12 @@ PLIST_SUB+=	"COCOON_LIB=${COCOON_LIB}"
 COPYDIRS=	*.txt tools/jetty tools/loader legal webapp
 
 PORT?=		8888
-PID_FILE?=	/var/run/${APP_NAME}.pid
+PID_FILE?=	${APP_HOME}/${APP_NAME}.pid
 RUNASUSER?=	www
 RUNASUID?=	80
 GROUP?=		www
 GID?=		80
-LOGFILE?=	/var/log/${APP_NAME}.log
+LOG_FILE?=	${APP_HOME}/${APP_NAME}.log
 
 SUBSTITUTIONS=	\
 	-e "s|%%APP_HOME%%|${APP_HOME}|g" \
@@ -49,12 +50,13 @@ SUBSTITUTIONS=	\
 	-e "s|%%PORT%%|${PORT}|g" \
 	-e "s|%%COCOON_LIB%%|${COCOON_LIB}|g" \
 	-e "s|%%JAVA_HOME%%|${JAVA_HOME}|g" \
+	-e "s|%%JAVA%%|${JAVA}|g" \
 	-e "s|%%PID_FILE%%|${PID_FILE}|g" \
 	-e "s|%%RUNASUSER%%|${RUNASUSER}|g" \
 	-e "s|%%RUNASUID%%|${RUNASUID}|g" \
 	-e "s|%%GROUP%%|${GROUP}|g" \
 	-e "s|%%GID%%|${GID}|g" \
-	-e "s|%%LOGFILE%%|${LOGFILE}|g" \
+	-e "s|%%LOG_FILE%%|${LOG_FILE}|g" \
 	-e "s|%%PYTHON_CMD%%|${PYTHON_CMD}|g"
 
 # Load options (before including bsd.port.pre.mk)
@@ -102,9 +104,10 @@ do-build:
 	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ./build.sh
 
 post-build:
-	${LN} -s ${WRKSRC}/build/webapp ${WRKSRC}/webapp
+	${TEST} -h ${WRKSRC}/webapp || ${LN} -s ${WRKSRC}/build/webapp ${WRKSRC}/webapp
 
 	@${ECHO_MSG} "===> Building packing list"
+	@> ${PLIST}
 
 	@cd ${WRKSRC} && ${FIND} -H ${COPYDIRS} -type f \
 	| ${SED} -e "s|^|${APP_NAME}/|" >> ${PLIST}
diff --git a/www/cocoon/Makefile.options b/www/cocoon/Makefile.options
index 3fe197519631..65a981367edd 100644
--- a/www/cocoon/Makefile.options
+++ b/www/cocoon/Makefile.options
@@ -18,6 +18,7 @@ OPTIONS+=	JSP	'Enable the jsp block'	on
 OPTIONS+=	LINKREWRITER	'Enable the linkrewriter block'	on
 OPTIONS+=	LUCENE	'Enable the lucene block'	on
 OPTIONS+=	NAMING	'Enable the naming block'	on
+OPTIONS+=	OJB	'Enable the ojb block'	on
 OPTIONS+=	PARANOID	'Enable the paranoid block'	on
 OPTIONS+=	POI	'Enable the poi block'	on
 OPTIONS+=	PORTAL	'Enable the portal block'	off
@@ -28,6 +29,10 @@ OPTIONS+=	VELOCITY	'Enable the velocity block'	on
 OPTIONS+=	WEB3	'Enable the web3 block'	on
 OPTIONS+=	XMLDB	'Enable the xmldb block'	on
 OPTIONS+=	XSP	'Enable the xsp block'	on
+OPTIONS+=	PHP	'Enable the php block'	off
+OPTIONS+=	PORTAL_FW	'Enable the portal-fw block'	off
+OPTIONS+=	SWF	'Enable the swf block'	off
+OPTIONS+=	WOODY	'Enable the woody block'	off
 OPTIONS+=	APPLES	'Enable the apples block'	on
 OPTIONS+=	ASCIIART	'Enable the asciiart block'	on
 OPTIONS+=	AXIS	'Enable the axis block'	on
@@ -41,12 +46,11 @@ OPTIONS+=	JMS	'Enable the jms block'	on
 OPTIONS+=	LINOTYPE	'Enable the linotype block'	on
 OPTIONS+=	MAIL	'Enable the mail block'	on
 OPTIONS+=	MIDI	'Enable the midi block'	on
-OPTIONS+=	OJB	'Enable the ojb block'	on
 OPTIONS+=	PETSTORE	'Enable the petstore block'	on
 OPTIONS+=	PROXY	'Enable the proxy block'	on
 OPTIONS+=	QDOX	'Enable the qdox block'	on
+OPTIONS+=	QUERYBEAN	'Enable the querybean block'	on
 OPTIONS+=	REPOSITORY	'Enable the repository block'	on
-OPTIONS+=	SCRATCHPAD	'Enable the scratchpad block'	on
 OPTIONS+=	SERIALIZERS	'Enable the serializers block'	on
 OPTIONS+=	SLIDE	'Enable the slide block'	on
 OPTIONS+=	SLOP	'Enable the slop block'	on
@@ -54,7 +58,3 @@ OPTIONS+=	STX	'Enable the stx block'	on
 OPTIONS+=	TAGLIB	'Enable the taglib block'	on
 OPTIONS+=	TOUR	'Enable the tour block'	on
 OPTIONS+=	WEBDAV	'Enable the webdav block'	on
-OPTIONS+=	PHP	'Enable the php block'	off
-OPTIONS+=	PORTAL_FW	'Enable the portal-fw block'	off
-OPTIONS+=	SWF	'Enable the swf block'	off
-OPTIONS+=	WOODY	'Enable the woody block'	off
diff --git a/www/cocoon/Makefile.test-options b/www/cocoon/Makefile.test-options
index 3fd9ebd9bc74..1a669d12c3dd 100644
--- a/www/cocoon/Makefile.test-options
+++ b/www/cocoon/Makefile.test-options
@@ -14,7 +14,6 @@ BLOCKS+=	bsf
 
 .if defined(WITH_CHAPERON)
 BLOCKS+=	chaperon
-BLOCKS+=	xsp
 .endif
 
 .if defined(WITH_DATABASES)
@@ -56,14 +55,20 @@ BLOCKS+=	xsp
 
 .if defined(WITH_LUCENE)
 BLOCKS+=	lucene
-BLOCKS+=	forms
-BLOCKS+=	xsp
 .endif
 
 .if defined(WITH_NAMING)
 BLOCKS+=	naming
 .endif
 
+.if defined(WITH_OJB)
+BLOCKS+=	ojb
+BLOCKS+=	databases
+BLOCKS+=	forms
+BLOCKS+=	hsqldb
+BLOCKS+=	xsp
+.endif
+
 .if defined(WITH_PARANOID)
 BLOCKS+=	paranoid
 .endif
@@ -75,7 +80,8 @@ BLOCKS+=	poi
 .if defined(WITH_PORTAL)
 BLOCKS+=	portal
 BLOCKS+=	authentication-fw
-BLOCKS+=	html
+BLOCKS+=	cron
+BLOCKS+=	forms
 BLOCKS+=	session-fw
 BLOCKS+=	xsp
 .endif
@@ -112,10 +118,29 @@ BLOCKS+=	xsp
 BLOCKS+=	xsp
 .endif
 
+.if defined(WITH_PHP)
+BLOCKS+=	php
+.endif
+
+.if defined(WITH_PORTAL_FW)
+BLOCKS+=	portal-fw
+BLOCKS+=	authentication-fw
+BLOCKS+=	session-fw
+BLOCKS+=	xsp
+.endif
+
+.if defined(WITH_SWF)
+BLOCKS+=	swf
+.endif
+
+.if defined(WITH_WOODY)
+BLOCKS+=	woody
+BLOCKS+=	xsp
+.endif
+
 .if defined(WITH_APPLES)
 BLOCKS+=	apples
 BLOCKS+=	forms
-BLOCKS+=	xsp
 .endif
 
 .if defined(WITH_ASCIIART)
@@ -145,7 +170,8 @@ BLOCKS+=	xsp
 .if defined(WITH_FACES)
 BLOCKS+=	faces
 BLOCKS+=	authentication-fw
-BLOCKS+=	html
+BLOCKS+=	cron
+BLOCKS+=	forms
 BLOCKS+=	portal
 BLOCKS+=	session-fw
 BLOCKS+=	taglib
@@ -154,7 +180,6 @@ BLOCKS+=	xsp
 
 .if defined(WITH_FORMS)
 BLOCKS+=	forms
-BLOCKS+=	xsp
 .endif
 
 .if defined(WITH_JAVAFLOW)
@@ -186,14 +211,6 @@ BLOCKS+=	asciiart
 BLOCKS+=	midi
 .endif
 
-.if defined(WITH_OJB)
-BLOCKS+=	ojb
-BLOCKS+=	databases
-BLOCKS+=	forms
-BLOCKS+=	hsqldb
-BLOCKS+=	xsp
-.endif
-
 .if defined(WITH_PETSTORE)
 BLOCKS+=	petstore
 BLOCKS+=	databases
@@ -211,25 +228,22 @@ BLOCKS+=	proxy
 BLOCKS+=	qdox
 .endif
 
-.if defined(WITH_REPOSITORY)
-BLOCKS+=	repository
+.if defined(WITH_QUERYBEAN)
+BLOCKS+=	querybean
 BLOCKS+=	databases
-BLOCKS+=	eventcache
+BLOCKS+=	forms
 BLOCKS+=	hsqldb
-BLOCKS+=	jms
+BLOCKS+=	lucene
+BLOCKS+=	ojb
 BLOCKS+=	xsp
 .endif
 
-.if defined(WITH_SCRATCHPAD)
-BLOCKS+=	scratchpad
-BLOCKS+=	axis
-BLOCKS+=	batik
-BLOCKS+=	cron
+.if defined(WITH_REPOSITORY)
+BLOCKS+=	repository
 BLOCKS+=	databases
 BLOCKS+=	eventcache
 BLOCKS+=	hsqldb
 BLOCKS+=	jms
-BLOCKS+=	repository
 BLOCKS+=	xsp
 .endif
 
@@ -264,7 +278,6 @@ BLOCKS+=	tour
 BLOCKS+=	batik
 BLOCKS+=	fop
 BLOCKS+=	forms
-BLOCKS+=	xsp
 .endif
 
 .if defined(WITH_WEBDAV)
@@ -277,23 +290,3 @@ BLOCKS+=	repository
 BLOCKS+=	xsp
 .endif
 
-.if defined(WITH_PHP)
-BLOCKS+=	php
-.endif
-
-.if defined(WITH_PORTAL_FW)
-BLOCKS+=	portal-fw
-BLOCKS+=	authentication-fw
-BLOCKS+=	session-fw
-BLOCKS+=	xsp
-.endif
-
-.if defined(WITH_SWF)
-BLOCKS+=	swf
-.endif
-
-.if defined(WITH_WOODY)
-BLOCKS+=	woody
-BLOCKS+=	xsp
-.endif
-
diff --git a/www/cocoon/distinfo b/www/cocoon/distinfo
index 2e142177587c..c51c2e47172b 100644
--- a/www/cocoon/distinfo
+++ b/www/cocoon/distinfo
@@ -1,2 +1,2 @@
-MD5 (cocoon-2.1.6-src.tar.gz) = d7a3a5b2c89452df95f85eeb031bbbae
-SIZE (cocoon-2.1.6-src.tar.gz) = 44430985
+MD5 (cocoon-2.1.7-src.tar.gz) = 423209dad3650e4f4fb1d76bd64a4747
+SIZE (cocoon-2.1.7-src.tar.gz) = 41950734
diff --git a/www/cocoon/files/cocoon.sh b/www/cocoon/files/cocoon.sh
index 8ca8b5719622..259ada14b103 100644
--- a/www/cocoon/files/cocoon.sh
+++ b/www/cocoon/files/cocoon.sh
@@ -19,7 +19,7 @@ rcvar=`set_rcvar`
 command=%%PREFIX%%/sbin/%%APP_NAME%%ctl
 command_args="$1"
 pidfile=%%PID_FILE%%
-procname=java
+procname=%%JAVA%%
 
 # set defaults
 
diff --git a/www/cocoon/files/cocoonctl b/www/cocoon/files/cocoonctl
index fa62902ead55..b1aad58b9002 100644
--- a/www/cocoon/files/cocoonctl
+++ b/www/cocoon/files/cocoonctl
@@ -6,43 +6,157 @@
 # Date Created:  2004-05-04 11:14:05
 # Revision:      $FreeBSD$
 ################################################################################
+# Copyright (c) 2004, Jean-Baptiste Quenot <jb.quenot@caraldi.com>
+# 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.
+# * The name of the contributors may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
+################################################################################
+#
+# Files handled by this script (pid file, log files) must reside in a writable
+# directory, ie the directory must be owned by the user running the program.
 
-import sys, os, signal, time
+import sys, os, signal, time, stat, re
 
-LOGFILE = "%%LOGFILE%%"
-PREFIX = "%%PREFIX%%"
-APP_NAME = "%%APP_NAME%%"
-PID_FILE = "%%PID_FILE%%"
+def readProcessId():
+    f = open(PID_FILE, 'r')
+    pid = int(f.readline())
+    f.close()
+    return pid
 
-if __name__ == '__main__':
-    if sys.argv[1] == "start":
-        # Append cocoon output to a log file
-        l = open(LOGFILE, 'a')
-        os.dup2(l.fileno(), sys.stdout.fileno())
-        os.dup2(l.fileno(), sys.stderr.fileno())
+def isProgramRunning(pid):
+    # Send a dummy signal to the process.  If it died, an exception is
+    # thrown
+    try:
+        os.kill(pid, signal.SIGCONT)
+        return 1
+    except OSError:
+        return 0
 
-        # Start cocoon in the background
-        command = PREFIX + "/sbin/" + APP_NAME + ".sh"
-        pid = os.spawnl(os.P_NOWAIT, command, command, "servlet")
+def usage():
+    print >> sys.stderr, "Usage: %s {start|stop|restart}" % sys.argv[0]
 
-        # Wait a little
-        time.sleep(0.4)
+def start():
+    cwd = os.getcwd()
+    if os.path.exists(PID_FILE):
+        # Read the process id
+        pid = readProcessId()
 
-        # Send a dummy signal to the process.  If it died, an exception is
-        # thrown
-        os.kill(pid, signal.SIGCONT)
+        if isProgramRunning(pid):
+            print >> sys.stderr, '%s already started' % APP_NAME
+            sys.exit(3)
 
-        # It's alive, so write down the process id
-        f = open(PID_FILE, 'w')
-        print >> f, pid
-        f.close()
-    elif sys.argv[1] == "stop":
+    if not(os.path.exists(COMMAND)):
+        print >> sys.stderr, '%s cannot be found' % COMMAND
+        sys.exit(3)
+
+    # Append program output to a log file
+    l = open(LOG_FILE, 'a')
+    orig_stderr = os.dup(sys.stderr.fileno())
+    os.dup2(l.fileno(), sys.stdout.fileno())
+    os.dup2(l.fileno(), sys.stderr.fileno())
+
+    finfo = os.stat(COMMAND)[stat.ST_MODE]
+    executable = stat.S_IMODE(finfo) & 0111
+    if not(executable):
+        sys.stderr = os.fdopen(orig_stderr, 'w')
+        print >> sys.stderr, 'Cannot run %s, execute bit is missing' % COMMAND
+        sys.exit(5)
+
+    if APP_HOME:
+        # Change current directory to APP_HOME
+        os.chdir(APP_HOME)
+
+    # Start program in the background
+    pid = os.spawnv(os.P_NOWAIT, COMMAND, ARGS)
+
+    # Wait a little
+    time.sleep(.4)
+    (status_pid, status) = os.waitpid(pid, os.WNOHANG)
+
+    # Check program exit status, if available
+    if status_pid != 0 and os.WIFEXITED(status):
+        sys.stderr = os.fdopen(orig_stderr, 'w')
+        print >> sys.stderr, 'Could not start %s.  Check %s for errors.' % (APP_NAME, LOG_FILE)
+        sys.exit(2)
+
+    # It's alive, so write down the process id
+    os.chdir(cwd)
+    f = open(PID_FILE, 'w')
+    print >> f, pid
+    f.close()
+
+def warnNotRunning():
+    if sys.argv[1] == "stop":
+        print >> sys.stderr, '%s is not running' % APP_NAME
+    else:
+        print >> sys.stderr, 'Warning: %s was not running' % APP_NAME
+
+def cleanup():
+    os.unlink(PID_FILE)
+
+def stop():
+    if os.path.exists(PID_FILE):
         # Read the process id
-        f = open(PID_FILE, 'r')
-        pid = int(f.readline())
-        f.close()
+        pid = readProcessId()
+    else:
+        warnNotRunning()
+        return
+
+    if not(isProgramRunning(pid)):
+        warnNotRunning()
+        cleanup()
+        return
+
+    # Terminate program
+    os.kill(pid, signal.SIGTERM)
+
+    while isProgramRunning(pid):
+        time.sleep(.1)
+
+    cleanup()
+
+if __name__ == '__main__':
+    LOG_FILE = "%%LOG_FILE%%"
+    APP_NAME = "%%APP_NAME%%"
+    APP_HOME = "%%APP_HOME%%"
+    PID_FILE = "%%PID_FILE%%"
+    COMMAND = "%%PREFIX%%/sbin/%%APP_NAME%%.sh"
+    ARGS = [COMMAND, "servlet"]
+
+    if len(sys.argv) != 2:
+        usage()
+        sys.exit(1)
+
+    if sys.argv[1] == "start":
+        start()
+
+    elif sys.argv[1] == "stop":
+        stop()
+
+    elif sys.argv[1] == "restart":
+        stop()
+        start()
 
-        # Terminate cocoon
-        os.kill(pid, signal.SIGTERM)
     else:
-        print "Usage: %s start|stop" % sys.argv[0]
+        usage()
+        sys.exit(1)
diff --git a/www/cocoon/files/pkg-deinstall b/www/cocoon/files/pkg-deinstall
index 55134b973319..b540c3647127 100644
--- a/www/cocoon/files/pkg-deinstall
+++ b/www/cocoon/files/pkg-deinstall
@@ -18,7 +18,7 @@ set -e
 PID_FILE=%%PID_FILE%%
 RUNASUSER=%%RUNASUSER%%
 APP_NAME=%%APP_NAME%%
-LOGFILE=%%LOGFILE%%
+LOG_FILE=%%LOG_FILE%%
 
 # Make sure we're in the right stage of the process
 if [ "$2" = "DEINSTALL" ]; then
@@ -43,8 +43,8 @@ if [ "$2" = "DEINSTALL" ]; then
         fi
     fi
 
-    echo -n ">> Removing log file (${LOGFILE})..."
-    if rm ${LOGFILE} > /dev/null 2> /dev/null ; then
+    echo -n ">> Removing log file (${LOG_FILE})..."
+    if rm ${LOG_FILE} > /dev/null 2> /dev/null ; then
         echo " [ DONE ]"
     else
         echo " [ FAILED ]"
diff --git a/www/cocoon/files/pkg-install b/www/cocoon/files/pkg-install
index 48ce6423e4fb..afd4a733da2e 100644
--- a/www/cocoon/files/pkg-install
+++ b/www/cocoon/files/pkg-install
@@ -16,7 +16,7 @@ GROUP=%%GROUP%%
 GID=%%GID%%
 APP_NAME=%%APP_NAME%%
 PID_FILE=%%PID_FILE%%
-LOGFILE=%%LOGFILE%%
+LOG_FILE=%%LOG_FILE%%
 
 if [ "$2" = "POST-INSTALL" ]; then
     # We're called after the 'make install' process
@@ -48,8 +48,6 @@ if [ "$2" = "POST-INSTALL" ]; then
     fi
 
     chown -R ${RUNASUSER}:${GROUP} $PKG_PREFIX/${APP_NAME}
-    touch ${LOGFILE} ${PID_FILE}
-    chown ${RUNASUSER}:${GROUP} ${LOGFILE} ${PID_FILE}
 fi
 
 exit 0
-- 
cgit v1.2.3