Subject: building java progs on (i386)solaris 9
To: None <tech-pkg@netbsd.org>
From: Hal Snyder <hal@vailsys.com>
List: tech-pkg
Date: 04/01/2004 21:35:04
Note Solaris 9 default install includes java:

$uname -a
SunOS dpssrsx04.vail 5.9 Generic_112234-10 i86pc i386 i86pc

$java -version
java version "1.4.1_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_06-b01)
Java HotSpot(TM) Client VM (build 1.4.1_06-b01, mixed mode)

The following have been built on a system where the only additions
after Solaris 9 are sfw gcc3 (for boot, later discarded) and pkgsrc.


$pkg_info | grep Apache
crimson-1.1.3       Apache.org implementation of JAXP, SAX, and DOM
apache-ant-1.6.1    "Apache Project's Java-Based make(1) replacement"
jakarta-servletapi-3.2.4 The Apache project's implementation of ...
jakarta-tomcat-3.2.4nb1 The Apache Project's Java Servlet 2.2 an...

With /etc/mk.conf:

USE_JAVA=       run
PKG_JVM=        sun-jdk14
PKG_JAVA_HOME=  /usr/java


Here are the workarounds:


1. pkgsrc insists on looking for kaffe/wonka and jre packages.

   java-vm.mk was patched as follows - I can see that the added .if is
   not a general fix but am not sure what to do there. Do we need
   USE_JAVA=native?

===
diff -u java-vm.mk.orig java-vm.mk
--- java-vm.mk.orig     Thu Apr  1 12:56:05 2004
+++ java-vm.mk  Thu Apr  1 15:14:50 2004
@@ -93,7 +93,7 @@
        NetBSD-*-i386 Linux-*-i[3-6]86 Darwin-*-*
 _ONLY_FOR_PLATFORMS.sun-jdk14= \
        NetBSD-1.5Z[A-Z]-i386 NetBSD-1.[6-9]*-i386 NetBSD-2*-i386 \
-       Linux-*-i[3-6]86
+       Linux-*-i[3-6]86 SunOS-5.9-*
 _ONLY_FOR_PLATFORMS.kaffe= \
        *-*-alpha *-*-arm *-*-arm32 *-*-i386 *-*-m68k *-*-mips* *-*-sparc *-*-powerpc
 _ONLY_FOR_PLATFORMS.wonka= \
@@ -255,6 +255,7 @@
 
 EVAL_PREFIX+=          _JAVA_HOME=${_JAVA_PKGBASE.${_PKG_JVM}}
 
+.if empty(USE_JAVA:M[rR][uU][nN])
 # We always need a run-time dependency on the JRE.
 .if defined(_JRE_PKGSRCDIR)
 .if defined(USE_BUILDLINK2) && empty(USE_BUILDLINK2:M[nN][oO])
@@ -263,6 +264,7 @@
 DEPENDS+=              ${_JRE_DEPENDENCY}
 .endif
 .endif
+.endif # empty(USE_JAVA:M[rR][uU][nN])
 
 # If we are building Java software, then we need a build-time dependency on
 # the JDK.

===

2. bmake install fails if there are no run-time dependencies.

First in the chain of dependencies is textproc/crimson.

With the above settings, bsd.pkg.mk (fake-pkg->print-pkg-size-depends)

  {MAKE} ${MAKEFLAGS} run-depends-list PACKAGE_DEPENDS_QUICK=true

produces an empty list, which causes pkg_info to fail with no
arguments. The hack was 

<       size_depends=`${MAKE} ${MAKEFLAGS} print-pkg-size-depends`;     \
---
>       size_depends=0; \



3. Extraction failure: bzcat ant... | gtar -xf - 

   Next dependency after textproc/crimson is devel/apache-ant.
   But bmake extract fails:

/usr/pkg/bin/gtar: apache-ant-1.6.1: Cannot unlink: File exists
/usr/pkg/bin/gtar: apache-ant-1.6.1/bin: Cannot unlink: File exists

   Note Solaris 9 comes with /usr/bin/bzcat and I see no way to
   override this in bsd.pkg.mk

.    if exists(/usr/bin/bzcat)
BZCAT=                  /usr/bin/bzcat
.    else
BZCAT=                  ${LOCALBASE}/bin/bzcat
BUILD_DEPENDS+=         bzip2>=0.9.0b:../../archivers/bzip2
.    endif # !exists bzcat

   But that does not matter because the problem persists when
   /usr/pkg/bin/bzip2 is hacked in. Problem occurred with both
   versions, apache-ant-1.6.1 and apache-ant-1.5.4.

Workaround is

   #bmake extract GTAR=/usr/pkg/bin/tar


With these three changes, devel/apache-ant, www/jakarta-servletapi,
and www/jakarta-tomcat build and make binary packages, and

   #tomcat=yes /usr/pkg/etc/rc.d/tomcat start

starts up the server.