* [gentoo-java] support for environment variables in package.env
@ 2007-05-19 0:07 Vlastimil Babka
2007-05-19 14:57 ` Petteri Räty
2007-05-25 22:21 ` Vlastimil Babka
0 siblings, 2 replies; 3+ messages in thread
From: Vlastimil Babka @ 2007-05-19 0:07 UTC (permalink / raw
To: Gentoo Java
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The need for this came with swt. To use embedded seamonkey/xulrunner
browser in apps using swt, the apps have to be started with
MOZILLA_FIVE_HOME variable pointing to /usr/lib/{seamonkey,xulrunner}/
according to what swt was built against. Currently there are two apps in
java-experimental that need this - zekr and rssowl.
So the idea is:
- - swt records MOZILLA_FIVE_HOME into its package.env via eclass
function, that also adds ENV_VARS="MOZILLA_FIVE_HOME" (space-separated
list) there to mark this variable(s) for exporting - I just copied this
idea from VM's env.d files we use
- - gjl looks for ENV_VARS in package and all deps transitively, and
exports the variables defined in them in the same package.env
Which means new java-config release and eclass change. Any package
exporting vars (a swt revbump) should RDEPEND on such new java-config
until it's stabled and we can force it in eclass, to ensure gjl will
pick the variable(s).
I've implemented this today (with my weak python foo :), so here are the
patches for review (inline):
Index: java-utils-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v
retrieving revision 1.84
diff -u -B -r1.84 java-utils-2.eclass
- --- java-utils-2.eclass 6 May 2007 09:47:36 -0000 1.84
+++ java-utils-2.eclass 19 May 2007 00:02:58 -0000
@@ -1120,7 +1120,33 @@
java-pkg_record-jar_ "${pkgs}" "${jar}"
fi
- - java-pkg_do_write_
+ java-pkg_do_write_
+}
+
+#
-
------------------------------------------------------------------------------
+# @ebuild-function java-pkg_register-environment-variable
+#
+# Register an arbitrary environment variable into package.env. The gjl
launcher
+# for this package or any package depending on this will export it into
+# environement before executing java command.
+# Must only be called in src_install phase.
+#
+# @param $1 - variable name
+# @param $2 - variable value
+#
-
------------------------------------------------------------------------------
+JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
+JAVA_PKG_EXTRA_ENV_VARS=""
+java-pkg_register-environment-variable() {
+ debug-print-function ${FUNCNAME} $*
+
+ java-pkg_check-phase install
+
+ [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
+
+ echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
+ JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
+
+ java-pkg_do_write_
}
# This function reads stdin, and based on that input, figures out how to
@@ -2143,6 +2169,14 @@
echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
[[ -n ${GENTOO_COMPILER} ]] && echo
"MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
+ # extra env variables
+ if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
+ cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}"
|| die
+ # nested echo to remove leading/trailing spaces
+ echo "ENV_VARS=\"$(echo
${JAVA_PKG_EXTRA_ENV_VARS})\"" \
+ >> "${JAVA_PKG_ENV}" || die
+ fi
+
# 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 ?"
Index: src/java_config/EnvironmentManager.py
===================================================================
- --- src/java_config/EnvironmentManager.py (revision 4675)
+++ src/java_config/EnvironmentManager.py (working copy)
@@ -308,6 +308,43 @@
return path
+ def add_pkg_env(self, pkg, env):
+ env_vars = pkg.query("ENV_VARS")
+ if (env_vars):
+ for var in env_vars.split(' '):
+ val = pkg.query(var)
+ assert val
+ if (not env.has_key(var)):
+ env[var] = val
+
+ def build_dep_env(self, pkgs, missing_deps):
+ env = {}
+
+ unresolved = Set()
+ resolved = Set()
+
+ for p in pkgs[:]:
+ pkg = self.get_package(p)
+ if pkg:
+ pkgs.remove(p)
+ unresolved.add(pkg)
+
+ while len(unresolved) > 0:
+ pkg = unresolved.pop()
+ resolved.add(pkg)
+
+ self.add_pkg_env(pkg, env)
+
+ for dep in pkg.deps():
+ p = self.get_package(dep[-1])
+
+ if p:
+ if p not in resolved:
+ unresolved.add(p)
+ else:
+ missing_deps.add(dep[-1])
+ return env
+
def set_classpath(self, targets, pkgs):
classpath = self.build_classpath(pkgs)
Index: src/gjl
===================================================================
- --- src/gjl (revision 4676)
+++ src/gjl (working copy)
@@ -120,6 +120,10 @@
else:
return None
+def get_env(package):
+ env = manager.build_dep_env([package.name()], Set())
+ return env
+
def get_jar(pkg, gjar):
jars = pkg.classpath()
if jars:
@@ -173,7 +177,10 @@
if options.get_args:
args = get_args(pkg)
if args:
- - print 'gjl_args="%s"' % ( args )
+ print 'gjl_args="%s";' % ( args )
+ env = get_env(pkg)
+ for k, v in env.iteritems():
+ print 'export %s="%s";' % ( k, v )
if options.jar:
jar = get_jar(pkg, options.jar)
- --- swt-3.2.2.ebuild 2007-04-28 14:07:38.000000000 +0200
+++ swt-3.2.2-r1.ebuild 2007-05-19 01:46:59.000000000 +0200
@@ -98,6 +98,17 @@
epatch "${FILESDIR}/${PN}-3.2.1-fbsd.patch"
}
+get_gecko() {
+ local gecko
+ # Wasn't able to succesfully run test with this
+ #
http://overlays.gentoo.org/proj/java/browser/testcases/dev-java/swt
+ #use firefox && local gecko="firefox"
+ use seamonkey && gecko="seamonkey"
+ use xulrunner && gecko="xulrunner"
+
+ echo ${gecko}
+}
+
src_compile() {
# Drop jikes support as it seems to be unfriendly with SWT
java-pkg_filter-compiler jikes
@@ -146,12 +157,7 @@
${make} make_gnome || die "Failed to build GNOME VFS
support"
fi
- - # Wasn't able to succesfully run test with this
- - #
http://overlays.gentoo.org/proj/java/browser/testcases/dev-java/swt
- - #use firefox && local gecko="firefox"
- - use seamonkey && local gecko="seamonkey"
- - use xulrunner && local gecko="xulrunner"
- -
+ local gecko="$(get_gecko)"
if [[ ${gecko} ]]; then
einfo "Building the Mozilla component"
#local idir="$(pkg-config ${gecko}-xpcom
- --variable=includedir)"
@@ -189,6 +195,10 @@
java-pkg_sointo /usr/$(get_libdir)
java-pkg_doso *.so
+ local gecko="$(get_gecko)"
+ [[ -n "${gecko}" ]] && java-pkg_register-environment-variable \
+ MOZILLA_FIVE_HOME "/usr/$(get_libdir)/${gecko}/"
+
dohtml about.html || die
}
New swt's package.env:
DESCRIPTION="GTK based SWT Library"
GENERATION="2"
CLASSPATH="/usr/share/swt-3/lib/swt.jar"
LIBRARY_PATH="/usr/lib"
VM=">=virtual/jre-1.4"
TARGET="1.4"
SOURCE="1.4"
MERGE_VM="sun-jdk-1.6.0.02"
MERGE_COMPILER="ecj-3.2"
MOZILLA_FIVE_HOME="/usr/lib/seamonkey/"
ENV_VARS="MOZILLA_FIVE_HOME"
Tested and works with rssowl, might try zekr later, removing it's
dolauncher --pre stuff that simulates this behaviour.
- --
Vlastimil Babka (Caster)
Gentoo/Java
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGTj/btbrAj05h3oQRAsMtAKCR6nRPhOSS5rg/GbEYymGt7bvzIACghCkO
rcz/OiakLwkUR2RmAZs8O04=
=ujnj
-----END PGP SIGNATURE-----
--
gentoo-java@gentoo.org mailing list
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-java] support for environment variables in package.env
2007-05-19 0:07 [gentoo-java] support for environment variables in package.env Vlastimil Babka
@ 2007-05-19 14:57 ` Petteri Räty
2007-05-25 22:21 ` Vlastimil Babka
1 sibling, 0 replies; 3+ messages in thread
From: Petteri Räty @ 2007-05-19 14:57 UTC (permalink / raw
To: Vlastimil Babka; +Cc: Gentoo Java
[-- Attachment #1: Type: text/plain, Size: 1443 bytes --]
Vlastimil Babka kirjoitti:
>
> Index: src/java_config/EnvironmentManager.py
> ===================================================================
> --- src/java_config/EnvironmentManager.py (revision 4675)
> +++ src/java_config/EnvironmentManager.py (working copy)
> @@ -308,6 +308,43 @@
>
> return path
>
> + def add_pkg_env(self, pkg, env):
> + env_vars = pkg.query("ENV_VARS")
> + if (env_vars):
> + for var in env_vars.split(' '):
> + val = pkg.query(var)
> + assert val
> + if (not env.has_key(var)):
> + env[var] = val
This probably could be named a bit better as I confuse pkg_env with the
package.env file.
if (not env.has_key(var)):
This is the same as not var in env
>>> dict = { "foo":"bar", "foo2":"bar2" }
>>> "foo" in dict
True
>>> "foo3" in dict
False
> +
> + def build_dep_env(self, pkgs, missing_deps):
> + env = {}
> +
> + unresolved = Set()
> + resolved = Set()
> +
> + for p in pkgs[:]:
for p in pkgs:
Although the current functions are not documented, it would help if we
documented all new functions using pydoc:
http://www.python.org/dev/peps/pep-0287/
If it works, I am fine with you committing it. Should probably get a
couple of other fixes in there at the same time too for a new release.
Regards,
Petteri
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-java] support for environment variables in package.env
2007-05-19 0:07 [gentoo-java] support for environment variables in package.env Vlastimil Babka
2007-05-19 14:57 ` Petteri Räty
@ 2007-05-25 22:21 ` Vlastimil Babka
1 sibling, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2007-05-25 22:21 UTC (permalink / raw
To: Gentoo Java
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The support was added to eclass and java-config-2.0.33. Remember you
need to RDEPEND on >=dev-java/java-config-2.0.33 in any ebuild that uses
the java-pkg_register-environment-variable call.
SWT was bumped to 3.2.2-r1 to add MOZILLA_FIVE_HOME variable so depend
on this version to use it (rssowl already does).
- --
Vlastimil Babka (Caster)
Gentoo/Java
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGV2FOtbrAj05h3oQRAm8+AJwJuN50gfIjrCGcxdnFcTP4/vRO6gCcD9Sc
Q0syvD6KKdQjnZaSo8CITXw=
=bdTb
-----END PGP SIGNATURE-----
--
gentoo-java@gentoo.org mailing list
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-25 22:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-19 0:07 [gentoo-java] support for environment variables in package.env Vlastimil Babka
2007-05-19 14:57 ` Petteri Räty
2007-05-25 22:21 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox