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

Contents of /eclass/perl-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.146 - (hide annotations) (download)
Wed Nov 5 00:24:33 2014 UTC (3 years, 2 months ago) by dilfridge
Branch: MAIN
Changes since 1.145: +1 -11 lines
Remove unused function perl_set_eprefix

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

  ViewVC Help
Powered by ViewVC 1.1.20