/[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.39 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.39 2003/06/01 11:48:22 mcummings 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
30 yes)
18DEPEND="dev-lang/perl 31 DEPEND="dev-lang/perl[-build]"
19 >=dev-perl/ExtUtils-MakeMaker-6.05-r4 32 RDEPEND="${DEPEND}"
20 ${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
21SRC_PREP="no" 69SRC_PREP="no"
70SRC_TEST="skip"
71PREFER_BUILDPL="yes"
22 72
23SITE_LIB="" 73pm_echovar=""
24ARCH_LIB="" 74perlinfo_done=false
25POD_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}
26 93
27perl-module_src_prep() { 94perl-module_src_prep() {
28 95 debug-print-function $FUNCNAME "$@"
96 [[ ${SRC_PREP} = yes ]] && return 0
29 SRC_PREP="yes" 97 SRC_PREP="yes"
30 perl Makefile.PL ${myconf} \ 98
31 PREFIX=${D}/usr 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})
108 else
109 local myconf_local=("${myconf[@]}")
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
121 fi
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
32} 147}
33 148
34perl-module_src_compile() { 149perl-module_src_compile() {
150 debug-print-function $FUNCNAME "$@"
151 perl_set_version
35 152
36 [ "${SRC_PREP}" != "yes" ] && perl-module_src_prep 153 has src_configure ${PERL_EXPF} || perl-module_src_prep
37 make ${mymake} || die "compilation failed" 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 \
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}" \
172 fi
38} 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#
39 195
40perl-module_src_test() { 196perl-module_src_test() {
41 make test 197 debug-print-function $FUNCNAME "$@"
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
42} 210}
43 211
44perl-module_src_install() { 212perl-module_src_install() {
45 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})
229 else
230 local myinst_local=("${myinst[@]}")
231 fi
232
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
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
258perl-module_pkg_preinst() {
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
46 perlinfo 277perlinfo() {
47 dodir ${POD_DIR} 278 debug-print-function $FUNCNAME "$@"
48 279 perl_set_version
49 test -z ${mytargets} && mytargets="install" 280}
50 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}
51 SITE_ARCH=${installsitearch} 291 SITE_ARCH=${installsitearch}
52 eval `perl '-V:installarchlib'` 292 SITE_LIB=${installsitelib}
53 ARCH_LIB=${installarchlib} 293 ARCH_LIB=${installarchlib}
54 294 VENDOR_LIB=${installvendorlib}
55 295 VENDOR_ARCH=${installvendorarch}
56 make \ 296}
57 PREFIX=${D}/usr \
58 INSTALLMAN1DIR=${D}/usr/share/man/man1 \
59 INSTALLMAN2DIR=${D}/usr/share/man/man2 \
60 INSTALLMAN3DIR=${D}/usr/share/man/man3 \
61 INSTALLMAN4DIR=${D}/usr/share/man/man4 \
62 INSTALLMAN5DIR=${D}/usr/share/man/man5 \
63 INSTALLMAN6DIR=${D}/usr/share/man/man6 \
64 INSTALLMAN7DIR=${D}/usr/share/man/man7 \
65 INSTALLMAN8DIR=${D}/usr/share/man/man8 \
66 INSTALLSITEMAN1DIR=${D}/usr/share/man/man1 \
67 INSTALLSITEMAN2DIR=${D}/usr/share/man/man2 \
68 INSTALLSITEMAN3DIR=${D}/usr/share/man/man3 \
69 INSTALLSITEMAN4DIR=${D}/usr/share/man/man4 \
70 INSTALLSITEMAN5DIR=${D}/usr/share/man/man5 \
71 INSTALLSITEMAN6DIR=${D}/usr/share/man/man6 \
72 INSTALLSITEMAN7DIR=${D}/usr/share/man/man7 \
73 INSTALLSITEMAN8DIR=${D}/usr/share/man/man8 \
74 INSTALLSITEARCH=${D}/${SITE_ARCH} \
75 INSTALLSCRIPT=${D}/usr/bin \
76 ${myinst} \
77 ${mytargets} || die
78 297
298fixlocalpod() {
299 debug-print-function $FUNCNAME "$@"
300 perl_delete_localpod
301}
79 302
80 if [ -f ${D}${ARCH_LIB}/perllocal.pod ]; 303perl_delete_localpod() {
81 then 304 debug-print-function $FUNCNAME "$@"
82 touch ${D}/${POD_DIR}/${P}.pod
83 sed -e "s:${D}::g" \
84 ${D}${ARCH_LIB}/perllocal.pod >> ${D}/${POD_DIR}/${P}.pod
85 touch ${D}/${POD_DIR}/${P}.pod.arch
86 cat ${D}/${POD_DIR}/${P}.pod >>${D}/${POD_DIR}/${P}.pod.arch
87 rm -f ${D}/${ARCH_LIB}/perllocal.pod
88 fi
89
90 if [ -f ${D}${SITE_LIB}/perllocal.pod ];
91 then
92 touch ${D}/${POD_DIR}/${P}.pod
93 sed -e "s:${D}::g" \
94 ${D}${SITE_LIB}/perllocal.pod >> ${D}/${POD_DIR}/${P}.pod
95 touch ${D}/${POD_DIR}/${P}.pod.site
96 cat ${D}/${POD_DIR}/${P}.pod >>${D}/${POD_DIR}/${P}.pod.site
97 rm -f ${D}/${SITE_LIB}/perllocal.pod
98 fi
99 305
100 for FILE in `find ${D} -type f -name "*.html" -o -name ".packlist"`; do 306 find "${D}" -type f -name perllocal.pod -delete
101 sed -ie "s:${D}:/:g" ${FILE} 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}/}"
102 done 324 done
103
104 dodoc Change* MANIFEST* README* ${mydoc}
105} 325}
106 326
327perl_delete_module_manpages() {
328 debug-print-function $FUNCNAME "$@"
107 329
108perl-module_pkg_setup() { 330 perl_set_eprefix
109 331
110 perlinfo 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
111} 337}
112 338
113 339
114perl-module_pkg_preinst() { 340perl_delete_packlist() {
115 341 debug-print-function $FUNCNAME "$@"
116 perlinfo 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
117} 348}
118 349
119perl-module_pkg_postinst() { 350perl_remove_temppath() {
351 debug-print-function $FUNCNAME "$@"
120 352
121 updatepod 353 find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
122} 354 if file "${f}" | grep -q -i " text" ; then
123 355 grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
124perl-module_pkg_prerm() { 356 sed -i -e "s:${D}:/:g" "${f}"
125
126 updatepod
127}
128
129perl-module_pkg_postrm() {
130
131 updatepod
132}
133
134perlinfo() {
135
136 if [ -f /usr/bin/perl ]
137 then
138 eval `perl '-V:installarchlib'`
139 eval `perl '-V:installsitearch'`
140 ARCH_LIB=${installarchlib}
141 SITE_LIB=${installsitearch}
142
143 eval `perl '-V:version'`
144 POD_DIR="/usr/share/perl/gentoo-pods/${version}"
145 fi 357 fi
146 358 done
147} 359}
148 360
149updatepod() { 361perl_link_duallife_scripts() {
150 perlinfo 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
151 366
152 if [ -d "${POD_DIR}" ] 367 perl_set_eprefix
153 then 368
154 for FILE in `find ${POD_DIR} -type f -name "*.pod.arch"`; do 369 local i ff
155 cat ${FILE} >> ${ARCH_LIB}/perllocal.pod 370 if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
156 rm -f ${FILE} 371 for i in "${DUALLIFESCRIPTS[@]}" ; do
372 alternatives_auto_makesym "/${i}" "/${i}-[0-9]*"
157 done 373 done
158 for FILE in `find ${POD_DIR} -type f -name "*.pod.site"`; do 374 for i in "${DUALLIFEMAN[@]}" ; do
159 cat ${FILE} >> ${SITE_LIB}/perllocal.pod 375 ff=`echo "${EROOT}"/${i%.1}-${PV}-${P}.1*`
160 rm -f ${FILE} 376 ff=${ff##*.1}
377 alternatives_auto_makesym "/${i}${ff}" "/${i%.1}-[0-9]*"
161 done 378 done
162 379 else
163 #cat ${POD_DIR}/*.pod.arch >> ${ARCH_LIB}/perllocal.pod 380 pushd "${ED}" > /dev/null
164 #cat ${POD_DIR}/*.pod.site >> ${SITE_LIB}/perllocal.pod 381 for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
165 #rm -f ${POD_DIR}/*.pod.site 382 mv ${i}{,-${PV}-${P}} || die
166 #rm -f ${POD_DIR}/*.pod.site 383 #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 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}
167 fi 402 fi
403 ;;
404 esac
168} 405}

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

  ViewVC Help
Powered by ViewVC 1.1.20