diff options
author | Paul de Vrieze <pauldv@gentoo.org> | 2006-06-22 19:57:54 +0000 |
---|---|---|
committer | Paul de Vrieze <pauldv@gentoo.org> | 2006-06-22 19:57:54 +0000 |
commit | 02de1c5112a9c604dfe467cf04ebfa8671c44180 (patch) | |
tree | f067ffa93fb5dbf7cd45f437c9f88d7e89038b05 | |
parent | New version (diff) | |
download | pauldv-02de1c5112a9c604dfe467cf04ebfa8671c44180.tar.gz pauldv-02de1c5112a9c604dfe467cf04ebfa8671c44180.tar.bz2 pauldv-02de1c5112a9c604dfe467cf04ebfa8671c44180.zip |
Take a lot of java stuff from the migration overlay on gentooexperimental. This includes a new eclipse ebuild for rc7
svn path=/trunk/overlay/; revision=4
-rw-r--r-- | dev-util/eclipse-sdk/Manifest | 25 | ||||
-rw-r--r-- | dev-util/eclipse-sdk/eclipse-sdk-3.2_rc7.ebuild | 327 | ||||
-rw-r--r-- | dev-util/eclipse-sdk/files/07-eclipse-3.2.patch | 42 | ||||
-rw-r--r-- | dev-util/eclipse-sdk/files/digest-eclipse-sdk-3.2_rc7 | 6 | ||||
-rw-r--r-- | dev-util/eclipse-sdk/files/eclipse-3.2 | 25 | ||||
-rw-r--r-- | dev-util/eclipse-sdk/files/eclipse-3.2.desktop | 9 | ||||
-rw-r--r-- | eclass/java-pkg-2.eclass | 85 | ||||
-rw-r--r-- | eclass/java-pkg.eclass | 422 | ||||
-rw-r--r-- | eclass/java-utils-2.eclass | 1747 | ||||
-rw-r--r-- | eclass/java-utils.eclass | 104 | ||||
-rw-r--r-- | eclass/java-vm-2.eclass | 149 |
11 files changed, 2858 insertions, 83 deletions
diff --git a/dev-util/eclipse-sdk/Manifest b/dev-util/eclipse-sdk/Manifest index 1398759..411485c 100644 --- a/dev-util/eclipse-sdk/Manifest +++ b/dev-util/eclipse-sdk/Manifest @@ -1,24 +1,22 @@ -AUX 07-eclipse-3.2.patch 2480 RMD160 776471d2426011339eda7a446ca32aab0e98f023 SHA1 9eb43f2245e434a1f1df949c819211b0709b954a SHA256 c7cf00d96f2b36d8d5f155a8711fbd472badff32c0d652a93c832b2607a16981 -MD5 a50777be585361c3353f6ffc896597b6 files/07-eclipse-3.2.patch 2480 -RMD160 776471d2426011339eda7a446ca32aab0e98f023 files/07-eclipse-3.2.patch 2480 -SHA256 c7cf00d96f2b36d8d5f155a8711fbd472badff32c0d652a93c832b2607a16981 files/07-eclipse-3.2.patch 2480 -AUX eclipse-3.2 1587 RMD160 c5d618ae81c2fb94e0a2279108945481623794f1 SHA1 42e79ecbf587459ecd3f4ec1033280efd2c55fb6 SHA256 2acea18cf92a0e9997718fb7b6e6d21de0344591c83d113975d06ad25b5f7b3f -MD5 fdf7fdf48f5851a666ab0b0c8d1e190e files/eclipse-3.2 1587 -RMD160 c5d618ae81c2fb94e0a2279108945481623794f1 files/eclipse-3.2 1587 -SHA256 2acea18cf92a0e9997718fb7b6e6d21de0344591c83d113975d06ad25b5f7b3f files/eclipse-3.2 1587 -AUX eclipse-3.2.desktop 226 RMD160 7dec133c198d1487302ad94daff4fe22efe03c9b SHA1 2854afccba994ed3042dc1b70101b2738db7cf06 SHA256 3640ba9a6aa4ee96a84ade83c46a059f91f8da53721916f2b933cbdc02e953ac -MD5 26c40f43c7646520e01ad4fa0562b11f files/eclipse-3.2.desktop 226 -RMD160 7dec133c198d1487302ad94daff4fe22efe03c9b files/eclipse-3.2.desktop 226 -SHA256 3640ba9a6aa4ee96a84ade83c46a059f91f8da53721916f2b933cbdc02e953ac files/eclipse-3.2.desktop 226 +AUX eclipse-3.2 1145 RMD160 141c5d412c50dcb106654b4078cbaf379b468130 SHA1 6c317e42b7697d849bbd5616519642be345c74f3 SHA256 920b48ed98bc18f6e90769fe084eced46304c4c1a8b3999c5644297f437b1cbd +MD5 f6ff94ca35dee12929539c1c6936d7c9 files/eclipse-3.2 1145 +RMD160 141c5d412c50dcb106654b4078cbaf379b468130 files/eclipse-3.2 1145 +SHA256 920b48ed98bc18f6e90769fe084eced46304c4c1a8b3999c5644297f437b1cbd files/eclipse-3.2 1145 AUX eclipse.1 2607 RMD160 06aaeb02a7c7720c8d8b26d9d1252095b6098a25 SHA1 c00e291630b69fee7187decb050411d428fc2f13 SHA256 5165b07f736763eab05decb39397be0be8ae03b77f614ba3794eff71d411537b MD5 32be5292ce0af7ff9c1866c1f59e1859 files/eclipse.1 2607 RMD160 06aaeb02a7c7720c8d8b26d9d1252095b6098a25 files/eclipse.1 2607 SHA256 5165b07f736763eab05decb39397be0be8ae03b77f614ba3794eff71d411537b files/eclipse.1 2607 +DIST eclipse-sdk-3.2_rc7-patches.tar.bz2 24935 RMD160 88423e6e04eda1b5d1d87ffded8c91f2034c45ad SHA1 ba1d82b143e2e33a91994e483651b6eb070d5055 SHA256 7c204cef97110f8018fd13212ddf48f915bed7fea7b95e11b40ff1e8a4c528d8 DIST eclipse-sourceBuild-srcIncluded-3.2RC5.zip 83458655 RMD160 86da05a76ea190b70a04218cebb720d56ff6bad9 SHA1 c91908f1c9a405b007214dbdd36651d415f34618 SHA256 00f028da5f3e481fc2cc12c753ded40c90ec1a95989c813797d83893163bf020 +DIST eclipse-sourceBuild-srcIncluded-3.2RC7.zip 82030272 RMD160 1e7e6107f791d023dc9c2a6ba8c1f3d6d0cfaf80 SHA1 903cb5ee695e6b071eb859666dc09a25d506518e SHA256 fbf6956fef7223e770e8362d7d388a99a9ff209f3c9ec6e0143d70c38a99ef1c EBUILD eclipse-sdk-3.2_rc5.ebuild 8772 RMD160 5e6f30d1f44d0458127e156bceb0572dc7c73e6f SHA1 6700134f1ca9cc0b549d853dcd9e9fd09499e237 SHA256 4813814d60e5062a001669e7e1f1cafb504c4d303a596a3f050300f54d7fbe6a MD5 892e54e495ea8e58785d62cbfb11b05d eclipse-sdk-3.2_rc5.ebuild 8772 RMD160 5e6f30d1f44d0458127e156bceb0572dc7c73e6f eclipse-sdk-3.2_rc5.ebuild 8772 SHA256 4813814d60e5062a001669e7e1f1cafb504c4d303a596a3f050300f54d7fbe6a eclipse-sdk-3.2_rc5.ebuild 8772 +EBUILD eclipse-sdk-3.2_rc7.ebuild 10392 RMD160 6f5f7124e2f7e21ffa3b7c0617b75f2e2914951c SHA1 163e4041e499d20901cd273e7f377ce510bea1d5 SHA256 e4d0ba04f2018c41763030cb7bc6c130e8d833172ae02f494b4f8c1bf5dea997 +MD5 92237f03d5e270010fa5711a7b57c712 eclipse-sdk-3.2_rc7.ebuild 10392 +RMD160 6f5f7124e2f7e21ffa3b7c0617b75f2e2914951c eclipse-sdk-3.2_rc7.ebuild 10392 +SHA256 e4d0ba04f2018c41763030cb7bc6c130e8d833172ae02f494b4f8c1bf5dea997 eclipse-sdk-3.2_rc7.ebuild 10392 MISC NOTES 88 RMD160 17d0a1de81a98536b861d08c042380db79f4505d SHA1 69d9245b7b5d9dc29a8c929a755d4d69c13ebcb3 SHA256 a0d5585d446af9859a74ed5a3a6f84b1cb8882a4d4cce8cd07573e32e8a1f024 MD5 794ce3d84a68356de7c1b45a10d7f896 NOTES 88 RMD160 17d0a1de81a98536b861d08c042380db79f4505d NOTES 88 @@ -26,3 +24,6 @@ SHA256 a0d5585d446af9859a74ed5a3a6f84b1cb8882a4d4cce8cd07573e32e8a1f024 NOTES 88 MD5 f89deb41d369bff477b21f7dacfe9eda files/digest-eclipse-sdk-3.2_rc5 313 RMD160 4cbfe556a59254bc098914c29f7b172bfa9eaed9 files/digest-eclipse-sdk-3.2_rc5 313 SHA256 f25ee3f9a8b49f7fab25ce512459266ab80576dcc37e28b889161266f2c8c4cf files/digest-eclipse-sdk-3.2_rc5 313 +MD5 ca95a16c25dfafa7204b484ed0ca4a6c files/digest-eclipse-sdk-3.2_rc7 596 +RMD160 f53c12c324b0a7b274cbb4852573a517c8266e8d files/digest-eclipse-sdk-3.2_rc7 596 +SHA256 375e1c95876b190e6db32b13b6337b3a1a57c59777b09aa74d7b8a5b9e7a6f6b files/digest-eclipse-sdk-3.2_rc7 596 diff --git a/dev-util/eclipse-sdk/eclipse-sdk-3.2_rc7.ebuild b/dev-util/eclipse-sdk/eclipse-sdk-3.2_rc7.ebuild new file mode 100644 index 0000000..2b79dd1 --- /dev/null +++ b/dev-util/eclipse-sdk/eclipse-sdk-3.2_rc7.ebuild @@ -0,0 +1,327 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-util/eclipse-sdk/eclipse-sdk-3.1.2-r2.ebuild,v 1.1 2006/04/20 13:49:19 nichoj Exp $ + +inherit eutils java-pkg-2 flag-o-matic check-reqs + +MY_PV=${PV/_rc/RC} +DATESTAMP=200606021317 +MY_A="eclipse-sourceBuild-srcIncluded-${MY_PV}.zip" +DESCRIPTION="Eclipse Tools Platform" +HOMEPAGE="http://www.eclipse.org/" +#SRC_URI="http://ftp.osuosl.org/pub/eclipse/eclipse/downloads/drops/S-${MY_PV}-${DATESTAMP}/${MY_A}" +SRC_URI="http://download.eclipse.org/eclipse/downloads/drops/S-${MY_PV}-${DATESTAMP}/${MY_A} +http://dev.gentoo.org/~nichoj/distfiles/${P}-patches.tar.bz2" +IUSE="nogecko-sdk gnome cairo opengl" +SLOT="3.2" +LICENSE="EPL-1.0" +# TODO might be able to have ia64 and ppc64 support +KEYWORDS="~x86 ~ppc ~amd64" +S="${WORKDIR}" + +COMMON_DEP=" + >=x11-libs/gtk+-2.2.4 + !nogecko-sdk? ( net-libs/gecko-sdk ) + gnome? ( =gnome-base/gnome-vfs-2* =gnome-base/libgnomeui-2* ) + opengl? ( virtual/opengl ) + >=dev-java/ant-core-1.6.5 + >=dev-java/ant-tasks-1.6.5 + =dev-java/lucene-1*" + +RDEPEND=">=virtual/jre-1.4 + ${COMMON_DEP}" +DEPEND=" + ${COMMON_DEP} + =virtual/jdk-1.4* + >=virtual/jdk-1.5 + >=sys-apps/findutils-4.1.7 + app-arch/unzip + app-arch/zip" +# Force 1.4 to be used for building +JAVA_PKG_NV_DEPEND="=virtual/jdk-1.4*" + +ECLIPSE_DIR="/usr/lib/eclipse-${SLOT}" +ECLIPSE_LINKS_DIR="${ECLIPSE_DIR}/links" + +# TODO: +# - use CFLAGS from make.conf when building native libraries +# - must patch eclipse build files +# - also submit patch to bugs.eclipse.org +# - ppc support not tested, but not explicitly broken either +# - make a extension location in /var/lib that's writable by 'eclipse' group +# - update man page + +pkg_setup() { + java-pkg-2_pkg_setup + + debug-print "Checking for sufficient physical RAM" + CHECKREQS_MEMORY="768" + check_reqs + + # All other gentoo archs match in eclipse build system except amd64 + if use amd64 ; then + eclipsearch=x86_64 + else + eclipsearch=${ARCH} + fi + + if use x86 ; then + jvmarch=i386 + else + jvmarch=${ARCH} + fi + + # Add the eclipse group, for our plugins/features directories + enewgroup eclipse +} + +src_unpack() { + unpack ${A} + + fix-swt-targets + + pushd plugins/org.apache.ant/lib >/dev/null + rm *.jar + java-pkg_jar-from ant-core,ant-tasks + popd >/dev/null + + pushd plugins/org.junit >/dev/null + rm *.jar + java-pkg_jar-from junit + popd >/dev/null + + pushd plugins/org.apache.lucene >/dev/null + rm *.jar + java-pkg_jar-from lucene-1 lucene.jar lucene-1.4.3.jar + popd >/dev/null + + # TODO replace stuff in plugins/org.eclipse.team.cvs.ssh2 + # TODO replace stuff in plugins/org.eclipse.tomcat + # TODO replace stuff in plugins/org.junit4 + + # begin: patches/comments from fedora + + # Build JNI libs + # FIXME: these should be built by upstream build method + # http://www.bagu.org/eclipse/plugin-source-drops.html + # https://bugs.eclipse.org/bugs/show_bug.cgi?id=71637 + # https://bugs.eclipse.org/bugs/show_bug.cgi?id=86848 + # GNU XML issue identified by Michael Koch + # patches 2, 4, 5 + epatch ${WORKDIR}/${P}-build.patch + epatch ${WORKDIR}/${P}-libupdatebuild.patch + epatch ${WORKDIR}/${P}-libupdatebuild2.patch + + # Build swttools.jar + # https://bugs.eclipse.org/bugs/show_bug.cgi?id=90364 + pushd plugins/org.eclipse.swt.gtk.linux.x86_64 >/dev/null + epatch ${WORKDIR}/${P}-swttools.patch # patch18 + popd >/dev/null + + # install location should automatically be added to homedir + # if ECLIPSE_HOME is not writable + # https://bugs.eclipse.org/bugs/show_bug.cgi?id=90630 + epatch ${WORKDIR}/${P}-updatehomedir.patch # patch22 + + # .so files installed in a strange location + # https://bugs.eclipse.org/bugs/show_bug.cgi?id=90535 + pushd plugins/org.eclipse.core.runtime >/dev/null + epatch ${WORKDIR}/${P}-fileinitializer.patch # patch24 + popd >/dev/null + + # https://bugs.eclipse.org/bugs/show_bug.cgi?id=98707 + # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=178726 +# TODO figure out why this doesn't apply +# pushd plugins/org.eclipse.compare >/dev/null +# epatch ${WORKDIR}/${P}-compare-create-api.patch # patch 33 +# popd >/dev/null + + # JPackage []s in names of symlinks ... + # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=162177 + pushd plugins/org.eclipse.jdt.core >/dev/null + epatch ${WORKDIR}/${P}-bz162177.patch # patch34 + popd >/dev/null + + epatch ${WORKDIR}/${P}-genjavadocoutput.patch # patch35 + + # buildHelpIndex caused a OutOfMemoryException + # https://bugs.eclipse.org/bugs/show_bug.cgi?id=114001 + epatch ${WORKDIR}/${P}-helpindexbuilder.patch # patch38 + + epatch ${WORKDIR}/${P}-usebuiltlauncher.patch # patch40 + + # Eclipse launcher does not follow symlinks + # https://bugs.eclipse.org/bugs/show_bug.cgi?id=79592 + # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=168726 + mkdir launchertmp + unzip -d launchertmp \ + plugins/org.eclipse.platform/launchersrc.zip >/dev/null || die "unzip failed" + pushd launchertmp >/dev/null + epatch ${WORKDIR}/${P}-launcher-link.patch # patch47 + zip -9 -r ../launchersrc.zip * >/dev/null || die "zip failed" + popd >/dev/null + mv launchersrc.zip plugins/org.eclipse.platform + rm -rf launchertmp + + pushd features/org.eclipse.platform.launchers >/dev/null + epatch ${WORKDIR}/${P}-launcher-link.patch # patch47 + popd >/dev/null + + # Don't attempt to link to Sun's javadocs + epatch ${WORKDIR}/${P}-javadoclinks.patch # patch48 + + # generic releng plugins that can be used to build plugins + # see this thread for deails: + # https://www.redhat.com/archives/fedora-devel-java-list/2006-April/msg00048.html + pushd plugins/org.eclipse.pde.build >/dev/null + epatch ${WORKDIR}/${P}-pde.build-add-package-build.patch # patch53 + sed --in-place "s:@eclipse_base@:${ECLIPSE_DIR}:" templates/package-build/build.properties + popd >/dev/null + + # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=191536 + # https://bugs.eclipse.org/bugs/show_bug.cgi?id=142861 + pushd plugins/org.eclipse.swt/Eclipse\ SWT >/dev/null + epatch ${WORKDIR}/${P}-swt-rm-ON_TOP.patch # patch54 + popd >/dev/null + + # We need to disable junit4 and apt until GCJ can handle Java5 code + # FIXME for some reason junit isn't using java5... + epatch ${WORKDIR}/${P}-disable-junit4-apt.patch # patch55 +} + +src_compile() { + # Figure out VM, set up ant classpath and native library paths + setup-jvm-opts + + if ! use nogecko-sdk ; then + einfo "Will compile embedded Mozilla support against net-libs/gecko-sdk" + setup-mozilla-opts + else + einfo "Not building embedded Mozilla support" + fi + + local java5vm=$(depend-java-query --get-vm ">=virtual/jdk-1.5") + local java5home=$(GENTOO_VM=${java5vm} java-config --jdk-home) + einfo "Using ${java5home} for java5home" + # TODO patch build to take buildId + ./build -os linux \ + -arch ${eclipsearch} \ + -ws gtk \ + -java5home ${java5home} || die "build failed" +} + +src_install() { + dodir /usr/lib + + # TODO maybe there's a better way of installing than extracting the tar? + [[ -f result/linux-gtk-${eclipsearch}-sdk.tar.gz ]] || die "tar.gz bundle was not built properly!" + tar zxf result/linux-gtk-${eclipsearch}-sdk.tar.gz -C ${D}/usr/lib \ + || die "Failed to extract the built package" + + mv ${D}/usr/lib/eclipse ${D}/${ECLIPSE_DIR} + insinto ${ECLIPSE_DIR} + exeinto ${ECLIPSE_DIR} + + debug-print "Installing eclipse-gtk binary" + doexe eclipse || die "Failed to install eclipse binary" + # need to rename inf file to eclipse-gtk.ini, see bug #128128 + newins eclipse.ini eclipse-gtk.ini + + # Install startup script + exeinto /usr/bin + doexe ${FILESDIR}/eclipse-${SLOT} + + make_desktop_entry eclipse-${SLOT} "Eclipse ${PV}" "${ECLIPSE_DIR}/icon.xpm" +} + +# ----------------------------------------------------------------------------- +# Helper functions +# ----------------------------------------------------------------------------- + +fix-swt-targets() { + # Select the set of native libraries to compile + local targets="make_swt make_awt make_atk" + + if use gnome ; then + einfo "Enabling GNOME VFS support" + targets="${targets} make_gnome" + fi + + if ! use nogecko-sdk ; then + einfo "Enabling embedded Mozilla support" + targets="${targets} make_mozilla" + fi + + if use cairo ; then + einfo "Enabling CAIRO support" + targets="${targets} make_cairo" + fi + + if use opengl ; then + einfo "Enabling OpenGL support" + targets="${targets} make_glx" + fi + + sed -i "s/^all:.*/all: ${targets}/" \ + "plugins/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak" \ + || die "Failed to tweak make_linux.mak" +} + +setup-jvm-opts() { + # Figure out correct boot classpath + # karltk: this should be handled by the java-pkg eclass in setup-vm + local bp="$(java-config --jdk-home)/jre/lib" + local bootclasspath=$(java-config --runtime) + if [[ ! -z "`java-config --java-version | grep IBM`" ]] ; then + # IBM JDK + JAVA_LIB_DIR="$(java-config --jdk-home)/jre/bin" + else + # Sun derived JDKs (Blackdown, Sun) + JAVA_LIB_DIR="$(java-config --jdk-home)/jre/lib/${jvmarch}" + fi + + einfo "Using bootclasspath ${bootclasspath}" + einfo "Using JVM library path ${JAVA_LIB_DIR}" + + if [[ ! -f ${JAVA_LIB_DIR}/libawt.so ]] ; then + die "Could not find libawt.so native library" + fi + + export AWT_LIB_PATH=${JAVA_LIB_DIR} +} + +setup-mozilla-opts() { + mozilla_dir="--mozdir-unset---" + + if [[ -f ${ROOT}/usr/lib/gecko-sdk/lib/libgtkembedmoz.so ]] ; then + mozilla_dir=/usr/lib/gecko-sdk + else + # TODO need to update this appropriately for gecko-sdk + eerror "You have enabled the embedded mozilla component, but no suitable" + eerror "provider was found. You need gecko-sdk compiled against" + eerror "gtk+ v2.0 or newer." + eerror "To merge it, execute 'USE=\"gtk2\" emerge mozilla' as root." + eerror "To disable embedded mozilla, remove \"mozilla\" from your USE flags." + die "Need Mozilla compiled with gtk+-2.x support" + fi + + export GECKO_SDK="${mozilla_dir}" + # TODO should this be using pkg-config? + export GECKO_INCLUDES="-include ${GECKO_SDK}/include/mozilla-config.h \ + -I${GECKO_SDK}/include/nspr \ + -I${GECKO_SDK}/include/nspr \ + -I${GECKO_SDK}/include/xpcom \ + -I${GECKO_SDK}/include/string \ + -I${GECKO_SDK}/include/embed_base \ + -I${JAVA_HOME}/include/linux" + export GECKO_LIBS="-L${GECKO_SDK}/lib -lgtkembedmoz" +} + +pkg_postinst() { + einfo "Users can now install plugins via Update Manager without any" + einfo "tweaking." + echo + einfo "Eclipse plugin packages (ie eclipse-cdt) will likely go away in" + einfo "the near future until they can be properly packaged. Update Manager" + einfo "is prefered in the meantime." +} diff --git a/dev-util/eclipse-sdk/files/07-eclipse-3.2.patch b/dev-util/eclipse-sdk/files/07-eclipse-3.2.patch deleted file mode 100644 index c76458e..0000000 --- a/dev-util/eclipse-sdk/files/07-eclipse-3.2.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- plugins/org.eclipse.core.runtime.compatibility.registry/build.xml 2006-04-18 07:54:25.000000000 +0300 -+++ plugins/org.eclipse.core.runtime.compatibility.registry/build.xml.fixed 2006-04-18 07:54:01.000000000 +0300 -@@ -79,6 +79,7 @@ - <pathelement path="${build.result.folder}/../org.eclipse.equinox.registry/runtime_registry_compatibility.jar"/> - <pathelement path="${build.result.folder}/../org.eclipse.equinox.registry/bin/"/> - <pathelement path="${build.result.folder}/../org.eclipse.equinox.registry/@dot"/> -+ <pathelement path="../org.eclipse.core.runtime/@dot"/> - <pathelement path="${build.result.folder}/../org.eclipse.osgi/bin/"/> - <pathelement path="${build.result.folder}/../org.eclipse.osgi/@dot"/> - <pathelement path="${build.result.folder}/../org.eclipse.core.jobs/bin/"/> ---- plugins/org.eclipse.update.core.linux/src/build.xml~ 2006-04-29 12:43:49.000000000 +0300 -+++ plugins/org.eclipse.update.core.linux/src/build.xml 2006-04-29 12:43:17.000000000 +0300 -@@ -5,7 +5,7 @@ - <!-- Set a meaningful default value for when it is not. --> - <property name="eclipse-home" value="${basedir}/../.."/> - <property name="jdk-path" value="${java.home}"/> -- <property name="destination" value="${eclipse-home}/org.eclipse.update.core.linux/os/linux/x86/"/> -+ <property name="destination" value="${eclipse-home}/org.eclipse.update.core.linux/os/linux/${arch}/"/> - <property name="obj-path" value="${eclipse-home}/org.eclipse.update.core.linux/src/"/> - <property name="src-path" value="${eclipse-home}/org.eclipse.update.core.linux/src/"/> - -@@ -47,17 +47,17 @@ - <property name="header-path" value="${jdk-path}/../include"/> - <property name="header-linux-path" value="${header-path}/linux" /> - -- <echo message="gcc -o ${library-file} -shared -I${src-path} -I${header-linux-path} ${library-file} -static -lc"/> -+ <echo message="gcc -o ${library-file} -shared -fPIC -I${src-path} -I${header-linux-path} ${library-file} -lc"/> - - <apply executable="gcc" dest="${eclipse-home}/" parallel="false"> - <arg value="-o"/> - <arg value="${library-file}"/> - <arg value="-shared"/> -+ <arg value="-fPIC"/> - <arg value="-I${src-path}"/> - <arg value="-I${header-path}"/> - <arg value="-I${header-linux-path}"/> - <srcfile/> -- <arg value="-static"/> - <arg value="-lc"/> - <fileset dir="${src-path}" includes="*.c"/> - <mapper type="glob" from="*.c" to="*.o"/> - diff --git a/dev-util/eclipse-sdk/files/digest-eclipse-sdk-3.2_rc7 b/dev-util/eclipse-sdk/files/digest-eclipse-sdk-3.2_rc7 new file mode 100644 index 0000000..6650416 --- /dev/null +++ b/dev-util/eclipse-sdk/files/digest-eclipse-sdk-3.2_rc7 @@ -0,0 +1,6 @@ +MD5 d5f9df81a83b9844c1a7ffeafb6c48d9 eclipse-sdk-3.2_rc7-patches.tar.bz2 24935 +RMD160 88423e6e04eda1b5d1d87ffded8c91f2034c45ad eclipse-sdk-3.2_rc7-patches.tar.bz2 24935 +SHA256 7c204cef97110f8018fd13212ddf48f915bed7fea7b95e11b40ff1e8a4c528d8 eclipse-sdk-3.2_rc7-patches.tar.bz2 24935 +MD5 9fa62b56c209713a32296f3ac65cf1d0 eclipse-sourceBuild-srcIncluded-3.2RC7.zip 82030272 +RMD160 1e7e6107f791d023dc9c2a6ba8c1f3d6d0cfaf80 eclipse-sourceBuild-srcIncluded-3.2RC7.zip 82030272 +SHA256 fbf6956fef7223e770e8362d7d388a99a9ff209f3c9ec6e0143d70c38a99ef1c eclipse-sourceBuild-srcIncluded-3.2RC7.zip 82030272 diff --git a/dev-util/eclipse-sdk/files/eclipse-3.2 b/dev-util/eclipse-sdk/files/eclipse-3.2 index 557d8d6..b8dfc7b 100644 --- a/dev-util/eclipse-sdk/files/eclipse-3.2 +++ b/dev-util/eclipse-sdk/files/eclipse-3.2 @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash # # Tiny startup wrapper for the Eclipse 3.2.x series # @@ -8,25 +8,10 @@ # Licensed under the GNU General Public License, version 2 # -if [ -f $HOME/.eclipserc ] ; then - . $HOME/.eclipserc -fi - -if [ -z "${ECLIPSE_HOME}" ] ; then - ECLIPSE_HOME=/usr/lib/eclipse-3.2 -fi +[[ -f $HOME/.eclipserc ]] && $HOME/.eclipserc -if [ "${PREFERRED_FRONTEND}" == "gtk" ] && [ -x ${ECLIPSE_HOME}/eclipse-gtk ] ; then - ECLIPSE_BIN=${ECLIPSE_HOME}/eclipse-gtk -elif [ "${PREFERRED_FRONTEND}" == "motif" ] && [ -x ${ECLIPSE_HOME}/eclipse-motif ] ; then - ECLIPSE_BIN=${ECLIPSE_HOME}/eclipse-motif -else - if [ -x ${ECLIPSE_HOME}/eclipse-gtk ] ; then - ECLIPSE_BIN=${ECLIPSE_HOME}/eclipse-gtk - elif [ -x ${ECLIPSE_HOME}/eclipse-motif ] ; then - ECLIPSE_BIN=${ECLIPSE_HOME}/eclipse-motif - fi -fi +ECLIPSE_HOME=${ECLIPSE_HOME:="/usr/lib/eclipse-3.2"} +ECLIPSE_BIN="${ECLIPSE_HOME}/eclipse" if [ ! -x ${ECLIPSE_BIN} ] ; then echo "Failed to find executable '${ECLIPSE_BIN}'" > /dev/stderr @@ -44,7 +29,7 @@ if [ $(whoami) == "root" ] ; then echo "!!! 3) 'emerge eclipse-sdk'" fi -if [ -d /usr/lib/gecko-sdk/lib/ ] && [ -f /usr/lib/gecko-sdk/lib/libgtkembedmoz.so ] ; then +if [[ -d /usr/lib/gecko-sdk/lib/ ]] && [[ -f /usr/lib/gecko-sdk/lib/libgtkembedmoz.so ]] ; then export MOZILLA_FIVE_HOME="/usr/lib/gecko-sdk/lib/" fi diff --git a/dev-util/eclipse-sdk/files/eclipse-3.2.desktop b/dev-util/eclipse-sdk/files/eclipse-3.2.desktop deleted file mode 100644 index 92a72c1..0000000 --- a/dev-util/eclipse-sdk/files/eclipse-3.2.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=Eclipse @PV@ -Comment=A Java Development Environment -Icon=/usr/lib/eclipse-3.2/icon.xpm -Exec=/usr/bin/eclipse-3.2 -Terminal=false -Type=Application -Categories=GNOME;Application;Development -StartupNotify=true diff --git a/eclass/java-pkg-2.eclass b/eclass/java-pkg-2.eclass new file mode 100644 index 0000000..cbaac83 --- /dev/null +++ b/eclass/java-pkg-2.eclass @@ -0,0 +1,85 @@ +# Eclass for Java packages +# +# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> +# Copyright (c) 2004-2005, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 +# + +inherit java-utils-2 + +# ----------------------------------------------------------------------------- +# @eclass-begin +# @eclass-summary Eclass for Java Packages +# +# This eclass should be inherited for pure Java packages, or by packages which +# need to use Java. +# ----------------------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# @depend +# +# Java packages need java-config, and a fairly new release of Portage. +# +# JAVA_PKG_E_DEPEND is defined in java-utils.eclass. +# ------------------------------------------------------------------------------ +DEPEND="${JAVA_PKG_E_DEPEND}" + +# ------------------------------------------------------------------------------ +# @rdepend +# +# Nothing special for RDEPEND... just the same as DEPEND. +# ------------------------------------------------------------------------------ +RDEPEND="${DEPEND}" + +EXPORT_FUNCTIONS pkg_setup + +# ------------------------------------------------------------------------------ +# @eclass-pkg_setup +# +# pkg_setup initializes the Java environment +# ------------------------------------------------------------------------------ +java-pkg-2_pkg_setup() { + java-pkg_init +} + +# ------------------------------------------------------------------------------ +# @note +# +# We need to initialize the environment in every function because Portage +# will source /etc/profile between phases and trample all over the env. +# This is accomplished by phase hooks, which is available with newer versions of +# portage. +# ------------------------------------------------------------------------------ + +pre_pkg-2_setup() { + java-pkg-2_pkg_setup +} + +pre_src_unpack() { + java-pkg-2_pkg_setup +} + +pre_src_compile() { + java-pkg-2_pkg_setup +} + +pre_src_install() { + java-pkg-2_pkg_setup +} + +pre_src_test() { + java-pkg-2_pkg_setup +} + +pre_pkg_preinst() { + java-pkg-2_pkg_setup +} + +pre_pkg_postinst() { + java-pkg-2_pkg_setup +} + +# ------------------------------------------------------------------------------ +# @eclass-end +# ------------------------------------------------------------------------------ diff --git a/eclass/java-pkg.eclass b/eclass/java-pkg.eclass new file mode 100644 index 0000000..dffe6f4 --- /dev/null +++ b/eclass/java-pkg.eclass @@ -0,0 +1,422 @@ +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/java-pkg.eclass,v 1.32 2005/12/06 20:10:50 betelgeuse Exp $ + +inherit multilib + +JAVA_CONFIG_DEP="|| ( =dev-java/java-config-1.3* =dev-java/java-config-1.2* )" +DEPEND="${JAVA_CONFIG_DEP}" +RDEPEND="${JAVA_CONFIG_DEP}" + + +EXPORT_FUNCTIONS pkg_setup + +# We need to do a few things to add compatibility between +# generation-1 and generation-2. + +# First we make sure java-config-1 will be used +export WANT_JAVA_CONFIG="1" + +# VMHANDLE is defined in /etc/env.d/20java. This is the handle java-config-2 +# uses for determining which VM to use. +# +# We set GENTOO_VM to this, to ensure that /usr/bin/java and company are using +# the right VM. +export GENTOO_VM="${VMHANDLE}" + +# During pkg_setup, we need to live some crumb trails that we're using +# in a mixed generation-1/generation-2 environment +# TODO need to make sure everything that inherits java-pkg and has a pkg_setup +# uses java-pkg_pkg_setup +java-pkg_pkg_setup() { + java-pkg_announce-qa-violation using deprecated eclass java-pkg + + # We need to do a little magic if java-config-2 is around + if has_version "=dev-java/java-config-2*"; then + ebegin "Enabling generation-2 compatibility" + if [[ -n ${GENTOO_VM} ]]; then + einfo "Using ${GENTOO_VM}" + eend 0 + else + eerror "There was a problem determining which VM to use for Generation-1" + eerror "See the list of available VMs by using: java-config-1 -L" + eerror "Then select on of those by using: java-config-1 -S <selected vm>" + eerror "And once that is done, run: env-update && source /etc/profile" + eerror "Then to continue the emerge: emerge --resume" + eend 1 + die "Couldn't determine VM for generation-1" + fi + fi +} + + +pkglistpath="${T}/java-pkg-list" + +java-pkg_doclass() +{ + debug-print-function ${FUNCNAME} $* + java-pkg_dojar $* +} + +java-pkg_do_init_() +{ + debug-print-function ${FUNCNAME} $* + + if [ -z "${JARDESTTREE}" ] ; then + JARDESTTREE="lib" + SODESTTREE=$(get_libdir) + fi + + # Set install paths + sharepath="${DESTTREE}/share" + if [ "$SLOT" == "0" ] ; then + pkg_name="${PN}" + else + pkg_name="${PN}-${SLOT}" + fi + + shareroot="${sharepath}/${pkg_name}" + + if [ -z "${jardest}" ] ; then + jardest="${shareroot}/${JARDESTTREE}" + fi + + if [ -z "${sodest}" ] ; then + sodest="/opt/${pkg_name}/${SODESTTREE}" + fi + + package_env="${D}${shareroot}/package.env" + + debug-print "JARDESTTREE=${JARDESTTREE}" + debug-print "SODESTTREE=${SODESTTREE}" + debug-print "sharepath=${sharepath}" + debug-print "shareroot=${shareroot}" + debug-print "jardest=${jardest}" + debug-print "sodest=${sodest}" + debug-print "package_env=${package_env}" + +} + +java-pkg_do_write_() +{ + # Create directory for package.env + dodir "${shareroot}" + + # Create package.env + echo "DESCRIPTION=${DESCRIPTION}" > "${package_env}" + echo "GENERATION=1" >> "${package_env}" + if [ -n "${cp_pkg}" ]; then + echo "CLASSPATH=${cp_prepend}:${cp_pkg}:${cp_append}" >> "${package_env}" + fi + if [ -n "${lp_pkg}" ]; then + echo "LIBRARY_PATH=${lp_prepend}:${lp_pkg}:${lp_append}" >> "${package_env}" + fi + if [ -f ${pkglistpath} ] ; then + pkgs=$(cat ${pkglistpath} | tr '\n' ':') + echo "DEPEND=${pkgs}" >> "${package_env}" + fi + + # Strip unnecessary leading and trailing colons + sed -e "s/=:/=/" -e "s/:$//" -i "${package_env}" +} + +java-pkg_do_getsrc_() +{ + # Check for symlink + if [ -L "${i}" ] ; then + cp "${i}" "${T}" + echo "${T}"/`/usr/bin/basename "${i}"` + + # Check for directory + elif [ -d "${i}" ] ; then + echo "java-pkg: warning, skipping directory ${i}" + continue + else + echo "${i}" + fi +} + + +java-pkg_doso() +{ + debug-print-function ${FUNCNAME} $* + [ -z "$1" ] + + java-pkg_do_init_ + + # Check for arguments + if [ -z "$*" ] ; then + die "at least one argument needed" + fi + + # Make sure directory is created + if [ ! -d "${D}${sodest}" ] ; then + install -d "${D}${sodest}" + fi + + for i in $* ; do + mysrc=$(java-pkg_do_getsrc_) + + # Install files + install -m 0755 "${mysrc}" "${D}${sodest}" || die "${mysrc} not found" + done + lp_pkg="${sodest}" + + java-pkg_do_write_ +} + +java-pkg_dojar() +{ + debug-print-function ${FUNCNAME} $* + [ -z "$1" ] + + java-pkg_do_init_ + + if [ -n "${DEP_PREPEND}" ] ; then + for i in ${DEP_PREPEND} + do + if [ -f "${sharepath}/${i}/package.env" ] ; then + debug-print "${i} path: ${sharepath}/${i}" + if [ -z "${cp_prepend}" ] ; then + cp_prepend=`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"` + else + cp_prepend="${cp_prepend}:"`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"` + fi + else + debug-print "Error: Package ${i} not found." + debug-print "${i} path: ${sharepath}/${i}" + die "Error in DEP_PREPEND." + fi + debug-print "cp_prepend=${cp_prepend}" + + done + fi + + if [ -n "${DEP_APPEND}" ] ; then + for i in ${DEP_APPEND} + do + if [ -f "${sharepath}/${i}/package.env" ] ; then + debug-print "${i} path: ${sharepath}/${i}" + if [ -z "${cp_append}" ] ; then + cp_append=`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"` + else + cp_append="${cp_append}:"`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"` + fi + else + debug-print "Error: Package ${i} not found." + debug-print "${i} path: ${sharepath}/${i}" + die "Error in DEP_APPEND." + fi + debug-print "cp_append=${cp_append}" + done + fi + + # Check for arguments + if [ -z "$*" ] ; then + die "at least one argument needed" + fi + + # Make sure directory is created + dodir ${jardest} + + for i in $* ; do + mysrc=$(java-pkg_do_getsrc_) + + # Install files + install -m 0644 "${mysrc}" "${D}${jardest}" || die "${mysrc} not found" + + # Build CLASSPATH + if [ -z "${cp_pkg}" ] ; then + cp_pkg="${jardest}"/`/usr/bin/basename "${i}"` + else + cp_pkg="${cp_pkg}:${jardest}/"`/usr/bin/basename "${i}"` + fi + done + + java-pkg_do_write_ +} + +java-pkg_newjar() +{ + if [ -z "${T}" ] || [ -z "${2}" ] ; then + die "java-pkg_newjar: Nothing defined to do" + fi + + rm -rf "${T}/${2}" + cp "${1}" "${T}/${2}" + java-pkg_dojar "${T}/${2}" +} + +java-pkg_dowar() +{ + debug-print-function ${FUNCNAME} $* + [ -z "$1" ] + + # Check for arguments + if [ -z "$*" ] ; then + die "at least one argument needed" + fi + + if [ -z "${WARDESTTREE}" ] ; then + WARDESTTREE="webapps" + fi + + sharepath="${DESTTREE}/share" + shareroot="${sharepath}/${PN}" + wardest="${shareroot}/${WARDESTTREE}" + + debug-print "WARDESTTREE=${WARDESTTREE}" + debug-print "sharepath=${sharepath}" + debug-print "shareroot=${shareroot}" + debug-print "wardest=${wardest}" + + # Patch from Joerg Schaible <joerg.schaible@gmx.de> + # Make sure directory is created + if [ ! -d "${D}${wardest}" ] ; then + install -d "${D}${wardest}" + fi + + for i in $* ; do + # Check for symlink + if [ -L "${i}" ] ; then + cp "${i}" "${T}" + mysrc="${T}"/`/usr/bin/basename "${i}"` + + # Check for directory + elif [ -d "${i}" ] ; then + echo "dowar: warning, skipping directory ${i}" + continue + else + mysrc="${i}" + fi + + # Install files + install -m 0644 "${mysrc}" "${D}${wardest}" + done +} + +java-pkg_dozip() +{ + debug-print-function ${FUNCNAME} $* + java-pkg_dojar $* +} + +_record-jar() +{ + echo "$(basename $2)@$1" >> ${pkglistpath} +} + +java-pkg_jarfrom() { + java-pkg_jar-from "$@" +} + +java-pkg_jar-from() +{ + debug-print-function ${FUNCNAME} $* + + local pkg=$1 + local jar=$2 + local destjar=$3 + + if [ -z "${destjar}" ] ; then + destjar=${jar} + fi + + for x in $(java-config --classpath=${pkg} | tr ':' ' '); do + if [ ! -f ${x} ] ; then + die "Installation problems with jars in ${pkg} - is it installed?" + return 1 + fi + _record-jar ${pkg} ${x} + if [ -z "${jar}" ] ; then + [[ -f $(basename ${x}) ]] && rm $(basename ${x}) + ln -snf ${x} $(basename ${x}) + elif [ "$(basename ${x})" == "${jar}" ] ; then + [[ -f ${destjar} ]] && rm ${destjar} + ln -snf ${x} ${destjar} + return 0 + fi + done + if [ -z "${jar}" ] ; then + return 0 + else + die "failed to find ${jar}" + fi +} + +java-pkg_getjar() +{ + + debug-print-function ${FUNCNAME} $* + + local pkg=$1 + local jar=$2 + + for x in $(java-config --classpath=${pkg} | tr ':' ' '); do + + if [ ! -f ${x} ] ; then + die "Installation problems with jars in ${pkg} - is it installed?" + fi + + _record-jar ${pkg} ${x} + + if [ "$(basename ${x})" == "${jar}" ] ; then + echo ${x} + return 0 + fi + done + die "Could not find $2 in $1" +} + +java-pkg_getjars() +{ + java-config --classpath=$1 +} + + +java-pkg_dohtml() +{ + dohtml -f package-list $@ +} + +java-pkg_jarinto() +{ + jardest=$1 +} + +java-pkg_sointo() +{ + sodest=$1 +} + +java-pkg_dosrc() { + java-pkg_do_init_ + + [ $# -lt 1 ] && die "${FUNCNAME[0]}: at least one argument needed" + + local target="${shareroot}/source/" + + local files + local startdir=$(pwd) + for x in ${@}; do + cd $(dirname ${x}) + zip -q -r ${T}/${PN}-src.zip $(basename ${x}) -i '*.java' + local res=$? + if [[ ${res} != 12 && ${res} != 0 ]]; then + die "zip failed" + fi + + cd ${startdir} + done + + dodir ${target} + install ${INSOPTIONS} "${T}/${PN}-src.zip" "${D}${target}" \ + || die "failed to install sources" +} + + +java-pkg_announce-qa-violation() { + if hasq java-strict ${FEATURES}; then + echo "Java QA Notice: $@" >&2 + fi +} diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass new file mode 100644 index 0000000..6f04b9e --- /dev/null +++ b/eclass/java-utils-2.eclass @@ -0,0 +1,1747 @@ +# Base eclass for Java packages +# +# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> +# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> +# Copyright (c) 2004-2005, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 +# + + +# ----------------------------------------------------------------------------- +# @eclass-begin +# @eclass-shortdesc Java Utility eclass +# @eclass-maintainer java@gentoo.org +# +# This eclass provides functionality which is used by +# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds. +# +# @warning +# You probably don't want to inherit this directly from an ebuild. Instead, +# you should inherit java-ant for Ant-based Java packages, java-pkg for other +# Java packages, or java-pkg-opt for packages that have optional Java support. +# +# ----------------------------------------------------------------------------- + +inherit eutils versionator multilib + +# ----------------------------------------------------------------------------- +# @section-begin variables +# @section-title Variables +# +# Summary of variables which control the behavior of building Java packges. +# ----------------------------------------------------------------------------- + +# Make sure we use java-config-2 +export WANT_JAVA_CONFIG="2" + +# ----------------------------------------------------------------------------- +# @variable-internal JAVA_PKG_E_DEPEND +# +# This is a convience variable to be used from the other java eclasses. This is +# the version of java-config we want to use. We also need a recent version +# portage, that includes phase hooks. +# ----------------------------------------------------------------------------- +JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 >=sys-apps/portage-2.1_pre1" + +# ----------------------------------------------------------------------------- +# @variable-external JAVA_PKG_ALLOW_VM_CHANGE +# @variable-default yes +# +# Allow this eclass to change the active VM? +# If your system VM isn't sufficient for the package, the build will fail. +# @note This is useful for testing specific VMs. +# ----------------------------------------------------------------------------- +JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} + +# ----------------------------------------------------------------------------- +# @variable-external JAVA_PKG_FORCE_VM +# +# Explicitly set a particular VM to use. If its not valid, it'll fall back to +# whatever /etc/java-config-2/build/jdk.conf would elect to use. +# +# Should only be used for testing and debugging. +# +# @example Use sun-jdk-1.5 to emerge foo +# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo +# +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# @variable-external JAVA_PKG_WANT_SOURCE +# +# Specify a specific VM version to compile for to use for -source. +# Normally this is determined from DEPEND. +# See java-pkg_get-source function below. +# +# Should only be used for testing and debugging. +# +# @seealso java-pkg_get-source +# +# @example Use 1.4 source to emerge baz +# JAVA_PKG_WANT_SOURCE=1.4 emerge baz +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# @variable-external JAVA_PKG_WANT_TARGET +# +# Same as JAVA_PKG_WANT_SOURCE above but for -target. +# See java-pkg_get-target function below. +# +# Should only be used for testing and debugging. +# +# @seealso java-pkg_get-target +# +# @example emerge bar to be compatible with 1.3 +# JAVA_PKG_WANT_TARGET=1.3 emerge bar +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# @variable-internal JAVA_PKG_COMPILER_DIR +# @default /usr/share/java-config-2/compiler +# +# Directory where compiler settings are saved, without trailing slash. +# Probably shouldn't touch this variable. +# ----------------------------------------------------------------------------- +JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} + + +# ----------------------------------------------------------------------------- +# @variable-internal JAVA_PKG_COMPILERS_CONF +# @variable-default /etc/java-config-2/build/compilers.conf +# +# Path to file containing information about which compiler to use. +# Can be overloaded, but it should be overloaded for testing. +# ----------------------------------------------------------------------------- +JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="/etc/java-config-2/build/compilers.conf"} + +# ----------------------------------------------------------------------------- +# @variable-external JAVA_PKG_FORCE_COMPILER +# +# Explicitly set a list of compilers to use. This is normally read from +# JAVA_PKG_COMPILERS_CONF. +# +# @note This should only be used internally or for testing. +# @example Use jikes and javac, in that order +# JAVA_PKG_FORCE_COMPILER="jikes javac" +# ----------------------------------------------------------------------------- + +# TODO document me +JAVA_PKG_QA_VIOLATIONS=0 + +# ----------------------------------------------------------------------------- +# @section-end variables +# ----------------------------------------------------------------------------- + + +# ----------------------------------------------------------------------------- +# @section-begin install +# @section-summary Install functions +# +# These are used to install Java-related things, such as jars, Javadocs, JNI +# libraries, etc. +# ----------------------------------------------------------------------------- + + +# ----------------------------------------------------------------------------- +# @ebuild-function java-pkg_dojar +# +# Installs any number of jars. +# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. +# You can use java-pkg_jarinto to change this path. +# You should never install a jar with a package version in the filename. +# Instead, use java-pkg_newjar defined below. +# +# @example +# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar +# +# @param $* - list of jars to install +# ------------------------------------------------------------------------------ +java-pkg_dojar() { + debug-print-function ${FUNCNAME} $* + + [[ ${#} -lt 1 ]] && die "At least one argument needed" + + java-pkg_check-phase install + java-pkg_init_paths_ + + # Create JARDEST if it doesn't exist + dodir ${JAVA_PKG_JARDEST} + + local jar + # for each jar + for jar in "$@"; do + local jar_basename=$(basename "${jar}") + + java-pkg_check-versioned-jar ${jar_basename} + + # check if it exists + if [[ -e "${jar}" ]] ; then + # install it into JARDEST if it's a non-symlink + if [[ ! -L "${jar}" ]] ; then + INSDESTTREE="${JAVA_PKG_JARDEST}" \ + doins "${jar}" || die "failed to install ${jar}" + java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" + debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" + # make a symlink to the original jar if it's symlink + else + # TODO use dosym, once we find something that could use it + # -nichoj + ln -s "$(readlink "${jar}")" "${D}${JAVA_PKG_JARDEST}/${jar_basename}" + debug-print "${jar} is a symlink, linking accordingly" + fi + else + die "${jar} does not exist" + fi + done + + java-pkg_do_write_ +} + + + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_regjar +# +# Records an already installed jar in the package.env +# This would mostly be used if the package has make or a custom script to +# install things. +# +# Example: +# java-pkg-regjar ${D}/opt/foo/lib/foo.jar +# +# @param $@ - jars to record +# ------------------------------------------------------------------------------ +# TODO fix me! +java-pkg_regjar() { + debug-print-function ${FUNCNAME} $* + + java-pkg_check-phase install + + [[ ${#} -lt 1 ]] && die "at least one argument needed" + + java-pkg_init_paths_ + + local jar jar_dir jar_file + for jar in "$@"; do + # TODO use java-pkg_check-versioned-jar + if [[ -e "${jar}" ]]; then + java-pkg_append_ JAVA_PKG_CLASSPATH "${jar}" + elif [[ -e "${D}${jar}" ]]; then + java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" + else + die "${jar} does not exist" + fi + done + + java-pkg_do_write_ +} + + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_newjar +# +# Installs a jar with a new name +# +# @example: install a versioned jar without the version +# java-pkg_newjar dist/${P}.jar ${PN}.jar +# +# @param $1 - jar to install +# @param $2 - new name for jar - defaults to ${PN}.jar if not specified +# ------------------------------------------------------------------------------ +java-pkg_newjar() { + debug-print-function ${FUNCNAME} $* + + local original_jar="${1}" + local new_jar="${2:-${PN}.jar}" + local new_jar_dest="${T}/${new_jar}" + + [[ -z ${original_jar} ]] && die "Must specify a jar to install" + [[ ! -f ${original_jar} ]] && die "${new_jar} does not exist!" + + rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" + cp "${original_jar}" "${new_jar_dest}" \ + || die "Failed to copy ${original_jar} to ${new_jar_dest}" + java-pkg_dojar "${new_jar_dest}" +} + + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_addcp +# +# Add something to the package's classpath. For jars, you should use dojar, +# newjar, or regjar. This is typically used to add directories to the classpath. +# +# TODO add example +# @param $@ - value to append to JAVA_PKG_CLASSPATH +# ------------------------------------------------------------------------------ +java-pkg_addcp() { + java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" + java-pkg_do_write_ +} + + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_doso +# +# Installs any number of JNI libraries +# They will be installed into /usr/lib by default, but java-pkg_sointo +# can be used change this path +# +# Example: +# java-pkg_doso *.so +# +# @param $@ - JNI libraries to install +# ------------------------------------------------------------------------------ +java-pkg_doso() { + debug-print-function ${FUNCNAME} $* + + [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}" + java-pkg_check-phase install + + [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" + + java-pkg_init_paths_ + + local lib + # for each lib + for lib in "$@" ; do + # if the lib exists... + if [[ -e "${lib}" ]] ; then + # install if it isn't a symlink + if [[ ! -L "${lib}" ]] ; then + INSDESTTREE="${JAVA_PKG_LIBDEST}" \ + INSOPTIONS="${LIBOPTIONS}" \ + doins "${lib}" || "failed to install ${lib}" + java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" + debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" + # otherwise make a symlink to the symlink's origin + else + # TODO use dosym + ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" + debug-print "${lib} is a symlink, linking accordanly" + fi + # otherwise die + else + die "${lib} does not exist" + fi + done + + java-pkg_do_write_ +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_regso +# +# Registers an already JNI library in package.env. +# +# Example: +# java-pkg_regso *.so /path/*.so +# +# @param $@ - JNI libraries to register +# ------------------------------------------------------------------------------ +java-pkg_regso() { + debug-print-function ${FUNCNAME} $* + + java-pkg_check-phase install + + [[ ${#} -lt 1 ]] && "at least one argument needed" + + java-pkg_init_paths_ + + local lib target_dir + for lib in "$@" ; do + # Check the absolute path of the lib + if [[ -e "${lib}" ]] ; then + target_dir="$(java-pkg_expand_dir_ ${lib})" + java-pkg_append_ JAVA_PKG_LIBRARY "/${target_dir#${D}}" + # Check the path of the lib relative to ${D} + elif [[ -e "${D}${lib}" ]]; then + target_dir="$(java-pkg_expand_dir_ ${D}${lib})" + java-pkg_append_ JAVA_PKG_LIBRARY "${target_dir}" + else + die "${lib} does not exist" + fi + done + + java-pkg_do_write_ +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_jarinto +# +# Changes the path jars are installed into +# +# @param $1 - new location to install jars into. +# ----------------------------------------------------------------------------- +java-pkg_jarinto() { + debug-print-function ${FUNCNAME} $* + + JAVA_PKG_JARDEST="${1}" +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_sointo +# +# Changes the path that JNI libraries are installed into. +# +# @param $1 - new location to install JNI libraries into. +# ------------------------------------------------------------------------------ +java-pkg_sointo() { + debug-print-function ${FUNCNAME} $* + + JAVA_PKG_LIBDEST="${1}" +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_dohtml +# +# Install Javadoc HTML documentation +# +# @example +# java-pkg_dohtml dist/docs/ +# +# ------------------------------------------------------------------------------ +java-pkg_dohtml() { + debug-print-function ${FUNCNAME} $* + + [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" + # TODO-nichoj find out what exactly -f package-list does + dohtml -f package-list "$@" + # this probably shouldn't be here but it provides + # a reasonable way to catch # docs for all of the + # old ebuilds. + java-pkg_recordjavadoc +} + +# TODO document +java-pkg_dojavadoc() { + local dir="$1" + + java-pkg_check-phase install + + [[ -z "${dir}" ]] && die "Must specify a directory!" + [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" + + local dir_to_install="${dir}" + if [[ "$(basename "${dir}")" != "api" ]]; then + dir_to_install="${T}/api" + # TODO use doins + cp -r "${dir}" "${dir_to_install}" || die "cp failed" + fi + + java-pkg_dohtml -r ${dir_to_install} +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_dosrc +# +# Installs a zip containing the source for a package, so it can used in +# from IDEs like eclipse and netbeans. +# +# Ebuild needs to DEPEND on app-arch/zip to use this. +# +# It also should be controlled by USE=source. +# +# @example: +# java-pkg_dosrc src/* +# +# ------------------------------------------------------------------------------ +# TODO change so it the arguments it takes are the base directories containing +# source -nichoj +# TODO should we be able to handle multiple calls to dosrc? -nichoj +# TODO maybe we can take an existing zip/jar? -nichoj +# FIXME apparently this fails if you give it an empty directories +java-pkg_dosrc() { + debug-print-function ${FUNCNAME} $* + + [ ${#} -lt 1 ] && die "At least one argument needed" + if ! hasq source ${IUSE}; then + echo "Java QA Notice: ${FUNCNAME} called without source in IUSE" + fi + + java-pkg_check-phase install + + [[ ${#} -lt 1 ]] && die "At least one argument needed" + + java-pkg_init_paths_ + + local zip_name="${PN}-src.zip" + local zip_path="${T}/${zip_name}" + local dir + for dir in ${@}; do + local dir_parent=$(dirname "${dir}") + local dir_name=$(basename "${dir}") + pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" + zip -q -r ${zip_path} ${dir_name} -i '*.java' + local result=$? + # 12 means zip has nothing to do + if [[ ${result} != 12 && ${result} != 0 ]]; then + die "failed to zip ${dir_name}" + fi + popd >/dev/null + done + + # Install the zip + INSDESTTREE=${JAVA_PKG_SOURCESPATH} \ + doins ${zip_path} || die "Failed to install source" + + JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}" + java-pkg_do_write_ +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_dolauncher +# +# Make a wrapper script to lauch/start this package +# If necessary, the wrapper will switch to the appropriate VM. +# +# @param $1 - filename of launcher to create +# @param $2 - options, as follows: +# --main the.main.class.too.start +# --jar /the/jar/too/launch.jar +# --java_args 'Extra arguments to pass too jave' +# --pkg_args 'extra arguments too pass too the package' +# --pwd +# -into +# -pre +# ------------------------------------------------------------------------------ +java-pkg_dolauncher() { + debug-print-function ${FUNCNAME} $* + + java-pkg_check-phase install + + [[ ${#} -lt 1 ]] && die "Need at least one argument" + + java-pkg_init_paths_ + + local name="${1}" + # TODO rename to launcher + local target="${T}/${name}" + local target_dir pre + shift + + echo "#!/bin/bash" > "${target}" + while [[ -n "${1}" && -n "${2}" ]]; do + local var=${1} value=${2} + if [[ "${var:0:2}" == "--" ]]; then + echo "gjl_${var:2}=\"${value}\"" >> "${target}" + elif [[ "${var}" == "-into" ]]; then + target_dir="${value}" + elif [[ "${var}" == "-pre" ]]; then + pre="${value}" + fi + shift 2 + done + echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" + [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" + echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" + + if [[ -n "${into}" ]]; then + DESTTREE="${target_dir}" dobin "${target}" + local ret=$? + return ${ret} + else + dobin "${target}" + fi +} + +# ------------------------------------------------------------------------------ +# Install war files. +# TODO document +# ------------------------------------------------------------------------------ +java-pkg_dowar() { + debug-print-function ${FUNCNAME} $* + + # Check for arguments + [[ ${#} -lt 1 ]] && die "At least one argument needed" + java-pkg_check-phase install + + java-pkg_init_paths_ + + local war + for war in $* ; do + local warpath + # TODO evaluate if we want to handle symlinks differently -nichoj + # Check for symlink + if [[ -L "${war}" ]] ; then + cp "${war}" "${T}" + warpath="${T}$(basename "${war}")" + # Check for directory + # TODO evaluate if we want to handle directories differently -nichoj + elif [[ -d "${war}" ]] ; then + echo "dowar: warning, skipping directory ${war}" + continue + else + warpath="${war}" + fi + + # Install those files like you mean it + INSOPTIONS="-m 0644" \ + INSDESTTREE=${JAVA_PKG_WARDEST} \ + doins ${warpath} + done +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_recordjavadoc +# Scan for JavaDocs, and record their existence in the package.env file +# +# TODO make sure this in the proper section +# ------------------------------------------------------------------------------ +java-pkg_recordjavadoc() +{ + debug-print-function ${FUNCNAME} $* + # the find statement is important + # as some packages include multiple trees of javadoc + JAVADOC_PATH="$(find ${D}/usr/share/doc/ -name allclasses-frame.html -printf '%h:')" + # remove $D - TODO: check this is ok with all cases of the above + JAVADOC_PATH="${JAVADOC_PATH//${D}}" + if [[ -n "${JAVADOC_PATH}" ]] ; then + debug-print "javadocs found in ${JAVADOC_PATH%:}" + java-pkg_do_write_ + else + debug-print "No javadocs found" + fi +} + +# ------------------------------------------------------------------------------ +# @section-end install +# ------------------------------------------------------------------------------ + +# ------------------------------------------------------------------------------ +# @begin-section query +# Use these to build the classpath for building a package. +# ------------------------------------------------------------------------------ + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_jar-from +# +# Makes a symlink to a jar from a certain package +# A lot of java packages include dependencies in a lib/ directory +# You can use this function to replace these bundled dependencies. +# +# Example: get all jars from xerces slot 2 +# java-pkg_jar-from xerces-2 +# Example: get a specific jar from xerces slot 2 +# java-pkg_jar-from xerces-2 xml-apis.jar +# Example get a specific jar from xerces slot 2, and name it diffrently +# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar +# +# @param $1 - Package to get jars from. +# @param $2 - jar from package. If not specified, all jars will be used. +# @param $3 - When a single jar is specified, destination filename of the +# symlink. Defaults to the name of the jar. +# ------------------------------------------------------------------------------ +# TODO could probably be cleaned up a little +java-pkg_jar-from() { + debug-print-function ${FUNCNAME} $* + + local target_pkg="${1}" target_jar="${2}" destjar="${3}" + + [[ -z ${target_pkg} ]] && die "Must specify a package" + + # default destjar to the target jar + [[ -z "${destjar}" ]] && destjar="${target_jar}" + + local classpath="$(java-config --classpath=${target_pkg})" + [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" + + local jar + for jar in ${classpath//:/ }; do + local jar_name=$(basename "${jar}") + if [[ ! -f "${jar}" ]] ; then + debug-print "${jar} from ${target_pkg} does not exist" + die "Installation problems with jars in ${target_pkg} - is it installed?" + fi + # If no specific target jar was indicated, link it + if [[ -z "${target_jar}" ]] ; then + [[ -f "${target_jar}" ]] && rm "${target_jar}" + ln -snf "${jar}" \ + || die "Failed to make symlink from ${jar} to ${jar_name}" + java-pkg_record-jar_ "${target_pkg}" "${jar}" + # otherwise, if the current jar is the target jar, link it + elif [[ "${jar_name}" == "${target_jar}" ]] ; then + [[ -f "${destjar}" ]] && rm "${destjar}" + ln -snf "${jar}" "${destjar}" \ + || die "Failed to make symlink from ${jar} to ${destjar}" + java-pkg_record-jar_ "${target_pkg}" "${jar}" + return 0 + fi + done + # if no target was specified, we're ok + if [[ -z "${target_jar}" ]] ; then + return 0 + # otherwise, die bitterly + else + die "Failed to find ${target_jar:-jar} in ${target_pkg}" + fi +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_jarfrom +# +# See java-pkg_jar-from +# ------------------------------------------------------------------------------ +java-pkg_jarfrom() { + java-pkg_jar-from "$@" +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_getjars +# +# Get the classpath provided by any number of packages +# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. +# +# Example: Get the classpath for xerces-2, +# java-pkg_getjars xerces-2 xalan +# Example Return: +# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar +# +# @param $@ - list of packages to get jars from +# ------------------------------------------------------------------------------ +java-pkg_getjars() { + debug-print-function ${FUNCNAME} $* + + [[ ${#} -lt 1 ]] && die "At least one argument needed" + + # NOTE could probably just pass $@ to java-config --classpath. and return it + local classpath pkg + for pkg in ${@//,/ }; do + #for pkg in $(echo "$@" | tr ',' ' '); do + jars="$(java-config --classpath=${pkg})" + debug-print "${pkg}:${jars}" + # TODO should we ensure jars exist? + if [[ -z "${classpath}" ]]; then + classpath="${jars}" + else + classpath="${classpath}:${jars}" + fi + java-pkg_record-jar_ "${pkg}" + done + echo "${classpath}" +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_getjar +# +# Get the filename of a single jar from a package +# +# @example +# java-pkg_getjar xerces-2 xml-apis.jar +# @example-return +# /usr/share/xerces-2/lib/xml-apis.jar +# +# @param $1 - package to use +# @param $2 - jar to get +# ------------------------------------------------------------------------------ +java-pkg_getjar() { + debug-print-function ${FUNCNAME} $* + + local pkg="${1}" target_jar="${2}" jar + [[ -z ${pkg} ]] && die "Must specify package to get a jar from" + [[ -z ${target_jar} ]] && die "Must specify jar to get" + + # TODO check that package is actually installed + local classpath=$(java-config --classpath=${pkg}) + [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" + for jar in ${classpath//:/ }; do + if [[ ! -f "${jar}" ]] ; then + die "Installation problems with jars in ${pkg} - is it installed?" + fi + + if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then + java-pkg_record-jar_ "${pkg}" "${jar}" + echo "${jar}" + return 0 + fi + done + + die "Could not find ${target_jar} in ${pkg}" + return 1 +} + +# This function reads stdin, and based on that input, figures out how to +# populate jars from the filesystem. +# Need to figure out a good way of making use of this, ie be able to use a +# string that was built instead of stdin +# NOTE: this isn't quite ready for primetime. +#java-pkg_populate-jars() { +# local line +# +# read line +# while [[ -n "${line}" ]]; do +# # Ignore comments +# [[ ${line%%#*} == "" ]] && continue +# +# # get rid of any spaces +# line="${line// /}" +# +# # format: path=jarinfo +# local path=${line%%=*} +# local jarinfo=${line##*=} +# +# # format: jar@package +# local jar=${jarinfo%%@*}.jar +# local package=${jarinfo##*@} +# if [[ -n ${replace_only} ]]; then +# [[ ! -f $path ]] && die "No jar exists at ${path}" +# fi +# if [[ -n ${create_parent} ]]; then +# local parent=$(dirname ${path}) +# mkdir -p "${parent}" +# fi +# java-pkg_jar-from "${package}" "${jar}" "${path}" +# +# read line +# done +#} + +# ------------------------------------------------------------------------------ +# @section-end query +# ------------------------------------------------------------------------------ + +# ------------------------------------------------------------------------------ +# @section-begin helper +# @section-summary Helper functions +# +# Various other functions to use from an ebuild +# ------------------------------------------------------------------------------ + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_need +# +# Adds virtual dependencies, which can optionally be controlled by a USE flag. +# Currently supported virtuals are: +# javamail +# jdbc-stdext +# jaf +# jdbc-rowset +# jms +# +# @param $1 - Optionally indicate that the dependencies are controlled by +# a use flag by specifying '--use' Requires $2. +# @param $2 - USE flag which will enable the dependencies. +# @param $@ - virtual packages to add depenedencies for +# ------------------------------------------------------------------------------ +# TODO rewrite to parse a line based declaration file instead -- karltk +#java-pkg_need() { +# debug-print-function ${FUNCNAME} $* +# local useflag +# if [[ ${1} == "--use" ]]; then +# useflag="${2}" +# shift 2 +# fi +# +# if [[ -z ${1} ]]; then +# die "Must specify at least one virtual package." +# fi +# +# local depstr newdepstr +# +# for virtual in ${@}; do +# if has ${virtual} ${JAVA_PKG_VNEED}; then +# debug-print "Already registered virtual ${virtual}" +# continue +# fi +# case ${virtual} in +# javamail) +# debug-print "java-pkg_need: adding javamail dependencies" +# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )" +# ;; +# jdbc-stdext) +# debug-print "java-pkg_need: adding jdbc-stdext dependencies" +# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )" +# ;; +# jaf) +# debug-print "java-pkg_need: adding jaf dependencies" +# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )" +# ;; +# jdbc-rowset) +# debug-print "java-pkg_need: adding jdbc-rowset dependencies" +# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )" +# ;; +# jms) +# debug-print "java-pkg_need: adding jms dependencies" +# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )" +# ;; +# *) +# die "Invalid virtual: ${virtual}" +# esac +# +# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}" +# +# if [[ -n ${useflag} ]]; then +# depstr="${depstr} ${useflag}? ( ${newdepstr} )" +# else +# depstr="${depstr} ${newdepstr}" +# fi +# done +# +# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}" +# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}" +# +# export DEPEND="${DEPEND} ${depstr}" +# export RDEPEND="${RDEPEND} ${depstr}" +#} + +# This should be used after S has been populated with symlinks to jars +# TODO document +java-pkg_ensure-no-bundled-jars() { + debug-print-function ${FUNCNAME} $* + pushd ${WORKDIR} >/dev/null 2>/dev/null + + local bundled_jars=$(find . -name "*.jar" -type f) + if [[ -n ${bundled_jars} ]]; then + echo "Bundled jars found:" + local jar + for jar in ${bundled_jars}; do + echo $(pwd)${jar/./} + done + die "Bundled jars found!" + + fi + popd >/dev/null 2>/dev/null +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_ensure-vm-version-sufficient +# +# Checks if we have a sufficient VM and dies if we don't. +# +# ------------------------------------------------------------------------------ +java-pkg_ensure-vm-version-sufficient() { + debug-print-function ${FUNCNAME} $* + + if ! java-pkg_is-vm-version-sufficient; then + debug-print "VM is not suffient" + eerror "Current Java VM cannot build this package" + einfo "Please use java-config -S to set the correct one" + die "Active Java VM cannot build this package" + fi +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_is-vm-version-sufficient +# +# @return zero - VM is sufficient +# @return non-zero - VM is not sufficient +# ------------------------------------------------------------------------------ +java-pkg_is-vm-version-sufficient() { + debug-print-function ${FUNCNAME} $* + + depend-java-query --is-sufficient "${DEPEND}" > /dev/null + return $? +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_ensure-vm-version-eq +# +# Die if the current VM is not equal to the argument passed. +# +# @param $@ - Desired VM version to ensure +# ------------------------------------------------------------------------------ +java-pkg_ensure-vm-version-eq() { + debug-print-function ${FUNCNAME} $* + + if ! java-pkg_is-vm-version-eq $@ ; then + debug-print "VM is not suffient" + eerror "This package requires a Java VM version = $@" + einfo "Please use java-config -S to set the correct one" + die "Active Java VM too old" + fi +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_is-vm-version-eq +# +# @param $@ - VM version to compare current VM to +# @return zero - VM versions are equal +# @return non-zero - VM version are not equal +# ------------------------------------------------------------------------------ +java-pkg_is-vm-version-eq() { + debug-print-function ${FUNCNAME} $* + + local needed_version="$@" + + [[ -z "${needed_version}" ]] && die "need an argument" + + local vm_version="$(java-pkg_get-vm-version)" + + vm_version="$(get_version_component_range 1-2 "${vm_version}")" + needed_version="$(get_version_component_range 1-2 "${needed_version}")" + + if [[ -z "${vm_version}" ]]; then + debug-print "Could not get JDK version from DEPEND" + return 1 + else + if [[ "${vm_version}" == "${needed_version}" ]]; then + debug-print "Detected a JDK(${vm_version}) = ${needed_version}" + return 0 + else + debug-print "Detected a JDK(${vm_version}) != ${needed_version}" + return 1 + fi + fi +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_ensure-vm-version-ge +# +# Die if the current VM is not greater than the desired version +# +# @param $@ - VM version to compare current to +# ------------------------------------------------------------------------------ +java-pkg_ensure-vm-version-ge() { + debug-print-function ${FUNCNAME} $* + + if ! java-pkg_is-vm-version-ge "$@" ; then + debug-print "vm is not suffient" + eerror "This package requires a Java VM version >= $@" + einfo "Please use java-config -S to set the correct one" + die "Active Java VM too old" + fi +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_is-vm-version-ge +# +# @param $@ - VM version to compare current VM to +# @return zero - current VM version is greater than checked version +# @return non-zero - current VM version is not greater than checked version +# ------------------------------------------------------------------------------ +java-pkg_is-vm-version-ge() { + debug-print-function ${FUNCNAME} $* + + local needed_version=$@ + local vm_version=$(java-pkg_get-vm-version) + if [[ -z "${vm_version}" ]]; then + debug-print "Could not get JDK version from DEPEND" + return 1 + else + if version_is_at_least "${needed_version}" "${vm_version}"; then + debug-print "Detected a JDK(${vm_version}) >= ${needed_version}" + return 0 + else + debug-print "Detected a JDK(${vm_version}) < ${needed_version}" + return 1 + fi + fi +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_get-source +# +# Determines what source version should be used, for passing to -source. +# Unless you want to break things you probably shouldn't set _WANT_SOURCE +# +# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE +# ------------------------------------------------------------------------------ +java-pkg_get-source() { + echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")} +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_get-target +# +# Determines what target version should be used, for passing to -target. +# If you don't care about lower versions, you can set _WANT_TARGET to the +# version of your JDK. +# Remember doing this will mostly like cause things to break. +# Doesn't allow it to be lower then the one in depend. +# Doesn't allow it to be higher then the active vm. +# +# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET +# ------------------------------------------------------------------------------ +java-pkg_get-target() { + local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}") + if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then + local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)" + if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then + echo ${JAVA_PKG_WANT_TARGET} + else + echo ${min} + fi + else + echo ${min} + fi + + #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} +} + +java-pkg_get-javac() { + debug-print-function ${FUNCNAME} $* + + java-pkg_init-compiler_ + local compiler="${GENTOO_COMPILER}" + + local compiler_executable + if [[ "${compiler}" = "javac" ]]; then + # nothing fancy needs to be done for javac + compiler_executable="javac" + else + # for everything else, try to determine from an env file + + local compiler_env="/usr/share/java-config-2/compiler/${compiler}" + if [[ -f ${compiler_env} ]]; then + local old_javac=${JAVAC} + unset JAVAC + # try to get value of JAVAC + compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" + export JAVAC=${old_javac} + + [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" + + # check that it's executable + if [[ ! -x ${compiler_executable} ]]; then + eerror "Could not find ${compiler_executable}!" + die "${compiler_executable} doesn't exist, or isn't executable" + fi + else + eerror "Could not find environment file for ${compiler}" + die "Could not find ${compiler_env}" + fi + fi + echo ${compiler_executable} +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_javac-args +# +# If an ebuild uses javac directly, instead of using ejavac, it should call this +# to know what -source/-target to use. +# +# @return string - arguments to pass to javac, complete with -target and -source +# ------------------------------------------------------------------------------ +java-pkg_javac-args() { + debug-print-function ${FUNCNAME} $* + + local want_source="$(java-pkg_get-source)" + local want_target="$(java-pkg_get-target)" + + local source_str="-source ${want_source}" + local target_str="-target ${want_target}" + + debug-print "want source: ${want_source}" + debug-print "want target: ${want_target}" + + if [[ -z "${want_source}" || -z "${want_target}" ]]; then + debug-print "could not find valid -source/-target values" + die "Could not find valid -source/-target values" + else + if java-pkg_is-vm-version-ge "1.4"; then + echo "${source_str} ${target_str}" + else + echo "${target_str}" + fi + fi +} + +# TODO document +java-pkg_get-jni-cflags() { + local flags="-I${JAVA_HOME}/include" + + # TODO figure out how to cope with other things than linux... + flags="${flags} -I${JAVA_HOME}/include/linux" + + echo ${flags} +} + +# ------------------------------------------------------------------------------ +# @section-end helper +# ------------------------------------------------------------------------------ + +# ------------------------------------------------------------------------------ +# @section-begin build +# @section-summary Build functions +# +# These are some functions for building a package. In particular, it consists of +# wrappers for javac and ant. +# ------------------------------------------------------------------------------ + +# ------------------------------------------------------------------------------ +# @ebuild-function eant +# +# Ant wrapper function. Will use the appropriate compiler, based on user-defined +# compiler. +# +# ------------------------------------------------------------------------------ +eant() { + debug-print-function ${FUNCNAME} $* + + local antflags + java-pkg_init-compiler_ + local compiler="${GENTOO_COMPILER}" + + local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" + + local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" + if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then + die "ANT_BUILD_COMPILER undefined in ${compiler_env}" + fi + + if [[ ${compiler} != "javac" ]]; then + antflags="-Dbuild.compiler=${build_compiler}" + # Figure out any extra stuff to put on the classpath for compilers aside + # from javac + # ANT_BUILD_COMPILER_DEPS should be something that could be passed to + # java-config -p + local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" + if [[ -n ${build_compiler_deps} ]]; then + antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" + fi + fi + + antflags="${antflags} -nouserlib -noclasspath" + + if [[ -n ${JAVA_PKG_DEBUG} ]]; then + antflags="${antflags} -debug" + fi + + [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" + ant ${antflags} "${@}" || die "eant failed" + +} + +# ------------------------------------------------------------------------------ +# @ebuild-function ejavac +# +# Javac wrapper function. Will use the appropriate compiler, based on +# /etc/java-config/compilers.conf +# +# @param $@ - Arguments to be passed to the compiler +# ------------------------------------------------------------------------------ +ejavac() { + debug-print-function ${FUNCNAME} $* + + local compiler_executable=$(java-pkg_get-javac) + + [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" + ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" +} + +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_filter-compiler +# +# Used to prevent the use of some compilers. Should be used in src_compile. +# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER +# +# @param $@ - compilers to filter +# ------------------------------------------------------------------------------ +java-pkg_filter-compiler() { + JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" +} + +# ------------------------------------------------------------------------------ +# @ebuild-function use_doc +# +# Helper function for getting ant to build javadocs. If the user has USE=doc, +# then 'javadoc' or the argument are returned. Otherwise, there is no return. +# +# The output of this should be passed to ant. +# +# Example: build javadocs by calling 'javadoc' target +# eant $(use_doc) +# Example: build javadocs by calling 'apidoc' target +# eant $(use_doc apidoc) +# +# @param $@ - Option value to return. Defaults to 'javadoc' +# @return string - Name of the target to create javadocs +# ------------------------------------------------------------------------------ +use_doc() { + use doc && echo ${@:-javadoc} +} + +# ------------------------------------------------------------------------------ +# @section-end build +# ------------------------------------------------------------------------------ + +# ------------------------------------------------------------------------------ +# @section-begin internal +# @section-summary Internal functions +# +# Do __NOT__ use any of these from an ebuild! These are only to be used from +# within the java eclasses. +# ------------------------------------------------------------------------------ + +# ----------------------------------------------------------------------------- +# @function-internal java-pkg_init +# +# The purpose of this function, as the name might imply, is to initialize the +# Java environment. It ensures that that there aren't any environment variables +# that'll muss things up. It initializes some variables, which are used +# internally. And most importantly, it'll switch the VM if necessary. +# +# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will +# call it during each of the phases of the merge process. +# +# ----------------------------------------------------------------------------- +java-pkg_init() { + unset JAVAC + unset JAVA_HOME + java-pkg_init_paths_ + java-pkg_switch-vm + PATH=${JAVA_HOME}/bin:${PATH} + + # TODO we will probably want to set JAVAC and JAVACFLAGS + + # Do some QA checks + java-pkg_check-jikes + + # When users have crazy classpaths some packages can fail to compile. + # and everything should work with empty CLASSPATH. + # This also helps prevent unexpected dependencies on random things + # from the CLASSPATH. + unset CLASSPATH +} + +# ------------------------------------------------------------------------------ +# @function-internal java-pkg-init-compiler_ +# +# This function attempts to figure out what compiler should be used. It does +# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the +# COMPILERS variable defined there. +# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER +# +# It will go through the list of compilers, and verify that it supports the +# target and source that are needed. If it is not suitable, then the next +# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking +# isn't done. +# +# Once the which compiler to use has been figured out, it is set to +# GENTOO_COMPILER. +# +# If you hadn't guessed, JAVA_PKG_FORCE_COMPILER is for testing only. +# +# If the user doesn't defined anything in JAVA_PKG_COMPILERS_CONF, or no +# suitable compiler was found there, then the default is to use javac provided +# by the current VM. +# +# +# @return name of the compiler to use +# ------------------------------------------------------------------------------ +java-pkg_init-compiler_() { + debug-print-function ${FUNCNAME} $* + + if [[ -n ${GENTOO_COMPILER} ]]; then + debug-print "GENTOO_COMPILER already set" + return + fi + + local compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" + debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" + + # Figure out if we should announce what compiler we're using + local compiler + for compiler in ${compilers}; do + debug-print "Checking ${compiler}..." + # javac should always be alright + if [[ ${compiler} = "javac" ]]; then + debug-print "Found javac... breaking" + export GENTOO_COMPILER="javac" + break + fi + + if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then + if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then + einfo "Filtering ${compiler}" + continue + fi + fi + + # for non-javac, we need to make sure it supports the right target and + # source + local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" + if [[ -f ${compiler_env} ]]; then + local desired_target="$(java-pkg_get-target)" + local desired_source="$(java-pkg_get-source)" + + + # Verify that the compiler supports target + local supported_target=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_TARGET}) + if ! has ${desired_target} ${supported_target}; then + ewarn "${compiler} does not support -target ${desired_target}, skipping" + continue + fi + + # -source was introduced in 1.3, so only check 1.3 and on + if version_is_at_least "${desired_soure}" "1.3"; then + # Verify that the compiler supports source + local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE}) + if ! has ${desired_source} ${supported_source}; then + ewarn "${compiler} does not support -source ${desired_source}, skipping" + continue + fi + fi + + # if you get here, then the compiler should be good to go + export GENTOO_COMPILER="${compiler}" + break + else + ewarn "Could not find configuration for ${compiler}, skipping" + ewarn "Perhaps it is not installed?" + continue + fi + done + + # If it hasn't been defined already, default to javac + if [[ -z ${GENTOO_COMPILER} ]]; then + if [[ -n ${compilers} ]]; then + einfo "No suitable compiler found: defaulting javac for compilation" + else + # probably don't need to notify users about the default. + :;#einfo "Defaulting to javac for compilation" + fi + export GENTOO_COMPILER=javac + else + einfo "Using ${GENTOO_COMPILER} for compilation" + fi + +} + +# ------------------------------------------------------------------------------ +# @internal-function init_paths_ +# +# Initializes some variables that will be used. These variables are mostly used +# to determine where things will eventually get installed. +# ------------------------------------------------------------------------------ +java-pkg_init_paths_() { + debug-print-function ${FUNCNAME} $* + + local pkg_name + if [[ "$SLOT" == "0" ]] ; then + JAVA_PKG_NAME="${PN}" + else + JAVA_PKG_NAME="${PN}-${SLOT}" + fi + + JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" + JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" + JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" + + [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" + [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" + [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" + + + # TODO maybe only print once? + debug-print "JAVA_PKG_SHAREPATH: ${JAVA_PKG_SHAREPATH}" + debug-print "JAVA_PKG_ENV: ${JAVA_PKG_ENV}" + debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}" + debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}" + debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}" +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_do_write_ +# +# Writes the package.env out to disk. +# +# ------------------------------------------------------------------------------ +# TODO change to do-write, to match everything else +java-pkg_do_write_() { + # Create directory for package.env + dodir "${JAVA_PKG_SHAREPATH}" + if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then + # Create package.env + ( + echo "DESCRIPTION=\"${DESCRIPTION}\"" + echo "GENERATION=\"2\"" + + [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" + [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" + [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" + [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" + echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! + ) > "${JAVA_PKG_ENV}" + + # register target/source + local target="$(java-pkg_get-target)" + local source="$(java-pkg_get-source)" + [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" + [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" + + # register javadoc info + [[ -n ${JAVADOC_PATH} ]] && echo "JAVADOC_PATH=\"${JAVADOC_PATH}\"" \ + >> ${JAVA_PKG_ENV} + # register source archives + [[ -n ${JAVA_SOURCES} ]] && echo "JAVA_SOURCES=\"${JAVA_SOURCES}\"" \ + >> ${JAVA_PKG_ENV} + + + echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" + [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" + + # Strip unnecessary leading and trailing colons + # TODO try to cleanup if possible + sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" + fi +} + + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_record-jar_ +# +# Record a dependency to the package.env +# +# ------------------------------------------------------------------------------ +JAVA_PKG_DEPEND="${T}/java-pkg-depend" + +java-pkg_record-jar_() { + debug-print-function ${FUNCNAME} $* + + local pkg=${1} jar=${2} append + if [[ -z "${jar}" ]]; then + append="${pkg}" + else + append="$(basename ${jar})@${pkg}" + fi + + echo ${append} >> ${JAVA_PKG_DEPEND} +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_append_ +# +# Appends a value to a variable +# +# Example: java-pkg_append_ CLASSPATH foo.jar +# @param $1 variable name to modify +# @param $2 value to append +# ------------------------------------------------------------------------------ +java-pkg_append_() { + debug-print-function ${FUNCNAME} $* + + local var="${1}" value="${2}" + if [[ -z "${!var}" ]] ; then + export ${var}="${value}" + else + local oldIFS=${IFS} cur haveit + IFS=':' + for cur in ${!var}; do + if [[ ${cur} == ${value} ]]; then + haveit="yes" + break + fi + done + [[ -z ${haveit} ]] && export ${var}="${!var}:${value}" + IFS=${oldIFS} + fi +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_expand_dir_ +# +# Gets the full path of the file/directory's parent. +# @param $1 - file/directory to find parent directory for +# @return - path to $1's parent directory +# ------------------------------------------------------------------------------ +java-pkg_expand_dir_() { + pushd "$(dirname "${1}")" >/dev/null 2>&1 + pwd + popd >/dev/null 2>&1 +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_func-exists +# +# Does the indicated function exist? +# +# @return 0 - function is declared +# @return 1 - function is undeclared +# ------------------------------------------------------------------------------ +java-pkg_func-exists() { + if [[ -n "$(declare -f ${1})" ]]; then + return 0 + else + return 1 + fi +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_setup-vm +# +# Sets up the environment for a specific VM +# +# ------------------------------------------------------------------------------ +java-pkg_setup-vm() { + debug-print-function ${FUNCNAME} $* + + local vendor="$(java-pkg_get-vm-vendor)" + if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then + addpredict "/dev/random" + elif [[ "${vendor}" == "ibm" ]]; then + addpredict "/proc/self/maps" + addpredict "/proc/cpuinfo" + export LANG="C" LC_ALL="C" + elif [[ "${vendor}" == "jrockit" ]]; then + addpredict "/proc/cpuinfo" + fi +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_needs-vm +# +# Does the current package depend on virtual/jdk? +# +# @return 0 - Package depends on virtual/jdk +# @return 1 - Package does not depend on virtual/jdk +# ------------------------------------------------------------------------------ +java-pkg_needs-vm() { + debug-print-function ${FUNCNAME} $* + + if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then + return 0 + fi + + return 1 +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_get-current-vm +# +# @return - The current VM being used +# ------------------------------------------------------------------------------ +java-pkg_get-current-vm() { + java-config -f +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_get-vm-vendor +# +# @return - The vendor of the current VM +# ------------------------------------------------------------------------------ +java-pkg_get-vm-vendor() { + debug-print-function ${FUNCNAME} $* + + local vm="$(java-pkg_get-current-vm)" + vm="${vm/-*/}" + echo "${vm}" +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_get-vm-version +# +# @return - The version of the current VM +# ------------------------------------------------------------------------------ +java-pkg_get-vm-version() { + debug-print-function ${FUNCNAME} $* + + java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_switch-vm +# +# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and +# verify that the current VM is sufficient. +# Setup the environment for the VM being used. +# ------------------------------------------------------------------------------ +java-pkg_switch-vm() { + if java-pkg_needs-vm; then + # Use the VM specified by JAVA_PKG_FORCE_VM + if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then + # If you're forcing the VM, I hope you know what your doing... + export GENTOO_VM="${JAVA_PKG_FORCE_VM}" + # if we're allowed to switch the vm... + elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then + debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" + if [[ -n ${JAVA_PKG_VNEED} ]]; then + export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" + else + export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" + fi + # otherwise just make sure the current VM is sufficient + else + java-pkg_ensure-vm-version-sufficient + fi + debug-print "Using: $(java-config -f)" + + java-pkg_setup-vm + + export JAVACFLAGS="$(java-pkg_javac-args)" + [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" + + export JAVA_HOME="$(java-config -g JAVA_HOME)" + export JDK_HOME=${JAVA_HOME} + + #TODO If you know a better solution let us know. + java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" + + local tann="${T}/announced-vm" + if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then + # Add a check for setup/preinst phase... to avoid duplicate outputs + # for when FEATURES=buildpkg + if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; + then + einfo "Using: $(java-config -f)" + [[ ! -f "${tann}" ]] && touch "${tann}" + fi + fi + + else + [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" + fi +} + +# ------------------------------------------------------------------------------ +# @internal-function java-pkg_die +# +# Enhanced die for Java packages, which displays some information that may be +# useful for debugging bugs on bugzilla. +# ------------------------------------------------------------------------------ +#register_die_hook java-pkg_die +if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then + EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" +fi + +java-pkg_die() { + echo "!!! When you file a bug report, please include the following information:" >&2 + echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 + echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 + echo "and of course, the output of emerge --info" >&2 +} + +# ------------------------------------------------------------------------------ +# @section-end internal +# ------------------------------------------------------------------------------ + +java-pkg_check-phase() { + local phase=${1} + local funcname=${2} + # TODO add check for java-stricter + if [[ ${EBUILD_PHASE} != ${phase} ]]; then + java-pkg_announce-qa-violation \ + "${funcname} used outside of src_${phase}" + fi +} + +java-pkg_check-versioned-jar() { + local jar=${1} + + if [[ ${jar} =~ ${PV} ]]; then + java-pkg_announce-qa-violation "installing versioned jar '${jar}'" + fi +} + +java-pkg_check-jikes() { + if hasq jikes ${IUSE}; then + java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" + fi +} + +java-pkg_announce-qa-violation() { + if hasq java-strict ${FEATURES}; then + echo "Java QA Notice: $@" >&2 + increment-qa-violations + fi +} + +increment-qa-violations() { + let "JAVA_PKG_QA_VIOLATIONS+=1" + export JAVA_PKG_QA_VIOLATIONS +} + +# ------------------------------------------------------------------------------ +# @eclass-end +# ------------------------------------------------------------------------------ diff --git a/eclass/java-utils.eclass b/eclass/java-utils.eclass new file mode 100644 index 0000000..3fc820f --- /dev/null +++ b/eclass/java-utils.eclass @@ -0,0 +1,104 @@ +# +# Helper class for all Java packages +# +# Copyright (c) 2004, Thomas Matthijs <axxo@keanu.be> +# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> +# Copyright (c) 2004, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 + +inherit eutils + +DESCRIPTION="Based on the $ECLASS eclass" + +JAVA_CONFIG_DEP="|| ( =dev-java/java-config-1.3* =dev-java/java-config-1.2* )" +DEPEND="${JAVA_CONFIG_DEP}" +RDEPEND="${JAVA_CONFIG_DEP}" + +export WANT_JAVA_CONFIG="1" + +EXPORT_FUNCTIONS pkg_setup + +java-utils_pkg_setup() { + java-utils_ensure-jdk + + java-utils_vm-version-sufficient +} + +java-utils_setup-vm() { + local vendor=`java-utils_get-vm-vendor` + if [[ ${vendor} = "sun-jdk" ]] && java-utils_is-vm-version-ge 1 5; then + addpredict "/dev/random" + elif [[ ${vendor} = "ibm-jdk-bin" ]]; then + addwrite "/proc/self/maps" + addwrite "/proc/cpuinfo" + elif [[ ${vendor} = "jrockit-jdk-bin" ]]; then + addwrite "/proc/cpuinfo" + fi +} + +java-utils_ensure-jdk() { + if ! java-utils_is-vm-jdk; then + eerror "A full JDK is needed by this package. You currently have no Java VM active or only a JRE" + eerror "Please use java-config -S to set your system vm to a JDK" + die "Active VM is not a JDK" + fi +} + +java-utils_is-vm-jdk() { + if [ "$JDK_HOME" ] && [ "$JDK_HOME" == "$JAVA_HOME" ]; then + return 0 + else + return 1 + fi +} + +java-utils_get-vm-vendor() { + local vm=$(java-config -f) + echo ${vm%-*} +} + +java-utils_get-vm-version() { + local version=$(java-config -f | sed -e "s/.*-\([0-9.]\+\).*/\1/") + echo ${version} +} + +java-utils_vm-version-sufficient() { + local version=$(echo ${DEPEND} | sed -e 's:.*virtual/jdk-\?\([^$ ]*\).*:\1:' -e 's:\.: :g') + if [ "${version}" != "" ]; then + java-utils_ensure-vm-version-ge ${version} + fi +} + +java-utils_ensure-vm-version-ge() { + if ! java-utils_is-vm-version-ge $@ ; then + eerror "This package requires a Java VM version >= $@" + einfo "Please use java-config -S to set the correct one" + die "Active Java VM too old" + fi +} + +java-utils_is-vm-version-ge() { + local user_major=${1:-0} + local user_minor=${2:-0} + local user_patch=${3:-0} + local user_version=${user_major}.${user_minor}.${user_patch} + + local vm_version=$(java-utils_get-vm-version) + + local vm_major=$(echo ${vm_version} | cut -d. -f1) + local vm_minor=$(echo ${vm_version} | cut -d. -f2) + local vm_patch=$(echo ${vm_version} | cut -d. -f3) + local vm_extra=$(echo ${vm_version} | cut -d. -f4) + + if [ ${vm_major} -ge ${user_major} ] && [ ${vm_minor} -gt ${user_minor} ] ; then + echo "Detected a JDK >= ${user_version}" + return 0 + elif [ ${vm_major} -ge ${user_major} ] && [ ${vm_minor} -ge ${user_minor} ] && [ ${vm_patch} -ge ${user_patch} ] ; then + echo "Detected a JDK >= ${user_version}" + return 0 + else + echo "Detected a JDK < ${user_version}" + return 1 + fi +} diff --git a/eclass/java-vm-2.eclass b/eclass/java-vm-2.eclass new file mode 100644 index 0000000..e4d2fac --- /dev/null +++ b/eclass/java-vm-2.eclass @@ -0,0 +1,149 @@ +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/java.eclass,v 1.20 2004/09/29 20:58:45 axxo Exp $ +# +# Author: Karl Trygve Kalleberg <karltk@gentoo.org> + +inherit eutils + +DEPEND=" + =dev-java/java-config-2.0* + =dev-java/java-config-1.3*" +RDEPEND=" + =dev-java/java-config-2.0* + =dev-java/java-config-1.3*" + +export WANT_JAVA_CONFIG=2 + +if [[ "${SLOT}" != "0" ]]; then + VMHANDLE=${PN}-${SLOT} +else + VMHANDLE=${PN} +fi + +JAVA_VM_CONFIG_DIR="/usr/share/java-config-2/vm" +JAVA_VM_DIR="/usr/lib/jvm" + +EXPORT_FUNCTIONS pkg_postinst pkg_prerm + +java-vm-2_pkg_postinst() { + # Set the generation-2 system VM, if it isn't set + if [[ -z "$(java-config-2 -f)" ]]; then + java_set_default_vm_ + fi + + if [[ ${JAVA_VM_NO_GENERATION1} != "true" ]]; then + local systemvm1="$(java-config-1 -f)" + # no generation-1 system-vm was yet set + if [[ -z "${systemvm1}" ]]; then + einfo "No valid generation-1 system-vm set, setting to ${P}" + java-config-1 --set-system-vm=${P} + # dirty check to see if we are upgrading current generation-1 system vm + elif [[ ${systemvm1} =~ "^${VMHANDLE}" ]]; then + einfo "Upgrading generation-1 system-vm... updating its env file" + java-config-1 --set-system-vm=${P} + fi + # else... some other VM is being updated, so we don't have to worry + fi + + java_mozilla_clean_ +} + +java-vm-2_pkg_prerm() { + if [[ "$(java-config -f)" == "${VMHANDLE}" ]]; then + ewarn "It appears you are removing your default system VM!" + ewarn "Please run java-config -L then java-config -S to set a new system VM!" + fi +} + +java_set_default_vm_() { + java-config-2 --set-system-vm="${VMHANDLE}" + + einfo " After installing ${P} this" + einfo " was set as the default JVM to run." +} + +get_system_arch() { + local sarch + sarch=$(echo ${ARCH} | sed -e s/[i]*.86/i386/ -e s/x86_64/amd64/ -e s/sun4u/sparc/ -e s/sparc64/sparc/ -e s/arm.*/arm/ -e s/sa110/arm/) + if [ -z "${sarch}" ]; then + sarch=$(uname -m | sed -e s/[i]*.86/i386/ -e s/x86_64/amd64/ -e s/sun4u/sparc/ -e s/sparc64/sparc/ -e s/arm.*/arm/ -e s/sa110/arm/) + fi + echo ${sarch} +} + +# TODO rename to something more evident, like install_env_file +set_java_env() { + local platform="$(get_system_arch)" + local env_file="${D}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}" + local old_env_file="${D}/etc/env.d/java/20${P}" + local source_env_file="${FILESDIR}/${VMHANDLE}" + + if [[ ! -f ${source_env_file} ]]; then + die "Unable to find the env file: ${source_env_file}" + fi + + dodir ${JAVA_VM_CONFIG_DIR} + dodir /etc/env.d/java # generation-1 compatibility + sed \ + -e "s/@P@/${P}/g" \ + -e "s/@PN@/${PN}/g" \ + -e "s/@PV@/${PV}/g" \ + -e "s/@PF@/${PF}/g" \ + -e "s/@PLATFORM@/${platform}/g" \ + -e "/^LDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \ + < ${source_env_file} \ + > ${env_file} || die "sed failed" + + echo "VMHANDLE=\"${VMHANDLE}\"" >> ${env_file} + + # generation-1 compatibility + if [[ ${JAVA_VM_NO_GENERATION1} != true ]]; then + # We need to strip some things out of the new style env, + # because these end up going in the env + sed -e 's/.*CLASSPATH.*//' \ + -e 's/.*PROVIDES.*//' \ + ${env_file} \ + > ${old_env_file} || die "failed to create old-style env file" + fi + + [[ -n ${JAVA_PROVIDE} ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" >> ${env_file} + + local java_home=$(source ${env_file}; echo ${JAVA_HOME}) + [[ -z ${java_home} ]] && die "No JAVA_HOME defined in ${env_file}" + + # Make the symlink + dosym ${java_home} ${JAVA_VM_DIR}/${VMHANDLE} \ + || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDE}" +} + + +java_get_plugin_dir_() { + echo /usr/$(get_libdir)/nsbrowser/plugins +} + +install_mozilla_plugin() { + local plugin=${1} + + if [ ! -f "${D}/${plugin}" ] ; then + die "Cannot find mozilla plugin at ${D}/${plugin}" + fi + + local plugin_dir=$(java_get_plugin_dir_) + dodir ${plugin_dir} + dosym ${plugin} ${plugin_dir}/javaplugin.so +} + +java_mozilla_clean_() { + # Because previously some ebuilds installed symlinks outside of pkg_install + # and are left behind, which forces you to manualy remove them to select the + # jdk/jre you want to use for java + local plugin_dir=$(java_get_plugin_dir_) + for file in ${plugin_dir}/javaplugin_*; do + rm -f ${file} + done + for file in ${plugin_dir}/libjavaplugin*; do + rm -f ${file} + done +} + |