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

Contents of /eclass/perl-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.164 - (hide annotations) (download)
Sun Mar 15 17:23:09 2015 UTC (3 years, 8 months ago) by dilfridge
Branch: MAIN
Changes since 1.163: +84 -21 lines
Detect dangerous environment variables, bug 543042; support Module::Build::Tiny directly, bug 495044

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

  ViewVC Help
Powered by ViewVC 1.1.20