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

Contents of /eclass/perl-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.161 - (show annotations) (download)
Wed Dec 17 16:40:53 2014 UTC (6 weeks ago) by dilfridge
Branch: MAIN
CVS Tags: HEAD
Changes since 1.160: +2 -7 lines
Remove code paths that are not called anymore

1 # Copyright 1999-2014 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.160 2014/12/13 21:06:07 dilfridge Exp $
4
5 # @ECLASS: perl-module.eclass
6 # @MAINTAINER:
7 # perl@gentoo.org
8 # @AUTHOR:
9 # Seemant Kulleen <seemant@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 multiprocessing unpacker
16 [[ ${CATEGORY} == "perl-core" ]] && inherit alternatives
17
18 PERL_EXPF="src_unpack src_prepare src_configure src_compile src_test src_install"
19
20 case "${EAPI:-0}" in
21 4|5)
22 [[ ${CATEGORY} == "perl-core" ]] && \
23 PERL_EXPF+=" pkg_postinst pkg_postrm"
24
25 case "${GENTOO_DEPEND_ON_PERL:-yes}" in
26 yes)
27 case "${EAPI:-0}" in
28 5)
29 case "${GENTOO_DEPEND_ON_PERL_SUBSLOT:-yes}" in
30 yes)
31 DEPEND="dev-lang/perl:=[-build(-)]"
32 ;;
33 *)
34 DEPEND="dev-lang/perl[-build(-)]"
35 ;;
36 esac
37 ;;
38 *)
39 DEPEND="|| ( >=dev-lang/perl-5.16 <dev-lang/perl-5.16[-build] )"
40 ;;
41 esac
42 RDEPEND="${DEPEND}"
43 ;;
44 esac
45 ;;
46 *)
47 die "EAPI=${EAPI} is not supported by perl-module.eclass"
48 ;;
49 esac
50
51 case "${EAPI:-0}" in
52 5)
53 ;;
54 *)
55 ewarn
56 ewarn "******************************************************************"
57 ewarn "${EBUILD}:"
58 ewarn "Support for EAPI=${EAPI:-0} in perl-module.eclass will be removed"
59 ewarn "on 1/Feb/2015. Please fix your overlay ebuilds to use EAPI=5."
60 ewarn "******************************************************************"
61 ewarn
62 ;;
63 esac
64
65 case "${PERL_EXPORT_PHASE_FUNCTIONS:-yes}" in
66 yes)
67 EXPORT_FUNCTIONS ${PERL_EXPF}
68 ;;
69 no)
70 debug-print "PERL_EXPORT_PHASE_FUNCTIONS=no"
71 ;;
72 *)
73 die "PERL_EXPORT_PHASE_FUNCTIONS=${PERL_EXPORT_PHASE_FUNCTIONS} is not supported by perl-module.eclass"
74 ;;
75 esac
76
77 LICENSE="${LICENSE:-|| ( Artistic GPL-1+ )}"
78
79 if [[ -n ${MY_PN} || -n ${MY_PV} || -n ${MODULE_VERSION} ]] ; then
80 : ${MY_P:=${MY_PN:-${PN}}-${MY_PV:-${MODULE_VERSION:-${PV}}}}
81 S=${MY_S:-${WORKDIR}/${MY_P}}
82 fi
83
84 [[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && \
85 MODULE_A="${MY_P:-${P}}.${MODULE_A_EXT:-tar.gz}"
86 [[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
87 SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION:+${MODULE_SECTION}/}${MODULE_A}"
88 [[ -z "${HOMEPAGE}" ]] && \
89 HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}/"
90
91 SRC_PREP="no"
92 SRC_TEST="skip"
93 PREFER_BUILDPL="yes"
94
95 pm_echovar=""
96 perlinfo_done=false
97
98 # @FUNCTION: perl-module_src_unpack
99 # @USAGE: perl-module_src_unpack
100 # @DESCRIPTION:
101 # Unpack the ebuild tarball(s).
102 # This function is to be called during the ebuild src_unpack() phase.
103 perl-module_src_unpack() {
104 debug-print-function $FUNCNAME "$@"
105
106 unpacker_src_unpack
107 }
108
109 # @FUNCTION: perl-module_src_prepare
110 # @USAGE: perl-module_src_prepare
111 # @DESCRIPTION:
112 # Get the ebuild sources ready.
113 # This function is to be called during the ebuild src_prepare() phase.
114 perl-module_src_prepare() {
115 debug-print-function $FUNCNAME "$@"
116 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
117 debug-print "$FUNCNAME: applying user patches"
118 epatch_user
119 if [[ ${PERL_RM_FILES[@]} ]]; then
120 debug-print "$FUNCNAME: stripping unneeded files"
121 perl_rm_files "${PERL_RM_FILES[@]}"
122 fi
123 perl_fix_osx_extra
124 esvn_clean
125 }
126
127 # @FUNCTION: perl-module_src_configure
128 # @USAGE: perl-module_src_configure
129 # @DESCRIPTION:
130 # Configure the ebuild sources.
131 # This function is to be called during the ebuild src_configure() phase.
132 perl-module_src_configure() {
133 debug-print-function $FUNCNAME "$@"
134
135 [[ ${SRC_PREP} = yes ]] && return 0
136 SRC_PREP="yes"
137
138 perl_set_version
139
140 [[ -z ${pm_echovar} ]] && export PERL_MM_USE_DEFAULT=1
141 # Disable ExtUtils::AutoInstall from prompting
142 export PERL_EXTUTILS_AUTOINSTALL="--skipdeps"
143
144 if [[ $(declare -p myconf 2>&-) != "declare -a myconf="* ]]; then
145 local myconf_local=(${myconf})
146 else
147 local myconf_local=("${myconf[@]}")
148 fi
149
150 if [[ ( ${PREFER_BUILDPL} == yes || ! -f Makefile.PL ) && -f Build.PL ]] ; then
151 einfo "Using Module::Build"
152 if [[ ${DEPEND} != *virtual/perl-Module-Build* && ${PN} != Module-Build ]] ; then
153 eqawarn "QA Notice: The ebuild uses Module::Build but doesn't depend on it."
154 eqawarn " Add virtual/perl-Module-Build to DEPEND!"
155 if [[ -n ${PERLQAFATAL} ]]; then
156 eerror "Bailing out due to PERLQAFATAL=1";
157 die;
158 fi
159 fi
160 set -- \
161 --installdirs=vendor \
162 --libdoc= \
163 --destdir="${D}" \
164 --create_packlist=0 \
165 "${myconf_local[@]}"
166 einfo "perl Build.PL" "$@"
167 perl Build.PL "$@" <<< "${pm_echovar}" \
168 || die "Unable to build!"
169 elif [[ -f Makefile.PL ]] ; then
170 einfo "Using ExtUtils::MakeMaker"
171 set -- \
172 PREFIX=${EPREFIX}/usr \
173 INSTALLDIRS=vendor \
174 INSTALLMAN3DIR='none' \
175 DESTDIR="${D}" \
176 "${myconf_local[@]}"
177 einfo "perl Makefile.PL" "$@"
178 perl Makefile.PL "$@" <<< "${pm_echovar}" \
179 || die "Unable to build!"
180 fi
181 if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then
182 einfo "No Make or Build file detected..."
183 return
184 fi
185 }
186
187 # @FUNCTION: perl-module_src_prep
188 # @USAGE: perl-module_src_prep
189 # @DESCRIPTION:
190 # Configure the ebuild sources (bis).
191 #
192 # This function is still around for historical reasons
193 # and will be soon deprecated.
194 #
195 # Please use the function above instead, perl-module_src_configure().
196 perl-module_src_prep() {
197 debug-print-function $FUNCNAME "$@"
198 ewarn "perl-modules.eclass: perl-module_src_prep is deprecated and will be removed. Please use perl-module_src_configure instead."
199 perl-module_src_configure
200 }
201
202 # @FUNCTION: perl-module_src_compile
203 # @USAGE: perl-module_src_compile
204 # @DESCRIPTION:
205 # Compile the ebuild sources.
206 # This function is to be called during the ebuild src_compile() phase.
207 perl-module_src_compile() {
208 debug-print-function $FUNCNAME "$@"
209 perl_set_version
210
211 if [[ $(declare -p mymake 2>&-) != "declare -a mymake="* ]]; then
212 local mymake_local=(${mymake})
213 else
214 local mymake_local=("${mymake[@]}")
215 fi
216
217 if [[ -f Build ]] ; then
218 ./Build build \
219 || die "Compilation failed"
220 elif [[ -f Makefile ]] ; then
221 set -- \
222 OTHERLDFLAGS="${LDFLAGS}" \
223 "${mymake_local[@]}"
224 einfo "emake" "$@"
225 emake "$@" \
226 || die "Compilation failed"
227 # OPTIMIZE="${CFLAGS}" \
228 fi
229 }
230
231 # @FUNCTION: perl-module_src-test
232 # @USAGE: perl-module_src_test()
233 # @DESCRIPTION:
234 # This code attempts to work out your threadingness from MAKEOPTS
235 # and apply them to Test::Harness.
236 #
237 # If you want more verbose testing, set TEST_VERBOSE=1
238 # in your bashrc | /etc/portage/make.conf | ENV
239 #
240 # or ebuild writers:
241 # If you wish to enable default tests w/ 'make test' ,
242 #
243 # SRC_TEST="do"
244 #
245 # If you wish to have threads run in parallel ( using the users makeopts )
246 # all of the following have been tested to work.
247 #
248 # SRC_TEST="do parallel"
249 # SRC_TEST="parallel"
250 # SRC_TEST="parallel do"
251 # SRC_TEST=parallel
252 #
253 perl-module_src_test() {
254 debug-print-function $FUNCNAME "$@"
255 if has 'do' ${SRC_TEST} || has 'parallel' ${SRC_TEST} ; then
256 if has "${TEST_VERBOSE:-0}" 0 && has 'parallel' ${SRC_TEST} ; then
257 export HARNESS_OPTIONS=j$(makeopts_jobs)
258 einfo "Test::Harness Jobs=$(makeopts_jobs)"
259 fi
260 ${perlinfo_done} || perl_set_version
261 if [[ -f Build ]] ; then
262 ./Build test verbose=${TEST_VERBOSE:-0} || die "test failed"
263 elif [[ -f Makefile ]] ; then
264 emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test failed"
265 fi
266 fi
267 }
268
269 # @FUNCTION: perl-module_src_install
270 # @USAGE: perl-module_src_install
271 # @DESCRIPTION:
272 # Install a Perl ebuild.
273 # This function is to be called during the ebuild src_install() phase.
274 perl-module_src_install() {
275 debug-print-function $FUNCNAME "$@"
276
277 perl_set_version
278
279 local f
280
281 if [[ -z ${mytargets} ]] ; then
282 case "${CATEGORY}" in
283 dev-perl|perl-core) mytargets="pure_install" ;;
284 *) mytargets="install" ;;
285 esac
286 fi
287
288 if [[ $(declare -p myinst 2>&-) != "declare -a myinst="* ]]; then
289 local myinst_local=(${myinst})
290 else
291 local myinst_local=("${myinst[@]}")
292 fi
293
294 if [[ -f Build ]] ; then
295 ./Build ${mytargets} \
296 || die "./Build ${mytargets} failed"
297 elif [[ -f Makefile ]] ; then
298 emake "${myinst_local[@]}" ${mytargets} \
299 || die "emake ${myinst_local[@]} ${mytargets} failed"
300 fi
301
302 perl_delete_module_manpages
303 perl_delete_localpod
304 perl_delete_packlist
305 perl_remove_temppath
306
307 for f in Change* CHANGES README* TODO FAQ ${mydoc}; do
308 [[ -s ${f} ]] && dodoc ${f}
309 done
310
311 perl_link_duallife_scripts
312 }
313
314 # @FUNCTION: perl-module_pkg_setup
315 # @USAGE: perl-module_pkg_setup
316 # @DESCRIPTION:
317 # This function was to be called during the pkg_setup() phase.
318 # Deprecated, to be removed. Where it is called, place a call to perl_set_version instead.
319 perl-module_pkg_setup() {
320 debug-print-function $FUNCNAME "$@"
321 ewarn "perl-modules.eclass: perl-module_pkg_setup is deprecated and will be removed. Please use perl_set_version instead."
322 perl_set_version
323 }
324
325 # @FUNCTION: perl-module_pkg_preinst
326 # @USAGE: perl-module_pkg_preinst
327 # @DESCRIPTION:
328 # This function was to be called during the pkg_preinst() phase.
329 # Deprecated, to be removed. Where it is called, place a call to perl_set_version instead.
330 perl-module_pkg_preinst() {
331 debug-print-function $FUNCNAME "$@"
332 ewarn "perl-modules.eclass: perl-module_pkg_preinst is deprecated and will be removed. Please use perl_set_version instead."
333 perl_set_version
334 }
335
336 # @FUNCTION: perl-module_pkg_postinst
337 # @USAGE: perl-module_pkg_postinst
338 # @DESCRIPTION:
339 # This function is to be called during the pkg_postinst() phase. It only does
340 # useful things for the perl-core category, where it handles the file renaming and symbolic
341 # links that prevent file collisions for dual-life packages installing scripts.
342 # In any other category it immediately exits.
343 perl-module_pkg_postinst() {
344 debug-print-function $FUNCNAME "$@"
345 if [[ ${CATEGORY} != perl-core ]] ; then
346 eqawarn "perl-module.eclass: You are calling perl-module_pkg_postinst outside the perl-core category."
347 eqawarn " This does not do anything; the call can be safely removed."
348 return 0
349 fi
350 perl_link_duallife_scripts
351 }
352
353 # @FUNCTION: perl-module_pkg_prerm
354 # @USAGE: perl-module_pkg_prerm
355 # @DESCRIPTION:
356 # This function was to be called during the pkg_prerm() phase.
357 # It does not do anything. Deprecated, to be removed.
358 perl-module_pkg_prerm() {
359 debug-print-function $FUNCNAME "$@"
360 ewarn "perl-module.eclass: perl-module_pkg_prerm does not do anything and will be removed. Please remove the call."
361 }
362
363 # @FUNCTION: perl-module_pkg_postrm
364 # @USAGE: perl-module_pkg_postrm
365 # @DESCRIPTION:
366 # This function is to be called during the pkg_postrm() phase. It only does
367 # useful things for the perl-core category, where it handles the file renaming and symbolic
368 # links that prevent file collisions for dual-life packages installing scripts.
369 # In any other category it immediately exits.
370 perl-module_pkg_postrm() {
371 debug-print-function $FUNCNAME "$@"
372 if [[ ${CATEGORY} != perl-core ]] ; then
373 eqawarn "perl-module.eclass: You are calling perl-module_pkg_postrm outside the perl-core category."
374 eqawarn " This does not do anything; the call can be safely removed."
375 return 0
376 fi
377 perl_link_duallife_scripts
378 }
379
380 # @FUNCTION: perl_set_version
381 # @USAGE: perl_set_version
382 # @DESCRIPTION:
383 # Extract version information and installation paths from the current Perl
384 # interpreter.
385 #
386 # This sets the following variables: PERL_VERSION, SITE_ARCH, SITE_LIB,
387 # ARCH_LIB, VENDOR_LIB, VENDOR_ARCH
388 #
389 # This function used to be called perlinfo as well.
390 perl_set_version() {
391 debug-print-function $FUNCNAME "$@"
392 debug-print "$FUNCNAME: perlinfo_done=${perlinfo_done}"
393 ${perlinfo_done} && return 0
394 perlinfo_done=true
395
396 local f version install{{site,vendor}{arch,lib},archlib}
397 eval "$(perl -V:{version,install{{site,vendor}{arch,lib},archlib}} )"
398 PERL_VERSION=${version}
399 SITE_ARCH=${installsitearch}
400 SITE_LIB=${installsitelib}
401 ARCH_LIB=${installarchlib}
402 VENDOR_LIB=${installvendorlib}
403 VENDOR_ARCH=${installvendorarch}
404 }
405
406 # @FUNCTION: perlinfo
407 # @USAGE: perlinfo
408 # @DESCRIPTION:
409 # This function is deprecated.
410 #
411 # Please use the function above instead, perl_set_version().
412 perlinfo() {
413 debug-print-function $FUNCNAME "$@"
414 ewarn "perl-modules.eclass: perlinfo is deprecated and will be removed. Please use perl_set_version instead."
415 perl_set_version
416 }
417
418 # @FUNCTION: perl_delete_localpod
419 # @USAGE: perl_delete_localpod
420 # @DESCRIPTION:
421 # Remove stray perllocal.pod files in the temporary install directory D.
422 #
423 # This function used to be called fixlocalpod as well.
424 perl_delete_localpod() {
425 debug-print-function $FUNCNAME "$@"
426
427 find "${D}" -type f -name perllocal.pod -delete
428 find "${D}" -depth -mindepth 1 -type d -empty -delete
429 }
430
431 # @FUNCTION: fixlocalpod
432 # @USAGE: fixlocalpod
433 # @DESCRIPTION:
434 # This function is deprecated.
435 #
436 # Please use the function above instead, perl_delete_localpod().
437 fixlocalpod() {
438 debug-print-function $FUNCNAME "$@"
439 ewarn "perl-modules.eclass: fixlocalpod is deprecated and will be removed. Please use perl_delete_localpod instead."
440 perl_delete_localpod
441 }
442
443 # @FUNCTION: perl_fix_osx_extra
444 # @USAGE: perl_fix_osx_extra
445 # @DESCRIPTION:
446 # Look through ${S} for AppleDouble encoded files and get rid of them.
447 perl_fix_osx_extra() {
448 debug-print-function $FUNCNAME "$@"
449
450 local f
451 find "${S}" -type f -name "._*" -print0 | while read -rd '' f ; do
452 einfo "Removing AppleDouble encoded Macintosh file: ${f#${S}/}"
453 rm -f "${f}"
454 f=${f#${S}/}
455 grep -q "${f}" "${S}"/MANIFEST && \
456 elog "AppleDouble encoded Macintosh file in MANIFEST: ${f#${S}/}"
457 done
458 }
459
460 # @FUNCTION: perl_delete_module_manpages
461 # @USAGE: perl_delete_module_manpages
462 # @DESCRIPTION:
463 # Bump off manpages installed by the current module such as *.3pm files as well
464 # as empty directories.
465 perl_delete_module_manpages() {
466 debug-print-function $FUNCNAME "$@"
467
468 if [[ -d "${ED}"/usr/share/man ]] ; then
469 find "${ED}"/usr/share/man -type f -name "*.3pm" -delete
470 find "${ED}"/usr/share/man -depth -type d -empty -delete
471 fi
472 }
473
474 # @FUNCTION: perl_delete_packlist
475 # @USAGE: perl_delete_packlist
476 # @DESCRIPTION:
477 # Look through ${D} for .packlist files, empty .bs files and empty directories,
478 # and get rid of items found.
479 perl_delete_packlist() {
480 debug-print-function $FUNCNAME "$@"
481 perl_set_version
482 if [[ -d ${D}/${VENDOR_ARCH} ]] ; then
483 find "${D}/${VENDOR_ARCH}" -type f -a \( -name .packlist \
484 -o \( -name '*.bs' -a -empty \) \) -delete
485 find "${D}" -depth -mindepth 1 -type d -empty -delete
486 fi
487 }
488
489 # @FUNCTION: perl_remove_temppath
490 # @USAGE: perl_remove_temppath
491 # @DESCRIPTION:
492 # Look through ${D} for text files containing the temporary installation
493 # folder (i.e. ${D}). If the pattern is found (i.e. " text"), replace it with `/'.
494 perl_remove_temppath() {
495 debug-print-function $FUNCNAME "$@"
496
497 find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
498 if file "${f}" | grep -q -i " text" ; then
499 grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
500 sed -i -e "s:${D}:/:g" "${f}"
501 fi
502 done
503 }
504
505 # @FUNCTION: perl_rm_files
506 # @USAGE: perl_rm_files "file_1" "file_2"
507 # @DESCRIPTION:
508 # Remove certain files from a Perl release and remove them from the MANIFEST
509 # while we're there.
510 #
511 # Most useful in src_prepare for nuking bad tests, and is highly recommended
512 # for any tests like 'pod.t', 'pod-coverage.t' or 'kwalitee.t', as what they
513 # test is completely irrelevant to end users, and frequently fail simply
514 # because the authors of Test::Pod... changed their recommendations, and thus
515 # failures are only useful feedback to Authors, not users.
516 #
517 # Removing from MANIFEST also avoids needless log messages warning
518 # users about files "missing from their kit".
519 perl_rm_files() {
520 debug-print-function $FUNCNAME "$@"
521 local skipfile="${T}/.gentoo_makefile_skip"
522 local manifile="${S}/MANIFEST"
523 local manitemp="${T}/.gentoo_manifest_temp"
524 oldifs="$IFS"
525 IFS="\n"
526 for filename in "$@"; do
527 einfo "Removing un-needed ${filename}";
528 # Remove the file
529 rm -f "${S}/${filename}"
530 [[ -e "${manifile}" ]] && echo "${filename}" >> "${skipfile}"
531 done
532 if [[ -e "${manifile}" && -e "${skipfile}" ]]; then
533 einfo "Fixing Manifest"
534 grep -v -F -f "${skipfile}" "${manifile}" > "${manitemp}"
535 mv -f -- "${manitemp}" "${manifile}"
536 rm -- "${skipfile}";
537 fi
538 IFS="$oldifs"
539 }
540
541 # @FUNCTION: perl_link_duallife_scripts
542 # @USAGE: perl_link_duallife_scripts
543 # @DESCRIPTION:
544 # Moves files and generates symlinks so dual-life packages installing scripts do not
545 # lead to file collisions. Mainly for use in pkg_postinst and pkg_postrm, and makes
546 # only sense for perl-core packages.
547 perl_link_duallife_scripts() {
548 debug-print-function $FUNCNAME "$@"
549 if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; then
550 return 0
551 fi
552
553 local i ff
554 if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
555 for i in "${DUALLIFESCRIPTS[@]}" ; do
556 alternatives_auto_makesym "/${i}" "/${i}-[0-9]*"
557 done
558 for i in "${DUALLIFEMAN[@]}" ; do
559 ff=`echo "${EROOT}"/${i%.1}-${PV}-${P}.1*`
560 ff=${ff##*.1}
561 alternatives_auto_makesym "/${i}${ff}" "/${i%.1}-[0-9]*"
562 done
563 else
564 pushd "${ED}" > /dev/null
565 for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
566 mv ${i}{,-${PV}-${P}} || die
567 #DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
568 DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i}
569 done
570 for i in $(find usr/share/man/man1 -maxdepth 1 -type f 2>/dev/null) ; do
571 mv ${i} ${i%.1}-${PV}-${P}.1 || die
572 DUALLIFEMAN[${#DUALLIFEMAN[*]}]=${i}
573 done
574 popd > /dev/null
575 fi
576 }

  ViewVC Help
Powered by ViewVC 1.1.20