/[gentoo-x86]/eclass/perl-module.eclass
Gentoo

Contents of /eclass/perl-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.128 - (show annotations) (download)
Sun Jan 23 22:12:13 2011 UTC (3 years, 6 months ago) by robbat2
Branch: MAIN
Changes since 1.127: +5 -2 lines
Add MODULE_A_EXT for g-cpan ease of use where upstream has other file extensions. Add reminder to document the variables later.

1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.127 2011/01/12 15:44:24 tove Exp $
4 #
5 # Author: Seemant Kulleen <seemant@gentoo.org>
6
7 # @ECLASS: perl-module.eclass
8 # @MAINTAINER:
9 # perl@gentoo.org
10 # @BLURB: eclass for perl modules
11 # @DESCRIPTION:
12 # The perl-module eclass is designed to allow easier installation of perl
13 # modules, and their incorporation into the Gentoo Linux system.
14
15 inherit eutils base
16 [[ ${CATEGORY} == "perl-core" ]] && inherit alternatives
17
18 PERL_EXPF="src_unpack src_compile src_test src_install"
19
20 case "${EAPI:-0}" in
21 0|1)
22 PERL_EXPF+=" pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm"
23 ;;
24 2|3)
25 PERL_EXPF+=" src_prepare src_configure"
26 [[ ${CATEGORY} == "perl-core" ]] && \
27 PERL_EXPF+=" pkg_postinst pkg_postrm"
28
29 case "${GENTOO_DEPEND_ON_PERL:-yes}" in
30 yes)
31 DEPEND="dev-lang/perl[-build]"
32 RDEPEND="${DEPEND}"
33 ;;
34 esac
35 ;;
36 *)
37 die "EAPI=${EAPI} is not supported by perl-module.eclass"
38 ;;
39 esac
40
41 case "${PERL_EXPORT_PHASE_FUNCTIONS:-yes}" in
42 yes)
43 EXPORT_FUNCTIONS ${PERL_EXPF}
44 ;;
45 no)
46 debug-print "PERL_EXPORT_PHASE_FUNCTIONS=no"
47 ;;
48 *)
49 die "PERL_EXPORT_PHASE_FUNCTIONS=${PERL_EXPORT_PHASE_FUNCTIONS} is not supported by perl-module.eclass"
50 ;;
51 esac
52
53 DESCRIPTION="Based on the $ECLASS eclass"
54
55 LICENSE="${LICENSE:-|| ( Artistic GPL-1 GPL-2 GPL-3 )}"
56
57 # TODO: Document variables: MODULE_VERSION, MODULE_A, MODULE_A_EXT,
58 # MODULE_AUTHOR, MODULE_SECTION, GENTOO_DEPEND_ON_PERL, PREFER_BUILDPL
59 if [[ -n ${MY_PN} || -n ${MY_PV} || -n ${MODULE_VERSION} ]] ; then
60 : ${MY_P:=${MY_PN:-${PN}}-${MY_PV:-${MODULE_VERSION:-${PV}}}}
61 S=${MY_S:-${WORKDIR}/${MY_P}}
62 fi
63 [[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && \
64 MODULE_A="${MY_P:-${P}}.${MODULE_A_EXT:-tar.gz}"
65 [[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
66 SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION:+${MODULE_SECTION}/}${MODULE_A}"
67 [[ -z "${HOMEPAGE}" ]] && \
68 HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}/"
69
70 SRC_PREP="no"
71 SRC_TEST="skip"
72 PREFER_BUILDPL="yes"
73
74 pm_echovar=""
75 perlinfo_done=false
76
77 perl-module_src_unpack() {
78 debug-print-function $FUNCNAME "$@"
79 base_src_unpack
80 has src_prepare ${PERL_EXPF} || perl-module_src_prepare
81 }
82
83 perl-module_src_prepare() {
84 debug-print-function $FUNCNAME "$@"
85 has src_prepare ${PERL_EXPF} && base_src_prepare
86 perl_fix_osx_extra
87 esvn_clean
88 }
89
90 perl-module_src_configure() {
91 debug-print-function $FUNCNAME "$@"
92 perl-module_src_prep
93 }
94
95 perl-module_src_prep() {
96 debug-print-function $FUNCNAME "$@"
97 [[ ${SRC_PREP} = yes ]] && return 0
98 SRC_PREP="yes"
99
100 perl_set_version
101 perl_set_eprefix
102
103 export PERL_MM_USE_DEFAULT=1
104 # Disable ExtUtils::AutoInstall from prompting
105 export PERL_EXTUTILS_AUTOINSTALL="--skipdeps"
106
107 if [[ $(declare -p myconf 2>&-) != "declare -a myconf="* ]]; then
108 local myconf_local=(${myconf})
109 else
110 local myconf_local=("${myconf[@]}")
111 fi
112
113 if [[ ( ${PREFER_BUILDPL} == yes || ! -f Makefile.PL ) && -f Build.PL ]] ; then
114 einfo "Using Module::Build"
115 if [[ ${DEPEND} != *virtual/perl-Module-Build* && ${PN} != Module-Build ]] ; then
116 eqawarn "QA Notice: The ebuild uses Module::Build but doesn't depend on it."
117 eqawarn " Add virtual/perl-Module-Build to DEPEND!"
118 if [[ -n ${PERLQAFATAL} ]]; then
119 eerror "Bailing out due to PERLQAFATAL=1";
120 die;
121 fi
122 fi
123 set -- \
124 --installdirs=vendor \
125 --libdoc= \
126 --destdir="${D}" \
127 --create_packlist=0 \
128 "${myconf_local[@]}"
129 einfo "perl Build.PL" "$@"
130 perl Build.PL "$@" <<< "${pm_echovar}" \
131 || die "Unable to build!"
132 elif [[ -f Makefile.PL ]] ; then
133 einfo "Using ExtUtils::MakeMaker"
134 set -- \
135 PREFIX=${EPREFIX}/usr \
136 INSTALLDIRS=vendor \
137 INSTALLMAN3DIR='none' \
138 DESTDIR="${D}" \
139 "${myconf_local[@]}"
140 einfo "perl Makefile.PL" "$@"
141 perl Makefile.PL "$@" <<< "${pm_echovar}" \
142 || die "Unable to build!"
143 fi
144 if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then
145 einfo "No Make or Build file detected..."
146 return
147 fi
148 }
149
150 perl-module_src_compile() {
151 debug-print-function $FUNCNAME "$@"
152 perl_set_version
153
154 has src_configure ${PERL_EXPF} || perl-module_src_prep
155
156 if [[ $(declare -p mymake 2>&-) != "declare -a mymake="* ]]; then
157 local mymake_local=(${mymake})
158 else
159 local mymake_local=("${mymake[@]}")
160 fi
161
162 if [[ -f Build ]] ; then
163 ./Build build \
164 || die "Compilation failed"
165 elif [[ -f Makefile ]] ; then
166 set -- \
167 OTHERLDFLAGS="${LDFLAGS}" \
168 "${mymake_local[@]}"
169 einfo "emake" "$@"
170 emake "$@" \
171 || die "Compilation failed"
172 # OPTIMIZE="${CFLAGS}" \
173 fi
174 }
175
176 # For testers:
177 # This code attempts to work out your threadingness from MAKEOPTS
178 # and apply them to Test::Harness.
179 #
180 # If you want more verbose testing, set TEST_VERBOSE=1
181 # in your bashrc | /etc/make.conf | ENV
182 #
183 # For ebuild writers:
184 # If you wish to enable default tests w/ 'make test' ,
185 #
186 # SRC_TEST="do"
187 #
188 # If you wish to have threads run in parallel ( using the users makeopts )
189 # all of the following have been tested to work.
190 #
191 # SRC_TEST="do parallel"
192 # SRC_TEST="parallel"
193 # SRC_TEST="parallel do"
194 # SRC_TEST=parallel
195 #
196
197 perl-module_src_test() {
198 debug-print-function $FUNCNAME "$@"
199 if has 'do' ${SRC_TEST} || has 'parallel' ${SRC_TEST} ; then
200 if has "${TEST_VERBOSE:-0}" 0 && has 'parallel' ${SRC_TEST} ; then
201 export HARNESS_OPTIONS=j$(echo -j1 ${MAKEOPTS} | sed -r "s/.*(-j\s*|--jobs=)([0-9]+).*/\2/" )
202 einfo "Test::Harness Jobs=${HARNESS_OPTIONS}"
203 fi
204 ${perlinfo_done} || perl_set_version
205 if [[ -f Build ]] ; then
206 ./Build test verbose=${TEST_VERBOSE:-0} || die "test failed"
207 elif [[ -f Makefile ]] ; then
208 emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test failed"
209 fi
210 fi
211 }
212
213 perl-module_src_install() {
214 debug-print-function $FUNCNAME "$@"
215
216 perl_set_version
217 perl_set_eprefix
218
219 local f
220
221 if [[ -z ${mytargets} ]] ; then
222 case "${CATEGORY}" in
223 dev-perl|perl-core) mytargets="pure_install" ;;
224 *) mytargets="install" ;;
225 esac
226 fi
227
228 if [[ $(declare -p myinst 2>&-) != "declare -a myinst="* ]]; then
229 local myinst_local=(${myinst})
230 else
231 local myinst_local=("${myinst[@]}")
232 fi
233
234 if [[ -f Build ]] ; then
235 ./Build ${mytargets} \
236 || die "./Build ${mytargets} failed"
237 elif [[ -f Makefile ]] ; then
238 emake "${myinst_local[@]}" ${mytargets} \
239 || die "emake ${myinst_local[@]} ${mytargets} failed"
240 fi
241
242 perl_delete_module_manpages
243 perl_delete_localpod
244 perl_delete_packlist
245 perl_remove_temppath
246
247 for f in Change* CHANGES README* TODO FAQ ${mydoc}; do
248 [[ -s ${f} ]] && dodoc ${f}
249 done
250
251 perl_link_duallife_scripts
252 }
253
254 perl-module_pkg_setup() {
255 debug-print-function $FUNCNAME "$@"
256 perl_set_version
257 }
258
259 perl-module_pkg_preinst() {
260 debug-print-function $FUNCNAME "$@"
261 perl_set_version
262 }
263
264 perl-module_pkg_postinst() {
265 debug-print-function $FUNCNAME "$@"
266 perl_link_duallife_scripts
267 }
268
269 perl-module_pkg_prerm() {
270 debug-print-function $FUNCNAME "$@"
271 }
272
273 perl-module_pkg_postrm() {
274 debug-print-function $FUNCNAME "$@"
275 perl_link_duallife_scripts
276 }
277
278 perlinfo() {
279 debug-print-function $FUNCNAME "$@"
280 perl_set_version
281 }
282
283 perl_set_version() {
284 debug-print-function $FUNCNAME "$@"
285 debug-print "$FUNCNAME: perlinfo_done=${perlinfo_done}"
286 ${perlinfo_done} && return 0
287 perlinfo_done=true
288
289 local f version install{{site,vendor}{arch,lib},archlib}
290 eval "$(perl -V:{version,install{{site,vendor}{arch,lib},archlib}} )"
291 PERL_VERSION=${version}
292 SITE_ARCH=${installsitearch}
293 SITE_LIB=${installsitelib}
294 ARCH_LIB=${installarchlib}
295 VENDOR_LIB=${installvendorlib}
296 VENDOR_ARCH=${installvendorarch}
297 }
298
299 fixlocalpod() {
300 debug-print-function $FUNCNAME "$@"
301 perl_delete_localpod
302 }
303
304 perl_delete_localpod() {
305 debug-print-function $FUNCNAME "$@"
306
307 find "${D}" -type f -name perllocal.pod -delete
308 find "${D}" -depth -mindepth 1 -type d -empty -delete
309 }
310
311 perl_fix_osx_extra() {
312 debug-print-function $FUNCNAME "$@"
313
314 # Remove "AppleDouble encoded Macintosh file"
315 local f
316 find "${S}" -type f -name "._*" -print0 | while read -rd '' f ; do
317 einfo "Removing AppleDouble encoded Macintosh file: ${f#${S}/}"
318 rm -f "${f}"
319 f=${f#${S}/}
320 # f=${f//\//\/}
321 # f=${f//\./\.}
322 # sed -i "/${f}/d" "${S}"/MANIFEST || die
323 grep -q "${f}" "${S}"/MANIFEST && \
324 elog "AppleDouble encoded Macintosh file in MANIFEST: ${f#${S}/}"
325 done
326 }
327
328 perl_delete_module_manpages() {
329 debug-print-function $FUNCNAME "$@"
330
331 perl_set_eprefix
332
333 if [[ -d "${ED}"/usr/share/man ]] ; then
334 # einfo "Cleaning out stray man files"
335 find "${ED}"/usr/share/man -type f -name "*.3pm" -delete
336 find "${ED}"/usr/share/man -depth -type d -empty -delete
337 fi
338 }
339
340
341 perl_delete_packlist() {
342 debug-print-function $FUNCNAME "$@"
343 perl_set_version
344 if [[ -d ${D}/${VENDOR_ARCH} ]] ; then
345 find "${D}/${VENDOR_ARCH}" -type f -a \( -name .packlist \
346 -o \( -name '*.bs' -a -empty \) \) -delete
347 find "${D}" -depth -mindepth 1 -type d -empty -delete
348 fi
349 }
350
351 perl_remove_temppath() {
352 debug-print-function $FUNCNAME "$@"
353
354 find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
355 if file "${f}" | grep -q -i " text" ; then
356 grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
357 sed -i -e "s:${D}:/:g" "${f}"
358 fi
359 done
360 }
361
362 perl_link_duallife_scripts() {
363 debug-print-function $FUNCNAME "$@"
364 if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; then
365 return 0
366 fi
367
368 perl_set_eprefix
369
370 local i ff
371 if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
372 for i in "${DUALLIFESCRIPTS[@]}" ; do
373 alternatives_auto_makesym "/usr/bin/${i}" "/usr/bin/${i}-[0-9]*"
374 ff=`echo "${EROOT}"/usr/share/man/man1/${i}-${PV}-${P}.1*`
375 ff=${ff##*.1}
376 alternatives_auto_makesym "/usr/share/man/man1/${i}.1${ff}" "/usr/share/man/man1/${i}-[0-9]*"
377 done
378 else
379 pushd "${ED}" > /dev/null
380 for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
381 mv ${i}{,-${PV}-${P}} || die
382 DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
383 if [[ -f usr/share/man/man1/${i##*/}.1 ]] ; then
384 mv usr/share/man/man1/${i##*/}{.1,-${PV}-${P}.1} || die
385 fi
386 done
387 popd > /dev/null
388 fi
389 }
390
391 perl_set_eprefix() {
392 debug-print-function $FUNCNAME "$@"
393 case ${EAPI:-0} in
394 0|1|2)
395 if ! use prefix; then
396 EPREFIX=
397 ED=${D}
398 EROOT=${ROOT}
399 fi
400 ;;
401 esac
402 }

  ViewVC Help
Powered by ViewVC 1.1.20