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

Diff of /eclass/perl-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.45.2.1 Revision 1.132
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2011 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.45.2.1 2003/07/25 20:24:36 avenj Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.132 2012/04/15 20:15:39 vapier Exp $
4# 4
5# @ECLASS: perl-module.eclass
6# @MAINTAINER:
7# perl@gentoo.org
8# @AUTHOR:
5# Author: Seemant Kulleen <seemant@gentoo.org> 9# Seemant Kulleen <seemant@gentoo.org>
6# 10# @BLURB: eclass for perl modules
11# @DESCRIPTION:
7# The perl-module eclass is designed to allow easier installation of perl 12# The perl-module eclass is designed to allow easier installation of perl
8# modules, and their incorporation into the Gentoo Linux system. 13# modules, and their incorporation into the Gentoo Linux system.
9 14
10ECLASS=perl-module 15inherit eutils base
11INHERITED="${INHERITED} ${ECLASS}" 16[[ ${CATEGORY} == "perl-core" ]] && inherit alternatives
12 17
18PERL_EXPF="src_unpack src_compile src_test src_install"
19
20case "${EAPI:-0}" in
21 0|1)
13EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm \ 22 PERL_EXPF+=" pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm"
14 src_compile src_install src_test \ 23 ;;
15 perlinfo updatepod 24 2|3|4)
25 PERL_EXPF+=" src_prepare src_configure"
26 [[ ${CATEGORY} == "perl-core" ]] && \
27 PERL_EXPF+=" pkg_postinst pkg_postrm"
16 28
17eval `perl '-V:version'` 29 case "${GENTOO_DEPEND_ON_PERL:-yes}" in
18newdepend ">=dev-lang/perl-5.8.0-r12" 30 yes)
31 DEPEND="dev-lang/perl[-build]"
32 RDEPEND="${DEPEND}"
33 ;;
34 esac
35 ;;
36 *)
37 die "EAPI=${EAPI} is not supported by perl-module.eclass"
38 ;;
39esac
40
41case "${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 die "PERL_EXPORT_PHASE_FUNCTIONS=${PERL_EXPORT_PHASE_FUNCTIONS} is not supported by perl-module.eclass"
50 ;;
51esac
52
53DESCRIPTION="Based on the $ECLASS eclass"
54
55LICENSE="${LICENSE:-|| ( Artistic GPL-1 GPL-2 GPL-3 )}"
56
57if [[ -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}}
60fi
61
62[[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && \
63 MODULE_A="${MY_P:-${P}}.${MODULE_A_EXT:-tar.gz}"
64[[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
65 SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION:+${MODULE_SECTION}/}${MODULE_A}"
66[[ -z "${HOMEPAGE}" ]] && \
67 HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}/"
68
19SRC_PREP="no" 69SRC_PREP="no"
70SRC_TEST="skip"
71PREFER_BUILDPL="yes"
20 72
21SITE_LIB="" 73pm_echovar=""
22ARCH_LIB="" 74perlinfo_done=false
23POD_DIR="" 75
76perl-module_src_unpack() {
77 debug-print-function $FUNCNAME "$@"
78 base_src_unpack
79 has src_prepare ${PERL_EXPF} || perl-module_src_prepare
80}
81
82perl-module_src_prepare() {
83 debug-print-function $FUNCNAME "$@"
84 has src_prepare ${PERL_EXPF} && base_src_prepare
85 perl_fix_osx_extra
86 esvn_clean
87}
88
89perl-module_src_configure() {
90 debug-print-function $FUNCNAME "$@"
91 perl-module_src_prep
92}
24 93
25perl-module_src_prep() { 94perl-module_src_prep() {
26 95 debug-print-function $FUNCNAME "$@"
96 [[ ${SRC_PREP} = yes ]] && return 0
27 SRC_PREP="yes" 97 SRC_PREP="yes"
28 if [ "${style}" == "builder" ]; then 98
29 perl ${S}/Build.PL destdir=${D} 99 perl_set_version
100 perl_set_eprefix
101
102 [[ -z ${pm_echovar} ]] && export PERL_MM_USE_DEFAULT=1
103 # Disable ExtUtils::AutoInstall from prompting
104 export PERL_EXTUTILS_AUTOINSTALL="--skipdeps"
105
106 if [[ $(declare -p myconf 2>&-) != "declare -a myconf="* ]]; then
107 local myconf_local=(${myconf})
30 else 108 else
31 perl Makefile.PL INSTALLDIRS=vendor ${myconf} \ 109 local myconf_local=("${myconf[@]}")
32 PREFIX=${D}/usr 110 fi
111
112 if [[ ( ${PREFER_BUILDPL} == yes || ! -f Makefile.PL ) && -f Build.PL ]] ; then
113 einfo "Using Module::Build"
114 if [[ ${DEPEND} != *virtual/perl-Module-Build* && ${PN} != Module-Build ]] ; then
115 eqawarn "QA Notice: The ebuild uses Module::Build but doesn't depend on it."
116 eqawarn " Add virtual/perl-Module-Build to DEPEND!"
117 if [[ -n ${PERLQAFATAL} ]]; then
118 eerror "Bailing out due to PERLQAFATAL=1";
119 die;
120 fi
33 fi 121 fi
34 122 set -- \
123 --installdirs=vendor \
124 --libdoc= \
125 --destdir="${D}" \
126 --create_packlist=0 \
127 "${myconf_local[@]}"
128 einfo "perl Build.PL" "$@"
129 perl Build.PL "$@" <<< "${pm_echovar}" \
130 || die "Unable to build!"
131 elif [[ -f Makefile.PL ]] ; then
132 einfo "Using ExtUtils::MakeMaker"
133 set -- \
134 PREFIX=${EPREFIX}/usr \
135 INSTALLDIRS=vendor \
136 INSTALLMAN3DIR='none' \
137 DESTDIR="${D}" \
138 "${myconf_local[@]}"
139 einfo "perl Makefile.PL" "$@"
140 perl Makefile.PL "$@" <<< "${pm_echovar}" \
141 || die "Unable to build!"
142 fi
143 if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then
144 einfo "No Make or Build file detected..."
145 return
146 fi
35} 147}
36 148
37perl-module_src_compile() { 149perl-module_src_compile() {
150 debug-print-function $FUNCNAME "$@"
151 perl_set_version
38 152
39 [ "${SRC_PREP}" != "yes" ] && perl-module_src_prep 153 has src_configure ${PERL_EXPF} || perl-module_src_prep
40 if [ "${style}" != "builder" ]; then 154
155 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 if [[ -f Build ]] ; then
162 ./Build build \
41 make ${mymake} || die "compilation failed" 163 || die "Compilation failed"
164 elif [[ -f Makefile ]] ; then
165 set -- \
166 OTHERLDFLAGS="${LDFLAGS}" \
167 "${mymake_local[@]}"
168 einfo "emake" "$@"
169 emake "$@" \
170 || die "Compilation failed"
171# OPTIMIZE="${CFLAGS}" \
42 fi 172 fi
43
44} 173}
174
175# 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#
45 195
46perl-module_src_test() { 196perl-module_src_test() {
47 if [ "${style}" == "builder" ]; then 197 debug-print-function $FUNCNAME "$@"
48 perl ${S}/Build test 198 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$(makeopts_jobs)
201 einfo "Test::Harness Jobs=$(makeopts_jobs)"
202 fi
203 ${perlinfo_done} || perl_set_version
204 if [[ -f Build ]] ; then
205 ./Build test verbose=${TEST_VERBOSE:-0} || die "test failed"
206 elif [[ -f Makefile ]] ; then
207 emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test failed"
208 fi
209 fi
210}
211
212perl-module_src_install() {
213 debug-print-function $FUNCNAME "$@"
214
215 perl_set_version
216 perl_set_eprefix
217
218 local f
219
220 if [[ -z ${mytargets} ]] ; then
221 case "${CATEGORY}" in
222 dev-perl|perl-core) mytargets="pure_install" ;;
223 *) mytargets="install" ;;
224 esac
225 fi
226
227 if [[ $(declare -p myinst 2>&-) != "declare -a myinst="* ]]; then
228 local myinst_local=(${myinst})
49 else 229 else
50 make test 230 local myinst_local=("${myinst[@]}")
51 fi 231 fi
52 232
53} 233 if [[ -f Build ]] ; then
234 ./Build ${mytargets} \
235 || die "./Build ${mytargets} failed"
236 elif [[ -f Makefile ]] ; then
237 emake "${myinst_local[@]}" ${mytargets} \
238 || die "emake ${myinst_local[@]} ${mytargets} failed"
239 fi
54 240
241 perl_delete_module_manpages
242 perl_delete_localpod
243 perl_delete_packlist
244 perl_remove_temppath
245
246 for f in Change* CHANGES README* TODO FAQ ${mydoc}; do
247 [[ -s ${f} ]] && dodoc ${f}
248 done
249
250 perl_link_duallife_scripts
251}
252
253perl-module_pkg_setup() {
254 debug-print-function $FUNCNAME "$@"
255 perl_set_version
256}
257
55perl-module_src_install() { 258perl-module_pkg_preinst() {
56 259 debug-print-function $FUNCNAME "$@"
260 perl_set_version
261}
262
263perl-module_pkg_postinst() {
264 debug-print-function $FUNCNAME "$@"
265 perl_link_duallife_scripts
266}
267
268perl-module_pkg_prerm() {
269 debug-print-function $FUNCNAME "$@"
270}
271
272perl-module_pkg_postrm() {
273 debug-print-function $FUNCNAME "$@"
274 perl_link_duallife_scripts
275}
276
57 perlinfo 277perlinfo() {
58 dodir ${POD_DIR} 278 debug-print-function $FUNCNAME "$@"
59 279 perl_set_version
60 test -z ${mytargets} && mytargets="install" 280}
61 eval `perl '-V:installsitearch'` 281
282perl_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}
62 SITE_ARCH=${installsitearch} 291 SITE_ARCH=${installsitearch}
63 eval `perl '-V:installarchlib'` 292 SITE_LIB=${installsitelib}
64 ARCH_LIB=${installarchlib} 293 ARCH_LIB=${installarchlib}
65 294 VENDOR_LIB=${installvendorlib}
66 if [ "${style}" == "builder" ]; then 295 VENDOR_ARCH=${installvendorarch}
67 perl ${S}/Build install 296}
297
298fixlocalpod() {
299 debug-print-function $FUNCNAME "$@"
300 perl_delete_localpod
301}
302
303perl_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
310perl_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
327perl_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
340perl_delete_packlist() {
341 debug-print-function $FUNCNAME "$@"
342 perl_set_version
343 if [[ -d ${D}/${VENDOR_ARCH} ]] ; then
344 find "${D}/${VENDOR_ARCH}" -type f -a \( -name .packlist \
345 -o \( -name '*.bs' -a -empty \) \) -delete
346 find "${D}" -depth -mindepth 1 -type d -empty -delete
347 fi
348}
349
350perl_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
361perl_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 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 ff=${ff##*.1}
377 alternatives_auto_makesym "/${i}${ff}" "/${i%.1}-[0-9]*"
378 done
68 else 379 else
69 make \ 380 pushd "${ED}" > /dev/null
70 PREFIX=${D}/usr \ 381 for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
71 INSTALLMAN1DIR=${D}/usr/share/man/man1 \ 382 mv ${i}{,-${PV}-${P}} || die
72 INSTALLMAN2DIR=${D}/usr/share/man/man2 \ 383 #DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
73 INSTALLMAN3DIR=${D}/usr/share/man/man3 \ 384 DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i}
74 INSTALLMAN4DIR=${D}/usr/share/man/man4 \
75 INSTALLMAN5DIR=${D}/usr/share/man/man5 \
76 INSTALLMAN6DIR=${D}/usr/share/man/man6 \
77 INSTALLMAN7DIR=${D}/usr/share/man/man7 \
78 INSTALLMAN8DIR=${D}/usr/share/man/man8 \
79 INSTALLSITEMAN1DIR=${D}/usr/share/man/man1 \
80 INSTALLSITEMAN2DIR=${D}/usr/share/man/man2 \
81 INSTALLSITEMAN3DIR=${D}/usr/share/man/man3 \
82 INSTALLSITEMAN4DIR=${D}/usr/share/man/man4 \
83 INSTALLSITEMAN5DIR=${D}/usr/share/man/man5 \
84 INSTALLSITEMAN6DIR=${D}/usr/share/man/man6 \
85 INSTALLSITEMAN7DIR=${D}/usr/share/man/man7 \
86 INSTALLSITEMAN8DIR=${D}/usr/share/man/man8 \
87 INSTALLSITEARCH=${D}/${SITE_ARCH} \
88 INSTALLSCRIPT=${D}/usr/bin \
89 ${myinst} \
90 ${mytargets} || die
91 fi
92
93 if [ -f ${D}${ARCH_LIB}/perllocal.pod ];
94 then
95 touch ${D}/${POD_DIR}/${P}.pod
96 sed -e "s:${D}::g" \
97 ${D}${ARCH_LIB}/perllocal.pod >> ${D}/${POD_DIR}/${P}.pod
98 touch ${D}/${POD_DIR}/${P}.pod.arch
99 cat ${D}/${POD_DIR}/${P}.pod >>${D}/${POD_DIR}/${P}.pod.arch
100 rm -f ${D}/${ARCH_LIB}/perllocal.pod
101 fi
102
103 if [ -f ${D}${SITE_LIB}/perllocal.pod ];
104 then
105 touch ${D}/${POD_DIR}/${P}.pod
106 sed -e "s:${D}::g" \
107 ${D}${SITE_LIB}/perllocal.pod >> ${D}/${POD_DIR}/${P}.pod
108 touch ${D}/${POD_DIR}/${P}.pod.site
109 cat ${D}/${POD_DIR}/${P}.pod >>${D}/${POD_DIR}/${P}.pod.site
110 rm -f ${D}/${SITE_LIB}/perllocal.pod
111 fi
112
113 for FILE in `find ${D} -type f -name "*.html" -o -name ".packlist"`; do
114 sed -i -e "s:${D}:/:g" ${FILE}
115 done
116
117 dodoc Change* MANIFEST* README* ${mydoc}
118}
119
120
121perl-module_pkg_setup() {
122
123 perlinfo
124}
125
126
127perl-module_pkg_preinst() {
128
129 perlinfo
130}
131
132perl-module_pkg_postinst() {
133
134 updatepod
135}
136
137perl-module_pkg_prerm() {
138
139 updatepod
140}
141
142perl-module_pkg_postrm() {
143
144 updatepod
145}
146
147perlinfo() {
148
149 if [ -f /usr/bin/perl ]
150 then
151 eval `perl '-V:installarchlib'`
152 eval `perl '-V:installsitearch'`
153 ARCH_LIB=${installarchlib}
154 SITE_LIB=${installsitearch}
155
156 eval `perl '-V:version'`
157 POD_DIR="/usr/share/perl/gentoo-pods/${version}"
158 fi
159
160}
161
162updatepod() {
163 perlinfo
164
165 if [ -d "${POD_DIR}" ]
166 then
167 for FILE in `find ${POD_DIR} -type f -name "*.pod.arch"`; do
168 cat ${FILE} >> ${ARCH_LIB}/perllocal.pod
169 rm -f ${FILE}
170 done 385 done
171 for FILE in `find ${POD_DIR} -type f -name "*.pod.site"`; do 386 for i in $(find usr/share/man/man1 -maxdepth 1 -type f 2>/dev/null) ; do
172 cat ${FILE} >> ${SITE_LIB}/perllocal.pod 387 mv ${i} ${i%.1}-${PV}-${P}.1 || die
173 rm -f ${FILE} 388 DUALLIFEMAN[${#DUALLIFEMAN[*]}]=${i}
174 done 389 done
390 popd > /dev/null
391 fi
392}
393
394perl_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}
175 fi 402 fi
403 ;;
404 esac
176} 405}

Legend:
Removed from v.1.45.2.1  
changed lines
  Added in v.1.132

  ViewVC Help
Powered by ViewVC 1.1.20