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

Contents of /eclass/perl-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.130 - (hide annotations) (download)
Tue Aug 9 11:48:31 2011 UTC (3 years ago) by tove
Branch: MAIN
Changes since 1.129: +14 -11 lines
Add dual-life scripts and man pages in two arrays. PERL_MM_USE_DEFAULT suppressed pm_echovar.

1 tove 1.117 # Copyright 1999-2009 Gentoo Foundation
2 vapier 1.30 # Distributed under the terms of the GNU General Public License v2
3 tove 1.130 # $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.126 2010/07/15 11:44:48 tove Exp $
4 vapier 1.33 #
5 seemant 1.1 # Author: Seemant Kulleen <seemant@gentoo.org>
6 tove 1.113
7     # @ECLASS: perl-module.eclass
8     # @MAINTAINER:
9     # perl@gentoo.org
10     # @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 tove 1.124 inherit eutils base
16     [[ ${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     0|1)
22 tove 1.124 PERL_EXPF+=" pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm"
23 tove 1.113 ;;
24 tove 1.129 2|3|4)
25 tove 1.124 PERL_EXPF+=" src_prepare src_configure"
26 tove 1.117 [[ ${CATEGORY} == "perl-core" ]] && \
27 tove 1.124 PERL_EXPF+=" pkg_postinst pkg_postrm"
28 tove 1.113
29     case "${GENTOO_DEPEND_ON_PERL:-yes}" in
30     yes)
31     DEPEND="dev-lang/perl[-build]"
32     RDEPEND="${DEPEND}"
33     ;;
34     esac
35     ;;
36 tove 1.123 *)
37 tove 1.127 die "EAPI=${EAPI} is not supported by perl-module.eclass"
38 tove 1.123 ;;
39 tove 1.113 esac
40 danarmak 1.13
41 tove 1.124 case "${PERL_EXPORT_PHASE_FUNCTIONS:-yes}" in
42     yes)
43     EXPORT_FUNCTIONS ${PERL_EXPF}
44     ;;
45     no)
46     debug-print "PERL_EXPORT_PHASE_FUNCTIONS=no"
47     ;;
48     *)
49 tove 1.127 die "PERL_EXPORT_PHASE_FUNCTIONS=${PERL_EXPORT_PHASE_FUNCTIONS} is not supported by perl-module.eclass"
50 tove 1.124 ;;
51     esac
52 tove 1.117
53 tove 1.113 DESCRIPTION="Based on the $ECLASS eclass"
54 seemant 1.1
55 hanno 1.122 LICENSE="${LICENSE:-|| ( Artistic GPL-1 GPL-2 GPL-3 )}"
56 robbat2 1.109
57 tove 1.127 if [[ -n ${MY_PN} || -n ${MY_PV} || -n ${MODULE_VERSION} ]] ; then
58     : ${MY_P:=${MY_PN:-${PN}}-${MY_PV:-${MODULE_VERSION:-${PV}}}}
59     S=${MY_S:-${WORKDIR}/${MY_P}}
60     fi
61 tove 1.130
62 robbat2 1.128 [[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && \
63     MODULE_A="${MY_P:-${P}}.${MODULE_A_EXT:-tar.gz}"
64 tove 1.113 [[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
65 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}"
66 tove 1.113 [[ -z "${HOMEPAGE}" ]] && \
67 tove 1.118 HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}/"
68 mcummings 1.66
69 azarah 1.11 SRC_PREP="no"
70 rac 1.55 SRC_TEST="skip"
71 mcummings 1.97 PREFER_BUILDPL="yes"
72 azarah 1.11
73 mcummings 1.101 pm_echovar=""
74 tove 1.113 perlinfo_done=false
75 seemant 1.35
76 mcummings 1.102 perl-module_src_unpack() {
77 tove 1.123 debug-print-function $FUNCNAME "$@"
78 tove 1.121 base_src_unpack
79 tove 1.117 has src_prepare ${PERL_EXPF} || perl-module_src_prepare
80 tove 1.113 }
81    
82     perl-module_src_prepare() {
83 tove 1.123 debug-print-function $FUNCNAME "$@"
84 tove 1.121 has src_prepare ${PERL_EXPF} && base_src_prepare
85 tove 1.123 perl_fix_osx_extra
86 tove 1.113 esvn_clean
87     }
88    
89     perl-module_src_configure() {
90 tove 1.123 debug-print-function $FUNCNAME "$@"
91 tove 1.113 perl-module_src_prep
92 mcummings 1.102 }
93    
94 aliz 1.15 perl-module_src_prep() {
95 tove 1.123 debug-print-function $FUNCNAME "$@"
96 tove 1.117 [[ ${SRC_PREP} = yes ]] && return 0
97 tove 1.113 SRC_PREP="yes"
98 rac 1.60
99 tove 1.123 perl_set_version
100     perl_set_eprefix
101 rac 1.60
102 tove 1.130 [[ -z ${pm_echovar} ]] && export PERL_MM_USE_DEFAULT=1
103 mcummings 1.90 # Disable ExtUtils::AutoInstall from prompting
104     export PERL_EXTUTILS_AUTOINSTALL="--skipdeps"
105 rac 1.64
106 tove 1.127 if [[ $(declare -p myconf 2>&-) != "declare -a myconf="* ]]; then
107     local myconf_local=(${myconf})
108     else
109     local myconf_local=("${myconf[@]}")
110     fi
111    
112     if [[ ( ${PREFER_BUILDPL} == yes || ! -f Makefile.PL ) && -f Build.PL ]] ; then
113 mcummings 1.97 einfo "Using Module::Build"
114 tove 1.120 if [[ ${DEPEND} != *virtual/perl-Module-Build* && ${PN} != Module-Build ]] ; then
115 tove 1.126 eqawarn "QA Notice: The ebuild uses Module::Build but doesn't depend on it."
116     eqawarn " Add virtual/perl-Module-Build to DEPEND!"
117 tove 1.127 if [[ -n ${PERLQAFATAL} ]]; then
118     eerror "Bailing out due to PERLQAFATAL=1";
119     die;
120     fi
121 tove 1.120 fi
122 tove 1.123 set -- \
123 tove 1.113 --installdirs=vendor \
124     --libdoc= \
125     --destdir="${D}" \
126     --create_packlist=0 \
127 tove 1.127 "${myconf_local[@]}"
128 tove 1.123 einfo "perl Build.PL" "$@"
129     perl Build.PL "$@" <<< "${pm_echovar}" \
130 tove 1.127 || die "Unable to build!"
131 tove 1.113 elif [[ -f Makefile.PL ]] ; then
132 mcummings 1.85 einfo "Using ExtUtils::MakeMaker"
133 tove 1.123 set -- \
134     PREFIX=${EPREFIX}/usr \
135 tove 1.113 INSTALLDIRS=vendor \
136     INSTALLMAN3DIR='none' \
137     DESTDIR="${D}" \
138 tove 1.127 "${myconf_local[@]}"
139 tove 1.123 einfo "perl Makefile.PL" "$@"
140     perl Makefile.PL "$@" <<< "${pm_echovar}" \
141 tove 1.127 || die "Unable to build!"
142 mcummings 1.88 fi
143 tove 1.113 if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then
144 mcummings 1.88 einfo "No Make or Build file detected..."
145 mcummings 1.85 return
146 mcummings 1.43 fi
147 azarah 1.11 }
148    
149 aliz 1.15 perl-module_src_compile() {
150 tove 1.123 debug-print-function $FUNCNAME "$@"
151     perl_set_version
152 tove 1.113
153 tove 1.117 has src_configure ${PERL_EXPF} || perl-module_src_prep
154 seemant 1.6
155 tove 1.127 if [[ $(declare -p mymake 2>&-) != "declare -a mymake="* ]]; then
156     local mymake_local=(${mymake})
157     else
158     local mymake_local=("${mymake[@]}")
159     fi
160    
161 tove 1.113 if [[ -f Build ]] ; then
162     ./Build build \
163 tove 1.127 || die "Compilation failed"
164 tove 1.113 elif [[ -f Makefile ]] ; then
165 tove 1.127 set -- \
166 tove 1.113 OTHERLDFLAGS="${LDFLAGS}" \
167 tove 1.127 "${mymake_local[@]}"
168     einfo "emake" "$@"
169     emake "$@" \
170     || die "Compilation failed"
171 tove 1.113 # OPTIMIZE="${CFLAGS}" \
172 mcummings 1.43 fi
173 seemant 1.8 }
174    
175 tove 1.117 # For testers:
176     # This code attempts to work out your threadingness from MAKEOPTS
177     # and apply them to Test::Harness.
178     #
179     # If you want more verbose testing, set TEST_VERBOSE=1
180     # in your bashrc | /etc/make.conf | ENV
181     #
182     # For ebuild writers:
183     # If you wish to enable default tests w/ 'make test' ,
184     #
185     # SRC_TEST="do"
186     #
187     # If you wish to have threads run in parallel ( using the users makeopts )
188     # all of the following have been tested to work.
189     #
190     # SRC_TEST="do parallel"
191     # SRC_TEST="parallel"
192     # SRC_TEST="parallel do"
193     # SRC_TEST=parallel
194     #
195    
196 aliz 1.15 perl-module_src_test() {
197 tove 1.123 debug-print-function $FUNCNAME "$@"
198 tove 1.117 if has 'do' ${SRC_TEST} || has 'parallel' ${SRC_TEST} ; then
199     if has "${TEST_VERBOSE:-0}" 0 && has 'parallel' ${SRC_TEST} ; then
200     export HARNESS_OPTIONS=j$(echo -j1 ${MAKEOPTS} | sed -r "s/.*(-j\s*|--jobs=)([0-9]+).*/\2/" )
201     einfo "Test::Harness Jobs=${HARNESS_OPTIONS}"
202     fi
203 tove 1.123 ${perlinfo_done} || perl_set_version
204 tove 1.113 if [[ -f Build ]] ; then
205 tove 1.117 ./Build test verbose=${TEST_VERBOSE:-0} || die "test failed"
206 tove 1.113 elif [[ -f Makefile ]] ; then
207 tove 1.117 emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test failed"
208 mcummings 1.68 fi
209 mcummings 1.43 fi
210 seemant 1.1 }
211    
212 aliz 1.15 perl-module_src_install() {
213 tove 1.123 debug-print-function $FUNCNAME "$@"
214    
215     perl_set_version
216     perl_set_eprefix
217    
218 tove 1.113 local f
219 swegener 1.76
220 tove 1.114 if [[ -z ${mytargets} ]] ; then
221     case "${CATEGORY}" in
222     dev-perl|perl-core) mytargets="pure_install" ;;
223     *) mytargets="install" ;;
224     esac
225     fi
226 swegener 1.76
227 tove 1.127 if [[ $(declare -p myinst 2>&-) != "declare -a myinst="* ]]; then
228     local myinst_local=(${myinst})
229     else
230     local myinst_local=("${myinst[@]}")
231     fi
232    
233 tove 1.113 if [[ -f Build ]] ; then
234     ./Build ${mytargets} \
235     || die "./Build ${mytargets} failed"
236     elif [[ -f Makefile ]] ; then
237 tove 1.127 emake "${myinst_local[@]}" ${mytargets} \
238     || die "emake ${myinst_local[@]} ${mytargets} failed"
239 tove 1.113 fi
240    
241 tove 1.123 perl_delete_module_manpages
242     perl_delete_localpod
243     perl_delete_packlist
244     perl_remove_temppath
245 mcummings 1.20
246 tove 1.123 for f in Change* CHANGES README* TODO FAQ ${mydoc}; do
247 tove 1.117 [[ -s ${f} ]] && dodoc ${f}
248 mcummings 1.98 done
249 mcummings 1.65
250 tove 1.123 perl_link_duallife_scripts
251 seemant 1.35 }
252    
253     perl-module_pkg_setup() {
254 tove 1.123 debug-print-function $FUNCNAME "$@"
255     perl_set_version
256 seemant 1.35 }
257    
258     perl-module_pkg_preinst() {
259 tove 1.123 debug-print-function $FUNCNAME "$@"
260     perl_set_version
261 seemant 1.35 }
262    
263 tove 1.117 perl-module_pkg_postinst() {
264 tove 1.123 debug-print-function $FUNCNAME "$@"
265     perl_link_duallife_scripts
266 tove 1.117 }
267 seemant 1.35
268 tove 1.123 perl-module_pkg_prerm() {
269     debug-print-function $FUNCNAME "$@"
270     }
271 seemant 1.35
272 tove 1.117 perl-module_pkg_postrm() {
273 tove 1.123 debug-print-function $FUNCNAME "$@"
274     perl_link_duallife_scripts
275 tove 1.117 }
276 tove 1.124
277     perlinfo() {
278     debug-print-function $FUNCNAME "$@"
279     perl_set_version
280     }
281    
282     perl_set_version() {
283     debug-print-function $FUNCNAME "$@"
284     debug-print "$FUNCNAME: perlinfo_done=${perlinfo_done}"
285     ${perlinfo_done} && return 0
286     perlinfo_done=true
287    
288     local f version install{{site,vendor}{arch,lib},archlib}
289     eval "$(perl -V:{version,install{{site,vendor}{arch,lib},archlib}} )"
290     PERL_VERSION=${version}
291     SITE_ARCH=${installsitearch}
292     SITE_LIB=${installsitelib}
293     ARCH_LIB=${installarchlib}
294     VENDOR_LIB=${installvendorlib}
295     VENDOR_ARCH=${installvendorarch}
296     }
297    
298     fixlocalpod() {
299     debug-print-function $FUNCNAME "$@"
300     perl_delete_localpod
301     }
302    
303     perl_delete_localpod() {
304     debug-print-function $FUNCNAME "$@"
305    
306     find "${D}" -type f -name perllocal.pod -delete
307     find "${D}" -depth -mindepth 1 -type d -empty -delete
308     }
309    
310     perl_fix_osx_extra() {
311     debug-print-function $FUNCNAME "$@"
312    
313     # Remove "AppleDouble encoded Macintosh file"
314     local f
315     find "${S}" -type f -name "._*" -print0 | while read -rd '' f ; do
316     einfo "Removing AppleDouble encoded Macintosh file: ${f#${S}/}"
317     rm -f "${f}"
318     f=${f#${S}/}
319     # f=${f//\//\/}
320     # f=${f//\./\.}
321     # sed -i "/${f}/d" "${S}"/MANIFEST || die
322     grep -q "${f}" "${S}"/MANIFEST && \
323     elog "AppleDouble encoded Macintosh file in MANIFEST: ${f#${S}/}"
324     done
325     }
326    
327     perl_delete_module_manpages() {
328     debug-print-function $FUNCNAME "$@"
329    
330     perl_set_eprefix
331    
332     if [[ -d "${ED}"/usr/share/man ]] ; then
333     # einfo "Cleaning out stray man files"
334     find "${ED}"/usr/share/man -type f -name "*.3pm" -delete
335     find "${ED}"/usr/share/man -depth -type d -empty -delete
336     fi
337     }
338    
339    
340     perl_delete_packlist() {
341     debug-print-function $FUNCNAME "$@"
342     perl_set_version
343 tove 1.125 if [[ -d ${D}/${VENDOR_ARCH} ]] ; then
344     find "${D}/${VENDOR_ARCH}" -type f -a \( -name .packlist \
345 tove 1.124 -o \( -name '*.bs' -a -empty \) \) -delete
346 tove 1.125 find "${D}" -depth -mindepth 1 -type d -empty -delete
347 tove 1.124 fi
348     }
349    
350     perl_remove_temppath() {
351     debug-print-function $FUNCNAME "$@"
352    
353     find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
354     if file "${f}" | grep -q -i " text" ; then
355     grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
356     sed -i -e "s:${D}:/:g" "${f}"
357     fi
358     done
359     }
360    
361     perl_link_duallife_scripts() {
362     debug-print-function $FUNCNAME "$@"
363     if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; then
364     return 0
365     fi
366    
367     perl_set_eprefix
368    
369     local i ff
370     if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
371     for i in "${DUALLIFESCRIPTS[@]}" ; do
372 tove 1.130 alternatives_auto_makesym "/${i}" "/${i}-[0-9]*"
373     done
374     for i in "${DUALLIFEMAN[@]}" ; do
375     ff=`echo "${EROOT}"/${i%.1}-${PV}-${P}.1*`
376 tove 1.124 ff=${ff##*.1}
377 tove 1.130 alternatives_auto_makesym "/${i}${ff}" "/${i%.1}-[0-9]*"
378 tove 1.124 done
379     else
380     pushd "${ED}" > /dev/null
381     for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
382     mv ${i}{,-${PV}-${P}} || die
383 tove 1.130 #DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
384     DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i}
385     done
386     for i in $(find usr/share/man/man1 -maxdepth 1 -type f 2>/dev/null) ; do
387     mv ${i} ${i%.1}-${PV}-${P}.1 || die
388     DUALLIFEMAN[${#DUALLIFEMAN[*]}]=${i}
389 tove 1.124 done
390     popd > /dev/null
391     fi
392     }
393    
394     perl_set_eprefix() {
395     debug-print-function $FUNCNAME "$@"
396     case ${EAPI:-0} in
397     0|1|2)
398     if ! use prefix; then
399     EPREFIX=
400     ED=${D}
401     EROOT=${ROOT}
402     fi
403     ;;
404     esac
405     }

  ViewVC Help
Powered by ViewVC 1.1.20