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

Contents of /eclass/perl-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.148 - (hide annotations) (download)
Sun Nov 9 21:34:29 2014 UTC (3 years, 11 months ago) by dilfridge
Branch: MAIN
Changes since 1.147: +19 -1 lines
Add docs and deprecate perlinfo and fixlocalpod

1 dilfridge 1.140 # Copyright 1999-2014 Gentoo Foundation
2 vapier 1.30 # Distributed under the terms of the GNU General Public License v2
3 dilfridge 1.148 # $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.147 2014/11/09 18:10:24 dilfridge Exp $
4 tove 1.113
5     # @ECLASS: perl-module.eclass
6     # @MAINTAINER:
7     # perl@gentoo.org
8 vapier 1.131 # @AUTHOR:
9     # Seemant Kulleen <seemant@gentoo.org>
10 tove 1.113 # @BLURB: eclass for perl modules
11     # @DESCRIPTION:
12 seemant 1.1 # The perl-module eclass is designed to allow easier installation of perl
13     # modules, and their incorporation into the Gentoo Linux system.
14 seemant 1.3
15 zlogene 1.139 inherit eutils multiprocessing unpacker
16 tove 1.124 [[ ${CATEGORY} == "perl-core" ]] && inherit alternatives
17 tove 1.117
18     PERL_EXPF="src_unpack src_compile src_test src_install"
19 tove 1.113
20     case "${EAPI:-0}" in
21 dilfridge 1.144 4|5)
22 tove 1.124 PERL_EXPF+=" src_prepare src_configure"
23 tove 1.117 [[ ${CATEGORY} == "perl-core" ]] && \
24 tove 1.124 PERL_EXPF+=" pkg_postinst pkg_postrm"
25 tove 1.113
26     case "${GENTOO_DEPEND_ON_PERL:-yes}" in
27 dilfridge 1.138 yes)
28     case "${EAPI:-0}" in
29     5)
30     case "${GENTOO_DEPEND_ON_PERL_SUBSLOT:-yes}" in
31     yes)
32     DEPEND="dev-lang/perl:=[-build(-)]"
33     ;;
34     *)
35     DEPEND="dev-lang/perl[-build(-)]"
36     ;;
37     esac
38     ;;
39     *)
40 mattst88 1.137 DEPEND="|| ( >=dev-lang/perl-5.16 <dev-lang/perl-5.16[-build] )"
41 tove 1.113 ;;
42 dilfridge 1.138 esac
43     RDEPEND="${DEPEND}"
44     ;;
45 tove 1.113 esac
46     ;;
47 tove 1.123 *)
48 tove 1.127 die "EAPI=${EAPI} is not supported by perl-module.eclass"
49 tove 1.123 ;;
50 tove 1.113 esac
51 danarmak 1.13
52 dilfridge 1.147 case "${EAPI:-0}" in
53     5)
54     ;;
55     *)
56     ewarn
57     ewarn "******************************************************************"
58     ewarn "${EBUILD}:"
59     ewarn "Support for EAPI=${EAPI:-0} in perl-module.eclass will be removed"
60     ewarn "on 1/Feb/2015. Please fix your overlay ebuilds to use EAPI=5."
61     ewarn "******************************************************************"
62     ewarn
63     ;;
64     esac
65 dilfridge 1.142
66 tove 1.124 case "${PERL_EXPORT_PHASE_FUNCTIONS:-yes}" in
67     yes)
68     EXPORT_FUNCTIONS ${PERL_EXPF}
69     ;;
70     no)
71     debug-print "PERL_EXPORT_PHASE_FUNCTIONS=no"
72     ;;
73     *)
74 tove 1.127 die "PERL_EXPORT_PHASE_FUNCTIONS=${PERL_EXPORT_PHASE_FUNCTIONS} is not supported by perl-module.eclass"
75 tove 1.124 ;;
76     esac
77 tove 1.117
78 hanno 1.122 LICENSE="${LICENSE:-|| ( Artistic GPL-1 GPL-2 GPL-3 )}"
79 robbat2 1.109
80 tove 1.127 if [[ -n ${MY_PN} || -n ${MY_PV} || -n ${MODULE_VERSION} ]] ; then
81     : ${MY_P:=${MY_PN:-${PN}}-${MY_PV:-${MODULE_VERSION:-${PV}}}}
82     S=${MY_S:-${WORKDIR}/${MY_P}}
83     fi
84 tove 1.130
85 robbat2 1.128 [[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && \
86     MODULE_A="${MY_P:-${P}}.${MODULE_A_EXT:-tar.gz}"
87 tove 1.113 [[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
88 tove 1.123 SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION:+${MODULE_SECTION}/}${MODULE_A}"
89 tove 1.113 [[ -z "${HOMEPAGE}" ]] && \
90 tove 1.118 HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}/"
91 mcummings 1.66
92 azarah 1.11 SRC_PREP="no"
93 rac 1.55 SRC_TEST="skip"
94 mcummings 1.97 PREFER_BUILDPL="yes"
95 azarah 1.11
96 mcummings 1.101 pm_echovar=""
97 tove 1.113 perlinfo_done=false
98 seemant 1.35
99 mcummings 1.102 perl-module_src_unpack() {
100 tove 1.123 debug-print-function $FUNCNAME "$@"
101 dilfridge 1.141
102 zlogene 1.139 unpacker_src_unpack
103 tove 1.117 has src_prepare ${PERL_EXPF} || perl-module_src_prepare
104 tove 1.113 }
105    
106     perl-module_src_prepare() {
107 tove 1.123 debug-print-function $FUNCNAME "$@"
108 zlogene 1.139 has src_prepare ${PERL_EXPF} && \
109     [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
110     debug-print "$FUNCNAME: applying user patches"
111     epatch_user
112 monsieurp 1.145 if [[ ${PERL_RM_FILES[@]} ]]; then
113     debug-print "$FUNCNAME: stripping unneeded files"
114     perl_rm_files "${PERL_RM_FILES[@]}"
115     fi
116 tove 1.123 perl_fix_osx_extra
117 tove 1.113 esvn_clean
118     }
119    
120     perl-module_src_configure() {
121 tove 1.123 debug-print-function $FUNCNAME "$@"
122 tove 1.113 perl-module_src_prep
123 mcummings 1.102 }
124    
125 aliz 1.15 perl-module_src_prep() {
126 tove 1.123 debug-print-function $FUNCNAME "$@"
127 tove 1.117 [[ ${SRC_PREP} = yes ]] && return 0
128 tove 1.113 SRC_PREP="yes"
129 rac 1.60
130 tove 1.123 perl_set_version
131 rac 1.60
132 tove 1.130 [[ -z ${pm_echovar} ]] && export PERL_MM_USE_DEFAULT=1
133 mcummings 1.90 # Disable ExtUtils::AutoInstall from prompting
134     export PERL_EXTUTILS_AUTOINSTALL="--skipdeps"
135 rac 1.64
136 tove 1.127 if [[ $(declare -p myconf 2>&-) != "declare -a myconf="* ]]; then
137     local myconf_local=(${myconf})
138     else
139     local myconf_local=("${myconf[@]}")
140     fi
141    
142     if [[ ( ${PREFER_BUILDPL} == yes || ! -f Makefile.PL ) && -f Build.PL ]] ; then
143 mcummings 1.97 einfo "Using Module::Build"
144 tove 1.120 if [[ ${DEPEND} != *virtual/perl-Module-Build* && ${PN} != Module-Build ]] ; then
145 tove 1.126 eqawarn "QA Notice: The ebuild uses Module::Build but doesn't depend on it."
146     eqawarn " Add virtual/perl-Module-Build to DEPEND!"
147 tove 1.127 if [[ -n ${PERLQAFATAL} ]]; then
148     eerror "Bailing out due to PERLQAFATAL=1";
149     die;
150     fi
151 tove 1.120 fi
152 tove 1.123 set -- \
153 tove 1.113 --installdirs=vendor \
154     --libdoc= \
155     --destdir="${D}" \
156     --create_packlist=0 \
157 tove 1.127 "${myconf_local[@]}"
158 tove 1.123 einfo "perl Build.PL" "$@"
159     perl Build.PL "$@" <<< "${pm_echovar}" \
160 tove 1.127 || die "Unable to build!"
161 tove 1.113 elif [[ -f Makefile.PL ]] ; then
162 mcummings 1.85 einfo "Using ExtUtils::MakeMaker"
163 tove 1.123 set -- \
164     PREFIX=${EPREFIX}/usr \
165 tove 1.113 INSTALLDIRS=vendor \
166     INSTALLMAN3DIR='none' \
167     DESTDIR="${D}" \
168 tove 1.127 "${myconf_local[@]}"
169 tove 1.123 einfo "perl Makefile.PL" "$@"
170     perl Makefile.PL "$@" <<< "${pm_echovar}" \
171 tove 1.127 || die "Unable to build!"
172 mcummings 1.88 fi
173 tove 1.113 if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then
174 mcummings 1.88 einfo "No Make or Build file detected..."
175 mcummings 1.85 return
176 mcummings 1.43 fi
177 azarah 1.11 }
178    
179 aliz 1.15 perl-module_src_compile() {
180 tove 1.123 debug-print-function $FUNCNAME "$@"
181     perl_set_version
182 tove 1.113
183 tove 1.117 has src_configure ${PERL_EXPF} || perl-module_src_prep
184 seemant 1.6
185 tove 1.127 if [[ $(declare -p mymake 2>&-) != "declare -a mymake="* ]]; then
186     local mymake_local=(${mymake})
187     else
188     local mymake_local=("${mymake[@]}")
189     fi
190    
191 tove 1.113 if [[ -f Build ]] ; then
192     ./Build build \
193 tove 1.127 || die "Compilation failed"
194 tove 1.113 elif [[ -f Makefile ]] ; then
195 tove 1.127 set -- \
196 tove 1.113 OTHERLDFLAGS="${LDFLAGS}" \
197 tove 1.127 "${mymake_local[@]}"
198     einfo "emake" "$@"
199     emake "$@" \
200     || die "Compilation failed"
201 tove 1.113 # OPTIMIZE="${CFLAGS}" \
202 mcummings 1.43 fi
203 seemant 1.8 }
204    
205 tove 1.117 # For testers:
206     # This code attempts to work out your threadingness from MAKEOPTS
207     # and apply them to Test::Harness.
208     #
209     # If you want more verbose testing, set TEST_VERBOSE=1
210 zmedico 1.136 # in your bashrc | /etc/portage/make.conf | ENV
211 tove 1.117 #
212     # For ebuild writers:
213     # If you wish to enable default tests w/ 'make test' ,
214     #
215     # SRC_TEST="do"
216     #
217     # If you wish to have threads run in parallel ( using the users makeopts )
218     # all of the following have been tested to work.
219     #
220     # SRC_TEST="do parallel"
221     # SRC_TEST="parallel"
222     # SRC_TEST="parallel do"
223     # SRC_TEST=parallel
224     #
225    
226 aliz 1.15 perl-module_src_test() {
227 tove 1.123 debug-print-function $FUNCNAME "$@"
228 tove 1.117 if has 'do' ${SRC_TEST} || has 'parallel' ${SRC_TEST} ; then
229     if has "${TEST_VERBOSE:-0}" 0 && has 'parallel' ${SRC_TEST} ; then
230 vapier 1.132 export HARNESS_OPTIONS=j$(makeopts_jobs)
231     einfo "Test::Harness Jobs=$(makeopts_jobs)"
232 tove 1.117 fi
233 tove 1.123 ${perlinfo_done} || perl_set_version
234 tove 1.113 if [[ -f Build ]] ; then
235 tove 1.117 ./Build test verbose=${TEST_VERBOSE:-0} || die "test failed"
236 tove 1.113 elif [[ -f Makefile ]] ; then
237 tove 1.117 emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test failed"
238 mcummings 1.68 fi
239 mcummings 1.43 fi
240 seemant 1.1 }
241    
242 aliz 1.15 perl-module_src_install() {
243 tove 1.123 debug-print-function $FUNCNAME "$@"
244    
245     perl_set_version
246    
247 tove 1.113 local f
248 swegener 1.76
249 tove 1.114 if [[ -z ${mytargets} ]] ; then
250     case "${CATEGORY}" in
251     dev-perl|perl-core) mytargets="pure_install" ;;
252     *) mytargets="install" ;;
253     esac
254     fi
255 swegener 1.76
256 tove 1.127 if [[ $(declare -p myinst 2>&-) != "declare -a myinst="* ]]; then
257     local myinst_local=(${myinst})
258     else
259     local myinst_local=("${myinst[@]}")
260     fi
261    
262 tove 1.113 if [[ -f Build ]] ; then
263     ./Build ${mytargets} \
264     || die "./Build ${mytargets} failed"
265     elif [[ -f Makefile ]] ; then
266 tove 1.127 emake "${myinst_local[@]}" ${mytargets} \
267     || die "emake ${myinst_local[@]} ${mytargets} failed"
268 tove 1.113 fi
269    
270 tove 1.123 perl_delete_module_manpages
271     perl_delete_localpod
272     perl_delete_packlist
273     perl_remove_temppath
274 mcummings 1.20
275 tove 1.123 for f in Change* CHANGES README* TODO FAQ ${mydoc}; do
276 tove 1.117 [[ -s ${f} ]] && dodoc ${f}
277 mcummings 1.98 done
278 mcummings 1.65
279 tove 1.123 perl_link_duallife_scripts
280 seemant 1.35 }
281    
282     perl-module_pkg_setup() {
283 tove 1.123 debug-print-function $FUNCNAME "$@"
284     perl_set_version
285 seemant 1.35 }
286    
287     perl-module_pkg_preinst() {
288 tove 1.123 debug-print-function $FUNCNAME "$@"
289     perl_set_version
290 seemant 1.35 }
291    
292 tove 1.117 perl-module_pkg_postinst() {
293 tove 1.123 debug-print-function $FUNCNAME "$@"
294     perl_link_duallife_scripts
295 tove 1.117 }
296 seemant 1.35
297 tove 1.123 perl-module_pkg_prerm() {
298     debug-print-function $FUNCNAME "$@"
299     }
300 seemant 1.35
301 tove 1.117 perl-module_pkg_postrm() {
302 tove 1.123 debug-print-function $FUNCNAME "$@"
303     perl_link_duallife_scripts
304 tove 1.117 }
305 tove 1.124
306     perlinfo() {
307     debug-print-function $FUNCNAME "$@"
308 dilfridge 1.148 eqawarn "perl-modules.eclass: perlinfo is deprecated and will be removed. Please use perl_set_version instead."
309 tove 1.124 perl_set_version
310     }
311    
312 dilfridge 1.148 # @FUNCTION: perl_set_version
313     # @USAGE: perl_set_version
314     # @DESCRIPTION:
315     # Extract version information and installation paths from the current Perl
316     # interpreter.
317     #
318     # This sets the following variables: PERL_VERSION, SITE_ARCH, SITE_LIB,
319     # ARCH_LIB, VENDOR_LIB, VENDOR_ARCH
320     #
321     # This function used to be called perlinfo as well.
322 tove 1.124 perl_set_version() {
323     debug-print-function $FUNCNAME "$@"
324     debug-print "$FUNCNAME: perlinfo_done=${perlinfo_done}"
325     ${perlinfo_done} && return 0
326     perlinfo_done=true
327    
328     local f version install{{site,vendor}{arch,lib},archlib}
329     eval "$(perl -V:{version,install{{site,vendor}{arch,lib},archlib}} )"
330     PERL_VERSION=${version}
331     SITE_ARCH=${installsitearch}
332     SITE_LIB=${installsitelib}
333     ARCH_LIB=${installarchlib}
334     VENDOR_LIB=${installvendorlib}
335     VENDOR_ARCH=${installvendorarch}
336     }
337    
338     fixlocalpod() {
339     debug-print-function $FUNCNAME "$@"
340 dilfridge 1.148 eqawarn "perl-modules.eclass: fixlocalpod is deprecated and will be removed. Please use perl_delete_localpod instead."
341 tove 1.124 perl_delete_localpod
342     }
343    
344 dilfridge 1.148 # @FUNCTION: perl_delete_localpod
345     # @USAGE: perl_delete_localpod
346     # @DESCRIPTION:
347     # Remove stray perllocal.pod files in the temporary install directory D.
348     #
349     # This function used to be called fixlocalpod as well.
350 tove 1.124 perl_delete_localpod() {
351     debug-print-function $FUNCNAME "$@"
352    
353     find "${D}" -type f -name perllocal.pod -delete
354     find "${D}" -depth -mindepth 1 -type d -empty -delete
355     }
356    
357     perl_fix_osx_extra() {
358     debug-print-function $FUNCNAME "$@"
359    
360     # Remove "AppleDouble encoded Macintosh file"
361     local f
362     find "${S}" -type f -name "._*" -print0 | while read -rd '' f ; do
363     einfo "Removing AppleDouble encoded Macintosh file: ${f#${S}/}"
364     rm -f "${f}"
365     f=${f#${S}/}
366     # f=${f//\//\/}
367     # f=${f//\./\.}
368     # sed -i "/${f}/d" "${S}"/MANIFEST || die
369     grep -q "${f}" "${S}"/MANIFEST && \
370     elog "AppleDouble encoded Macintosh file in MANIFEST: ${f#${S}/}"
371     done
372     }
373    
374     perl_delete_module_manpages() {
375     debug-print-function $FUNCNAME "$@"
376    
377     if [[ -d "${ED}"/usr/share/man ]] ; then
378     # einfo "Cleaning out stray man files"
379     find "${ED}"/usr/share/man -type f -name "*.3pm" -delete
380     find "${ED}"/usr/share/man -depth -type d -empty -delete
381     fi
382     }
383    
384    
385     perl_delete_packlist() {
386     debug-print-function $FUNCNAME "$@"
387     perl_set_version
388 tove 1.125 if [[ -d ${D}/${VENDOR_ARCH} ]] ; then
389     find "${D}/${VENDOR_ARCH}" -type f -a \( -name .packlist \
390 tove 1.124 -o \( -name '*.bs' -a -empty \) \) -delete
391 tove 1.125 find "${D}" -depth -mindepth 1 -type d -empty -delete
392 tove 1.124 fi
393     }
394    
395     perl_remove_temppath() {
396     debug-print-function $FUNCNAME "$@"
397    
398     find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
399     if file "${f}" | grep -q -i " text" ; then
400     grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
401     sed -i -e "s:${D}:/:g" "${f}"
402     fi
403     done
404     }
405    
406 monsieurp 1.145 # @FUNCTION: perl_rm_files
407     # @USAGE: perl_rm_files "file_1" "file_2"
408     # @DESCRIPTION:
409     # Remove certain files from a Perl release and remove them from the MANIFEST
410     # while we're there.
411     #
412     # Most useful in src_prepare for nuking bad tests, and is highly recommended
413     # for any tests like 'pod.t', 'pod-coverage.t' or 'kwalitee.t', as what they
414     # test is completely irrelevant to end users, and frequently fail simply
415     # because the authors of Test::Pod... changed their recommendations, and thus
416     # failures are only useful feedback to Authors, not users.
417     #
418     # Removing from MANIFEST also avoids needless log messages warning
419     # users about files "missing from their kit".
420     perl_rm_files() {
421     debug-print-function $FUNCNAME "$@"
422     local skipfile="${T}/.gentoo_makefile_skip"
423     local manifile="${S}/MANIFEST"
424     local manitemp="${T}/.gentoo_manifest_temp"
425     oldifs="$IFS"
426     IFS="\n"
427     for filename in "$@"; do
428     einfo "Removing un-needed ${filename}";
429     # Remove the file
430     rm -f "${S}/${filename}"
431     [[ -e "${manifile}" ]] && echo "${filename}" >> "${skipfile}"
432     done
433     if [[ -e "${manifile}" && -e "${skipfile}" ]]; then
434     einfo "Fixing Manifest"
435     grep -v -F -f "${skipfile}" "${manifile}" > "${manitemp}"
436     mv -f -- "${manitemp}" "${manifile}"
437     rm -- "${skipfile}";
438     fi
439     IFS="$oldifs"
440     }
441    
442 tove 1.124 perl_link_duallife_scripts() {
443     debug-print-function $FUNCNAME "$@"
444     if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; then
445     return 0
446     fi
447    
448     local i ff
449     if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
450     for i in "${DUALLIFESCRIPTS[@]}" ; do
451 tove 1.130 alternatives_auto_makesym "/${i}" "/${i}-[0-9]*"
452     done
453     for i in "${DUALLIFEMAN[@]}" ; do
454     ff=`echo "${EROOT}"/${i%.1}-${PV}-${P}.1*`
455 tove 1.124 ff=${ff##*.1}
456 tove 1.130 alternatives_auto_makesym "/${i}${ff}" "/${i%.1}-[0-9]*"
457 tove 1.124 done
458     else
459     pushd "${ED}" > /dev/null
460     for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
461     mv ${i}{,-${PV}-${P}} || die
462 tove 1.130 #DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
463     DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i}
464     done
465     for i in $(find usr/share/man/man1 -maxdepth 1 -type f 2>/dev/null) ; do
466     mv ${i} ${i%.1}-${PV}-${P}.1 || die
467     DUALLIFEMAN[${#DUALLIFEMAN[*]}]=${i}
468 tove 1.124 done
469     popd > /dev/null
470     fi
471     }

  ViewVC Help
Powered by ViewVC 1.1.20