1 |
-----BEGIN PGP SIGNED MESSAGE----- |
2 |
Hash: SHA1 |
3 |
|
4 |
The need for this came with swt. To use embedded seamonkey/xulrunner |
5 |
browser in apps using swt, the apps have to be started with |
6 |
MOZILLA_FIVE_HOME variable pointing to /usr/lib/{seamonkey,xulrunner}/ |
7 |
according to what swt was built against. Currently there are two apps in |
8 |
java-experimental that need this - zekr and rssowl. |
9 |
|
10 |
So the idea is: |
11 |
- - swt records MOZILLA_FIVE_HOME into its package.env via eclass |
12 |
function, that also adds ENV_VARS="MOZILLA_FIVE_HOME" (space-separated |
13 |
list) there to mark this variable(s) for exporting - I just copied this |
14 |
idea from VM's env.d files we use |
15 |
- - gjl looks for ENV_VARS in package and all deps transitively, and |
16 |
exports the variables defined in them in the same package.env |
17 |
|
18 |
Which means new java-config release and eclass change. Any package |
19 |
exporting vars (a swt revbump) should RDEPEND on such new java-config |
20 |
until it's stabled and we can force it in eclass, to ensure gjl will |
21 |
pick the variable(s). |
22 |
|
23 |
I've implemented this today (with my weak python foo :), so here are the |
24 |
patches for review (inline): |
25 |
|
26 |
Index: java-utils-2.eclass |
27 |
=================================================================== |
28 |
RCS file: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v |
29 |
retrieving revision 1.84 |
30 |
diff -u -B -r1.84 java-utils-2.eclass |
31 |
- --- java-utils-2.eclass 6 May 2007 09:47:36 -0000 1.84 |
32 |
+++ java-utils-2.eclass 19 May 2007 00:02:58 -0000 |
33 |
@@ -1120,7 +1120,33 @@ |
34 |
java-pkg_record-jar_ "${pkgs}" "${jar}" |
35 |
fi |
36 |
|
37 |
- - java-pkg_do_write_ |
38 |
+ java-pkg_do_write_ |
39 |
+} |
40 |
+ |
41 |
+# |
42 |
- |
43 |
------------------------------------------------------------------------------ |
44 |
+# @ebuild-function java-pkg_register-environment-variable |
45 |
+# |
46 |
+# Register an arbitrary environment variable into package.env. The gjl |
47 |
launcher |
48 |
+# for this package or any package depending on this will export it into |
49 |
+# environement before executing java command. |
50 |
+# Must only be called in src_install phase. |
51 |
+# |
52 |
+# @param $1 - variable name |
53 |
+# @param $2 - variable value |
54 |
+# |
55 |
- |
56 |
------------------------------------------------------------------------------ |
57 |
+JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env" |
58 |
+JAVA_PKG_EXTRA_ENV_VARS="" |
59 |
+java-pkg_register-environment-variable() { |
60 |
+ debug-print-function ${FUNCNAME} $* |
61 |
+ |
62 |
+ java-pkg_check-phase install |
63 |
+ |
64 |
+ [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments" |
65 |
+ |
66 |
+ echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} |
67 |
+ JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" |
68 |
+ |
69 |
+ java-pkg_do_write_ |
70 |
} |
71 |
|
72 |
# This function reads stdin, and based on that input, figures out how to |
73 |
@@ -2143,6 +2169,14 @@ |
74 |
echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" |
75 |
[[ -n ${GENTOO_COMPILER} ]] && echo |
76 |
"MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" |
77 |
|
78 |
+ # extra env variables |
79 |
+ if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then |
80 |
+ cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" |
81 |
|| die |
82 |
+ # nested echo to remove leading/trailing spaces |
83 |
+ echo "ENV_VARS=\"$(echo |
84 |
${JAVA_PKG_EXTRA_ENV_VARS})\"" \ |
85 |
+ >> "${JAVA_PKG_ENV}" || die |
86 |
+ fi |
87 |
+ |
88 |
# Strip unnecessary leading and trailing colons |
89 |
# TODO try to cleanup if possible |
90 |
sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i |
91 |
"${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" |
92 |
|
93 |
Index: src/java_config/EnvironmentManager.py |
94 |
=================================================================== |
95 |
- --- src/java_config/EnvironmentManager.py (revision 4675) |
96 |
+++ src/java_config/EnvironmentManager.py (working copy) |
97 |
@@ -308,6 +308,43 @@ |
98 |
|
99 |
return path |
100 |
|
101 |
+ def add_pkg_env(self, pkg, env): |
102 |
+ env_vars = pkg.query("ENV_VARS") |
103 |
+ if (env_vars): |
104 |
+ for var in env_vars.split(' '): |
105 |
+ val = pkg.query(var) |
106 |
+ assert val |
107 |
+ if (not env.has_key(var)): |
108 |
+ env[var] = val |
109 |
+ |
110 |
+ def build_dep_env(self, pkgs, missing_deps): |
111 |
+ env = {} |
112 |
+ |
113 |
+ unresolved = Set() |
114 |
+ resolved = Set() |
115 |
+ |
116 |
+ for p in pkgs[:]: |
117 |
+ pkg = self.get_package(p) |
118 |
+ if pkg: |
119 |
+ pkgs.remove(p) |
120 |
+ unresolved.add(pkg) |
121 |
+ |
122 |
+ while len(unresolved) > 0: |
123 |
+ pkg = unresolved.pop() |
124 |
+ resolved.add(pkg) |
125 |
+ |
126 |
+ self.add_pkg_env(pkg, env) |
127 |
+ |
128 |
+ for dep in pkg.deps(): |
129 |
+ p = self.get_package(dep[-1]) |
130 |
+ |
131 |
+ if p: |
132 |
+ if p not in resolved: |
133 |
+ unresolved.add(p) |
134 |
+ else: |
135 |
+ missing_deps.add(dep[-1]) |
136 |
+ return env |
137 |
+ |
138 |
def set_classpath(self, targets, pkgs): |
139 |
classpath = self.build_classpath(pkgs) |
140 |
|
141 |
Index: src/gjl |
142 |
=================================================================== |
143 |
- --- src/gjl (revision 4676) |
144 |
+++ src/gjl (working copy) |
145 |
@@ -120,6 +120,10 @@ |
146 |
else: |
147 |
return None |
148 |
|
149 |
+def get_env(package): |
150 |
+ env = manager.build_dep_env([package.name()], Set()) |
151 |
+ return env |
152 |
+ |
153 |
def get_jar(pkg, gjar): |
154 |
jars = pkg.classpath() |
155 |
if jars: |
156 |
@@ -173,7 +177,10 @@ |
157 |
if options.get_args: |
158 |
args = get_args(pkg) |
159 |
if args: |
160 |
- - print 'gjl_args="%s"' % ( args ) |
161 |
+ print 'gjl_args="%s";' % ( args ) |
162 |
+ env = get_env(pkg) |
163 |
+ for k, v in env.iteritems(): |
164 |
+ print 'export %s="%s";' % ( k, v ) |
165 |
|
166 |
if options.jar: |
167 |
jar = get_jar(pkg, options.jar) |
168 |
|
169 |
- --- swt-3.2.2.ebuild 2007-04-28 14:07:38.000000000 +0200 |
170 |
+++ swt-3.2.2-r1.ebuild 2007-05-19 01:46:59.000000000 +0200 |
171 |
@@ -98,6 +98,17 @@ |
172 |
epatch "${FILESDIR}/${PN}-3.2.1-fbsd.patch" |
173 |
} |
174 |
|
175 |
+get_gecko() { |
176 |
+ local gecko |
177 |
+ # Wasn't able to succesfully run test with this |
178 |
+ # |
179 |
http://overlays.gentoo.org/proj/java/browser/testcases/dev-java/swt |
180 |
+ #use firefox && local gecko="firefox" |
181 |
+ use seamonkey && gecko="seamonkey" |
182 |
+ use xulrunner && gecko="xulrunner" |
183 |
+ |
184 |
+ echo ${gecko} |
185 |
+} |
186 |
+ |
187 |
src_compile() { |
188 |
# Drop jikes support as it seems to be unfriendly with SWT |
189 |
java-pkg_filter-compiler jikes |
190 |
@@ -146,12 +157,7 @@ |
191 |
${make} make_gnome || die "Failed to build GNOME VFS |
192 |
support" |
193 |
fi |
194 |
|
195 |
- - # Wasn't able to succesfully run test with this |
196 |
- - # |
197 |
http://overlays.gentoo.org/proj/java/browser/testcases/dev-java/swt |
198 |
- - #use firefox && local gecko="firefox" |
199 |
- - use seamonkey && local gecko="seamonkey" |
200 |
- - use xulrunner && local gecko="xulrunner" |
201 |
- - |
202 |
+ local gecko="$(get_gecko)" |
203 |
if [[ ${gecko} ]]; then |
204 |
einfo "Building the Mozilla component" |
205 |
#local idir="$(pkg-config ${gecko}-xpcom |
206 |
- --variable=includedir)" |
207 |
@@ -189,6 +195,10 @@ |
208 |
java-pkg_sointo /usr/$(get_libdir) |
209 |
java-pkg_doso *.so |
210 |
|
211 |
+ local gecko="$(get_gecko)" |
212 |
+ [[ -n "${gecko}" ]] && java-pkg_register-environment-variable \ |
213 |
+ MOZILLA_FIVE_HOME "/usr/$(get_libdir)/${gecko}/" |
214 |
+ |
215 |
dohtml about.html || die |
216 |
} |
217 |
|
218 |
|
219 |
New swt's package.env: |
220 |
|
221 |
DESCRIPTION="GTK based SWT Library" |
222 |
GENERATION="2" |
223 |
CLASSPATH="/usr/share/swt-3/lib/swt.jar" |
224 |
LIBRARY_PATH="/usr/lib" |
225 |
VM=">=virtual/jre-1.4" |
226 |
TARGET="1.4" |
227 |
SOURCE="1.4" |
228 |
MERGE_VM="sun-jdk-1.6.0.02" |
229 |
MERGE_COMPILER="ecj-3.2" |
230 |
MOZILLA_FIVE_HOME="/usr/lib/seamonkey/" |
231 |
ENV_VARS="MOZILLA_FIVE_HOME" |
232 |
|
233 |
Tested and works with rssowl, might try zekr later, removing it's |
234 |
dolauncher --pre stuff that simulates this behaviour. |
235 |
- -- |
236 |
Vlastimil Babka (Caster) |
237 |
Gentoo/Java |
238 |
-----BEGIN PGP SIGNATURE----- |
239 |
Version: GnuPG v1.4.7 (GNU/Linux) |
240 |
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org |
241 |
|
242 |
iD8DBQFGTj/btbrAj05h3oQRAsMtAKCR6nRPhOSS5rg/GbEYymGt7bvzIACghCkO |
243 |
rcz/OiakLwkUR2RmAZs8O04= |
244 |
=ujnj |
245 |
-----END PGP SIGNATURE----- |
246 |
-- |
247 |
gentoo-java@g.o mailing list |