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

Contents of /eclass/perl-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.147 - (hide annotations) (download)
Sun Nov 9 18:10:24 2014 UTC (3 years, 8 months ago) by dilfridge
Branch: MAIN
Changes since 1.146: +14 -27 lines
All in-tree ebuilds with EAPI=4 using perl-module.eclass are gone. Switch deprecation message to super-annoying mode.

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.147 # $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.146 2014/11/05 00:24:33 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     perl_set_version
309     }
310    
311     perl_set_version() {
312     debug-print-function $FUNCNAME "$@"
313     debug-print "$FUNCNAME: perlinfo_done=${perlinfo_done}"
314     ${perlinfo_done} && return 0
315     perlinfo_done=true
316    
317     local f version install{{site,vendor}{arch,lib},archlib}
318     eval "$(perl -V:{version,install{{site,vendor}{arch,lib},archlib}} )"
319     PERL_VERSION=${version}
320     SITE_ARCH=${installsitearch}
321     SITE_LIB=${installsitelib}
322     ARCH_LIB=${installarchlib}
323     VENDOR_LIB=${installvendorlib}
324     VENDOR_ARCH=${installvendorarch}
325     }
326    
327     fixlocalpod() {
328     debug-print-function $FUNCNAME "$@"
329     perl_delete_localpod
330     }
331    
332     perl_delete_localpod() {
333     debug-print-function $FUNCNAME "$@"
334    
335     find "${D}" -type f -name perllocal.pod -delete
336     find "${D}" -depth -mindepth 1 -type d -empty -delete
337     }
338    
339     perl_fix_osx_extra() {
340     debug-print-function $FUNCNAME "$@"
341    
342     # Remove "AppleDouble encoded Macintosh file"
343     local f
344     find "${S}" -type f -name "._*" -print0 | while read -rd '' f ; do
345     einfo "Removing AppleDouble encoded Macintosh file: ${f#${S}/}"
346     rm -f "${f}"
347     f=${f#${S}/}
348     # f=${f//\//\/}
349     # f=${f//\./\.}
350     # sed -i "/${f}/d" "${S}"/MANIFEST || die
351     grep -q "${f}" "${S}"/MANIFEST && \
352     elog "AppleDouble encoded Macintosh file in MANIFEST: ${f#${S}/}"
353     done
354     }
355    
356     perl_delete_module_manpages() {
357     debug-print-function $FUNCNAME "$@"
358    
359     if [[ -d "${ED}"/usr/share/man ]] ; then
360     # einfo "Cleaning out stray man files"
361     find "${ED}"/usr/share/man -type f -name "*.3pm" -delete
362     find "${ED}"/usr/share/man -depth -type d -empty -delete
363     fi
364     }
365    
366    
367     perl_delete_packlist() {
368     debug-print-function $FUNCNAME "$@"
369     perl_set_version
370 tove 1.125 if [[ -d ${D}/${VENDOR_ARCH} ]] ; then
371     find "${D}/${VENDOR_ARCH}" -type f -a \( -name .packlist \
372 tove 1.124 -o \( -name '*.bs' -a -empty \) \) -delete
373 tove 1.125 find "${D}" -depth -mindepth 1 -type d -empty -delete
374 tove 1.124 fi
375     }
376    
377     perl_remove_temppath() {
378     debug-print-function $FUNCNAME "$@"
379    
380     find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
381     if file "${f}" | grep -q -i " text" ; then
382     grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
383     sed -i -e "s:${D}:/:g" "${f}"
384     fi
385     done
386     }
387    
388 monsieurp 1.145 # @FUNCTION: perl_rm_files
389     # @USAGE: perl_rm_files "file_1" "file_2"
390     # @DESCRIPTION:
391     # Remove certain files from a Perl release and remove them from the MANIFEST
392     # while we're there.
393     #
394     # Most useful in src_prepare for nuking bad tests, and is highly recommended
395     # for any tests like 'pod.t', 'pod-coverage.t' or 'kwalitee.t', as what they
396     # test is completely irrelevant to end users, and frequently fail simply
397     # because the authors of Test::Pod... changed their recommendations, and thus
398     # failures are only useful feedback to Authors, not users.
399     #
400     # Removing from MANIFEST also avoids needless log messages warning
401     # users about files "missing from their kit".
402     perl_rm_files() {
403     debug-print-function $FUNCNAME "$@"
404     local skipfile="${T}/.gentoo_makefile_skip"
405     local manifile="${S}/MANIFEST"
406     local manitemp="${T}/.gentoo_manifest_temp"
407     oldifs="$IFS"
408     IFS="\n"
409     for filename in "$@"; do
410     einfo "Removing un-needed ${filename}";
411     # Remove the file
412     rm -f "${S}/${filename}"
413     [[ -e "${manifile}" ]] && echo "${filename}" >> "${skipfile}"
414     done
415     if [[ -e "${manifile}" && -e "${skipfile}" ]]; then
416     einfo "Fixing Manifest"
417     grep -v -F -f "${skipfile}" "${manifile}" > "${manitemp}"
418     mv -f -- "${manitemp}" "${manifile}"
419     rm -- "${skipfile}";
420     fi
421     IFS="$oldifs"
422     }
423    
424 tove 1.124 perl_link_duallife_scripts() {
425     debug-print-function $FUNCNAME "$@"
426     if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; then
427     return 0
428     fi
429    
430     local i ff
431     if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
432     for i in "${DUALLIFESCRIPTS[@]}" ; do
433 tove 1.130 alternatives_auto_makesym "/${i}" "/${i}-[0-9]*"
434     done
435     for i in "${DUALLIFEMAN[@]}" ; do
436     ff=`echo "${EROOT}"/${i%.1}-${PV}-${P}.1*`
437 tove 1.124 ff=${ff##*.1}
438 tove 1.130 alternatives_auto_makesym "/${i}${ff}" "/${i%.1}-[0-9]*"
439 tove 1.124 done
440     else
441     pushd "${ED}" > /dev/null
442     for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
443     mv ${i}{,-${PV}-${P}} || die
444 tove 1.130 #DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
445     DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i}
446     done
447     for i in $(find usr/share/man/man1 -maxdepth 1 -type f 2>/dev/null) ; do
448     mv ${i} ${i%.1}-${PV}-${P}.1 || die
449     DUALLIFEMAN[${#DUALLIFEMAN[*]}]=${i}
450 tove 1.124 done
451     popd > /dev/null
452     fi
453     }

  ViewVC Help
Powered by ViewVC 1.1.20