/[gentoo-alt]/trunk/prefix/eclass/java-pkg.eclass
Gentoo

Contents of /trunk/prefix/eclass/java-pkg.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 982 - (show annotations) (download)
Thu Feb 2 04:20:17 2006 UTC (13 years, 2 months ago) by kito
File size: 7493 byte(s)
Initial eclass import from gentoo-x86
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.32 2005/12/06 20:10:50 betelgeuse Exp $
4
5 pkglistpath="${T}/java-pkg-list"
6
7 java-pkg_doclass()
8 {
9 debug-print-function ${FUNCNAME} $*
10 java-pkg_dojar $*
11 }
12
13 java-pkg_do_init_()
14 {
15 debug-print-function ${FUNCNAME} $*
16
17 if [ -z "${JARDESTTREE}" ] ; then
18 JARDESTTREE="lib"
19 SODESTTREE="lib"
20 fi
21
22 # Set install paths
23 sharepath="${DESTTREE}/share"
24 if [ "$SLOT" == "0" ] ; then
25 pkg_name="${PN}"
26 else
27 pkg_name="${PN}-${SLOT}"
28 fi
29
30 shareroot="${sharepath}/${pkg_name}"
31
32 if [ -z "${jardest}" ] ; then
33 jardest="${shareroot}/${JARDESTTREE}"
34 fi
35
36 if [ -z "${sodest}" ] ; then
37 sodest="/opt/${pkg_name}/${SODESTTREE}"
38 fi
39
40 package_env="${D}${shareroot}/package.env"
41
42 debug-print "JARDESTTREE=${JARDESTTREE}"
43 debug-print "SODESTTREE=${SODESTTREE}"
44 debug-print "sharepath=${sharepath}"
45 debug-print "shareroot=${shareroot}"
46 debug-print "jardest=${jardest}"
47 debug-print "sodest=${sodest}"
48 debug-print "package_env=${package_env}"
49 }
50
51 java-pkg_do_write_()
52 {
53 # Create directory for package.env
54 if [ ! -d "${D}${shareroot}" ] ; then
55 install -d "${D}${shareroot}"
56 fi
57
58 # Create package.env
59 echo "DESCRIPTION=${DESCRIPTION}" > "${package_env}"
60 if [ -n "${cp_pkg}" ]; then
61 echo "CLASSPATH=${cp_prepend}:${cp_pkg}:${cp_append}" >> "${package_env}"
62 fi
63 if [ -n "${lp_pkg}" ]; then
64 echo "LIBRARY_PATH=${lp_prepend}:${lp_pkg}:${lp_append}" >> "${package_env}"
65 fi
66 if [ -f ${pkglistpath} ] ; then
67 pkgs=$(cat ${pkglistpath} | tr '\n' ':')
68 echo "DEPEND=${pkgs}" >> "${package_env}"
69 fi
70
71 # Strip unnecessary leading and trailing colons
72 sed -e "s/=:/=/" -e "s/:$//" -i "${package_env}"
73 }
74
75 java-pkg_do_getsrc_()
76 {
77 # Check for symlink
78 if [ -L "${i}" ] ; then
79 cp "${i}" "${T}"
80 echo "${T}"/`/usr/bin/basename "${i}"`
81
82 # Check for directory
83 elif [ -d "${i}" ] ; then
84 echo "java-pkg: warning, skipping directory ${i}"
85 continue
86 else
87 echo "${i}"
88 fi
89 }
90
91
92 java-pkg_doso()
93 {
94 debug-print-function ${FUNCNAME} $*
95 [ -z "$1" ]
96
97 java-pkg_do_init_
98
99 # Check for arguments
100 if [ -z "$*" ] ; then
101 die "at least one argument needed"
102 fi
103
104 # Make sure directory is created
105 if [ ! -d "${D}${sodest}" ] ; then
106 install -d "${D}${sodest}"
107 fi
108
109 for i in $* ; do
110 mysrc=$(java-pkg_do_getsrc_)
111
112 # Install files
113 install -m 0755 "${mysrc}" "${D}${sodest}" || die "${mysrc} not found"
114 done
115 lp_pkg="${sodest}"
116
117 java-pkg_do_write_
118 }
119
120 java-pkg_dojar()
121 {
122 debug-print-function ${FUNCNAME} $*
123 [ -z "$1" ]
124
125 java-pkg_do_init_
126
127 if [ -n "${DEP_PREPEND}" ] ; then
128 for i in ${DEP_PREPEND}
129 do
130 if [ -f "${sharepath}/${i}/package.env" ] ; then
131 debug-print "${i} path: ${sharepath}/${i}"
132 if [ -z "${cp_prepend}" ] ; then
133 cp_prepend=`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"`
134 else
135 cp_prepend="${cp_prepend}:"`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"`
136 fi
137 else
138 debug-print "Error: Package ${i} not found."
139 debug-print "${i} path: ${sharepath}/${i}"
140 die "Error in DEP_PREPEND."
141 fi
142 debug-print "cp_prepend=${cp_prepend}"
143
144 done
145 fi
146
147 if [ -n "${DEP_APPEND}" ] ; then
148 for i in ${DEP_APPEND}
149 do
150 if [ -f "${sharepath}/${i}/package.env" ] ; then
151 debug-print "${i} path: ${sharepath}/${i}"
152 if [ -z "${cp_append}" ] ; then
153 cp_append=`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"`
154 else
155 cp_append="${cp_append}:"`grep "CLASSPATH=" "${sharepath}/${i}/package.env" | sed "s/CLASSPATH=//"`
156 fi
157 else
158 debug-print "Error: Package ${i} not found."
159 debug-print "${i} path: ${sharepath}/${i}"
160 die "Error in DEP_APPEND."
161 fi
162 debug-print "cp_append=${cp_append}"
163 done
164 fi
165
166 # Check for arguments
167 if [ -z "$*" ] ; then
168 die "at least one argument needed"
169 fi
170
171 # Make sure directory is created
172 if [ ! -d "${D}${jardest}" ] ; then
173 install -d "${D}${jardest}"
174 fi
175
176 for i in $* ; do
177 mysrc=$(java-pkg_do_getsrc_)
178
179 # Install files
180 install -m 0644 "${mysrc}" "${D}${jardest}" || die "${mysrc} not found"
181
182 # Build CLASSPATH
183 if [ -z "${cp_pkg}" ] ; then
184 cp_pkg="${jardest}"/`/usr/bin/basename "${i}"`
185 else
186 cp_pkg="${cp_pkg}:${jardest}/"`/usr/bin/basename "${i}"`
187 fi
188 done
189
190 java-pkg_do_write_
191 }
192
193 java-pkg_newjar()
194 {
195 if [ -z "${T}" ] || [ -z "${2}" ] ; then
196 die "java-pkg_newjar: Nothing defined to do"
197 fi
198
199 rm -rf "${T}/${2}"
200 cp "${1}" "${T}/${2}"
201 java-pkg_dojar "${T}/${2}"
202 }
203
204 java-pkg_dowar()
205 {
206 debug-print-function ${FUNCNAME} $*
207 [ -z "$1" ]
208
209 # Check for arguments
210 if [ -z "$*" ] ; then
211 die "at least one argument needed"
212 fi
213
214 if [ -z "${WARDESTTREE}" ] ; then
215 WARDESTTREE="webapps"
216 fi
217
218 sharepath="${DESTTREE}/share"
219 shareroot="${sharepath}/${PN}"
220 wardest="${shareroot}/${WARDESTTREE}"
221
222 debug-print "WARDESTTREE=${WARDESTTREE}"
223 debug-print "sharepath=${sharepath}"
224 debug-print "shareroot=${shareroot}"
225 debug-print "wardest=${wardest}"
226
227 # Patch from Joerg Schaible <joerg.schaible@gmx.de>
228 # Make sure directory is created
229 if [ ! -d "${D}${wardest}" ] ; then
230 install -d "${D}${wardest}"
231 fi
232
233 for i in $* ; do
234 # Check for symlink
235 if [ -L "${i}" ] ; then
236 cp "${i}" "${T}"
237 mysrc="${T}"/`/usr/bin/basename "${i}"`
238
239 # Check for directory
240 elif [ -d "${i}" ] ; then
241 echo "dowar: warning, skipping directory ${i}"
242 continue
243 else
244 mysrc="${i}"
245 fi
246
247 # Install files
248 install -m 0644 "${mysrc}" "${D}${wardest}"
249 done
250 }
251
252 java-pkg_dozip()
253 {
254 debug-print-function ${FUNCNAME} $*
255 java-pkg_dojar $*
256 }
257
258 _record-jar()
259 {
260 echo "$(basename $2)@$1" >> ${pkglistpath}
261 }
262
263 java-pkg_jarfrom() {
264 java-pkg_jar-from "$@"
265 }
266
267 java-pkg_jar-from()
268 {
269 debug-print-function ${FUNCNAME} $*
270
271 local pkg=$1
272 local jar=$2
273 local destjar=$3
274
275 if [ -z "${destjar}" ] ; then
276 destjar=${jar}
277 fi
278
279 for x in $(java-config --classpath=${pkg} | tr ':' ' '); do
280 if [ ! -f ${x} ] ; then
281 die "Installation problems with jars in ${pkg} - is it installed?"
282 return 1
283 fi
284 _record-jar ${pkg} ${x}
285 if [ -z "${jar}" ] ; then
286 [[ -f $(basename ${x}) ]] && rm $(basename ${x})
287 ln -snf ${x} $(basename ${x})
288 elif [ "$(basename ${x})" == "${jar}" ] ; then
289 [[ -f ${destjar} ]] && rm ${destjar}
290 ln -snf ${x} ${destjar}
291 return 0
292 fi
293 done
294 if [ -z "${jar}" ] ; then
295 return 0
296 else
297 die "failed to find ${jar}"
298 fi
299 }
300
301 java-pkg_getjar()
302 {
303
304 debug-print-function ${FUNCNAME} $*
305
306 local pkg=$1
307 local jar=$2
308
309 for x in $(java-config --classpath=${pkg} | tr ':' ' '); do
310
311 if [ ! -f ${x} ] ; then
312 die "Installation problems with jars in ${pkg} - is it installed?"
313 fi
314
315 _record-jar ${pkg} ${x}
316
317 if [ "$(basename ${x})" == "${jar}" ] ; then
318 echo ${x}
319 return 0
320 fi
321 done
322 die "Could not find $2 in $1"
323 }
324
325 java-pkg_getjars()
326 {
327 java-config --classpath=$1
328 }
329
330
331 java-pkg_dohtml()
332 {
333 dohtml -f package-list $@
334 }
335
336 java-pkg_jarinto()
337 {
338 jardest=$1
339 }
340
341 java-pkg_sointo()
342 {
343 sodest=$1
344 }
345
346 java-pkg_dosrc() {
347 java-pkg_do_init_
348
349 [ $# -lt 1 ] && die "${FUNCNAME[0]}: at least one argument needed"
350
351 local target="${shareroot}/source/"
352
353 local files
354 local startdir=$(pwd)
355 for x in ${@}; do
356 cd $(dirname ${x})
357 zip -q -r ${T}/${PN}-src.zip $(basename ${x}) -i '*.java'
358 local res=$?
359 if [[ ${res} != 12 && ${res} != 0 ]]; then
360 die "zip failed"
361 fi
362
363 cd ${startdir}
364 done
365
366 dodir ${target}
367 install ${INSOPTIONS} "${T}/${PN}-src.zip" "${D}${target}" \
368 || die "failed to install sources"
369 }

  ViewVC Help
Powered by ViewVC 1.1.20