Subject: openoffice2-bin and java
To: None <tech-pkg@netbsd.org>
From: Geert Hendrickx <ghen@telenet.be>
List: tech-pkg
Date: 10/21/2005 13:54:33
--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I already discussed this with Michael, but we didn't reach consensus; 

OpenOffice 2 needs a Java Runtime Environment for some features (e.g. the
documents wizard in Writer, the media player, ...), but works without one,
too.  

Right now, the files/soffice startup script adds all /usr/pkg/java/*
subdirectories to the PATH when starting OpenOffice, so it will look for
JRE's there.  However, this gives a few problems.  Only Linux binary JRE's
will work, since OOo links to them.  But the JRE detection can't seem to
make this distinction, so you can e.g. add a native JRE (wip/jdk14) to the
list, but you will get an error when you try to use the Java-dependent
features.  Also, when you have lang/kaffe installed (in /usr/pkg/java),
this causes long delays in OOo's Java detection, it is probably confused by
Kaffe not behaving as it expected.  Anyway, to make a long story short, I
would like to do this: make the admin choose _one_ (Linux) JRE at install
time, and make the startup script only add that one directory to the PATH.
Implementation would look like this: 

===>
Index: Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/misc/openoffice2-bin/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- Makefile	20 Oct 2005 14:05:39 -0000	1.4
+++ Makefile	21 Oct 2005 11:50:40 -0000
@@ -86,14 +85,21 @@
 DISTNAME=	# Dummy to prevent error from missing DISTNAME
 .endif
 
+.include "options.mk"
+
 do-install:
 	${RM} -f ${WRKDIR}/PLIST.nouniq
 	${RPM2PKG} ${RPM2PKGARGS} ${WRKSRC}/*.rpm
 	uniq ${WRKDIR}/PLIST.nouniq >${WRKDIR}/PLIST
+.if !empty(JRE)
 	${RM} -f ${PREFIX}/bin/soffice
 	${SED}  -e "s|@@PREFIX@@|${PREFIX}|g" -e "s|@@OO_VER@@|${OO_VER}|g" \
+		-e "s|@@JRE@@|${JRE}|g" \
 		< ${FILESDIR}/soffice > ${PREFIX}/bin/soffice
 	${CHMOD} +x ${PREFIX}/bin/soffice
+.else
+	${LN} -sf ../openoffice.org${OO_VER}/program/soffice ${PREFIX}/bin/soffice
+.endif
 .for i in scalc sdraw simpress swriter
 	${LN} -sf ../openoffice.org${OO_VER}/program/${i} ${PREFIX}/bin/${i}
 .endfor
Index: files/soffice
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/misc/openoffice2-bin/files/soffice,v
retrieving revision 1.2
diff -u -r1.2 soffice
--- files/soffice	10 Oct 2005 20:08:49 -0000	1.2
+++ files/soffice	21 Oct 2005 11:50:40 -0000
@@ -7,16 +7,10 @@
 # make sure we can find `whoami` on solaris
 PATH=${PATH}:/usr/ucb
 
-# add an existing java directory to $PATH to allow OOo to
+# add the chosen java directory to $PATH to allow OOo to
 # automatically find it
-#
-if [ -d "@@PREFIX@@/java" ]; then
-  for i in @@PREFIX@@/java/*; do
-    if [ -f "$i/bin/java" ]; then
-	export PATH=$PATH:$i/bin
-    fi
-  done
-fi
+PATH=${PATH}:@@JRE@@
+
 # default data seg size is too small for java
 ulimit -d `ulimit -H -d`
<===

i.e. a run-time dependency on zero or one Linux JRE.  This solves all the
problems above.  

A slightly different alternative options.mk could look like this: 

===>
# $NetBSD

PKG_OPTIONS_VAR=		PKG_OPTIONS.openoffice2-bin
PKG_OPTIONS_OPTIONAL_GROUPS=	jre
PKG_OPTIONS_GROUP.jre=		sun-jre13 sun-jre14 sun-jre15

.include "../../mk/bsd.options.mk"

.if !empty(PKG_OPTIONS:Msun-jre13)
.include "../../lang/sun-jre13/buildlink3.mk"
JRE=	${BUILDLINK_JAVA_PREFIX.sun-jre13}
.endif

.if !empty(PKG_OPTIONS:Msun-jre14)
.include "../../lang/sun-jre14/buildlink3.mk"
JRE=	${BUILDLINK_JAVA_PREFIX.sun-jre14}
.endif

.if !empty(PKG_OPTIONS:Msun-jre15)
.include "../../lang/sun-jre15/buildlink3.mk"
JRE=	${BUILDLINK_JAVA_PREFIX.sun-jre15}
.endif
<===

i.e., an OPTIONAL_GROUP containin only JRE's (not the option "no-jre"),
defaulting to none (with the same result as "no-jre").  I prefer the
REQUIRED_GROUP though, to make it more clear that no-jre is an actual
option. :-)  

What do you think?  

	Geert

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="oo_jre.diff"

? options.mk_optional
? options.mk_required
Index: Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/misc/openoffice2-bin/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- Makefile	20 Oct 2005 14:05:39 -0000	1.4
+++ Makefile	21 Oct 2005 11:50:40 -0000
@@ -1,6 +1,6 @@
 # $NetBSD: Makefile,v 1.4 2005/10/20 14:05:39 mrauch Exp $
 
-PKGNAME=		openoffice2-bin-2.0.0
+PKGNAME=		openoffice-bin-2.0.0
 CATEGORIES=		misc
 MASTER_SITES=		${MASTER_SITE_OPENOFFICE:=stable/2.0.0/}
 DISTFILES=		${DISTNAME}${EXTRACT_SUFX}
@@ -24,7 +24,6 @@
 
 CONFLICTS+=		staroffice-[0-9]*
 CONFLICTS+=		openoffice-[0-9]*
-CONFLICTS+=		openoffice-bin-[0-9]*
 CONFLICTS+=		openoffice-linux-[0-9]*
 
 ONLY_FOR_PLATFORM=	NetBSD-1.6*-i386 NetBSD-[2-9]*-i386
@@ -86,14 +85,21 @@
 DISTNAME=	# Dummy to prevent error from missing DISTNAME
 .endif
 
+.include "options.mk"
+
 do-install:
 	${RM} -f ${WRKDIR}/PLIST.nouniq
 	${RPM2PKG} ${RPM2PKGARGS} ${WRKSRC}/*.rpm
 	uniq ${WRKDIR}/PLIST.nouniq >${WRKDIR}/PLIST
+.if !empty(JRE)
 	${RM} -f ${PREFIX}/bin/soffice
 	${SED}  -e "s|@@PREFIX@@|${PREFIX}|g" -e "s|@@OO_VER@@|${OO_VER}|g" \
+		-e "s|@@JRE@@|${JRE}|g" \
 		< ${FILESDIR}/soffice > ${PREFIX}/bin/soffice
 	${CHMOD} +x ${PREFIX}/bin/soffice
+.else
+	${LN} -sf ../openoffice.org${OO_VER}/program/soffice ${PREFIX}/bin/soffice
+.endif
 .for i in scalc sdraw simpress swriter
 	${LN} -sf ../openoffice.org${OO_VER}/program/${i} ${PREFIX}/bin/${i}
 .endfor
Index: files/soffice
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/misc/openoffice2-bin/files/soffice,v
retrieving revision 1.2
diff -u -r1.2 soffice
--- files/soffice	10 Oct 2005 20:08:49 -0000	1.2
+++ files/soffice	21 Oct 2005 11:50:40 -0000
@@ -7,16 +7,10 @@
 # make sure we can find `whoami` on solaris
 PATH=${PATH}:/usr/ucb
 
-# add an existing java directory to $PATH to allow OOo to
+# add the chosen java directory to $PATH to allow OOo to
 # automatically find it
-#
-if [ -d "@@PREFIX@@/java" ]; then
-  for i in @@PREFIX@@/java/*; do
-    if [ -f "$i/bin/java" ]; then
-	export PATH=$PATH:$i/bin
-    fi
-  done
-fi
+PATH=${PATH}:@@JRE@@
+
 # default data seg size is too small for java
 ulimit -d `ulimit -H -d`
 

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="options.mk_required"

# $NetBSD

PKG_OPTIONS_VAR=		PKG_OPTIONS.openoffice2-bin
PKG_OPTIONS_REQUIRED_GROUPS=	jre
PKG_OPTIONS_GROUP.jre=		no-jre sun-jre13 sun-jre14 sun-jre15
PKG_SUGGESTED_OPTIONS=		no-jre

.include "../../mk/bsd.options.mk"

.if !empty(PKG_OPTIONS:Msun-jre13)
.include "../../lang/sun-jre13/buildlink3.mk"
JRE=	${BUILDLINK_JAVA_PREFIX.sun-jre13}
.endif

.if !empty(PKG_OPTIONS:Msun-jre14)
.include "../../lang/sun-jre14/buildlink3.mk"
JRE=	${BUILDLINK_JAVA_PREFIX.sun-jre14}
.endif

.if !empty(PKG_OPTIONS:Msun-jre15)
.include "../../lang/sun-jre15/buildlink3.mk"
JRE=	${BUILDLINK_JAVA_PREFIX.sun-jre15}
.endif


--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="options.mk_optional"

# $NetBSD

PKG_OPTIONS_VAR=		PKG_OPTIONS.openoffice2-bin
PKG_OPTIONS_OPTIONAL_GROUPS=	jre
PKG_OPTIONS_GROUP.jre=		sun-jre13 sun-jre14 sun-jre15

.include "../../mk/bsd.options.mk"

.if !empty(PKG_OPTIONS:Msun-jre13)
.include "../../lang/sun-jre13/buildlink3.mk"
JRE=	${BUILDLINK_JAVA_PREFIX.sun-jre13}
.endif

.if !empty(PKG_OPTIONS:Msun-jre14)
.include "../../lang/sun-jre14/buildlink3.mk"
JRE=	${BUILDLINK_JAVA_PREFIX.sun-jre14}
.endif

.if !empty(PKG_OPTIONS:Msun-jre15)
.include "../../lang/sun-jre15/buildlink3.mk"
JRE=	${BUILDLINK_JAVA_PREFIX.sun-jre15}
.endif


--vkogqOf2sHV7VnPd--