Bug 139372 - java/jboss5 reorganization.
Summary: java/jboss5 reorganization.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Herve Quiroz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-06 03:40 UTC by Jonathan Chen
Modified: 2009-11-18 22:20 UTC (History)
0 users

See Also:


Attachments
file.diff (30.87 KB, patch)
2009-10-06 03:40 UTC, Jonathan Chen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Chen 2009-10-06 03:40:01 UTC
Reorganise the JBoss5 port:
  - remove daemonctl, use root startup (following tomcat, geronimo, etc).
  - allow arbitrary arguments to be handed to JBoss (long standing bug).
  - reorganise the directory structure to follow hier(7)
	 * JBOSS_HOME = /usr/local/share/jboss5
	 * deployment directory = /var/jboss5
	 * log directory = /var/log/jboss5

Request maintainership.

A note in UPDATING may be warranted due to directory relocations.

Fix: This patch removes the following files:
	files/daemonctl.1.in
	files/daemonctl.c.in
	files/patch-build-common.xml
	files/patch-build.xml
Comment 1 Jonathan Chen 2009-10-06 20:52:22 UTC
Please use this updated patch which fixes package creation.
-- 
Jonathan Chen <jonc@chen.org.nz>
----------------------------------------------------------------------
                                                 Vini, vidi, velcro...
                                         I came, I saw, I stuck around


diff -ruN /usr/ports/java/jboss5/Makefile ./Makefile
--- /usr/ports/java/jboss5/Makefile	2009-09-07 09:12:34.000000000 +1200
+++ ./Makefile	2009-10-07 08:42:24.000000000 +1300
@@ -5,87 +5,60 @@
 # $FreeBSD: ports/java/jboss5/Makefile,v 1.50 2009/09/02 17:13:03 miwi Exp $
 #
 
-PORTNAME=	${APP_TITLE:L}
+PORTNAME=	jboss
 PORTVERSION=	5.1.0.GA
 PORTEPOCH=	1
 CATEGORIES=	java devel
 MASTER_SITES=	SF/${PORTNAME}/JBoss/JBoss-${PORTVERSION}
 DISTNAME=	${PORTNAME}-${PORTVERSION}-src
 
-MAINTAINER=	ports@FreeBSD.org
+MAINTAINER=	jonc@chen.org.nz
 COMMENT=	Open-source J2EE application server (5.x family)
 
-BUILD_DEPENDS=	ant:${PORTSDIR}/devel/apache-ant
-
 LATEST_LINK=	jboss5
 USE_JAVA=	yes
 JAVA_VERSION=	1.5+
 USE_ANT=	yes
+DATADIR=	${PREFIX}/share/${UNIQUENAME}
+DOCSDIR=	${PREFIX}/share/doc/${UNIQUENAME}
 
 MANUAL_PACKAGE_BUILD=	fetches files in build phase
 
 MAKE_ARGS=	-buildfile build/build.xml
 
 USE_RC_SUBR=	jboss5.sh
-SUB_FILES=	pkg-install pkg-deinstall pkg-message daemonctl.1 daemonctl.c
+SUB_FILES=	pkg-install pkg-deinstall pkg-message
 
+PORTDATA=	*
 .if !defined(NOPORTDOCS)
 PORTDOCS=	*
 .endif
 
-APP_HOME?=	${PREFIX}/${APP_SHORTNAME}
-DOCSDIR=	${PREFIX}/share/doc/${LATEST_LINK}
-LOG_DIR=	${APP_HOME}/log
-APP_TITLE=	JBoss
-APP_SHORTNAME=	${UNIQUENAME}
-CONTROL_SCRIPT_NAME=	${APP_SHORTNAME}ctl
-CONTROL_SCRIPT=	${PREFIX}/bin/${CONTROL_SCRIPT_NAME}
-CONTROL_SCRIPT_MANPAGE_TITLE=	${CONTROL_SCRIPT_NAME:U}
-STARTUP_SCRIPT_NAME=	${APP_SHORTNAME}.sh
-STARTUP_SCRIPT=	${PREFIX}/etc/rc.d/${STARTUP_SCRIPT_NAME}
+VAR_DIR?=	/var
+LOG_DIR?=	${VAR_DIR}/log/${UNIQUENAME}
+DEPLOY_DIR?=	${VAR_DIR}/${UNIQUENAME}
 USER=		www
 GROUP=		www
 STDOUT_LOG=	${LOG_DIR}/stdout.log
 STDERR_LOG=	${LOG_DIR}/stderr.log
-AUTO_START?=	NO
-STOP_TIMEOUT?=	5
-PID_FILE=	/var/run/${APP_SHORTNAME}.pid
-JAVA_OPTS=
-JAVA_CP=	bin/run.jar:${JAVA_HOME}/lib/tools.jar
-JAVA_MAIN=	org.jboss.Main
-MAN1=		${CONTROL_SCRIPT_NAME}.1
+STOP_TIMEOUT?=	10
+PID_FILE=	/var/run/${UNIQUENAME}.pid
 
 JBOSSOUTPUT=	${WRKSRC}/build/output/${PORTNAME}-${PORTVERSION}
-APP_HOME_FILES=	bin client lib server common
+APP_HOME_FILES=	bin/run.jar client lib common
 
 PKGMESSAGE=	${WRKDIR}/pkg-message
 
-PLIST_FILES=	${CONTROL_SCRIPT:S,^${PREFIX}/,,} \
-		${STDOUT_LOG:S,^${PREFIX}/,,} \
-		${STDERR_LOG:S,^${PREFIX}/,,}
-
-SUB_LIST=	APP_HOME=${APP_HOME} \
-		APP_SHORTNAME=${APP_SHORTNAME} \
-		APP_TITLE=${APP_TITLE} \
-		CONTROL_SCRIPT=${CONTROL_SCRIPT} \
-		CONTROL_SCRIPT_MANPAGE_TITLE=${CONTROL_SCRIPT_MANPAGE_TITLE} \
-		CONTROL_SCRIPT_NAME=${CONTROL_SCRIPT_NAME} \
+SUB_LIST=	APP_HOME=${DATADIR} \
+		APP_SHORTNAME=${UNIQUENAME} \
 		GROUP=${GROUP} \
-		JAVA=${JAVA} \
-		JAVA_CP=${JAVA_CP} \
-		JAVA_HOME=${JAVA_HOME} \
-		JAVA_MAIN=${JAVA_MAIN} \
-		JAVA_OPTS=${JAVA_OPTS} \
-		JAVA_PORT_VERSION=${JAVA_PORT_VERSION} \
-		JAVA_PORT_OS_DESCRIPTION=${JAVA_PORT_OS_DESCRIPTION} \
-		JAR_FILE=${JAR_FILE} \
 		LOG_DIR=${LOG_DIR} \
+		DEPLOY_DIR=${DEPLOY_DIR} \
 		PID_FILE=${PID_FILE} \
 		PKGNAME=${PKGNAME} \
 		PORTNAME=${PORTNAME} \
 		PORTVERSION=${PORTVERSION} \
 		PREFIX=${PREFIX} \
-		STARTUP_SCRIPT=${STARTUP_SCRIPT} \
 		STDERR_LOG=${STDERR_LOG} \
 		STDOUT_LOG=${STDOUT_LOG} \
 		STOP_TIMEOUT=${STOP_TIMEOUT} \
@@ -93,35 +66,17 @@
 
 .include <bsd.port.pre.mk>
 
-pre-patch:
-	@${ECHO_MSG} "Installation settings:"
-	@${ECHO_MSG} "   Destination directory:    ${APP_HOME}"
-	@${ECHO_MSG} "   Control program location: ${CONTROL_SCRIPT}"
-	@${ECHO_MSG} "   Startup script location:  ${STARTUP_SCRIPT}"
-	@${ECHO_MSG} "   Location of JDK:          ${JAVA_HOME}"
-	@${ECHO_MSG} "   Location of Java port:    ${JAVA_PORT}"
-	@${ECHO_MSG} "   Startup Java Options:     ${JAVA_OPTS}"
-	@${ECHO_MSG} "   Running as (user/group):  ${USER}/${GROUP}"
-	@${ECHO_MSG} "   Logfile stdout:           ${STDOUT_LOG}"
-	@${ECHO_MSG} "   Logfile stderr:           ${STDERR_LOG}"
-	@${ECHO_MSG} "   Starting after install:   ${AUTO_START}"
-	@${ECHO_MSG} "   Stop time-out:            ${STOP_TIMEOUT} sec."
-
-pre-install:
-	@${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
-
 do-install:
-	cd ${WRKDIR} && ${CC} ${CFLAGS} -o ${CONTROL_SCRIPT_NAME} daemonctl.c
-	${MKDIR} ${APP_HOME} && ${CHOWN} ${USER}:${GROUP} ${APP_HOME}
+	${MKDIR} ${DATADIR}/bin && ${CHOWN} -R ${USER}:${GROUP} ${DATADIR}
 	${MKDIR} ${LOG_DIR} && ${CHOWN} ${USER}:${GROUP} ${LOG_DIR}
+	${MKDIR} ${DEPLOY_DIR} && ${CHOWN} ${USER}:${GROUP} ${DEPLOY_DIR}
 	(cd ${JBOSSOUTPUT} && ${FIND} ${APP_HOME_FILES} |\
-		${CPIO} -pdmu -R ${USER}:${GROUP} ${APP_HOME})
-	${INSTALL} -o ${USER} -g ${GROUP} -m 06754\
-		${WRKDIR}/${CONTROL_SCRIPT_NAME} ${CONTROL_SCRIPT}
+		${CPIO} -pdmu -R ${USER}:${GROUP} ${DATADIR})
+	(cd ${JBOSSOUTPUT}/server && ${FIND} . |\
+		${CPIO} -pdmu -R ${USER}:${GROUP} ${DEPLOY_DIR})
 	${INSTALL} -o ${USER} -g ${GROUP} -m 0640 /dev/null ${STDOUT_LOG}
 	${INSTALL} -o ${USER} -g ${GROUP} -m 0640 /dev/null ${STDERR_LOG}
 	${INSTALL} -o ${USER} -g ${GROUP} -m 0640 /dev/null ${PID_FILE}
-	${INSTALL_MAN} ${WRKDIR}/daemonctl.1 ${MANPREFIX}/man/man1/${CONTROL_SCRIPT_NAME}.1
 .if !defined(NOPORTDOCS)
 	cd ${JBOSSOUTPUT}/docs \
 		&& ${FIND} . -type d -exec ${MKDIR} ${DOCSDIR}/{} \; \
@@ -129,15 +84,15 @@
 .endif
 
 post-install:
-	@${FIND} -s ${APP_HOME_FILES:S,^,${JBOSSOUTPUT}/,} -not -type d | \
-		${SED} -ne 's,^${JBOSSOUTPUT},${APP_HOME:S,${PREFIX}/,,},p' >> ${TMPPLIST}
-	@${FIND} -s -d ${APP_HOME_FILES:S,^,${JBOSSOUTPUT}/,} -type d | \
-		${SED} -ne 's,^${JBOSSOUTPUT},@dirrm ${APP_HOME:S,${PREFIX}/,,},p' >> ${TMPPLIST}
-	@${ECHO_CMD} "@dirrm ${APP_HOME:S,^${PREFIX}/,,}/log" >> ${TMPPLIST}
-	@${ECHO_CMD} "@dirrm ${APP_HOME:S,^${PREFIX}/,,}" >> ${TMPPLIST}
-.if ${AUTO_START} == "YES"
-	@${CONTROL_SCRIPT} start || true
-.endif
+	@${ECHO_CMD} "@cwd ${VAR_DIR}" >> ${TMPPLIST}
+	@${FIND} -s ${JBOSSOUTPUT}/server -not -type d | \
+		${SED} -ne 's,^${JBOSSOUTPUT}/server/,${DEPLOY_DIR:S,^${VAR_DIR}/,,}/,p' >> ${TMPPLIST}
+	@${FIND} -s -d ${JBOSSOUTPUT}/server -type d | \
+		${SED} -ne 's,^${JBOSSOUTPUT}/server/,@dirrm ${DEPLOY_DIR:S,^${VAR_DIR}/,,}/,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${DEPLOY_DIR:S,^${VAR_DIR}/,,}" >> ${TMPPLIST}
+	@${ECHO_CMD} "${STDOUT_LOG:S,^${VAR_DIR}/,,}" >> ${TMPPLIST}
+	@${ECHO_CMD} "${STDERR_LOG:S,^${VAR_DIR}/,,}" >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${LOG_DIR:S,^${VAR_DIR}/,,}" >> ${TMPPLIST}
 .if !defined(BATCH)
 	@${CAT} ${PKGMESSAGE}
 .endif
diff -ruN /usr/ports/java/jboss5/files/daemonctl.1.in ./files/daemonctl.1.in
--- /usr/ports/java/jboss5/files/daemonctl.1.in	2007-03-28 17:47:17.000000000 +1200
+++ ./files/daemonctl.1.in	1970-01-01 12:00:00.000000000 +1200
@@ -1,78 +0,0 @@
-.Dd February 21, 2002
-.Dt %%CONTROL_SCRIPT_MANPAGE_TITLE%% 1
-.Os FreeBSD
-.Sh NAME
-.Nm %%CONTROL_SCRIPT_NAME%%
-.Nd %%APP_TITLE%% server control interface
-.Sh SYNOPSIS
-.Nm
-.Op Fl java-options
-.Ar {start|restart|stop}
-.Sh DESCRIPTION
-The
-.Nm
-program provides an restricted interface to the %%APP_TITLE%%
-application server. The
-.Nm
-program is only accessible to users in the 'www' group, and will
-only invoke the %%JAVA_PORT_OS_DESCRIPTION%% %%JAVA_PORT_VERSION%% JVM.
-.Pp
-Any Java options listed are handed off directly to the JVM. Any
-classpath options will be ignored.
-.Pp
-The program expects exactly one of the following terminating commands:
-.Bl -tag -width indent
-.It Ar start
-Start %%APP_TITLE%%, if it is not already running.
-.It Ar restart
-Restart %%APP_TITLE%%. If it is already running, then it will be stopped and
-then started right after that. Otherwise it will just be started up.
-.It Ar stop
-Stop %%APP_TITLE%%, if it is actually running.
-.El
-.Sh ERRORS
-The following error conditions are detected. They will be checked in the
-specified order. In each case an error message is printed with the name of the
-control program prepended.
-.Pp
-If no argument is passed, then a simple help message is printed and the
-program exists with error code 0.
-.Pp
-If at least one argument is passed, but it is different from
-.Ar start ,
-.Ar restart
-or
-.Ar stop
-then the help message is printed as well, and the program exits with error
-code 1.
-.Pp
-The following errors conditions are defined:
-.Bl -tag -width indent
-.It Em Illegal program argument (error code 1)
-.It Em PID file not found (error code 2)
-.It Em PID file too large (error code 3)
-.It Em PID file contains illegal character (error code 4)
-.It Em Kill of process failed (error code 5)
-.It Em %%APP_TITLE%% is already running (error code 6)
-.It Em %%APP_TITLE%% is not running (error code 7)
-.It Em Unable to chdir to the %%APP_TITLE%% home directory (error code 8)
-.It Em Unable to open the stdout log file (error code 9)
-.It Em Unable to open the stderr log file (error code 10)
-.It Em Unable to start %%APP_TITLE%% (error code 11)
-.El
-.Sh FILES
-.Bl -tag -width -indent
-.It Pa %%PID_FILE%%
-The %%APP_TITLE%% PID file that is used to store the process ID of the
-currently running process in. It is emptied as soon as the server is stopped
-and filled with the process ID when it is started. It should never be writable
-for anyone but
-.Em www ,
-.It Pa %%STARTUP_SCRIPT%%
-A script that starts the
-.Nm
-program. It is used to start %%APP_TITLE%% at startup time.
-.El
-.Sh AUTHORS
-.An Ernst de Haan Aq znerd@FreeBSD.org
-.An Jonathan Chen Aq jonc@chen.org.nz
diff -ruN /usr/ports/java/jboss5/files/daemonctl.c.in ./files/daemonctl.c.in
--- /usr/ports/java/jboss5/files/daemonctl.c.in	2007-03-28 17:47:17.000000000 +1200
+++ ./files/daemonctl.c.in	1970-01-01 12:00:00.000000000 +1200
@@ -1,557 +0,0 @@
-/*
- * -*- mode: Fundamental; tab-width: 4; -*-
- * ex:ts=4
- *
- * Daemon control program, with Java Startup options.
- *
- *	Original by Ernst de Haan <znerd@freebsd.org>
- *	www/jakarta-tomcat4/files/daemonctl.c
- *
- * $FreeBSD: ports/java/jboss5/files/daemonctl.c.in,v 1.1 2007/03/28 05:47:17 delphij Exp $
- */
-
-#include <assert.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <sys/errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-
-#define	TRUE	1
-#define	FALSE	0
-
-/* The interval in seconds between the checks to make sure the process
-   died after a kill */
-#define STOP_TIME_INTERVAL		1
-
-#define ERR_ILLEGAL_ARGUMENT				1
-#define ERR_PID_FILE_NOT_FOUND				2
-#define ERR_KILL_FAILED						5
-#define ERR_ALREADY_RUNNING					6
-#define ERR_NOT_RUNNING						7
-#define ERR_CHDIR_TO_APP_HOME				8
-#define ERR_ACCESS_JAR_FILE					17
-#define ERR_STDOUT_LOGFILE_OPEN				9
-#define ERR_STDERR_LOGFILE_OPEN				10
-#define ERR_FORK_FAILED						11
-#define ERR_STAT_JAVA_HOME					12
-#define ERR_JAVA_HOME_NOT_DIR				13
-#define ERR_STAT_JAVA_CMD					14
-#define ERR_JAVA_CMD_NOT_FILE				15
-#define ERR_JAVA_CMD_NOT_EXECUTABLE			16
-
-/*
-	Function declarations.
- */
-static void printUsage (void);
-static int readPID (void);
-static void writePID (int pid);
-static void clearPID (void);
-static void start (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
-static void stop (void);
-static void restart (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
-static void logOutput (char *);
-
-/*
-	Globals
- */
-static int isQuiet = FALSE;
-static char * optQuiet = "-q",			/* quiet option */
-			* optConfig = "-config";	/* jboss configuration option */
-
-/**
- * Main function. This function is called when this program is executed.
- *
- * @param argc
- *    the number of arguments plus one, so always greater than 0.
- *
- * @param argv
- *    the arguments in an array of character pointers, where the last argument
- *    element is followed by a NULL element.
- */
-int
-main (
- int argc,
- char *argv [])
-{
-	/* Declare variables, like all other good ANSI C programs do :) */
-	int i, javaOpt, jbossOpt;
-	char *argument, **javaArgs, **jbossArgs;
-
-	/* Parse the arguments */
-	if (argc < 2)
-	{
-		printUsage ();
-		return 0;
-	}
-
-	/* XXX: Fix for setting up the environment for the java wrapper script */
-	setuid (geteuid ());
-	setgid (getegid ());
-
-	/*
-		Build up java and jboss option blocks.
-	 */
-	javaOpt = jbossOpt = 0;
-	for (i = 1; i < argc; i++)
-	{
-		if (strcmp (argv [i], optQuiet) == 0)
-		{
-			isQuiet = TRUE;
-
-		} else if (strcmp (argv [i], optConfig) == 0)
-		{
-			jbossOpt += 2;
-			if (++i >= argc)
-			{
-				printUsage ();
-				return ERR_ILLEGAL_ARGUMENT;
-			}
-
-		} else if (*argv [i] == '-')
-		{
-			javaOpt++;
-		}
-	}
-	if (javaOpt == 0)
-		javaArgs = NULL;
-	else
-	{
-		int j = 0;
-		javaArgs = malloc (sizeof (char *) * javaOpt);
-		for (i = 0; i < argc; i++)
-		{
-			if (strcmp (argv [i], optQuiet) &&
-				strcmp (argv [i], optConfig) &&
-				*argv [i] == '-')
-			{
-				javaArgs [j++] = argv [i];
-			}
-		}
-	}
-	if (jbossOpt == 0)
-		jbossArgs = NULL;
-	else
-	{
-		int j = 0;
-		jbossArgs = malloc (sizeof (char *) * jbossOpt);
-		for (i = 0; i < argc; i++)
-		{
-			if (strcmp (argv [i], optConfig) == 0)
-			{
-				jbossArgs [j++] = "-c";
-				jbossArgs [j++] = argv [++i];
-			}
-		}
-	}
-
-	/*
-		Decide on just what to call.
-	 */
-	argument = argv [argc - 1];
-	if (strcmp ("start", argument) == 0)
-	{
-		start (javaOpt, javaArgs, jbossOpt, jbossArgs);
-
-	} else if (strcmp ("stop", argument) == 0)
-	{
-		stop ();
-
-	} else if (strcmp ("restart", argument) == 0)
-	{
-		restart (javaOpt, javaArgs, jbossOpt, jbossArgs);
-
-	} else {
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Illegal argument \"%s\".\n", argument);
-		printUsage ();
-		exit (ERR_ILLEGAL_ARGUMENT);
-	}
-
-	return EXIT_SUCCESS;
-}
-
-/**
- * Prints usage information to stdout.
- */
-static void
-printUsage (void)
-{
-	printf ("Usage: %%CONTROL_SCRIPT_NAME%% [java-options] [-config jbossconfig] {start|stop|restart}\n");
-}
-
-/**
- * Reads a PID from the PID file.
- *
- * @return
- *    the PID, or -1 if the file was empty.
- */
-static int
-readPID (void)
-{
-	FILE * file;
-	int pid;
-
-	logOutput (">> Reading PID file (%%PID_FILE%%)...");
-	file = fopen ("%%PID_FILE%%", "r");
-	if (!file)
-	{
-		logOutput (" [ FAILED ]\n");
-		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for reading: ");
-		exit (ERR_PID_FILE_NOT_FOUND);
-	}
-	if (fscanf (file, "%d", &pid) < 1)
-		pid = -1;
-	fclose (file);
-
-	logOutput (" [ DONE ]\n");
-	return pid;
-}
-
-/**
- * Writes a process ID to the specified file. The file is identified by a file
- * handle.
- *
- * @param pid
- *    the PID to store, always greater than 0.
- */
-static void
-writePID (
- int pid)
-{
-	FILE * file;
-
-	logOutput (">> Writing PID file...");
-	file = fopen ("%%PID_FILE%%", "w");
-	if (!file)
-	{
-		logOutput (" [ FAILED ]\n");
-		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for writing: ");
-		exit (ERR_PID_FILE_NOT_FOUND);
-	}
-	fprintf (file, "%d\n", pid);
-	fclose (file);
-
-	logOutput (" [ DONE ]\n");
-}
-
-/**
-	Truncate the PID file.
- */
-static void
-clearPID (void)
-{
-	if (truncate ("%%PID_FILE%%", 0) != 0)
-	{
-		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to clear %%PID_FILE%%: ");
-		exit (ERR_PID_FILE_NOT_FOUND);
-	}
-}
-
-/**
- * Checks if the specified process is running.
- *
- * @param pid
- *    the process id, greater than 0.
- *
- * @return
- *    0 if the specified process is not running, a different value otherwise.
- */
-static int
-existsProcess (
- int pid)
-{
-	int result;
-
-	/* Check preconditions */
-	assert (pid > 0);
-
-	/* See if the process exists */
-   	result = kill (pid, 0);
-
-	/* If the result is 0, then the process exists */
-	return result == 0;
-}
-
-/**
- * Kills the process identified by the specified ID.
- *
- * @param pid
- *    the process id, greater than 0.
- */
-static void
-killProcess (
- int pid)
-{
-	int result;
-	unsigned int waited;
-	unsigned int forced;
-	unsigned int interval = STOP_TIME_INTERVAL;
-	unsigned int timeout  = %%STOP_TIMEOUT%%;
-
-	/* Check preconditions */
-	assert (pid > 0);
-
-	if (!isQuiet)
-		printf (">> Terminating process %d...", pid);
-	result = kill (pid, SIGTERM);
-	if (result < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
-		perror (NULL);
-		exit (ERR_KILL_FAILED);
-	}
-
-	/* Wait until the process is actually killed */
-    result = existsProcess (pid);
-	for (waited=0; result == 1 && waited < timeout; waited += interval)
-	{
-		logOutput (".");
-		fflush (stdout);
-		sleep (interval);
-    	result = existsProcess (pid);
-	}
-
-	/* If the process still exists, then have no mercy and kill it */
-	forced = 0;
-	if (result == 1)
-	{
-		/* Force the process to die */
-		result = kill (pid, SIGKILL);
-		if (result == 0) {
-			forced = 1;
-			logOutput (" [ KILLED ]\n");
-			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Process %d did not terminate within %%STOP_TIMEOUT%% sec. Killed.\n", pid);
-		} else if (result != ESRCH) {
-			logOutput (" [ FAILED ]\n");
-			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
-			perror (NULL);
-			exit (ERR_KILL_FAILED);
-		}
-	}
-
-	if (forced == 0) {
-		logOutput (" [ DONE ]\n");
-	}
-}
-
-/**
- * Starts the daemon.
- */
-static void
-start (
- int javaOpt,
- char * javaArgs [],
- int jbossOpt,
- char * jbossArgs [])
-{
-	int i, argc;
-	char ** argv;
-	int pid;
-	int result;
-	int stdoutLogFile;
-	int stderrLogFile;
-	struct stat sb;
-
-	pid = readPID ();
-
-	logOutput (">> Starting %%APP_TITLE%% %%PORTVERSION%%...");
-	if (pid != -1)
-	{
-		/* Check if the process actually exists */
-		result = existsProcess (pid);
-		if (result == 1)
-		{
-			logOutput (" [ FAILED ]\n");
-			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is already running, PID is %d.\n", pid);
-			exit (ERR_ALREADY_RUNNING);
-		}
-	}
-
-	/* Check if the JDK home directory is actually a directory */
-	result = stat ("%%JAVA_HOME%%", &sb);
-	if (result != 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA_HOME%%: ");
-		perror (NULL);
-		exit (ERR_STAT_JAVA_HOME);
-	}
-	if (!S_ISDIR (sb.st_mode)) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java home directory %%JAVA_HOME%% is not a directory.\n");
-		exit (ERR_JAVA_HOME_NOT_DIR);
-	}
-
-	/* Check if the Java command is actually an executable regular file */
-	result = stat ("%%JAVA%%", &sb);
-	if (result != 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA%%: ");
-		perror (NULL);
-		exit (ERR_STAT_JAVA_CMD);
-	}
-	if (!S_ISREG (sb.st_mode)) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not a regular file.\n");
-		exit (ERR_JAVA_CMD_NOT_FILE);
-	}
-	result = access ("%%JAVA%%", X_OK);
-	if (result != 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not executable: ");
-		perror (NULL);
-		exit (ERR_JAVA_CMD_NOT_EXECUTABLE);
-	}
-
-	/* Change directory */
-	result = chdir ("%%APP_HOME%%");
-	if (result < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access directory %%APP_HOME%%: ");
-		perror (NULL);
-		exit (ERR_CHDIR_TO_APP_HOME);
-	}
-
-	/* See if the JAR file exists */
-	result = access ("%%APP_HOME%%/%%JAR_FILE%%", R_OK);
-	if (result < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access JAR file %%APP_HOME%%/%%JAR_FILE%%: ");
-		perror (NULL);
-		exit (ERR_ACCESS_JAR_FILE);
-	}
-
-	/* Open the stdout log file */
-	stdoutLogFile = open ("%%STDOUT_LOG%%", O_WRONLY);
-	if (stdoutLogFile < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDOUT_LOG%% for writing: ");
-		perror (NULL);
-		exit (ERR_STDOUT_LOGFILE_OPEN);
-	}
-	lseek (stdoutLogFile, (off_t) 0, SEEK_END);
-
-	/* Open the stderr log file */
-	stderrLogFile = open ("%%STDERR_LOG%%", O_WRONLY);
-	if (stderrLogFile < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDERR_LOG%% for writing: ");
-		perror (NULL);
-		exit (ERR_STDERR_LOGFILE_OPEN);
-	}
-	lseek (stderrLogFile, (off_t) 0, SEEK_END);
-
-	/* Split this process in two */
-	switch (pid = fork ())
-	{
-	case -1:
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to fork: ");
-		perror (NULL);
-		exit (ERR_FORK_FAILED);
-		break;
-
-	case 0:
-		/* Redirect stdout to log file */
-		dup2 (stdoutLogFile, STDOUT_FILENO);
-
-		/* Redirect stderr to log file */
-		dup2 (stderrLogFile, STDERR_FILENO);
-
-		/* TODO: Support redirection of both stdout and stderr to the same
-				 file using pipe (2) */
-
-		/*
-			Build the argument vector, with the java/jboss options if any.
-		 */
-		argv = malloc (sizeof (char *) * (javaOpt + jbossOpt + 5));
-		argc = 0;
-		argv [argc++] = "%%JAVA%%";
-		for (i = 0; i < javaOpt; i++)
-			argv [argc++] = javaArgs [i];
-		argv [argc++] = "-cp";
-		argv [argc++] = "%%JAVA_CP%%";
-		argv [argc++] = "%%JAVA_MAIN%%";
-		for (i = 0; i < jbossOpt; i++)
-			argv [argc++] = jbossArgs [i];
-		argv [argc++] = NULL;
-
-		/* Execute the command */
-		execv (argv [0], argv);
-		perror (NULL);
-		break;
-
-	default:
-		logOutput (" [ DONE ]\n");
-		writePID (pid);
-	}
-}
-
-/**
- * Stops the daemon.
- */
-static void
-stop (void)
-{
-	int pid;
-
-	pid = readPID ();
-
-	logOutput (">> Checking if %%APP_TITLE%% %%PORTVERSION%% is running...");
-
-	/* If there is a PID, see if the process still exists */
-	if (pid != -1)
-	{
-		int result = kill (pid, 0);
-		if (result != 0 && errno == ESRCH)
-		{
-			clearPID ();
-			pid = -1;
-		}
-	}
-
-	/* If there is no running process, produce an error */
-	if (pid == -1)
-	{
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is currently not running.\n");
-		exit (ERR_NOT_RUNNING);
-	}
-	logOutput (" [ DONE ]\n");
-
-	/* Terminate the process */
-	killProcess (pid);
-	clearPID ();
-}
-
-
-/**
- * Restarts the process. If it not currently running, then it will fail.
- */
-static void
-restart (
- int javaOpt,
- char * javaArgs [],
- int jbossOpt,
- char * jbossArgs [])
-{
-	stop ();
-	start (javaOpt, javaArgs, jbossOpt, jbossArgs);
-}
-
-/**
-	Output log to stdout.
- */
-static void
-logOutput (
- char * string)
-{
-	if (!isQuiet)
-		printf (string);
-}
diff -ruN /usr/ports/java/jboss5/files/jboss5.sh.in ./files/jboss5.sh.in
--- /usr/ports/java/jboss5/files/jboss5.sh.in	2007-03-28 17:47:17.000000000 +1200
+++ ./files/jboss5.sh.in	2009-10-07 08:31:15.000000000 +1300
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# %%APP_TITLE%% startup script.
+# %%APP_SHORTNAME%% startup script.
 #
 # $FreeBSD: ports/java/jboss5/files/jboss5.sh.in,v 1.1 2007/03/28 05:47:17 delphij Exp $
 #
@@ -9,53 +9,95 @@
 # REQUIRE: NETWORKING SERVERS
 
 # Add the following lines to /etc/rc.conf to enable %%APP_SHORTNAME%%:
-# %%APP_SHORTNAME%%_enable (bool):		Set to "NO" by default.
-#				Set it to "YES" to enable %%APP_SHORTNAME%%
-# %%APP_SHORTNAME%%_flags (str):		Set to "-server" by default.
-#				Extra JVM flags.
-# %%APP_SHORTNAME%%_config (str):		Set to "" by default
-#				JBoss server config, eg {all|default|minimal|standard}
+# %%APP_SHORTNAME%%_enable (bool):      Set to "YES" to enable %%APP_SHORTNAME%%
+# %%APP_SHORTNAME%%_jvm_opts (str):     Extra JVM flags.
+# %%APP_SHORTNAME%%_args (str):         Optional arguments to JBoss
 #
+
+%%APP_SHORTNAME%%_user="%%USER%%"
+%%APP_SHORTNAME%%_enable="${%%APP_SHORTNAME%%_enable:-"NO"}"
+%%APP_SHORTNAME%%_jvm_opts="${%%APP_SHORTNAME%%_jvm_opts:-"-server -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"}"
+
 . %%RC_SUBR%%
 
 name="%%APP_SHORTNAME%%"
 rcvar=`set_rcvar`
 
-start_cmd="%%APP_SHORTNAME%%_start"
-restart_cmd="%%APP_SHORTNAME%%_restart"
+start_precmd="pid_touch"
+stop_cmd="%%APP_SHORTNAME%%_stop"
 pidfile="%%PID_FILE%%"
-procname="%%JAVA%%"
 
-[ -z "$%%APP_SHORTNAME%%_enable" ]	&& %%APP_SHORTNAME%%_enable="NO"
-[ -z "$%%APP_SHORTNAME%%_flags" ]	&& %%APP_SHORTNAME%%_flags="-server"
-[ -z "$%%APP_SHORTNAME%%_config" ]	&& %%APP_SHORTNAME%%_config=""
+JBOSS_HOME="%%APP_HOME%%"
+JBOSS_DEPLOY="%%DEPLOY_DIR%%"
+JAVA_OPTS="${%%APP_SHORTNAME%%_jvm_opts} \
+  -Djboss.server.base.dir=${JBOSS_DEPLOY} \
+  -Djboss.server.base.url=file://${JBOSS_DEPLOY} \
+  -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed \
+  -classpath ${JBOSS_HOME}/bin/run.jar org.jboss.Main"
+JBOSS_STDOUT="%%STDOUT_LOG%%"
+JBOSS_STDERR="%%STDERR_LOG%%"
+
+command="/usr/sbin/daemon"
+flags="-p ${pidfile} java ${JAVA_OPTS} ${%%APP_SHORTNAME%%_args} >> ${JBOSS_STDOUT} 2>> ${JBOSS_STDERR}"
+
+pid_touch ()
+{
+	touch $pidfile
+	chown %%USER%% $pidfile
+}
 
-%%APP_SHORTNAME%%_start ()
+%%APP_SHORTNAME%%_stop ()
 {
-	checkyesno %%APP_SHORTNAME%%_enable &&
-	{
-		if [ ! -f ${pidfile} ]
+	# Subvert the check_pid_file procname check.
+	if [ -f ${pidfile} ]
+	then
+		read rc_pid junk < $pidfile
+		if [ ! -z "${rc_pid}" ]
 		then
-			touch ${pidfile}
-			chown %%USER%%:%%GROUP%% ${pidfile}
+			procname=`ps -o ucomm= ${rc_pid}`
 		fi
+	fi
 
-		echo "Starting %%APP_SHORTNAME%%."
-		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} start
-	}
+	rc_pid=$(check_pidfile $pidfile *$procname*)
+
+	if [ -z "${rc_pid}" ]
+	then
+		[ -n "${rc_fast}" ] && return 0
+		if [ -n "${pidfile}" ]
+		then
+			echo "${name} not running? (check ${pidfile})."
+		else
+			echo "${name} not running?"
+		fi
+		return 1
+	fi
+
+	echo "Stopping ${name}."
+	kill ${rc_pid} 2> /dev/null
+	jboss_wait_max_for_pid %%STOP_TIMEOUT%% ${rc_pid}
+	kill -KILL ${rc_pid} 2> /dev/null && echo "Killed."
+	rm -f ${pidfile}
 }
 
-%%APP_SHORTNAME%%_restart ()
+jboss_wait_max_for_pid ()
 {
-	checkyesno %%APP_SHORTNAME%%_enable &&
-	{
-		echo "Restarting %%APP_SHORTNAME%%."
-		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} restart
-	}
+	_timeout=$1
+	shift
+	_pid=$1
+	_prefix=
+	while [ $_timeout -gt 0 ]
+	do
+		echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_pid
+		_prefix=", "
+		sleep 2
+		kill -0 $_pid 2> /dev/null || break
+		_timeout=$(($_timeout-2))
+	done
+	if [ -n "$_prefix" ]; then
+		echo "."
+	fi
 }
 
 load_rc_config $name
 
-[ -n "${%%APP_SHORTNAME%%_config}" ] && %%APP_SHORTNAME%%_configflag="-config"
-
 run_rc_command "$1"
diff -ruN /usr/ports/java/jboss5/files/patch-build-common.xml ./files/patch-build-common.xml
--- /usr/ports/java/jboss5/files/patch-build-common.xml	2008-09-09 17:09:45.000000000 +1200
+++ ./files/patch-build-common.xml	1970-01-01 12:00:00.000000000 +1200
@@ -1,12 +0,0 @@
---- ./tools/etc/buildmagic/build-common.xml.orig	Sun Mar 25 20:25:52 2007
-+++ ./tools/etc/buildmagic/build-common.xml	Sun Mar 25 20:27:18 2007
-@@ -20,6 +20,7 @@
-   <fail unless="buildmagic.ant.compatible">
-   Unsupported Ant version:
-     ${ant.version}
--  Please install a version which is compatible with Ant ${buildmagic.ant16.baseversion}.
-+  Please install a version which is compatible with Ant ${buildmagic.ant16.baseversion}
-+  or ${buildmagic.ant17.baseversion}.
-   </fail>
- 
-   <!-- JDK Detection -->
diff -ruN /usr/ports/java/jboss5/files/patch-build.xml ./files/patch-build.xml
--- /usr/ports/java/jboss5/files/patch-build.xml	2007-03-28 17:47:17.000000000 +1200
+++ ./files/patch-build.xml	1970-01-01 12:00:00.000000000 +1200
@@ -1,39 +0,0 @@
---- ./build/build.xml.orig	Sun Mar 25 21:29:21 2007
-+++ ./build/build.xml	Sun Mar 25 21:30:56 2007
-@@ -40,6 +40,36 @@
-    -->
- 
-   <target name="init" unless="init.disable" depends="_buildmagic:init">
-+      <!-- Make sure we have the right version of Ant -->
-+      <property name="buildmagic.ant15.baseversion" value="1.5"/>
-+      <property name="buildmagic.ant16.baseversion" value="1.6"/>
-+      <property name="buildmagic.ant17.baseversion" value="1.7"/>
-+      <!--
-+        | Add new conditions for other supported Ant versions when they
-+        | become avaialble.
-+       -->
-+
-+      <condition property="buildmagic.ant.compatible">
-+      <or>
-+         <contains string="${ant.version}"
-+            substring="Ant version ${buildmagic.ant15.baseversion}"/>
-+         <contains string="${ant.version}"
-+            substring="Ant version ${buildmagic.ant16.baseversion}"/>
-+         <contains string="${ant.version}"
-+            substring="Ant version ${buildmagic.ant17.baseversion}"/>
-+      </or>
-+      </condition>
-+
-+      <fail unless="buildmagic.ant.compatible">
-+
-+       Unsupported Ant version:
-+
-+       ${ant.version}
-+
-+       Please install a version which is compatible with Ant ${buildmagic.ant15.baseversion} or ${buildmagic.ant16.baseversion}
-+       or ${buildmagic.ant17.baseversion}.
-+
-+      </fail>
-   </target>
- 
- 
diff -ruN /usr/ports/java/jboss5/files/pkg-message.in ./files/pkg-message.in
--- /usr/ports/java/jboss5/files/pkg-message.in	2007-03-28 17:47:17.000000000 +1200
+++ ./files/pkg-message.in	2009-10-06 11:08:32.000000000 +1300
@@ -1,7 +1,5 @@
-%%PKGNAME%% has been installed in %%APP_HOME%%.
+%%PKGNAME%% has been installed in %%DATADIR%%.
 
-If a user should be able to use %%CONTROL_SCRIPT_NAME%%, put it in the group '%%GROUP%%'.
+The deployment directory for applications is %%DEPLOY_DIR%%.
 
-Use 'man %%CONTROL_SCRIPT_NAME%%' for information about starting and stopping %%APP_TITLE%%.
-
-To run the %%APP_TITLE%% server from startup, add %%APP_SHORTNAME%%_enable="YES" in your /etc/rc.conf. Extra options can be found in the startup script.
+To run the %%PORTNAME%% server from startup, add %%APP_SHORTNAME%%_enable="YES" in your /etc/rc.conf. Extra options can be found in the startup script.
diff -ruN /usr/ports/java/jboss5/pkg-descr ./pkg-descr
--- /usr/ports/java/jboss5/pkg-descr	2007-03-28 17:47:16.000000000 +1200
+++ ./pkg-descr	2009-10-06 15:15:51.000000000 +1300
@@ -1,13 +1,17 @@
-JBoss AS 5 GA will be Java EE 5 certified and will include the following core
-technologies.
+This is the final release of the JBoss 5.0 series for the Java EE5 codebase
+that fully complies with the Java EE5 conformance testing certification
+requirements.
 
-    * JBoss Microcontainer - POJO based microcontainer removing the dependency
-      on JMX
+Many key features of JBoss 5 are provided by integrating other standalone
+JBoss projects: 
+
+    * JBoss Microcontainer 2.0.2 - POJO based microcontainer removing the
+      dependency on JMX
     * EJB 3.0 - Fully certified as part of the Java EE 5 compliant JBoss AS 5
-    * Hibernate 3.2 - JPA certified
-    * JBoss Messaging 1.2 - the next generation messaging platform from JBoss
+    * Hibernate 3.3.1 - JPA certified
+    * JBoss Messaging 1.4.1 - the next generation messaging platform from JBoss
       with HA features.
-    * JBoss WebServices 2.0 - new custom built JAX-WS compliant WebServices
+    * JBoss WebServices 3.0.4 - new custom built JAX-WS compliant WebServices
       stack.
     * JBoss Seam 1.1 - a powerful new application framework to build next
       generation Web 2.0 applications by unifying and integrating popular
Comment 2 Herve Quiroz freebsd_committer freebsd_triage 2009-11-10 06:43:03 UTC
Responsible Changed
From-To: freebsd-ports-bugs->hq

I'll handle this
Comment 3 Jonathan Chen 2009-11-10 22:17:53 UTC
Here's an updated patch which has a knob to allow logging to
go to a pipe instead of the default log-output files.

Generated log files are now not part of the pkg-plist.
-- 
Jonathan Chen <jonc@chen.org.nz>

diff -ruN /usr/ports/java/jboss5/Makefile ./Makefile
--- /usr/ports/java/jboss5/Makefile	2009-09-07 09:12:34.000000000 +1200
+++ ./Makefile	2009-11-11 10:57:19.000000000 +1300
@@ -5,123 +5,71 @@
 # $FreeBSD: ports/java/jboss5/Makefile,v 1.50 2009/09/02 17:13:03 miwi Exp $
 #
 
-PORTNAME=	${APP_TITLE:L}
+PORTNAME=	jboss
 PORTVERSION=	5.1.0.GA
 PORTEPOCH=	1
 CATEGORIES=	java devel
 MASTER_SITES=	SF/${PORTNAME}/JBoss/JBoss-${PORTVERSION}
 DISTNAME=	${PORTNAME}-${PORTVERSION}-src
 
-MAINTAINER=	ports@FreeBSD.org
+MAINTAINER=	jonc@chen.org.nz
 COMMENT=	Open-source J2EE application server (5.x family)
 
-BUILD_DEPENDS=	ant:${PORTSDIR}/devel/apache-ant
-
 LATEST_LINK=	jboss5
 USE_JAVA=	yes
 JAVA_VERSION=	1.5+
 USE_ANT=	yes
+DATADIR=	${PREFIX}/share/${UNIQUENAME}
+DOCSDIR=	${PREFIX}/share/doc/${UNIQUENAME}
 
 MANUAL_PACKAGE_BUILD=	fetches files in build phase
 
 MAKE_ARGS=	-buildfile build/build.xml
 
 USE_RC_SUBR=	jboss5.sh
-SUB_FILES=	pkg-install pkg-deinstall pkg-message daemonctl.1 daemonctl.c
+SUB_FILES=	pkg-install pkg-deinstall pkg-message
 
+PORTDATA=	*
 .if !defined(NOPORTDOCS)
 PORTDOCS=	*
 .endif
 
-APP_HOME?=	${PREFIX}/${APP_SHORTNAME}
-DOCSDIR=	${PREFIX}/share/doc/${LATEST_LINK}
-LOG_DIR=	${APP_HOME}/log
-APP_TITLE=	JBoss
-APP_SHORTNAME=	${UNIQUENAME}
-CONTROL_SCRIPT_NAME=	${APP_SHORTNAME}ctl
-CONTROL_SCRIPT=	${PREFIX}/bin/${CONTROL_SCRIPT_NAME}
-CONTROL_SCRIPT_MANPAGE_TITLE=	${CONTROL_SCRIPT_NAME:U}
-STARTUP_SCRIPT_NAME=	${APP_SHORTNAME}.sh
-STARTUP_SCRIPT=	${PREFIX}/etc/rc.d/${STARTUP_SCRIPT_NAME}
+VAR_DIR?=	/var
+LOG_DIR?=	${VAR_DIR}/log/${UNIQUENAME}
+DEPLOY_DIR?=	${VAR_DIR}/${UNIQUENAME}
 USER=		www
 GROUP=		www
-STDOUT_LOG=	${LOG_DIR}/stdout.log
-STDERR_LOG=	${LOG_DIR}/stderr.log
-AUTO_START?=	NO
-STOP_TIMEOUT?=	5
-PID_FILE=	/var/run/${APP_SHORTNAME}.pid
-JAVA_OPTS=
-JAVA_CP=	bin/run.jar:${JAVA_HOME}/lib/tools.jar
-JAVA_MAIN=	org.jboss.Main
-MAN1=		${CONTROL_SCRIPT_NAME}.1
+STOP_TIMEOUT?=	10
+PID_FILE=	/var/run/${UNIQUENAME}.pid
 
 JBOSSOUTPUT=	${WRKSRC}/build/output/${PORTNAME}-${PORTVERSION}
-APP_HOME_FILES=	bin client lib server common
+APP_HOME_FILES=	bin/run.jar client lib common
 
 PKGMESSAGE=	${WRKDIR}/pkg-message
 
-PLIST_FILES=	${CONTROL_SCRIPT:S,^${PREFIX}/,,} \
-		${STDOUT_LOG:S,^${PREFIX}/,,} \
-		${STDERR_LOG:S,^${PREFIX}/,,}
-
-SUB_LIST=	APP_HOME=${APP_HOME} \
-		APP_SHORTNAME=${APP_SHORTNAME} \
-		APP_TITLE=${APP_TITLE} \
-		CONTROL_SCRIPT=${CONTROL_SCRIPT} \
-		CONTROL_SCRIPT_MANPAGE_TITLE=${CONTROL_SCRIPT_MANPAGE_TITLE} \
-		CONTROL_SCRIPT_NAME=${CONTROL_SCRIPT_NAME} \
+SUB_LIST=	APP_HOME=${DATADIR} \
+		APP_SHORTNAME=${UNIQUENAME} \
 		GROUP=${GROUP} \
-		JAVA=${JAVA} \
-		JAVA_CP=${JAVA_CP} \
-		JAVA_HOME=${JAVA_HOME} \
-		JAVA_MAIN=${JAVA_MAIN} \
-		JAVA_OPTS=${JAVA_OPTS} \
-		JAVA_PORT_VERSION=${JAVA_PORT_VERSION} \
-		JAVA_PORT_OS_DESCRIPTION=${JAVA_PORT_OS_DESCRIPTION} \
-		JAR_FILE=${JAR_FILE} \
 		LOG_DIR=${LOG_DIR} \
+		DEPLOY_DIR=${DEPLOY_DIR} \
 		PID_FILE=${PID_FILE} \
 		PKGNAME=${PKGNAME} \
 		PORTNAME=${PORTNAME} \
 		PORTVERSION=${PORTVERSION} \
 		PREFIX=${PREFIX} \
-		STARTUP_SCRIPT=${STARTUP_SCRIPT} \
-		STDERR_LOG=${STDERR_LOG} \
-		STDOUT_LOG=${STDOUT_LOG} \
 		STOP_TIMEOUT=${STOP_TIMEOUT} \
 		USER=${USER}
 
 .include <bsd.port.pre.mk>
 
-pre-patch:
-	@${ECHO_MSG} "Installation settings:"
-	@${ECHO_MSG} "   Destination directory:    ${APP_HOME}"
-	@${ECHO_MSG} "   Control program location: ${CONTROL_SCRIPT}"
-	@${ECHO_MSG} "   Startup script location:  ${STARTUP_SCRIPT}"
-	@${ECHO_MSG} "   Location of JDK:          ${JAVA_HOME}"
-	@${ECHO_MSG} "   Location of Java port:    ${JAVA_PORT}"
-	@${ECHO_MSG} "   Startup Java Options:     ${JAVA_OPTS}"
-	@${ECHO_MSG} "   Running as (user/group):  ${USER}/${GROUP}"
-	@${ECHO_MSG} "   Logfile stdout:           ${STDOUT_LOG}"
-	@${ECHO_MSG} "   Logfile stderr:           ${STDERR_LOG}"
-	@${ECHO_MSG} "   Starting after install:   ${AUTO_START}"
-	@${ECHO_MSG} "   Stop time-out:            ${STOP_TIMEOUT} sec."
-
-pre-install:
-	@${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
-
 do-install:
-	cd ${WRKDIR} && ${CC} ${CFLAGS} -o ${CONTROL_SCRIPT_NAME} daemonctl.c
-	${MKDIR} ${APP_HOME} && ${CHOWN} ${USER}:${GROUP} ${APP_HOME}
-	${MKDIR} ${LOG_DIR} && ${CHOWN} ${USER}:${GROUP} ${LOG_DIR}
+	${MKDIR} ${DATADIR}/bin && ${CHOWN} -R ${USER}:${GROUP} ${DATADIR}
+	${MKDIR} ${DEPLOY_DIR} && ${CHOWN} ${USER}:${GROUP} ${DEPLOY_DIR}
 	(cd ${JBOSSOUTPUT} && ${FIND} ${APP_HOME_FILES} |\
-		${CPIO} -pdmu -R ${USER}:${GROUP} ${APP_HOME})
-	${INSTALL} -o ${USER} -g ${GROUP} -m 06754\
-		${WRKDIR}/${CONTROL_SCRIPT_NAME} ${CONTROL_SCRIPT}
-	${INSTALL} -o ${USER} -g ${GROUP} -m 0640 /dev/null ${STDOUT_LOG}
-	${INSTALL} -o ${USER} -g ${GROUP} -m 0640 /dev/null ${STDERR_LOG}
+		${CPIO} -pdmu -R ${USER}:${GROUP} ${DATADIR})
+	(cd ${JBOSSOUTPUT}/server && ${FIND} . |\
+		${CPIO} -pdmu -R ${USER}:${GROUP} ${DEPLOY_DIR})
 	${INSTALL} -o ${USER} -g ${GROUP} -m 0640 /dev/null ${PID_FILE}
-	${INSTALL_MAN} ${WRKDIR}/daemonctl.1 ${MANPREFIX}/man/man1/${CONTROL_SCRIPT_NAME}.1
 .if !defined(NOPORTDOCS)
 	cd ${JBOSSOUTPUT}/docs \
 		&& ${FIND} . -type d -exec ${MKDIR} ${DOCSDIR}/{} \; \
@@ -129,15 +77,12 @@
 .endif
 
 post-install:
-	@${FIND} -s ${APP_HOME_FILES:S,^,${JBOSSOUTPUT}/,} -not -type d | \
-		${SED} -ne 's,^${JBOSSOUTPUT},${APP_HOME:S,${PREFIX}/,,},p' >> ${TMPPLIST}
-	@${FIND} -s -d ${APP_HOME_FILES:S,^,${JBOSSOUTPUT}/,} -type d | \
-		${SED} -ne 's,^${JBOSSOUTPUT},@dirrm ${APP_HOME:S,${PREFIX}/,,},p' >> ${TMPPLIST}
-	@${ECHO_CMD} "@dirrm ${APP_HOME:S,^${PREFIX}/,,}/log" >> ${TMPPLIST}
-	@${ECHO_CMD} "@dirrm ${APP_HOME:S,^${PREFIX}/,,}" >> ${TMPPLIST}
-.if ${AUTO_START} == "YES"
-	@${CONTROL_SCRIPT} start || true
-.endif
+	@${ECHO_CMD} "@cwd ${VAR_DIR}" >> ${TMPPLIST}
+	@${FIND} -s ${JBOSSOUTPUT}/server -not -type d | \
+		${SED} -ne 's,^${JBOSSOUTPUT}/server/,${DEPLOY_DIR:S,^${VAR_DIR}/,,}/,p' >> ${TMPPLIST}
+	@${FIND} -s -d ${JBOSSOUTPUT}/server -type d | \
+		${SED} -ne 's,^${JBOSSOUTPUT}/server/,@dirrm ${DEPLOY_DIR:S,^${VAR_DIR}/,,}/,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${DEPLOY_DIR:S,^${VAR_DIR}/,,}" >> ${TMPPLIST}
 .if !defined(BATCH)
 	@${CAT} ${PKGMESSAGE}
 .endif
diff -ruN /usr/ports/java/jboss5/files/daemonctl.1.in ./files/daemonctl.1.in
--- /usr/ports/java/jboss5/files/daemonctl.1.in	2007-03-28 17:47:17.000000000 +1200
+++ ./files/daemonctl.1.in	1970-01-01 12:00:00.000000000 +1200
@@ -1,78 +0,0 @@
-.Dd February 21, 2002
-.Dt %%CONTROL_SCRIPT_MANPAGE_TITLE%% 1
-.Os FreeBSD
-.Sh NAME
-.Nm %%CONTROL_SCRIPT_NAME%%
-.Nd %%APP_TITLE%% server control interface
-.Sh SYNOPSIS
-.Nm
-.Op Fl java-options
-.Ar {start|restart|stop}
-.Sh DESCRIPTION
-The
-.Nm
-program provides an restricted interface to the %%APP_TITLE%%
-application server. The
-.Nm
-program is only accessible to users in the 'www' group, and will
-only invoke the %%JAVA_PORT_OS_DESCRIPTION%% %%JAVA_PORT_VERSION%% JVM.
-.Pp
-Any Java options listed are handed off directly to the JVM. Any
-classpath options will be ignored.
-.Pp
-The program expects exactly one of the following terminating commands:
-.Bl -tag -width indent
-.It Ar start
-Start %%APP_TITLE%%, if it is not already running.
-.It Ar restart
-Restart %%APP_TITLE%%. If it is already running, then it will be stopped and
-then started right after that. Otherwise it will just be started up.
-.It Ar stop
-Stop %%APP_TITLE%%, if it is actually running.
-.El
-.Sh ERRORS
-The following error conditions are detected. They will be checked in the
-specified order. In each case an error message is printed with the name of the
-control program prepended.
-.Pp
-If no argument is passed, then a simple help message is printed and the
-program exists with error code 0.
-.Pp
-If at least one argument is passed, but it is different from
-.Ar start ,
-.Ar restart
-or
-.Ar stop
-then the help message is printed as well, and the program exits with error
-code 1.
-.Pp
-The following errors conditions are defined:
-.Bl -tag -width indent
-.It Em Illegal program argument (error code 1)
-.It Em PID file not found (error code 2)
-.It Em PID file too large (error code 3)
-.It Em PID file contains illegal character (error code 4)
-.It Em Kill of process failed (error code 5)
-.It Em %%APP_TITLE%% is already running (error code 6)
-.It Em %%APP_TITLE%% is not running (error code 7)
-.It Em Unable to chdir to the %%APP_TITLE%% home directory (error code 8)
-.It Em Unable to open the stdout log file (error code 9)
-.It Em Unable to open the stderr log file (error code 10)
-.It Em Unable to start %%APP_TITLE%% (error code 11)
-.El
-.Sh FILES
-.Bl -tag -width -indent
-.It Pa %%PID_FILE%%
-The %%APP_TITLE%% PID file that is used to store the process ID of the
-currently running process in. It is emptied as soon as the server is stopped
-and filled with the process ID when it is started. It should never be writable
-for anyone but
-.Em www ,
-.It Pa %%STARTUP_SCRIPT%%
-A script that starts the
-.Nm
-program. It is used to start %%APP_TITLE%% at startup time.
-.El
-.Sh AUTHORS
-.An Ernst de Haan Aq znerd@FreeBSD.org
-.An Jonathan Chen Aq jonc@chen.org.nz
diff -ruN /usr/ports/java/jboss5/files/daemonctl.c.in ./files/daemonctl.c.in
--- /usr/ports/java/jboss5/files/daemonctl.c.in	2007-03-28 17:47:17.000000000 +1200
+++ ./files/daemonctl.c.in	1970-01-01 12:00:00.000000000 +1200
@@ -1,557 +0,0 @@
-/*
- * -*- mode: Fundamental; tab-width: 4; -*-
- * ex:ts=4
- *
- * Daemon control program, with Java Startup options.
- *
- *	Original by Ernst de Haan <znerd@freebsd.org>
- *	www/jakarta-tomcat4/files/daemonctl.c
- *
- * $FreeBSD: ports/java/jboss5/files/daemonctl.c.in,v 1.1 2007/03/28 05:47:17 delphij Exp $
- */
-
-#include <assert.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <sys/errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-
-#define	TRUE	1
-#define	FALSE	0
-
-/* The interval in seconds between the checks to make sure the process
-   died after a kill */
-#define STOP_TIME_INTERVAL		1
-
-#define ERR_ILLEGAL_ARGUMENT				1
-#define ERR_PID_FILE_NOT_FOUND				2
-#define ERR_KILL_FAILED						5
-#define ERR_ALREADY_RUNNING					6
-#define ERR_NOT_RUNNING						7
-#define ERR_CHDIR_TO_APP_HOME				8
-#define ERR_ACCESS_JAR_FILE					17
-#define ERR_STDOUT_LOGFILE_OPEN				9
-#define ERR_STDERR_LOGFILE_OPEN				10
-#define ERR_FORK_FAILED						11
-#define ERR_STAT_JAVA_HOME					12
-#define ERR_JAVA_HOME_NOT_DIR				13
-#define ERR_STAT_JAVA_CMD					14
-#define ERR_JAVA_CMD_NOT_FILE				15
-#define ERR_JAVA_CMD_NOT_EXECUTABLE			16
-
-/*
-	Function declarations.
- */
-static void printUsage (void);
-static int readPID (void);
-static void writePID (int pid);
-static void clearPID (void);
-static void start (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
-static void stop (void);
-static void restart (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
-static void logOutput (char *);
-
-/*
-	Globals
- */
-static int isQuiet = FALSE;
-static char * optQuiet = "-q",			/* quiet option */
-			* optConfig = "-config";	/* jboss configuration option */
-
-/**
- * Main function. This function is called when this program is executed.
- *
- * @param argc
- *    the number of arguments plus one, so always greater than 0.
- *
- * @param argv
- *    the arguments in an array of character pointers, where the last argument
- *    element is followed by a NULL element.
- */
-int
-main (
- int argc,
- char *argv [])
-{
-	/* Declare variables, like all other good ANSI C programs do :) */
-	int i, javaOpt, jbossOpt;
-	char *argument, **javaArgs, **jbossArgs;
-
-	/* Parse the arguments */
-	if (argc < 2)
-	{
-		printUsage ();
-		return 0;
-	}
-
-	/* XXX: Fix for setting up the environment for the java wrapper script */
-	setuid (geteuid ());
-	setgid (getegid ());
-
-	/*
-		Build up java and jboss option blocks.
-	 */
-	javaOpt = jbossOpt = 0;
-	for (i = 1; i < argc; i++)
-	{
-		if (strcmp (argv [i], optQuiet) == 0)
-		{
-			isQuiet = TRUE;
-
-		} else if (strcmp (argv [i], optConfig) == 0)
-		{
-			jbossOpt += 2;
-			if (++i >= argc)
-			{
-				printUsage ();
-				return ERR_ILLEGAL_ARGUMENT;
-			}
-
-		} else if (*argv [i] == '-')
-		{
-			javaOpt++;
-		}
-	}
-	if (javaOpt == 0)
-		javaArgs = NULL;
-	else
-	{
-		int j = 0;
-		javaArgs = malloc (sizeof (char *) * javaOpt);
-		for (i = 0; i < argc; i++)
-		{
-			if (strcmp (argv [i], optQuiet) &&
-				strcmp (argv [i], optConfig) &&
-				*argv [i] == '-')
-			{
-				javaArgs [j++] = argv [i];
-			}
-		}
-	}
-	if (jbossOpt == 0)
-		jbossArgs = NULL;
-	else
-	{
-		int j = 0;
-		jbossArgs = malloc (sizeof (char *) * jbossOpt);
-		for (i = 0; i < argc; i++)
-		{
-			if (strcmp (argv [i], optConfig) == 0)
-			{
-				jbossArgs [j++] = "-c";
-				jbossArgs [j++] = argv [++i];
-			}
-		}
-	}
-
-	/*
-		Decide on just what to call.
-	 */
-	argument = argv [argc - 1];
-	if (strcmp ("start", argument) == 0)
-	{
-		start (javaOpt, javaArgs, jbossOpt, jbossArgs);
-
-	} else if (strcmp ("stop", argument) == 0)
-	{
-		stop ();
-
-	} else if (strcmp ("restart", argument) == 0)
-	{
-		restart (javaOpt, javaArgs, jbossOpt, jbossArgs);
-
-	} else {
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Illegal argument \"%s\".\n", argument);
-		printUsage ();
-		exit (ERR_ILLEGAL_ARGUMENT);
-	}
-
-	return EXIT_SUCCESS;
-}
-
-/**
- * Prints usage information to stdout.
- */
-static void
-printUsage (void)
-{
-	printf ("Usage: %%CONTROL_SCRIPT_NAME%% [java-options] [-config jbossconfig] {start|stop|restart}\n");
-}
-
-/**
- * Reads a PID from the PID file.
- *
- * @return
- *    the PID, or -1 if the file was empty.
- */
-static int
-readPID (void)
-{
-	FILE * file;
-	int pid;
-
-	logOutput (">> Reading PID file (%%PID_FILE%%)...");
-	file = fopen ("%%PID_FILE%%", "r");
-	if (!file)
-	{
-		logOutput (" [ FAILED ]\n");
-		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for reading: ");
-		exit (ERR_PID_FILE_NOT_FOUND);
-	}
-	if (fscanf (file, "%d", &pid) < 1)
-		pid = -1;
-	fclose (file);
-
-	logOutput (" [ DONE ]\n");
-	return pid;
-}
-
-/**
- * Writes a process ID to the specified file. The file is identified by a file
- * handle.
- *
- * @param pid
- *    the PID to store, always greater than 0.
- */
-static void
-writePID (
- int pid)
-{
-	FILE * file;
-
-	logOutput (">> Writing PID file...");
-	file = fopen ("%%PID_FILE%%", "w");
-	if (!file)
-	{
-		logOutput (" [ FAILED ]\n");
-		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for writing: ");
-		exit (ERR_PID_FILE_NOT_FOUND);
-	}
-	fprintf (file, "%d\n", pid);
-	fclose (file);
-
-	logOutput (" [ DONE ]\n");
-}
-
-/**
-	Truncate the PID file.
- */
-static void
-clearPID (void)
-{
-	if (truncate ("%%PID_FILE%%", 0) != 0)
-	{
-		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to clear %%PID_FILE%%: ");
-		exit (ERR_PID_FILE_NOT_FOUND);
-	}
-}
-
-/**
- * Checks if the specified process is running.
- *
- * @param pid
- *    the process id, greater than 0.
- *
- * @return
- *    0 if the specified process is not running, a different value otherwise.
- */
-static int
-existsProcess (
- int pid)
-{
-	int result;
-
-	/* Check preconditions */
-	assert (pid > 0);
-
-	/* See if the process exists */
-   	result = kill (pid, 0);
-
-	/* If the result is 0, then the process exists */
-	return result == 0;
-}
-
-/**
- * Kills the process identified by the specified ID.
- *
- * @param pid
- *    the process id, greater than 0.
- */
-static void
-killProcess (
- int pid)
-{
-	int result;
-	unsigned int waited;
-	unsigned int forced;
-	unsigned int interval = STOP_TIME_INTERVAL;
-	unsigned int timeout  = %%STOP_TIMEOUT%%;
-
-	/* Check preconditions */
-	assert (pid > 0);
-
-	if (!isQuiet)
-		printf (">> Terminating process %d...", pid);
-	result = kill (pid, SIGTERM);
-	if (result < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
-		perror (NULL);
-		exit (ERR_KILL_FAILED);
-	}
-
-	/* Wait until the process is actually killed */
-    result = existsProcess (pid);
-	for (waited=0; result == 1 && waited < timeout; waited += interval)
-	{
-		logOutput (".");
-		fflush (stdout);
-		sleep (interval);
-    	result = existsProcess (pid);
-	}
-
-	/* If the process still exists, then have no mercy and kill it */
-	forced = 0;
-	if (result == 1)
-	{
-		/* Force the process to die */
-		result = kill (pid, SIGKILL);
-		if (result == 0) {
-			forced = 1;
-			logOutput (" [ KILLED ]\n");
-			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Process %d did not terminate within %%STOP_TIMEOUT%% sec. Killed.\n", pid);
-		} else if (result != ESRCH) {
-			logOutput (" [ FAILED ]\n");
-			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
-			perror (NULL);
-			exit (ERR_KILL_FAILED);
-		}
-	}
-
-	if (forced == 0) {
-		logOutput (" [ DONE ]\n");
-	}
-}
-
-/**
- * Starts the daemon.
- */
-static void
-start (
- int javaOpt,
- char * javaArgs [],
- int jbossOpt,
- char * jbossArgs [])
-{
-	int i, argc;
-	char ** argv;
-	int pid;
-	int result;
-	int stdoutLogFile;
-	int stderrLogFile;
-	struct stat sb;
-
-	pid = readPID ();
-
-	logOutput (">> Starting %%APP_TITLE%% %%PORTVERSION%%...");
-	if (pid != -1)
-	{
-		/* Check if the process actually exists */
-		result = existsProcess (pid);
-		if (result == 1)
-		{
-			logOutput (" [ FAILED ]\n");
-			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is already running, PID is %d.\n", pid);
-			exit (ERR_ALREADY_RUNNING);
-		}
-	}
-
-	/* Check if the JDK home directory is actually a directory */
-	result = stat ("%%JAVA_HOME%%", &sb);
-	if (result != 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA_HOME%%: ");
-		perror (NULL);
-		exit (ERR_STAT_JAVA_HOME);
-	}
-	if (!S_ISDIR (sb.st_mode)) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java home directory %%JAVA_HOME%% is not a directory.\n");
-		exit (ERR_JAVA_HOME_NOT_DIR);
-	}
-
-	/* Check if the Java command is actually an executable regular file */
-	result = stat ("%%JAVA%%", &sb);
-	if (result != 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA%%: ");
-		perror (NULL);
-		exit (ERR_STAT_JAVA_CMD);
-	}
-	if (!S_ISREG (sb.st_mode)) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not a regular file.\n");
-		exit (ERR_JAVA_CMD_NOT_FILE);
-	}
-	result = access ("%%JAVA%%", X_OK);
-	if (result != 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not executable: ");
-		perror (NULL);
-		exit (ERR_JAVA_CMD_NOT_EXECUTABLE);
-	}
-
-	/* Change directory */
-	result = chdir ("%%APP_HOME%%");
-	if (result < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access directory %%APP_HOME%%: ");
-		perror (NULL);
-		exit (ERR_CHDIR_TO_APP_HOME);
-	}
-
-	/* See if the JAR file exists */
-	result = access ("%%APP_HOME%%/%%JAR_FILE%%", R_OK);
-	if (result < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access JAR file %%APP_HOME%%/%%JAR_FILE%%: ");
-		perror (NULL);
-		exit (ERR_ACCESS_JAR_FILE);
-	}
-
-	/* Open the stdout log file */
-	stdoutLogFile = open ("%%STDOUT_LOG%%", O_WRONLY);
-	if (stdoutLogFile < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDOUT_LOG%% for writing: ");
-		perror (NULL);
-		exit (ERR_STDOUT_LOGFILE_OPEN);
-	}
-	lseek (stdoutLogFile, (off_t) 0, SEEK_END);
-
-	/* Open the stderr log file */
-	stderrLogFile = open ("%%STDERR_LOG%%", O_WRONLY);
-	if (stderrLogFile < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDERR_LOG%% for writing: ");
-		perror (NULL);
-		exit (ERR_STDERR_LOGFILE_OPEN);
-	}
-	lseek (stderrLogFile, (off_t) 0, SEEK_END);
-
-	/* Split this process in two */
-	switch (pid = fork ())
-	{
-	case -1:
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to fork: ");
-		perror (NULL);
-		exit (ERR_FORK_FAILED);
-		break;
-
-	case 0:
-		/* Redirect stdout to log file */
-		dup2 (stdoutLogFile, STDOUT_FILENO);
-
-		/* Redirect stderr to log file */
-		dup2 (stderrLogFile, STDERR_FILENO);
-
-		/* TODO: Support redirection of both stdout and stderr to the same
-				 file using pipe (2) */
-
-		/*
-			Build the argument vector, with the java/jboss options if any.
-		 */
-		argv = malloc (sizeof (char *) * (javaOpt + jbossOpt + 5));
-		argc = 0;
-		argv [argc++] = "%%JAVA%%";
-		for (i = 0; i < javaOpt; i++)
-			argv [argc++] = javaArgs [i];
-		argv [argc++] = "-cp";
-		argv [argc++] = "%%JAVA_CP%%";
-		argv [argc++] = "%%JAVA_MAIN%%";
-		for (i = 0; i < jbossOpt; i++)
-			argv [argc++] = jbossArgs [i];
-		argv [argc++] = NULL;
-
-		/* Execute the command */
-		execv (argv [0], argv);
-		perror (NULL);
-		break;
-
-	default:
-		logOutput (" [ DONE ]\n");
-		writePID (pid);
-	}
-}
-
-/**
- * Stops the daemon.
- */
-static void
-stop (void)
-{
-	int pid;
-
-	pid = readPID ();
-
-	logOutput (">> Checking if %%APP_TITLE%% %%PORTVERSION%% is running...");
-
-	/* If there is a PID, see if the process still exists */
-	if (pid != -1)
-	{
-		int result = kill (pid, 0);
-		if (result != 0 && errno == ESRCH)
-		{
-			clearPID ();
-			pid = -1;
-		}
-	}
-
-	/* If there is no running process, produce an error */
-	if (pid == -1)
-	{
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is currently not running.\n");
-		exit (ERR_NOT_RUNNING);
-	}
-	logOutput (" [ DONE ]\n");
-
-	/* Terminate the process */
-	killProcess (pid);
-	clearPID ();
-}
-
-
-/**
- * Restarts the process. If it not currently running, then it will fail.
- */
-static void
-restart (
- int javaOpt,
- char * javaArgs [],
- int jbossOpt,
- char * jbossArgs [])
-{
-	stop ();
-	start (javaOpt, javaArgs, jbossOpt, jbossArgs);
-}
-
-/**
-	Output log to stdout.
- */
-static void
-logOutput (
- char * string)
-{
-	if (!isQuiet)
-		printf (string);
-}
diff -ruN /usr/ports/java/jboss5/files/jboss5.sh.in ./files/jboss5.sh.in
--- /usr/ports/java/jboss5/files/jboss5.sh.in	2007-03-28 17:47:17.000000000 +1200
+++ ./files/jboss5.sh.in	2009-11-11 11:03:03.000000000 +1300
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# %%APP_TITLE%% startup script.
+# %%APP_SHORTNAME%% startup script.
 #
 # $FreeBSD: ports/java/jboss5/files/jboss5.sh.in,v 1.1 2007/03/28 05:47:17 delphij Exp $
 #
@@ -9,53 +9,105 @@
 # REQUIRE: NETWORKING SERVERS
 
 # Add the following lines to /etc/rc.conf to enable %%APP_SHORTNAME%%:
-# %%APP_SHORTNAME%%_enable (bool):		Set to "NO" by default.
-#				Set it to "YES" to enable %%APP_SHORTNAME%%
-# %%APP_SHORTNAME%%_flags (str):		Set to "-server" by default.
-#				Extra JVM flags.
-# %%APP_SHORTNAME%%_config (str):		Set to "" by default
-#				JBoss server config, eg {all|default|minimal|standard}
+# %%APP_SHORTNAME%%_enable (bool):      Set to "YES" to enable %%APP_SHORTNAME%%
+# %%APP_SHORTNAME%%_jvm_opts (str):     Extra JVM flags.
+# %%APP_SHORTNAME%%_args (str):         Optional arguments to JBoss
+# %%APP_SHORTNAME%%_logging (str)       JBoss log output. A pipe command may be used.
 #
+
 . %%RC_SUBR%%
 
+%%APP_SHORTNAME%%_user="%%USER%%"
+%%APP_SHORTNAME%%_logdir="%%LOG_DIR%%"
+
 name="%%APP_SHORTNAME%%"
 rcvar=`set_rcvar`
 
+load_rc_config $name
+
+%%APP_SHORTNAME%%_enable="${%%APP_SHORTNAME%%_enable:-"NO"}"
+%%APP_SHORTNAME%%_jvm_opts="${%%APP_SHORTNAME%%_jvm_opts:-"-server -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"}"
+%%APP_SHORTNAME%%_logging="${%%APP_SHORTNAME%%_logging:-">> ${%%APP_SHORTNAME%%_logdir}/stdout.log 2>> ${%%APP_SHORTNAME%%_logdir}/stderr.log"}"
+
 start_cmd="%%APP_SHORTNAME%%_start"
-restart_cmd="%%APP_SHORTNAME%%_restart"
+stop_cmd="%%APP_SHORTNAME%%_stop"
 pidfile="%%PID_FILE%%"
-procname="%%JAVA%%"
 
-[ -z "$%%APP_SHORTNAME%%_enable" ]	&& %%APP_SHORTNAME%%_enable="NO"
-[ -z "$%%APP_SHORTNAME%%_flags" ]	&& %%APP_SHORTNAME%%_flags="-server"
-[ -z "$%%APP_SHORTNAME%%_config" ]	&& %%APP_SHORTNAME%%_config=""
+JBOSS_HOME="%%APP_HOME%%"
+JBOSS_DEPLOY="%%DEPLOY_DIR%%"
+JBOSS_MAIN="org.jboss.Main"
+JAVA_OPTS="${%%APP_SHORTNAME%%_jvm_opts} \
+  -Djboss.server.base.dir=${JBOSS_DEPLOY} \
+  -Djboss.server.base.url=file://${JBOSS_DEPLOY} \
+  -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed \
+  -classpath ${JBOSS_HOME}/bin/run.jar ${JBOSS_MAIN}"
 
 %%APP_SHORTNAME%%_start ()
 {
-	checkyesno %%APP_SHORTNAME%%_enable &&
-	{
-		if [ ! -f ${pidfile} ]
+	if [ ! -d "${%%APP_SHORTNAME%%_logdir}" ]
+	then
+		mkdir -p ${%%APP_SHORTNAME%%_logdir}
+		chown ${%%APP_SHORTNAME%%_user} ${%%APP_SHORTNAME%%_logdir}
+	fi
+
+	echo "Starting %%APP_SHORTNAME%%."
+	daemon -u ${%%APP_SHORTNAME%%_user} sh -c "java ${JAVA_OPTS} ${%%APP_SHORTNAME%%_args} ${%%APP_SHORTNAME%%_logging} &"
+
+	sleep 1		# let daemon(8) and sh(1) finish before executing pgrep(1)
+	pgrep -U ${%%APP_SHORTNAME%%_user} -f ${JBOSS_MAIN} > ${pidfile}
+	chown ${%%APP_SHORTNAME%%_user} $pidfile
+}
+
+%%APP_SHORTNAME%%_stop ()
+{
+	# Subvert the check_pid_file procname check.
+	if [ -f ${pidfile} ]
+	then
+		read rc_pid junk < $pidfile
+		if [ ! -z "${rc_pid}" ]
 		then
-			touch ${pidfile}
-			chown %%USER%%:%%GROUP%% ${pidfile}
+			procname=`ps -o ucomm= ${rc_pid}`
 		fi
+	fi
 
-		echo "Starting %%APP_SHORTNAME%%."
-		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} start
-	}
+	rc_pid=$(check_pidfile $pidfile *$procname*)
+
+	if [ -z "${rc_pid}" ]
+	then
+		[ -n "${rc_fast}" ] && return 0
+		if [ -n "${pidfile}" ]
+		then
+			echo "${name} not running? (check ${pidfile})."
+		else
+			echo "${name} not running?"
+		fi
+		return 1
+	fi
+
+	echo "Stopping ${name}."
+	kill ${rc_pid} 2> /dev/null
+	jboss_wait_max_for_pid %%STOP_TIMEOUT%% ${rc_pid}
+	kill -KILL ${rc_pid} 2> /dev/null && echo "Killed."
+	rm -f ${pidfile}
 }
 
-%%APP_SHORTNAME%%_restart ()
+jboss_wait_max_for_pid ()
 {
-	checkyesno %%APP_SHORTNAME%%_enable &&
-	{
-		echo "Restarting %%APP_SHORTNAME%%."
-		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} restart
-	}
+	_timeout=$1
+	shift
+	_pid=$1
+	_prefix=
+	while [ $_timeout -gt 0 ]
+	do
+		echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_pid
+		_prefix=", "
+		sleep 2
+		kill -0 $_pid 2> /dev/null || break
+		_timeout=$(($_timeout-2))
+	done
+	if [ -n "$_prefix" ]; then
+		echo "."
+	fi
 }
 
-load_rc_config $name
-
-[ -n "${%%APP_SHORTNAME%%_config}" ] && %%APP_SHORTNAME%%_configflag="-config"
-
 run_rc_command "$1"
diff -ruN /usr/ports/java/jboss5/files/patch-build-common.xml ./files/patch-build-common.xml
--- /usr/ports/java/jboss5/files/patch-build-common.xml	2008-09-09 17:09:45.000000000 +1200
+++ ./files/patch-build-common.xml	1970-01-01 12:00:00.000000000 +1200
@@ -1,12 +0,0 @@
---- ./tools/etc/buildmagic/build-common.xml.orig	Sun Mar 25 20:25:52 2007
-+++ ./tools/etc/buildmagic/build-common.xml	Sun Mar 25 20:27:18 2007
-@@ -20,6 +20,7 @@
-   <fail unless="buildmagic.ant.compatible">
-   Unsupported Ant version:
-     ${ant.version}
--  Please install a version which is compatible with Ant ${buildmagic.ant16.baseversion}.
-+  Please install a version which is compatible with Ant ${buildmagic.ant16.baseversion}
-+  or ${buildmagic.ant17.baseversion}.
-   </fail>
- 
-   <!-- JDK Detection -->
diff -ruN /usr/ports/java/jboss5/files/patch-build.xml ./files/patch-build.xml
--- /usr/ports/java/jboss5/files/patch-build.xml	2007-03-28 17:47:17.000000000 +1200
+++ ./files/patch-build.xml	1970-01-01 12:00:00.000000000 +1200
@@ -1,39 +0,0 @@
---- ./build/build.xml.orig	Sun Mar 25 21:29:21 2007
-+++ ./build/build.xml	Sun Mar 25 21:30:56 2007
-@@ -40,6 +40,36 @@
-    -->
- 
-   <target name="init" unless="init.disable" depends="_buildmagic:init">
-+      <!-- Make sure we have the right version of Ant -->
-+      <property name="buildmagic.ant15.baseversion" value="1.5"/>
-+      <property name="buildmagic.ant16.baseversion" value="1.6"/>
-+      <property name="buildmagic.ant17.baseversion" value="1.7"/>
-+      <!--
-+        | Add new conditions for other supported Ant versions when they
-+        | become avaialble.
-+       -->
-+
-+      <condition property="buildmagic.ant.compatible">
-+      <or>
-+         <contains string="${ant.version}"
-+            substring="Ant version ${buildmagic.ant15.baseversion}"/>
-+         <contains string="${ant.version}"
-+            substring="Ant version ${buildmagic.ant16.baseversion}"/>
-+         <contains string="${ant.version}"
-+            substring="Ant version ${buildmagic.ant17.baseversion}"/>
-+      </or>
-+      </condition>
-+
-+      <fail unless="buildmagic.ant.compatible">
-+
-+       Unsupported Ant version:
-+
-+       ${ant.version}
-+
-+       Please install a version which is compatible with Ant ${buildmagic.ant15.baseversion} or ${buildmagic.ant16.baseversion}
-+       or ${buildmagic.ant17.baseversion}.
-+
-+      </fail>
-   </target>
- 
- 
diff -ruN /usr/ports/java/jboss5/files/pkg-message.in ./files/pkg-message.in
--- /usr/ports/java/jboss5/files/pkg-message.in	2007-03-28 17:47:17.000000000 +1200
+++ ./files/pkg-message.in	2009-10-06 11:08:32.000000000 +1300
@@ -1,7 +1,5 @@
-%%PKGNAME%% has been installed in %%APP_HOME%%.
+%%PKGNAME%% has been installed in %%DATADIR%%.
 
-If a user should be able to use %%CONTROL_SCRIPT_NAME%%, put it in the group '%%GROUP%%'.
+The deployment directory for applications is %%DEPLOY_DIR%%.
 
-Use 'man %%CONTROL_SCRIPT_NAME%%' for information about starting and stopping %%APP_TITLE%%.
-
-To run the %%APP_TITLE%% server from startup, add %%APP_SHORTNAME%%_enable="YES" in your /etc/rc.conf. Extra options can be found in the startup script.
+To run the %%PORTNAME%% server from startup, add %%APP_SHORTNAME%%_enable="YES" in your /etc/rc.conf. Extra options can be found in the startup script.
diff -ruN /usr/ports/java/jboss5/pkg-descr ./pkg-descr
--- /usr/ports/java/jboss5/pkg-descr	2007-03-28 17:47:16.000000000 +1200
+++ ./pkg-descr	2009-10-06 15:15:51.000000000 +1300
@@ -1,13 +1,17 @@
-JBoss AS 5 GA will be Java EE 5 certified and will include the following core
-technologies.
+This is the final release of the JBoss 5.0 series for the Java EE5 codebase
+that fully complies with the Java EE5 conformance testing certification
+requirements.
 
-    * JBoss Microcontainer - POJO based microcontainer removing the dependency
-      on JMX
+Many key features of JBoss 5 are provided by integrating other standalone
+JBoss projects: 
+
+    * JBoss Microcontainer 2.0.2 - POJO based microcontainer removing the
+      dependency on JMX
     * EJB 3.0 - Fully certified as part of the Java EE 5 compliant JBoss AS 5
-    * Hibernate 3.2 - JPA certified
-    * JBoss Messaging 1.2 - the next generation messaging platform from JBoss
+    * Hibernate 3.3.1 - JPA certified
+    * JBoss Messaging 1.4.1 - the next generation messaging platform from JBoss
       with HA features.
-    * JBoss WebServices 2.0 - new custom built JAX-WS compliant WebServices
+    * JBoss WebServices 3.0.4 - new custom built JAX-WS compliant WebServices
       stack.
     * JBoss Seam 1.1 - a powerful new application framework to build next
       generation Web 2.0 applications by unifying and integrating popular
Comment 4 Herve Quiroz freebsd_committer freebsd_triage 2009-11-14 22:44:14 UTC
Hi Jonathan,

Don't you think we should bump PORTREVISION given the changes?

BTW, I was thinking about adding some entry regarding the changes and
what they mean for current users in UPDATING. Could you please think
about such message?

Herve
Comment 5 herve.quiroz 2009-11-14 23:27:28 UTC
Hi Jonathan,

I get the following error when deinstalling the port:

===>  Deinstalling for java/jboss5
===>   Deinstalling jboss-5.1.0.GA,1
pkg_delete: unable to completely remove directory '/var/jboss5/default'
pkg_delete: unable to completely remove directory '/var/jboss5'
pkg_delete: couldn't entirely delete package (perhaps the packing list is
incorrectly specified?)

Herve
Comment 6 Jonathan Chen 2009-11-15 08:27:21 UTC
On Sun, Nov 15, 2009 at 12:27:28AM +0100, Herve Quiroz wrote:
> Hi Jonathan,
> 
> I get the following error when deinstalling the port:
> 
> ===>  Deinstalling for java/jboss5
> ===>   Deinstalling jboss-5.1.0.GA,1
> pkg_delete: unable to completely remove directory '/var/jboss5/default'
> pkg_delete: unable to completely remove directory '/var/jboss5'
> pkg_delete: couldn't entirely delete package (perhaps the packing list is
> incorrectly specified?)

When JBoss starts up, all sorts of temporary files get created (which
aren't listed in the pkg-list). These will prevent a clean directory
removal. This problem also exists for other app-servers. I don't think
it matters.
-- 
Jonathan Chen <jonc@chen.org.nz>
Comment 7 Jonathan Chen 2009-11-15 08:32:22 UTC
On Sat, Nov 14, 2009 at 11:44:14PM +0100, Herve Quiroz wrote:
> Hi Jonathan,
> 
> Don't you think we should bump PORTREVISION given the changes?

Yes; but there isn't any functional changes, so I wasn't too sure.

> BTW, I was thinking about adding some entry regarding the changes and
> what they mean for current users in UPDATING. Could you please think
> about such message?

How about something like:

    The JBoss directory structure has been reorganised to more
    closely follow hier(7) guidelines; in particular moving transient
    and deployment files to /var/jboss5, and allowing /usr to be
    read-only.

Cheers.
-- 
Jonathan Chen <jonc@chen.org.nz>
----------------------------------------------------------------------
"With sufficient thrust, pigs fly just fine. However, this is not necessarily
a good idea. It is hard to be sure where they are going to land, and it
could be dangerous sitting under them as they fly overhead." -- RFC 1925
Comment 8 dfilter service freebsd_committer freebsd_triage 2009-11-18 22:11:59 UTC
hq          2009-11-18 22:11:46 UTC

  FreeBSD ports repository

  Modified files:
    java/jboss5          Makefile pkg-descr 
    java/jboss5/files    jboss5.sh.in pkg-message.in 
  Removed files:
    java/jboss5/files    daemonctl.1.in daemonctl.c.in 
                         patch-build-common.xml patch-build.xml 
  Log:
  Reorganise the JBoss5 port:
  - remove daemonctl, use root startup (following tomcat, geronimo, etc)
  - allow arbitrary arguments to be handed to JBoss (long standing bug)
  - reorganise the directory structure to follow hier(7)
    * JBOSS_HOME = /usr/local/share/jboss5
    * deployment directory = /var/jboss5
    * log directory = /var/log/jboss5
  - Take maintainership
  - Bump PORTREVISION
  
  PR:             139372
  Submitted by:   Jonathan Chen <jonc@chen.org.nz>
  
  Revision  Changes    Path
  1.51      +27 -81    ports/java/jboss5/Makefile
  1.2       +0 -78     ports/java/jboss5/files/daemonctl.1.in (dead)
  1.2       +0 -557    ports/java/jboss5/files/daemonctl.c.in (dead)
  1.2       +83 -31    ports/java/jboss5/files/jboss5.sh.in
  1.3       +0 -12     ports/java/jboss5/files/patch-build-common.xml (dead)
  1.2       +0 -39     ports/java/jboss5/files/patch-build.xml (dead)
  1.2       +3 -5      ports/java/jboss5/files/pkg-message.in
  1.4       +11 -7     ports/java/jboss5/pkg-descr
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 9 dfilter service freebsd_committer freebsd_triage 2009-11-18 22:12:22 UTC
hq          2009-11-18 22:12:07 UTC

  FreeBSD ports repository

  Modified files:
    .                    UPDATING 
  Log:
  Add entry for www/jboss5
  
  PR:             139372
  Submitted by:   Jonathan Chen <jonc@chen.org.nz>
  
  Revision  Changes    Path
  1.869     +10 -1     ports/UPDATING
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 10 Herve Quiroz freebsd_committer freebsd_triage 2009-11-18 22:12:26 UTC
State Changed
From-To: open->closed

Patch commited. Thanks for your contribution.