Bug 96659 - [PATCH] devel/maven: Improve launcher shell script
Summary: [PATCH] devel/maven: Improve launcher shell script
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: 2006-05-02 14:30 UTC by Herve Quiroz
Modified: 2006-06-25 21:45 UTC (History)
1 user (show)

See Also:


Attachments
maven-1.0.2_1.patch (4.51 KB, patch)
2006-05-02 14:30 UTC, Herve Quiroz
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Herve Quiroz freebsd_committer 2006-05-02 14:30:16 UTC
With this patch, the launcher shell script will set JAVA_HOME if no value is
defined. The default value is the JDK that got chosen by the ports system at
install time. We will be able to improve the script further when ports/96050
gets commited.

To reduce the complexity of the launcher, it is now a plain new shell script,
configured via SUB_FILES.

While I was here, I also switched pkg-message to SUB_FILES (although its
content could now be altered given ${JAVA_HOME} is not mandatory to run Maven
anymore).

PORTREVISION bumped.

Added file(s):
- files/maven.sh.in
- files/pkg-message.in

Removed file(s):
- pkg-message
- files/patch-maven-home

Port maintainer (jbq@caraldi.com) is cc'd.

Generated with FreeBSD Port Tools 0.75
Comment 1 Edwin Groothuis freebsd_committer 2006-05-02 14:37:46 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback
Comment 2 Herve Quiroz freebsd_committer 2006-05-02 14:42:10 UTC
Responsible Changed
From-To: freebsd-ports-bugs->hq

Submitter is commiter
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2006-05-04 14:35:39 UTC
State Changed
From-To: feedback->open

Maintainer approved.
Comment 4 Herve Quiroz freebsd_committer 2006-05-09 22:30:58 UTC
State Changed
From-To: open->feedback

New patch for maintainer to review, based on our previous discussion. 

Now maven will only try to set a default value for JAVA_HOME and MAVEN_HOME 
when none is already set. This should allow more flexibility over the current 
version because a user may launch Maven with no particular environement 
variables set.  Moreover, the user always has the ability to override both 
MAVEN_HOME and JAVA_HOME. 

I tweaked pkg-message to reflect the fact that setting JAVA_HOME is no longer 
mandatory to run Maven. 


Index: Makefile 
=================================================================== 
RCS file: /home/ncvs/ports/devel/maven/Makefile,v 
retrieving revision 1.9 
diff -u -r1.9 Makefile 
--- Makefile	4 Apr 2006 08:08:47 -0000	1.9 
+++ Makefile	9 May 2006 21:33:01 -0000 
@@ -7,6 +7,7 @@ 

PORTNAME=	maven 
PORTVERSION=	1.0.2 
+PORTREVISION=	1 
CATEGORIES=	devel java 
MASTER_SITES=	${MASTER_SITE_APACHE} 
MASTER_SITE_SUBDIR=	${PORTNAME}/binaries 
@@ -20,7 +21,7 @@ 
NO_BUILD=	yes 
DATADIR=	${JAVASHAREDIR}/${PORTNAME} 
PKGMESSAGE=	${WRKDIR}/pkg-message 
-SUBSTITUTIONS=	-e 's,%%DATADIR%%,${DATADIR},g' 
+SUBSTITUTIONS=	-e 's,%%DATADIR%%,${DATADIR},g ; s,%%JAVA_HOME%%,${JAVA_HOME},g' 
REINPLACE_FILES=	${WRKSRC}/bin/maven 

post-configure: 
Index: pkg-message 
=================================================================== 
RCS file: /home/ncvs/ports/devel/maven/pkg-message,v 
retrieving revision 1.5 
diff -u -r1.5 pkg-message 
--- pkg-message	4 Apr 2006 08:08:47 -0000	1.5 
+++ pkg-message	9 May 2006 21:33:01 -0000 
@@ -1,11 +1,8 @@ 

-To work with Maven you need to set the following environment variable: 
-  * JAVA_HOME 
-    Set it to the base directory of your java installation. 
- 
-Then, you should initialize your repository with: 
+You may initialize your repository with: 
%%DATADIR%%/bin/install_repo.sh ~/.maven/repository 

If you are behind a proxy, create a ~/.mavenrc file with something like: 
MAVEN_OPTS="$MAVEN_OPTS -Dmaven.proxy.host=YOUR_PROXY_HOSTNAME 
-Dmaven.proxy.port=YOUR_PROXY_PORT" 
+ 
Index: files/patch-maven-home 
=================================================================== 
RCS file: /home/ncvs/ports/devel/maven/files/patch-maven-home,v 
retrieving revision 1.1 
diff -u -r1.1 patch-maven-home 
--- files/patch-maven-home	4 Apr 2006 08:08:47 -0000	1.1 
+++ files/patch-maven-home	9 May 2006 21:33:01 -0000 
@@ -1,10 +1,15 @@ 
+$FreeBSD$ 
+ 
+Sets default values for both JAVA_HOME and MAVEN_HOME 
+ 
--- bin/maven.orig	Tue Dec  7 12:13:46 2004 
-+++ bin/maven	Sat Apr  1 00:07:23 2006 
-@@ -19,6 +19,7 @@ 
++++ bin/maven	Tue May  9 23:22:51 2006 
+@@ -19,6 +19,8 @@ 
#   reserved. 

FOREHEAD_VERSION=1.0-beta-5 
-+MAVEN_HOME=%%DATADIR%% 
++: ${MAVEN_HOME="%%DATADIR%%"} 
++: ${JAVA_HOME="%%JAVA_HOME%%"} 

if [ -z "$MAVEN_OPTS" ] ; then 
MAVEN_OPTS="-Xmx256m"
Comment 5 Jean-Baptiste Quenot 2006-06-01 17:12:44 UTC
The last 9 May patch appears to be mangled:

patch: **** malformed patch at line 10: PORTNAME=       maven

Could you please resubmit?
-- 
     Jean-Baptiste Quenot
aka  John Banana Qwerty
http://caraldi.com/jbq/
Comment 6 Jean-Baptiste Quenot 2006-06-19 16:06:58 UTC
The patch looks good!

However, I can't find the syntax ${parameter=word} in sh(1) man
page.  It works, but this is an undocumented use of variable
substitution...

Apparently the right syntax is ${parameter:=word} for assigning a
default value.
-- 
     Jean-Baptiste Quenot
aka  John Banana Qwerty
http://caraldi.com/jbq/
Comment 7 Herve Quiroz freebsd_committer 2006-06-19 17:12:51 UTC
State Changed
From-To: feedback->open

Patch approved.
Comment 8 Herve Quiroz freebsd_committer 2006-06-19 17:15:45 UTC
State Changed
From-To: open->feedback

I just produced a new patch with the following changes: 

- Use new features from javavmwrapper 2.2 to set a default value for JAVA_HOME 
- Set JAVACMD to the executable from javavmwrapper 
- Set a default value for MAVEN_HOME only when not already defined 
- Update pkg-message to reflect these changes 

Could you please review it? 


Index: Makefile 
=================================================================== 
RCS file: /home/ncvs/ports/devel/maven/Makefile,v 
retrieving revision 1.9 
diff -u -r1.9 Makefile 
--- Makefile	4 Apr 2006 08:08:47 -0000	1.9 
+++ Makefile	19 Jun 2006 16:15:31 -0000 
@@ -14,13 +14,18 @@ 
MAINTAINER=	jbq@caraldi.com 
COMMENT=	Java project management and project comprehension tool 

+RUN_DEPENDS=	java:${PORTSDIR}/java/javavmwrapper 
+ 
USE_BZIP2=	yes 
USE_JAVA=	yes 
JAVA_VERSION=	1.3+ 
NO_BUILD=	yes 
DATADIR=	${JAVASHAREDIR}/${PORTNAME} 
PKGMESSAGE=	${WRKDIR}/pkg-message 
-SUBSTITUTIONS=	-e 's,%%DATADIR%%,${DATADIR},g' 
+SUBSTITUTIONS=	-e 's,%%DATADIR%%,${DATADIR},g'  
+		-e 's,%%LOCALBASE%%,${LOCALBASE},g'  
+		-e 's,%%GREP%%,${GREP},g'  
+		-e 's,%%CUT%%,${CUT},g' 
REINPLACE_FILES=	${WRKSRC}/bin/maven 

post-configure: 
Index: pkg-message 
=================================================================== 
RCS file: /home/ncvs/ports/devel/maven/pkg-message,v 
retrieving revision 1.5 
diff -u -r1.5 pkg-message 
--- pkg-message	4 Apr 2006 08:08:47 -0000	1.5 
+++ pkg-message	19 Jun 2006 16:15:31 -0000 
@@ -1,9 +1,5 @@ 

-To work with Maven you need to set the following environment variable: 
-  * JAVA_HOME 
-    Set it to the base directory of your java installation. 
- 
-Then, you should initialize your repository with: 
+You may initialize your repository with: 
%%DATADIR%%/bin/install_repo.sh ~/.maven/repository 

If you are behind a proxy, create a ~/.mavenrc file with something like: 
Index: files/patch-maven-home 
=================================================================== 
RCS file: /home/ncvs/ports/devel/maven/files/patch-maven-home,v 
retrieving revision 1.1 
diff -u -r1.1 patch-maven-home 
--- files/patch-maven-home	4 Apr 2006 08:08:47 -0000	1.1 
+++ files/patch-maven-home	19 Jun 2006 16:15:31 -0000 
@@ -1,10 +1,26 @@ 
+$FreeBSD$ 
+ 
+. Set default FreeBSD values for MAVEN_HOME, JAVA_HOME and JAVACMD 
+. Use 'exec' to launch the JVM 
+ 
--- bin/maven.orig	Tue Dec  7 12:13:46 2004 
-+++ bin/maven	Sat Apr  1 00:07:23 2006 
-@@ -19,6 +19,7 @@ 
++++ bin/maven	Mon Jun 19 17:31:50 2006 
+@@ -19,6 +19,9 @@ 
#   reserved. 

FOREHEAD_VERSION=1.0-beta-5 
-+MAVEN_HOME=%%DATADIR%% 
++: ${MAVEN_HOME="%%DATADIR%%"} 
++: ${JAVA_HOME="`JAVAVM_DRYRUN=yes %%LOCALBASE%%/bin/java | %%GREP%% '^JAVA_HOME' | %%CUT%% -c11-`"} 
++: ${JAVACMD="%%LOCALBASE%%/bin/java"} 

if [ -z "$MAVEN_OPTS" ] ; then 
MAVEN_OPTS="-Xmx256m" 
+@@ -150,7 +153,7 @@ 
+   MAVEN_OPTS="$MAVEN_OPTS -Dmaven.home.local=${MAVEN_HOME_LOCAL}"  
+ fi 
+    
+-"$JAVACMD"  
++exec "$JAVACMD"  
+   $MAVEN_OPTS  
+   -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl  
+   -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
Comment 9 Jean-Baptiste Quenot 2006-06-19 17:40:45 UTC
* Hervé Quiroz:
>
> - Use new features from javavmwrapper 2.3 to set a default value for JAVA_HOME
> - Set JAVACMD to the executable from javavmwrapper
> - Set a default value for MAVEN_HOME only when not already defined
> - Update pkg-message to reflect these changes

Thanks for your patch, see comments below.

> +RUN_DEPENDS=	java:${PORTSDIR}/java/javavmwrapper

The JDK already has this dependency.  Is it really needed?

> : ${JAVA_HOME="`JAVAVM_DRYRUN=yes %%LOCALBASE%%/bin/java | %%GREP%% '^JAVA_HOME' | %%CUT%% -c11-`"}

To be more generic I would rewrite this as:

> : ${JAVA_HOME="`JAVAVM_DRYRUN=yes %%LOCALBASE%%/bin/java | %%GREP%% '^JAVA_HOME' | %%CUT%% -d= -f2`"}

<note>
   I tried another option which does not correctly work because literal values are not escaped:

   (JAVAVM_DRYRUN=yes javavm ; echo 'echo $JAVA_HOME' )| sh
</note>

Also you don't need to set both JAVACMD and JAVA_HOME, only JAVACMD is
needed.
-- 
     Jean-Baptiste Quenot
aka  John Banana Qwerty
http://caraldi.com/jbq/
Comment 10 Herve Quiroz freebsd_committer 2006-06-25 21:44:31 UTC
State Changed
From-To: feedback->closed

Patch commited with modifications suggested by the maintainer.