From 81c8db1a2b05e0e5d6791d77ff0e628f131f0ce7 Mon Sep 17 00:00:00 2001 From: Greg Lewis Date: Thu, 20 Nov 2003 21:44:14 +0000 Subject: . Avoid conflict between resin2 and resin3 . Fix resin{2,3}ctl first line (perl path) . Pid file is no more created in the Makefile . New resin.sh startup script, manages pid file . pkg-[de]install and pkg-message are now generated . Do not write anything after including bsd.port.post.mk . Packages are now supported (reported by Arcadius Ahouansou) . Integration with apxs for [de]activating mod_caucho PR: 57566 Submitted by: Jean-Baptiste Quenot (maintainer) --- www/resin3/Makefile | 100 +++++++++++---- www/resin3/files/install.sh | 51 ++++++++ www/resin3/files/patch-apache-Makefile.in | 12 ++ www/resin3/files/patch-apache2-Makefile.in | 12 ++ www/resin3/files/patch-wrapper | 8 ++ www/resin3/files/pkg-deinstall | 52 ++++++++ www/resin3/files/pkg-install | 50 ++++++++ www/resin3/files/pkg-message.in | 4 + www/resin3/files/resin.sh.in | 53 ++++++++ www/resin3/pkg-deinstall | 43 ------- www/resin3/pkg-install | 100 --------------- www/resin3/pkg-message | 6 - www/resin3/pkg-plist | 193 ++++++++++++++--------------- 13 files changed, 415 insertions(+), 269 deletions(-) create mode 100644 www/resin3/files/install.sh create mode 100644 www/resin3/files/patch-apache-Makefile.in create mode 100644 www/resin3/files/patch-apache2-Makefile.in create mode 100644 www/resin3/files/patch-wrapper create mode 100644 www/resin3/files/pkg-deinstall create mode 100644 www/resin3/files/pkg-install create mode 100644 www/resin3/files/pkg-message.in create mode 100644 www/resin3/files/resin.sh.in delete mode 100644 www/resin3/pkg-deinstall delete mode 100644 www/resin3/pkg-install delete mode 100644 www/resin3/pkg-message (limited to 'www') diff --git a/www/resin3/Makefile b/www/resin3/Makefile index 0460d76011b3..74b028245d07 100644 --- a/www/resin3/Makefile +++ b/www/resin3/Makefile @@ -2,11 +2,14 @@ # Whom: Jean-Baptiste Quenot # Date Created: 2003-09-29 14:17:14 # +# ex:ts=20:sw=20 +# # $FreeBSD$ # PORTNAME= resin PORTVERSION= 3.0.3 +PORTREVISION= 1 CATEGORIES= www java MASTER_SITES= http://www.caucho.com/download/ @@ -23,58 +26,111 @@ RUNASUID?= 80 GROUP?= ${RUNASUSER} GID?= ${RUNASUID} PORT?= 8080 -APP_HOME?= ${PREFIX}/${PKGNAMEPREFIX}${PORTNAME} +# Do not use PKGNAMESUFFIX here because version info is already in PORTVERSION +# If we used PKGNAMESUFFIX, the package name would be resin2-2.1.11 +APP_NAME_SUFFIX= ${PORTVERSION:C/\..*$//} +APP_NAME?= ${PORTNAME}${APP_NAME_SUFFIX} +APP_HOME?= ${PREFIX}/${APP_NAME} WITH_APACHE?= NO WITH_APACHE2?= NO +PID_FILE?= /var/run/${APP_NAME}.pid # Other settings APXS?= ${LOCALBASE}/sbin/apxs MOD_DIR?= `${APXS} -q LIBEXECDIR` +PKGINSTALL= ${WRKDIR}/pkg-install +PKGDEINSTALL= ${WRKDIR}/pkg-deinstall +PKGMESSAGE= ${WRKDIR}/pkg-message +# We need WRKSRC and WRKDIR right now so define them "manually" +WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION} +WRKDIR?= ${WRKDIRPREFIX}${.CURDIR}/work +REINPLACE_FILES= ${WRKSRC}/src/c/plugin/apache/Makefile.in \ + ${WRKSRC}/src/c/plugin/apache2/Makefile.in +REPLACE_FILES= ${FILESDIR}/pkg-install \ + ${FILESDIR}/pkg-deinstall \ + ${FILESDIR}/install.sh \ + ${FILESDIR}/pkg-message.in \ + ${WRKSRC}/conf/resin.conf \ + ${WRKSRC}/bin/wrapper.pl.in \ + ${FILESDIR}/resin.sh.in # Pass JAVA_HOME as determined by bsd.java.mk CONFIGURE_ARGS+= --with-java-home=${JAVA_HOME} # Install the Apache plugin if needed -.if defined(WITH_APACHE) && ($(WITH_APACHE) == yes || $(WITH_APACHE) == YES) +.if defined(WITH_APACHE) && (${WITH_APACHE} == yes || ${WITH_APACHE} == YES) # # Apache 1.3 # BUILD_DEPENDS+= ${APXS}:${PORTSDIR}/www/apache13 CONFIGURE_ARGS+= --with-apxs=${APXS} PLIST_SUB+= MOD_DIR=libexec/apache -.elif defined(WITH_APACHE2) && ($(WITH_APACHE2) == yes || $(WITH_APACHE2) == YES) +# Allow apxs invocations +PLIST_SUB+= APACHE="" +.elif defined(WITH_APACHE2) && (${WITH_APACHE2} == yes || ${WITH_APACHE2} == YES) # # Apache 2 # BUILD_DEPENDS+= ${APXS}:${PORTSDIR}/www/apache2 CONFIGURE_ARGS+= --with-apxs=${APXS} PLIST_SUB+= MOD_DIR=libexec/apache2 +# Allow apxs invocations +PLIST_SUB+= APACHE="" .else PLIST_SUB+= MOD_DIR="@comment " +# Prevent apxs invocations +PLIST_SUB+= APACHE="@comment " .endif +PLIST_SUB+= APP_NAME=${APP_NAME} +PLIST_SUB+= APXS=${APXS} + +SUBSTITUTIONS= -e "s|%%APP_HOME%%|${APP_HOME}|g" \ + -e "s|%%APP_NAME%%|${APP_NAME}|g" \ + -e "s|%%APXS%%|${APXS}|g" \ + -e "s|%%FILESDIR%%|${FILESDIR}|g" \ + -e "s|%%GROUP%%|${GROUP}|g" \ + -e "s|%%GID%%|${GID}|g" \ + -e "s|%%JAVA_HOME%%|${JAVA_HOME}|g" \ + -e "s|%%PERL%%|${PERL}|g" \ + -e "s|%%PID_FILE%%|${PID_FILE}|g" \ + -e "s|%%PORT%%|${PORT}|g" \ + -e "s|%%PORTNAME%%|${PORTNAME}|g" \ + -e "s|%%PREFIX%%|${PREFIX}|g" \ + -e "s|%%RUNASUID%%|${RUNASUID}|g" \ + -e "s|%%RUNASUSER%%|${RUNASUSER}|g" \ + -e "s|%%WRKDIR%%|${WRKDIR}|g" \ + -e "s|%%WRKSRC%%|${WRKSRC}|g" + .include -# Do not change the PID file location unless you also change it in pkg-deinstall script -PID_FILE= /var/run/resin.pid +post-patch: +.for FILE in ${REINPLACE_FILES} + @${SED} -i bak ${SUBSTITUTIONS} ${FILE} +.endfor +.for FILE in ${REPLACE_FILES} + @${SED} ${SUBSTITUTIONS} ${FILE} > ${WRKDIR}/`basename ${FILE}` +.endfor + @fmt -w 80 < ${WRKDIR}/pkg-message.in > ${PKGMESSAGE} +.if (defined(WITH_APACHE2) && (${WITH_APACHE2} == yes || ${WITH_APACHE2} == YES) || \ +defined(WITH_APACHE) && (${WITH_APACHE} == yes || ${WITH_APACHE} == YES)) + @${ECHO_CMD} >> ${PKGMESSAGE} + @${ECHO_CMD} The Resin Apache module mod_caucho has been activated \ + in the Apache configuration file, where you should also \ + add a line to specify the location of the Resin configuration \ + server, for example: | fmt -w 80 >> ${PKGMESSAGE} + @${ECHO_CMD} ResinConfigServer localhost 6802 >> ${PKGMESSAGE} +.endif + @${MV} ${WRKDIR}/wrapper.pl.in ${WRKSRC}/bin/wrapper.pl.in +# Resin does not handle installation, so proceed now post-install: - ${TOUCH} ${PID_FILE} - ${CHOWN} ${RUNASUID}:${GID} ${PID_FILE} - ${MKDIR} ${APP_HOME} - @PREFIX=${PREFIX} \ - PKGNAMEPREFIX=${PKGNAMEPREFIX} \ - PORTNAME=${PORTNAME} \ - WRKSRC=${WRKSRC} \ - RUNASUSER=${RUNASUSER} \ - RUNASUID=${RUNASUID} \ - GROUP=${GROUP} \ - GID=${GID} \ - PORT=${PORT} \ - APP_HOME=${APP_HOME} \ - JAVA_HOME=${JAVA_HOME} \ - ${SH} pkg-install ${PKGNAME} POST-INSTALL + @${SH} ${WRKDIR}/install.sh + @${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL + @${ECHO_CMD} + @${ECHO_CMD} "********************************************************************************" + @${CAT} ${PKGMESSAGE} + @${ECHO_CMD} "********************************************************************************" + @${ECHO_CMD} .include - -# ex:ts=18 diff --git a/www/resin3/files/install.sh b/www/resin3/files/install.sh new file mode 100644 index 000000000000..24794c4e9be9 --- /dev/null +++ b/www/resin3/files/install.sh @@ -0,0 +1,51 @@ +#! /bin/sh + +set -e + +warning() { + echo "Kept %%PREFIX%%/etc/%%APP_NAME%%.xml intact from previous installation, please diff" + echo "against %%APP_NAME%%.xml-dist" +} + +# Install config file only if none is already there +if test -e %%PREFIX%%/etc/%%APP_NAME%%.xml && \ + ! cmp -s %%WRKDIR%%/resin.conf %%PREFIX%%/etc/%%APP_NAME%%.xml ; then + echo + echo "********************************************************************************" + warning | fmt -w 80 + echo "********************************************************************************" + echo +else + install %%WRKDIR%%/resin.conf %%PREFIX%%/etc/%%APP_NAME%%.xml + echo Installed %%PREFIX%%/etc/%%APP_NAME%%.xml +fi + +# Install new config file with '-dist' appended +install %%WRKDIR%%/resin.conf %%PREFIX%%/etc/%%APP_NAME%%.xml-dist +echo Installed %%PREFIX%%/etc/%%APP_NAME%%.xml-dist + +install %%WRKSRC%%/conf/app-default.xml %%PREFIX%%/etc/ +echo Installed %%PREFIX%%/etc/app-default.xml + +install %%WRKDIR%%/resin.sh.in %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh +chmod 755 %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh +echo Installed %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh + +install %%WRKSRC%%/bin/wrapper.pl %%PREFIX%%/sbin/%%APP_NAME%%ctl +echo Installed %%PREFIX%%/sbin/%%APP_NAME%%ctl + +test -d %%APP_HOME%% || mkdir %%APP_HOME%% +echo Created installation directory %%APP_HOME%% + +list() +{ + for dir in doc lib libexec xsl ; do + ( cd %%WRKSRC%% ; find $dir ) + done +} + +# Remove all empty dirs +( cd %%WRKSRC%% ; find doc -type d -empty -delete ) + +echo Installing in %%APP_HOME%% +list | xargs tar -C %%WRKSRC%% -cf- | tar -C %%APP_HOME%% -xpf- diff --git a/www/resin3/files/patch-apache-Makefile.in b/www/resin3/files/patch-apache-Makefile.in new file mode 100644 index 000000000000..4b10a88f34b5 --- /dev/null +++ b/www/resin3/files/patch-apache-Makefile.in @@ -0,0 +1,12 @@ +--- src/c/plugin/apache/Makefile.in.orig Thu Nov 13 09:27:52 2003 ++++ src/c/plugin/apache/Makefile.in Thu Nov 13 09:28:36 2003 +@@ -28,8 +28,7 @@ + $(CC) -c $(INCLUDES) $(CFLAGS) $< + + install : +- sh install.sh -conf $(apache_conf) -libexec $(apache_libexec) \ +- -resin_home $(resin_home) ++ %%APXS%% -i -a -n caucho mod_caucho.so + + clean : + - rm *.o *.lo *.la *.so diff --git a/www/resin3/files/patch-apache2-Makefile.in b/www/resin3/files/patch-apache2-Makefile.in new file mode 100644 index 000000000000..21abaf49de07 --- /dev/null +++ b/www/resin3/files/patch-apache2-Makefile.in @@ -0,0 +1,12 @@ +--- src/c/plugin/apache2/Makefile.in.orig Tue Sep 23 00:54:34 2003 ++++ src/c/plugin/apache2/Makefile.in Mon Nov 17 11:33:19 2003 +@@ -30,8 +30,7 @@ + $(CC) -c $(INCLUDES) $(CFLAGS) $< + + install : +- sh install.sh -conf $(apache_conf) -apache_dir $(apache_dir) \ +- -libexec $(apache_libexec) -resin_home $(resin_home) ++ %%APXS%% -i -a -n caucho mod_caucho.so + + clean : + - rm *.o *.lo *.so diff --git a/www/resin3/files/patch-wrapper b/www/resin3/files/patch-wrapper new file mode 100644 index 000000000000..7d3f9aadfb18 --- /dev/null +++ b/www/resin3/files/patch-wrapper @@ -0,0 +1,8 @@ +--- bin/wrapper.pl.in.orig Sat Oct 4 09:45:23 2003 ++++ bin/wrapper.pl.in Sat Oct 4 09:45:43 2003 +@@ -1,4 +1,4 @@ +-#! @PERL@ ++#! %%PERL%% + # + # Copyright(c) 1998-2002 Caucho Technology + # diff --git a/www/resin3/files/pkg-deinstall b/www/resin3/files/pkg-deinstall new file mode 100644 index 000000000000..b56243508443 --- /dev/null +++ b/www/resin3/files/pkg-deinstall @@ -0,0 +1,52 @@ +#!/bin/sh +# +# This script does the following. +# +# * Checks if the PID file exists. If it does, it kills the +# process and removes the PID file. +# +# * Checks if the 'www' user exists. If it does, then it displays +# a message. +# +# $FreeBSD: /tmp/pcvs/ports/www/resin3/files/Attic/pkg-deinstall,v 1.1 2003-11-20 21:44:14 glewis Exp $ +# +# Borrowed from the jakarta-tomcat port +# + +set -e + +PID_FILE=%%PID_FILE%% +RUNASUSER=%%RUNASUSER%% + +# Make sure we're in the right stage of the process +if [ "$2" = "DEINSTALL" ]; then + + # Kill the process if it is still running + if [ -s ${PID_FILE} ]; then + PID=`cat ${PID_FILE}` + echo -n ">> Killing %%APP_NAME%% process (${PID})..." + + if /bin/kill ${PID} > /dev/null 2> /dev/null ; then + echo " [ DONE ]" + else + echo " [ FAILED ]" + fi + + echo -n ">> Removing PID file (${PID_FILE})..." + + if rm ${PID_FILE} > /dev/null 2> /dev/null ; then + echo " [ DONE ]" + else + echo " [ FAILED ]" + fi + fi +fi + +if [ "$2" = "POST-DEINSTALL" ]; then + # If the user exists, then display a message + if pw usershow "$RUNASUSER" 2>/dev/null 1>&2; then + echo "To delete the $RUNASUSER user permanently, use 'pw userdel $RUNASUSER'" + fi +fi + +exit 0 diff --git a/www/resin3/files/pkg-install b/www/resin3/files/pkg-install new file mode 100644 index 000000000000..09c24fd66750 --- /dev/null +++ b/www/resin3/files/pkg-install @@ -0,0 +1,50 @@ +#!/bin/sh +# +# Checks if the requested user and group exist. If they don't, then +# an attempt is made to create both. +# +# $FreeBSD: /tmp/pcvs/ports/www/resin3/files/Attic/pkg-install,v 1.1 2003-11-20 21:44:14 glewis Exp $ +# +# Borrowed from the jakarta-tomcat port +# + +set -e + +RUNASUSER=%%RUNASUSER%% +RUNASUID=%%RUNASUID%% +GROUP=%%GROUP%% +GID=%%GID%% + +if [ "$2" = "POST-INSTALL" ]; then + # We're called after the 'make install' process + # See if the group already exists + if ! pw groupshow "${GROUP}" 2>/dev/null 1>&2; then + + # If not, try to create it + if pw groupadd ${GROUP} -g ${GID}; then + echo "Added group \"${GROUP}\"." + else + echo "Adding group \"${GROUP}\" failed..." + exit 1 + fi + fi + + # See if the user already exists + if ! pw usershow "${RUNASUSER}" 2>/dev/null 1>&2; then + + # If not, try to create it + if pw useradd ${RUNASUSER} -u ${RUNASUID} -g ${GROUP} -h - \ + -s "/sbin/nologin" -d "/nonexistent" \ + -c "World Wide Web Owner"; \ + then + echo "Added user \"${RUNASUSER}\"." + else + echo "Adding user \"${RUNASUSER}\" failed..." + exit 1 + fi + fi + + chown -R %%RUNASUSER%%:%%GROUP%% $PKG_PREFIX/%%APP_NAME%% +fi + +exit 0 diff --git a/www/resin3/files/pkg-message.in b/www/resin3/files/pkg-message.in new file mode 100644 index 000000000000..820698b9dda9 --- /dev/null +++ b/www/resin3/files/pkg-message.in @@ -0,0 +1,4 @@ +Resin is now installed in %%APP_HOME%%. You may want to start it using the +startup script installed as %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh, and then point +your web browser to the default home page at http://localhost:%%PORT%%/ to read +the doc. Resin can be configured using %%PREFIX%%/etc/%%APP_NAME%%.xml. diff --git a/www/resin3/files/resin.sh.in b/www/resin3/files/resin.sh.in new file mode 100644 index 000000000000..425dd0f8a8f7 --- /dev/null +++ b/www/resin3/files/resin.sh.in @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Resin startup script. +# +# Borrowed from jakarta-tomcat41 +# +# $FreeBSD$ +# + +# Determine PREFIX +if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/${0##*/}\$"); then + echo "$0: Cannot determine the PREFIX" >&2 + exit 1 +fi + +# Set some variables +MYSELF=`basename $0` +ARGS="-conf $PREFIX/etc/%%APP_NAME%%.xml \ +-chdir \ +-name %%APP_NAME%% \ +-class com.caucho.server.resin.Resin \ +-pid %%PID_FILE%%" +PATH=/usr/sbin:/usr/bin:/bin + +export JAVA_HOME=%%JAVA_HOME%% +export RESIN_HOME=$PREFIX/%%APP_NAME%% + +set -e + +case "$1" in + start) + echo -n ' ' + truncate -s 0 %%PID_FILE%% + chown %%RUNASUSER%%:%%GROUP%% %%PID_FILE%% + chmod 600 %%PID_FILE%% + su -f -m %%RUNASUSER%% -c "exec $PREFIX/sbin/%%APP_NAME%%ctl $ARGS start" \ + >/dev/null && echo -n '%%APP_NAME%%' + ;; + + stop) + echo -n ' ' + chown %%RUNASUSER%%:%%GROUP%% %%PID_FILE%% + chmod 600 %%PID_FILE%% + su -f -m %%RUNASUSER%% -c "exec $PREFIX/sbin/%%APP_NAME%%ctl $ARGS stop" \ + >/dev/null 2>&1 ; echo -n '%%APP_NAME%%' + ;; + *) + echo "" + echo "Usage: ${MYSELF} { start | stop }" + echo "" + exit 64 + ;; +esac diff --git a/www/resin3/pkg-deinstall b/www/resin3/pkg-deinstall deleted file mode 100644 index f5ec53c59f44..000000000000 --- a/www/resin3/pkg-deinstall +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# -# This script does the following. -# -# * Checks if the PID file exists. If it does, it kills the -# process and removes the PID file. -# -# * Checks if the 'www' user exists. If it does, then it displays -# a message. -# - -# Make sure we're in the right stage of the process -if [ "$2" = "DEINSTALL" ]; then - - # Kill the process if it is still running - PID_FILE=/var/run/resin.pid - if [ -s ${PID_FILE} ]; then - PID=`cat ${PID_FILE}` - echo -n ">> Killing Resin process (${PID})..." - /bin/kill ${PID} > /dev/null 2> /dev/null - if [ $? -eq 0 ]; then - echo " [ DONE ]" - else - echo " [ FAILED ]" - fi - echo -n ">> Removing PID file (${PID_FILE})..." - rm ${PID_FILE} > /dev/null 2> /dev/null - if [ $? -eq 0 ]; then - echo " [ DONE ]" - else - echo " [ FAILED ]" - fi - fi -fi - -if [ "$2" = "POST-DEINSTALL" ]; then - # If the user exists, then display a message - if pw usershow "www" 2>/dev/null 1>&2; then - echo "To delete the www user permanently, use 'pw userdel www'" - fi -fi - -exit 0 diff --git a/www/resin3/pkg-install b/www/resin3/pkg-install deleted file mode 100644 index c4757bf6c24e..000000000000 --- a/www/resin3/pkg-install +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh -e -# -# Checks if the 'www' user and group exist. If they don't, then -# an attempt is made to create both. -# -# Borrowed to the jakarta-tomcat port - -# Make sure we're called during the 'make install' process -if [ "$2" != "POST-INSTALL" ]; then - exit 0 -fi - -# See if the group already exists -if ! pw groupshow "${GROUP}" 2>/dev/null 1>&2; then - - # If not, try to create it - if pw groupadd ${GROUP} -g ${GID}; then - echo "Added group \"${GROUP}\"." - else - echo "Adding group \"${GROUP}\" failed..." - exit 1 - fi -fi - -# See if the user already exists -if ! pw usershow "${RUNASUSER}" 2>/dev/null 1>&2; then - - # If not, try to create it - if pw useradd ${RUNASUSER} -u ${RUNASUID} -g ${GROUP} -h - \ - -s "/sbin/nologin" -d "/nonexistent" \ - -c "World Wide Web Owner"; \ - then - echo "Added user \"${RUNASUSER}\"." - else - echo "Adding user \"${RUNASUSER}\" failed..." - exit 1 - fi -fi - - -################################################################################ - -sed -i -e "s|%%PORT%%|$PORT|g" $WRKSRC/conf/resin.conf - -# Install config file only if none is already there -if test -e $PREFIX/etc/resin.xml && ! diff $WRKSRC/conf/resin.conf $PREFIX/etc/resin.xml >/dev/null; then - cat <