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

Contents of /eclass/perl-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.145 - (hide annotations) (download)
Sat Nov 1 22:08:54 2014 UTC (4 years, 1 month ago) by monsieurp
Branch: MAIN
Changes since 1.144: +41 -1 lines
Introducing perl_rm_files() function. See #520756.

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

  ViewVC Help
Powered by ViewVC 1.1.20