/[gentoo-x86]/eclass/java-pkg.eclass
Gentoo

Contents of /eclass/java-pkg.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.53 - (show annotations) (download)
Mon Nov 30 04:19:36 2009 UTC (4 years, 11 months ago) by abcd
Branch: MAIN
CVS Tags: HEAD
Changes since 1.52: +1 -1 lines
FILE REMOVED
Remove eclasses that have been marked as deprecated for >=2 years; schedule other deprecated eclasses for removal

1 # Copyright 1999-2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/java-pkg.eclass,v 1.52 2007/04/25 18:24:37 robbat2 Exp $
4
5 inherit multilib
6
7 EXPORT_FUNCTIONS pkg_setup
8
9 # We need to do a few things to add compatibility between
10 # generation-1 and generation-2.
11
12 # First we make sure java-config-1 will be used
13 export WANT_JAVA_CONFIG="1"
14
15 # We can't depend on java-config directly because some packages use this eclass
16 # only with the java use flag.
17 # http://bugs.gentoo.org/show_bug.cgi?id=137971
18 #DEPEND="
19 # =dev-java/java-config-1.3*
20 # =dev-java/java-config-2*"
21
22 # During pkg_setup, we need to do a few extra things to ensure things work in a
23 # mixed generation-1/generation-2 environment
24 # TODO need to make sure everything that inherits java-pkg and has a pkg_setup
25 # uses java-pkg_pkg_setup
26 java-pkg_pkg_setup() {
27 java-pkg_announce-qa-violation "using deprecated eclass java-pkg"
28
29 # We need to do a little magic if java-config-2 is around
30 if has_version "=dev-java/java-config-2*"; then
31 # we only want to enable the Java stuff if
32 # there isn't a Java use flag (means its a pure Java pckage)
33 # or if there is a Java use flag and it is enabled
34 if ! hasq java ${IUSE} || use java; then
35 initialize-java-environment
36 if [[ -n ${GENTOO_VM} ]]; then
37 einfo "Using Generation-1 System VM: ${GENTOO_VM}"
38 else
39 echo
40 eerror "There was a problem determining which VM to use for generation-1"
41 eerror "This is because the way Java is handled on Gentoo has drastically changed."
42 if ! has_version "=virtual/jdk-1.4*" || ! has_version "=virtual/jdk-1.3*"; then
43 ewarn "There does not seem to be a 1.4 or 1.3 JDK installed."
44 ewarn "You should probably install =virtual/jdk-1.4* or =virtual/jdk-1.3*"
45 ewarn "It is important to have either a 1.4 or 1.3 JDK installed"
46 ewarn "in order for the old and new Java systems to coexist"
47 ewarn "Details about this can be found at:"
48 ewarn "\thttp://overlays.gentoo.org/proj/java/wiki/Why_We_Need_Java14"
49 ewarn "If you wonder why we can't just depend on the needed JDK version,"
50 ewarn "then read https://bugs.gentoo.org/show_bug.cgi?id=144240"
51 echo
52 fi
53
54 eerror "You should run, and follow the advice of:"
55 eerror "\t/usr/bin/java-check-environment"
56
57 eerror "You will also likely want to follow the Java Upgrade Guide:"
58 eerror "\thttp://www.gentoo.org/proj/en/java/java-upgrade.xml"
59 eerror "If you have problems with the guide, please see:"
60 eerror "\thttp://overlays.gentoo.org/proj/java/wiki/Common_Problems"
61 die "Expected VMHANDLE to be defined in the env"
62 fi
63 fi
64 fi
65 }
66
67 initialize-java-environment() {
68 if has_version "=dev-java/java-config-2*"; then
69 # VMHANDLE is the variable in an env file that identifies how java-config-2
70 # knows a VM. With each VM, we have a 'compatible' env file installed to
71 # /etc/env.d/java, so java-config-1 can work.
72 #
73 # So, here we set GENTOO_VM to be VMHANDLE, and thus to the
74 # generation-1 system VM.
75 export GENTOO_VM=$(java-config-1 -g VMHANDLE)
76
77 # use java-config-2, with GENTOO_VM set to generation-1 system vm, to
78 # setup JAVA_HOME
79 export JAVA_HOME=$(java-config-2 --jdk-home)
80 export JDK_HOME=$(java-config-2 --jdk-home)
81 # make sure JAVAC and JAVA are set correctly
82 export JAVAC=$(java-config-2 --javac)
83 export JAVA=$(java-config-2 --java)
84 fi
85 # Otherwise, JAVA_HOME should be defined already
86 }
87
88 # These are pre hooks to make sure JAVA_HOME is set properly.
89 # note: don't need pkg_setup, since we define it here
90 # FIXME remove these hooks after portage-2.1.1 is stable, as
91 # it has proper env saving
92 pre_src_unpack() {
93 initialize-java-environment
94 }
95
96 pre_src_compile() {
97 initialize-java-environment
98 }
99
100 pre_src_install() {
101 initialize-java-environment
102 }
103
104 pre_src_test() {
105 initialize-java-environment
106 }
107
108 pre_pkg_preinst() {
109 initialize-java-environment
110 }
111
112 pre_pkg_postinst() {
113 initialize-java-environment
114 }
115
116
117 pkglistpath="${T}/java-pkg-list"
118
119 java-pkg_doclass()
120 {
121 debug-print-function ${FUNCNAME} $*
122 java-pkg_dojar $*
123 }
124
125 java-pkg_do_init_()
126 {
127 debug-print-function ${FUNCNAME} $*
128
129 if [ -z "${JARDESTTREE}" ] ; then
130 JARDESTTREE="lib"
131 SODESTTREE=$(get_libdir)
132 fi
133
134 # Set install paths
135 sharepath="${DESTTREE}/share"
136 if [ "$SLOT" == "0" ] ; then
137 pkg_name="${PN}"
138 else
139 pkg_name="${PN}-${SLOT}"
140 fi
141
142 shareroot="${sharepath}/${pkg_name}"
143
144 if [ -z "${jardest}" ] ; then
145 jardest="${shareroot}/${JARDESTTREE}"
146 fi
147
148 if [ -z "${sodest}" ] ; then
149 sodest="/opt/${pkg_name}/${SODESTTREE}"
150 fi
151
152 package_env="${D}${shareroot}/package.env"
153
154 debug-print "JARDESTTREE=${JARDESTTREE}"
155 debug-print "SODESTTREE=${SODESTTREE}"
156 debug-print "sharepath=${sharepath}"
157 debug-print "shareroot=${shareroot}"
158 debug-print "jardest=${jardest}"
159 debug-print "sodest=${sodest}"
160 debug-print "package_env=${package_env}"
161
162 }
163
164 java-pkg_do_write_()
165 {
166 debug-print-function ${FUNCNAME} $*
167 # Create directory for package.env
168 dodir "${shareroot}"
169
170 # Create package.env
171 echo "DESCRIPTION=${DESCRIPTION}" > "${package_env}"
172 echo "GENERATION=1" >> "${package_env}"
173 if [ -n "${cp_pkg}" ]; then
174 debug-print "cp_prepend: ${cp_prepend}"
175 debug-print "cp_pkg: ${cp_pkg}"
176 debug-print "cp_append: ${cp_append}"
177 echo "CLASSPATH=${cp_prepend}:${cp_pkg}:${cp_append}" >> "${package_env}"
178 fi
179 if [ -n "${lp_pkg}" ]; then
180 echo "LIBRARY_PATH=${lp_prepend}:${lp_pkg}:${lp_append}" >> "${package_env}"
181 fi
182 if [ -f ${pkglistpath} ] ; then
183 pkgs=$(cat ${pkglistpath} | tr '\n' ':')
184 echo "DEPEND=${pkgs}" >> "${package_env}"
185 fi
186
187 # Strip unnecessary leading and trailing colons
188 sed -e "s/=:/=/" -e "s/:$//" -i "${package_env}"
189 }
190
191 java-pkg_do_getsrc_()
192 {
193 # Check for symlink
194 if [ -L "${i}" ] ; then
195 cp "${i}" "${T}"
196 echo "${T}"/`/usr/bin/basename "${i}"`
197
198 # Check for directory
199 elif [ -d "${i}" ] ; then
200 echo "java-pkg: warning, skipping directory ${i}"
201 continue
202 else
203 echo "${i}"
204 fi
205 }
206
207
208 java-pkg_doso()
209 {
210 debug-print-function ${FUNCNAME} $*
211 [ -z "$1" ]
212
213 java-pkg_do_init_
214
215 # Check for arguments
216 if [ -z "$*" ] ; then
217 die "at least one argument needed"
218 fi
219
220 # Make sure directory is created
221 if [ ! -d "${D}${sodest}" ] ; then
222 install -d "${D}${sodest}"
223 fi
224
225 for i in $* ; do
226 mysrc=$(java-pkg_do_getsrc_)
227
228 # Install files
229 install -m 0755 "${mysrc}" "${D}${sodest}" || die "${mysrc} not found"
230 done
231 lp_pkg="${sodest}"
232
233 java-pkg_do_write_
234 }
235
236 java-pkg_dojar()
237 {
238 debug-print-function ${FUNCNAME} $*
239 [ -z "$1" ]
240
241 java-pkg_do_init_
242
243 if [ -n "${DEP_PREPEND}" ] ; then
244 for i in ${DEP_PREPEND}
245 do
246 if [ -f "${sharepath}/${i}/package.env" ] ; then
247 debug-print "${i} path: ${sharepath}/${i}"
248 if [ -z "${cp_prepend}" ] ; then
249 cp_prepend=`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"`
250 else
251 cp_prepend="${cp_prepend}:"`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"`
252 fi
253 else
254 debug-print "Error: Package ${i} not found."
255 debug-print "${i} path: ${sharepath}/${i}"
256 die "Error in DEP_PREPEND."
257 fi
258 debug-print "cp_prepend=${cp_prepend}"
259
260 done
261 fi
262
263 if [ -n "${DEP_APPEND}" ] ; then
264 for i in ${DEP_APPEND}
265 do
266 if [ -f "${sharepath}/${i}/package.env" ] ; then
267 debug-print "${i} path: ${sharepath}/${i}"
268 # Before removing the quotes this caused
269 # https://bugs.gentoo.org/show_bug.cgi?id=155590
270 # There was also an extra quote in the else that could also be
271 # the cause.
272 if [ -z "${cp_append}" ] ; then
273 cp_append=$(grep "CLASSPATH=" "${sharepath}/${i}/package.env" \
274 | sed -e "s/CLASSPATH=//" -e 's/"//g')
275 else
276 cp_append="${cp_append}:$(grep "CLASSPATH=" \
277 "${sharepath}/${i}/package.env" \
278 | sed -e "s/CLASSPATH=//" -e 's/"//g')"
279 fi
280 else
281 debug-print "Error: Package ${i} not found."
282 debug-print "${i} path: ${sharepath}/${i}"
283 die "Error in DEP_APPEND."
284 fi
285 debug-print "cp_append=${cp_append}"
286 done
287 fi
288
289 # Check for arguments
290 if [ -z "$*" ] ; then
291 die "at least one argument needed"
292 fi
293
294 # Make sure directory is created
295 dodir ${jardest}
296
297 for i in $* ; do
298 mysrc=$(java-pkg_do_getsrc_)
299
300 # Install files
301 install -m 0644 "${mysrc}" "${D}${jardest}" || die "${mysrc} not found"
302
303 # Build CLASSPATH
304 if [ -z "${cp_pkg}" ] ; then
305 cp_pkg="${jardest}"/`/usr/bin/basename "${i}"`
306 else
307 cp_pkg="${cp_pkg}:${jardest}/"`/usr/bin/basename "${i}"`
308 fi
309 done
310
311 java-pkg_do_write_
312 }
313
314 java-pkg_newjar()
315 {
316 if [ -z "${T}" ] || [ -z "${2}" ] ; then
317 die "java-pkg_newjar: Nothing defined to do"
318 fi
319
320 rm -rf "${T}/${2}"
321 cp "${1}" "${T}/${2}"
322 java-pkg_dojar "${T}/${2}"
323 }
324
325 java-pkg_dowar()
326 {
327 debug-print-function ${FUNCNAME} $*
328 [ -z "$1" ]
329
330 # Check for arguments
331 if [ -z "$*" ] ; then
332 die "at least one argument needed"
333 fi
334
335 if [ -z "${WARDESTTREE}" ] ; then
336 WARDESTTREE="webapps"
337 fi
338
339 sharepath="${DESTTREE}/share"
340 shareroot="${sharepath}/${PN}"
341 wardest="${shareroot}/${WARDESTTREE}"
342
343 debug-print "WARDESTTREE=${WARDESTTREE}"
344 debug-print "sharepath=${sharepath}"
345 debug-print "shareroot=${shareroot}"
346 debug-print "wardest=${wardest}"
347
348 # Patch from Joerg Schaible <joerg.schaible@gmx.de>
349 # Make sure directory is created
350 if [ ! -d "${D}${wardest}" ] ; then
351 install -d "${D}${wardest}"
352 fi
353
354 for i in $* ; do
355 # Check for symlink
356 if [ -L "${i}" ] ; then
357 cp "${i}" "${T}"
358 mysrc="${T}"/`/usr/bin/basename "${i}"`
359
360 # Check for directory
361 elif [ -d "${i}" ] ; then
362 echo "dowar: warning, skipping directory ${i}"
363 continue
364 else
365 mysrc="${i}"
366 fi
367
368 # Install files
369 install -m 0644 "${mysrc}" "${D}${wardest}"
370 done
371 }
372
373 java-pkg_dozip()
374 {
375 debug-print-function ${FUNCNAME} $*
376 java-pkg_dojar $*
377 }
378
379 _record-jar()
380 {
381 echo "$(basename $2)@$1" >> ${pkglistpath}
382 }
383
384 java-pkg_jarfrom() {
385 java-pkg_jar-from "$@"
386 }
387
388 java-pkg_jar-from()
389 {
390 debug-print-function ${FUNCNAME} $*
391
392 local pkg=$1
393 local jar=$2
394 local destjar=$3
395
396 if [ -z "${destjar}" ] ; then
397 destjar=${jar}
398 fi
399
400 for x in $(java-config --classpath=${pkg} | tr ':' ' '); do
401 if [ ! -f ${x} ] ; then
402 die "Installation problems with jars in ${pkg} - is it installed?"
403 return 1
404 fi
405 _record-jar ${pkg} ${x}
406 if [ -z "${jar}" ] ; then
407 [[ -f $(basename ${x}) ]] && rm $(basename ${x})
408 ln -snf ${x} $(basename ${x})
409 elif [ "$(basename ${x})" == "${jar}" ] ; then
410 [[ -f ${destjar} ]] && rm ${destjar}
411 ln -snf ${x} ${destjar}
412 return 0
413 fi
414 done
415 if [ -z "${jar}" ] ; then
416 return 0
417 else
418 die "failed to find ${jar}"
419 fi
420 }
421
422 java-pkg_getjar()
423 {
424
425 debug-print-function ${FUNCNAME} $*
426
427 local pkg=$1
428 local jar=$2
429
430 for x in $(java-config --classpath=${pkg} | tr ':' ' '); do
431
432 if [ ! -f ${x} ] ; then
433 die "Installation problems with jars in ${pkg} - is it installed?"
434 fi
435
436 _record-jar ${pkg} ${x}
437
438 if [ "$(basename ${x})" == "${jar}" ] ; then
439 echo ${x}
440 return 0
441 fi
442 done
443 die "Could not find $2 in $1"
444 }
445
446 java-pkg_getjars()
447 {
448 java-config --classpath=$1
449 }
450
451
452
453 java-pkg_dohtml()
454 {
455 dohtml -f package-list $@
456 }
457
458 java-pkg_jarinto()
459 {
460 jardest=$1
461 }
462
463 java-pkg_sointo()
464 {
465 sodest=$1
466 }
467
468 java-pkg_dosrc() {
469 java-pkg_do_init_
470
471 [ $# -lt 1 ] && die "${FUNCNAME[0]}: at least one argument needed"
472
473 local target="${shareroot}/source/"
474
475 local files
476 local startdir=$(pwd)
477 for x in ${@}; do
478 cd $(dirname ${x})
479 zip -q -r ${T}/${PN}-src.zip $(basename ${x}) -i '*.java'
480 local res=$?
481 if [[ ${res} != 12 && ${res} != 0 ]]; then
482 die "zip failed"
483 fi
484
485 cd ${startdir}
486 done
487
488 dodir ${target}
489 install ${INSOPTIONS} "${T}/${PN}-src.zip" "${D}${target}" \
490 || die "failed to install sources"
491 }
492
493
494 java-pkg_announce-qa-violation() {
495 [[ "${JAVA_PKG_STRICT}" ]] && ewarn "Java QA Notice: $@"
496 }

  ViewVC Help
Powered by ViewVC 1.1.20