/[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.118 Revision 1.124
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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.118 2009/11/10 12:53:53 tove Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.124 2010/04/22 11:43:30 tove Exp $
4# 4#
5# Author: Seemant Kulleen <seemant@gentoo.org> 5# Author: Seemant Kulleen <seemant@gentoo.org>
6 6
7# @ECLASS: perl-module.eclass 7# @ECLASS: perl-module.eclass
8# @MAINTAINER: 8# @MAINTAINER:
17 17
18PERL_EXPF="src_unpack src_compile src_test src_install" 18PERL_EXPF="src_unpack src_compile src_test src_install"
19 19
20case "${EAPI:-0}" in 20case "${EAPI:-0}" in
21 0|1) 21 0|1)
22 PERL_EXPF="${PERL_EXPF} pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm" 22 PERL_EXPF+=" pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm"
23 ;; 23 ;;
24 2) 24 2|3)
25 PERL_EXPF="${PERL_EXPF} src_prepare src_configure" 25 PERL_EXPF+=" src_prepare src_configure"
26 [[ ${CATEGORY} == "perl-core" ]] && \ 26 [[ ${CATEGORY} == "perl-core" ]] && \
27 PERL_EXPF="${PERL_EXPF} pkg_postinst pkg_postrm" 27 PERL_EXPF+=" pkg_postinst pkg_postrm"
28 28
29 case "${GENTOO_DEPEND_ON_PERL:-yes}" in 29 case "${GENTOO_DEPEND_ON_PERL:-yes}" in
30 yes) 30 yes)
31 DEPEND="dev-lang/perl[-build]" 31 DEPEND="dev-lang/perl[-build]"
32 RDEPEND="${DEPEND}" 32 RDEPEND="${DEPEND}"
33 ;; 33 ;;
34 esac 34 esac
35 ;; 35 ;;
36 *)
37 DEPEND="EAPI-UNSUPPORTED"
38 ;;
36esac 39esac
37 40
41case "${PERL_EXPORT_PHASE_FUNCTIONS:-yes}" in
42 yes)
38EXPORT_FUNCTIONS ${PERL_EXPF} 43 EXPORT_FUNCTIONS ${PERL_EXPF}
44 ;;
45 no)
46 debug-print "PERL_EXPORT_PHASE_FUNCTIONS=no"
47 ;;
48 *)
49 DEPEND+=" PERL_EXPORT_PHASE_FUNCTIONS-UNSUPPORTED"
50 ;;
51esac
39 52
40DESCRIPTION="Based on the $ECLASS eclass" 53DESCRIPTION="Based on the $ECLASS eclass"
41 54
42LICENSE="${LICENSE:-|| ( Artistic GPL-2 )}" 55LICENSE="${LICENSE:-|| ( Artistic GPL-1 GPL-2 GPL-3 )}"
43 56
44[[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && MODULE_A="${MY_P:-${P}}.tar.gz" 57[[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && MODULE_A="${MY_P:-${P}}.tar.gz"
45[[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \ 58[[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
46 SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION}/${MODULE_A}" 59 SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION:+${MODULE_SECTION}/}${MODULE_A}"
47[[ -z "${HOMEPAGE}" ]] && \ 60[[ -z "${HOMEPAGE}" ]] && \
48 HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}/" 61 HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}/"
49 62
50SRC_PREP="no" 63SRC_PREP="no"
51SRC_TEST="skip" 64SRC_TEST="skip"
52PREFER_BUILDPL="yes" 65PREFER_BUILDPL="yes"
53 66
54PERL_VERSION=""
55SITE_ARCH=""
56SITE_LIB=""
57ARCH_LIB=""
58VENDOR_ARCH=""
59VENDOR_LIB=""
60
61pm_echovar="" 67pm_echovar=""
62perlinfo_done=false 68perlinfo_done=false
63 69
64perl-module_src_unpack() { 70perl-module_src_unpack() {
71 debug-print-function $FUNCNAME "$@"
65 base_src_unpack unpack 72 base_src_unpack
66 has src_prepare ${PERL_EXPF} || perl-module_src_prepare 73 has src_prepare ${PERL_EXPF} || perl-module_src_prepare
67} 74}
68 75
69perl-module_src_prepare() { 76perl-module_src_prepare() {
70 if [[ -n ${PATCHES} ]] ; then 77 debug-print-function $FUNCNAME "$@"
71 base_src_unpack autopatch 78 has src_prepare ${PERL_EXPF} && base_src_prepare
72 fi 79 perl_fix_osx_extra
73 esvn_clean 80 esvn_clean
74} 81}
75 82
76perl-module_src_configure() { 83perl-module_src_configure() {
84 debug-print-function $FUNCNAME "$@"
77 perl-module_src_prep 85 perl-module_src_prep
78} 86}
79 87
80perl-module_src_prep() { 88perl-module_src_prep() {
89 debug-print-function $FUNCNAME "$@"
81 [[ ${SRC_PREP} = yes ]] && return 0 90 [[ ${SRC_PREP} = yes ]] && return 0
82 SRC_PREP="yes" 91 SRC_PREP="yes"
83 92
84 ${perlinfo_done} || perlinfo 93 perl_set_version
94 perl_set_eprefix
85 95
86 export PERL_MM_USE_DEFAULT=1 96 export PERL_MM_USE_DEFAULT=1
87 # Disable ExtUtils::AutoInstall from prompting 97 # Disable ExtUtils::AutoInstall from prompting
88 export PERL_EXTUTILS_AUTOINSTALL="--skipdeps" 98 export PERL_EXTUTILS_AUTOINSTALL="--skipdeps"
89 99
90 if [[ ${PREFER_BUILDPL} == yes && -f Build.PL ]] ; then 100 if [[ ${PREFER_BUILDPL} == yes && -f Build.PL ]] ; then
91 einfo "Using Module::Build" 101 einfo "Using Module::Build"
92 perl Build.PL \ 102 if [[ ${DEPEND} != *virtual/perl-Module-Build* && ${PN} != Module-Build ]] ; then
103 ewarn "QA Notice: The ebuild uses Module::Build but doesn't depend on it."
104 ewarn " Add virtual/perl-Module-Build to DEPEND!"
105 fi
106 set -- \
93 --installdirs=vendor \ 107 --installdirs=vendor \
94 --libdoc= \ 108 --libdoc= \
95 --destdir="${D}" \ 109 --destdir="${D}" \
96 --create_packlist=0 \ 110 --create_packlist=0 \
97 ${myconf} \ 111 ${myconf}
98 <<< "${pm_echovar}" \ 112 einfo "perl Build.PL" "$@"
113 perl Build.PL "$@" <<< "${pm_echovar}" \
99 || die "Unable to build! (are you using USE=\"build\"?)" 114 || die "Unable to build! (are you using USE=\"build\"?)"
100 elif [[ -f Makefile.PL ]] ; then 115 elif [[ -f Makefile.PL ]] ; then
101 einfo "Using ExtUtils::MakeMaker" 116 einfo "Using ExtUtils::MakeMaker"
102 perl Makefile.PL \ 117 set -- \
103 PREFIX=/usr \ 118 PREFIX=${EPREFIX}/usr \
104 INSTALLDIRS=vendor \ 119 INSTALLDIRS=vendor \
105 INSTALLMAN3DIR='none' \ 120 INSTALLMAN3DIR='none' \
106 DESTDIR="${D}" \ 121 DESTDIR="${D}" \
107 ${myconf} \ 122 ${myconf}
108 <<< "${pm_echovar}" \ 123 einfo "perl Makefile.PL" "$@"
124 perl Makefile.PL "$@" <<< "${pm_echovar}" \
109 || die "Unable to build! (are you using USE=\"build\"?)" 125 || die "Unable to build! (are you using USE=\"build\"?)"
110 fi 126 fi
111 if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then 127 if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then
112 einfo "No Make or Build file detected..." 128 einfo "No Make or Build file detected..."
113 return 129 return
114 fi 130 fi
115} 131}
116 132
117perl-module_src_compile() { 133perl-module_src_compile() {
118 ${perlinfo_done} || perlinfo 134 debug-print-function $FUNCNAME "$@"
135 perl_set_version
119 136
120 has src_configure ${PERL_EXPF} || perl-module_src_prep 137 has src_configure ${PERL_EXPF} || perl-module_src_prep
121 138
122 if [[ -f Build ]] ; then 139 if [[ -f Build ]] ; then
123 ./Build build \ 140 ./Build build \
151# SRC_TEST="parallel do" 168# SRC_TEST="parallel do"
152# SRC_TEST=parallel 169# SRC_TEST=parallel
153# 170#
154 171
155perl-module_src_test() { 172perl-module_src_test() {
173 debug-print-function $FUNCNAME "$@"
156 if has 'do' ${SRC_TEST} || has 'parallel' ${SRC_TEST} ; then 174 if has 'do' ${SRC_TEST} || has 'parallel' ${SRC_TEST} ; then
157 if has "${TEST_VERBOSE:-0}" 0 && has 'parallel' ${SRC_TEST} ; then 175 if has "${TEST_VERBOSE:-0}" 0 && has 'parallel' ${SRC_TEST} ; then
158 export HARNESS_OPTIONS=j$(echo -j1 ${MAKEOPTS} | sed -r "s/.*(-j\s*|--jobs=)([0-9]+).*/\2/" ) 176 export HARNESS_OPTIONS=j$(echo -j1 ${MAKEOPTS} | sed -r "s/.*(-j\s*|--jobs=)([0-9]+).*/\2/" )
159 einfo "Test::Harness Jobs=${HARNESS_OPTIONS}" 177 einfo "Test::Harness Jobs=${HARNESS_OPTIONS}"
160 fi 178 fi
161 ${perlinfo_done} || perlinfo 179 ${perlinfo_done} || perl_set_version
162 if [[ -f Build ]] ; then 180 if [[ -f Build ]] ; then
163 ./Build test verbose=${TEST_VERBOSE:-0} || die "test failed" 181 ./Build test verbose=${TEST_VERBOSE:-0} || die "test failed"
164 elif [[ -f Makefile ]] ; then 182 elif [[ -f Makefile ]] ; then
165 emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test failed" 183 emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test failed"
166 fi 184 fi
167 fi 185 fi
168} 186}
169 187
170perl-module_src_install() { 188perl-module_src_install() {
189 debug-print-function $FUNCNAME "$@"
190
191 perl_set_version
192 perl_set_eprefix
193
171 local f 194 local f
172 ${perlinfo_done} || perlinfo
173 195
174 if [[ -z ${mytargets} ]] ; then 196 if [[ -z ${mytargets} ]] ; then
175 case "${CATEGORY}" in 197 case "${CATEGORY}" in
176 dev-perl|perl-core) mytargets="pure_install" ;; 198 dev-perl|perl-core) mytargets="pure_install" ;;
177 *) mytargets="install" ;; 199 *) mytargets="install" ;;
184 elif [[ -f Makefile ]] ; then 206 elif [[ -f Makefile ]] ; then
185 emake ${myinst} ${mytargets} \ 207 emake ${myinst} ${mytargets} \
186 || die "emake ${myinst} ${mytargets} failed" 208 || die "emake ${myinst} ${mytargets} failed"
187 fi 209 fi
188 210
189 if [[ -d "${D}"/usr/share/man ]] ; then 211 perl_delete_module_manpages
190# einfo "Cleaning out stray man files" 212 perl_delete_localpod
191 find "${D}"/usr/share/man -type f -name "*.3pm" -delete 213 perl_delete_packlist
192 find "${D}"/usr/share/man -depth -type d -empty -delete 214 perl_remove_temppath
193 fi
194 215
195 fixlocalpod
196
197 for f in Change* CHANGES README* TODO ${mydoc}; do 216 for f in Change* CHANGES README* TODO FAQ ${mydoc}; do
198 [[ -s ${f} ]] && dodoc ${f} 217 [[ -s ${f} ]] && dodoc ${f}
199 done 218 done
200 219
220 perl_link_duallife_scripts
221}
222
223perl-module_pkg_setup() {
224 debug-print-function $FUNCNAME "$@"
225 perl_set_version
226}
227
228perl-module_pkg_preinst() {
229 debug-print-function $FUNCNAME "$@"
230 perl_set_version
231}
232
233perl-module_pkg_postinst() {
234 debug-print-function $FUNCNAME "$@"
235 perl_link_duallife_scripts
236}
237
238perl-module_pkg_prerm() {
239 debug-print-function $FUNCNAME "$@"
240}
241
242perl-module_pkg_postrm() {
243 debug-print-function $FUNCNAME "$@"
244 perl_link_duallife_scripts
245}
246
247perlinfo() {
248 debug-print-function $FUNCNAME "$@"
249 perl_set_version
250}
251
252perl_set_version() {
253 debug-print-function $FUNCNAME "$@"
254 debug-print "$FUNCNAME: perlinfo_done=${perlinfo_done}"
255 ${perlinfo_done} && return 0
256 perlinfo_done=true
257
258 local f version install{{site,vendor}{arch,lib},archlib}
259 eval "$(perl -V:{version,install{{site,vendor}{arch,lib},archlib}} )"
260 PERL_VERSION=${version}
261 SITE_ARCH=${installsitearch}
262 SITE_LIB=${installsitelib}
263 ARCH_LIB=${installarchlib}
264 VENDOR_LIB=${installvendorlib}
265 VENDOR_ARCH=${installvendorarch}
266}
267
268fixlocalpod() {
269 debug-print-function $FUNCNAME "$@"
270 perl_delete_localpod
271}
272
273perl_delete_localpod() {
274 debug-print-function $FUNCNAME "$@"
275
276 find "${D}" -type f -name perllocal.pod -delete
277 find "${D}" -depth -mindepth 1 -type d -empty -delete
278}
279
280perl_fix_osx_extra() {
281 debug-print-function $FUNCNAME "$@"
282
283 # Remove "AppleDouble encoded Macintosh file"
284 local f
285 find "${S}" -type f -name "._*" -print0 | while read -rd '' f ; do
286 einfo "Removing AppleDouble encoded Macintosh file: ${f#${S}/}"
287 rm -f "${f}"
288 f=${f#${S}/}
289 # f=${f//\//\/}
290 # f=${f//\./\.}
291 # sed -i "/${f}/d" "${S}"/MANIFEST || die
292 grep -q "${f}" "${S}"/MANIFEST && \
293 elog "AppleDouble encoded Macintosh file in MANIFEST: ${f#${S}/}"
294 done
295}
296
297perl_delete_module_manpages() {
298 debug-print-function $FUNCNAME "$@"
299
300 perl_set_eprefix
301
302 if [[ -d "${ED}"/usr/share/man ]] ; then
303# einfo "Cleaning out stray man files"
304 find "${ED}"/usr/share/man -type f -name "*.3pm" -delete
305 find "${ED}"/usr/share/man -depth -type d -empty -delete
306 fi
307}
308
309
310perl_delete_packlist() {
311 debug-print-function $FUNCNAME "$@"
312 perl_set_version
201 if [[ -d ${D}/${VENDOR_LIB} ]] ; then 313 if [[ -d ${D}/${VENDOR_LIB} ]] ; then
202 find "${D}/${VENDOR_LIB}" -type f -a \( -name .packlist \ 314 find "${D}/${VENDOR_LIB}" -type f -a \( -name .packlist \
203 -o \( -name '*.bs' -a -empty \) \) -delete 315 -o \( -name '*.bs' -a -empty \) \) -delete
204 find "${D}/${VENDOR_LIB}" -depth -mindepth 1 -type d -empty -delete 316 find "${D}/${VENDOR_LIB}" -depth -mindepth 1 -type d -empty -delete
205 fi 317 fi
318}
319
320perl_remove_temppath() {
321 debug-print-function $FUNCNAME "$@"
206 322
207 find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do 323 find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
208 if file "${f}" | grep -q -i " text" ; then 324 if file "${f}" | grep -q -i " text" ; then
209 grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}" 325 grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
210 sed -i -e "s:${D}:/:g" "${f}" 326 sed -i -e "s:${D}:/:g" "${f}"
211 fi 327 fi
212 done 328 done
213
214 linkduallifescripts
215} 329}
216 330
217perl-module_pkg_setup() {
218 ${perlinfo_done} || perlinfo
219}
220
221perl-module_pkg_preinst() {
222 ${perlinfo_done} || perlinfo
223}
224
225perl-module_pkg_postinst() {
226 linkduallifescripts
227}
228
229perl-module_pkg_prerm() { : ; }
230
231perl-module_pkg_postrm() {
232 linkduallifescripts
233}
234
235perlinfo() {
236 perlinfo_done=true
237
238 local f version install{{site,vendor}{arch,lib},archlib}
239 for f in version install{{site,vendor}{arch,lib},archlib} ; do
240 eval "$(perl -V:${f} )"
241 done
242 PERL_VERSION=${version}
243 SITE_ARCH=${installsitearch}
244 SITE_LIB=${installsitelib}
245 ARCH_LIB=${installarchlib}
246 VENDOR_LIB=${installvendorlib}
247 VENDOR_ARCH=${installvendorarch}
248}
249
250fixlocalpod() {
251 find "${D}" -type f -name perllocal.pod -delete
252 find "${D}" -depth -mindepth 1 -type d -empty -delete
253}
254
255linkduallifescripts() { 331perl_link_duallife_scripts() {
332 debug-print-function $FUNCNAME "$@"
256 if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.10.1" ; then 333 if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; then
257 return 0 334 return 0
258 fi 335 fi
336
337 perl_set_eprefix
259 338
260 local i ff 339 local i ff
261 if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then 340 if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
262 for i in "${DUALLIFESCRIPTS[@]}" ; do 341 for i in "${DUALLIFESCRIPTS[@]}" ; do
263 alternatives_auto_makesym "/usr/bin/${i}" "/usr/bin/${i}-[0-9]*" 342 alternatives_auto_makesym "/usr/bin/${i}" "/usr/bin/${i}-[0-9]*"
264 ff=`echo "${ROOT}"/usr/share/man/man1/${i}-${PV}-${P}.1*` 343 ff=`echo "${EROOT}"/usr/share/man/man1/${i}-${PV}-${P}.1*`
265 ff=${ff##*.1} 344 ff=${ff##*.1}
266 alternatives_auto_makesym "/usr/share/man/man1/${i}.1${ff}" "/usr/share/man/man1/${i}-[0-9]*" 345 alternatives_auto_makesym "/usr/share/man/man1/${i}.1${ff}" "/usr/share/man/man1/${i}-[0-9]*"
267 done 346 done
268 else 347 else
269 pushd "${D}" > /dev/null 348 pushd "${ED}" > /dev/null
270 for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do 349 for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
271 mv ${i}{,-${PV}-${P}} || die 350 mv ${i}{,-${PV}-${P}} || die
272 DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/} 351 DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
273 if [[ -f usr/share/man/man1/${i##*/}.1 ]] ; then 352 if [[ -f usr/share/man/man1/${i##*/}.1 ]] ; then
274 mv usr/share/man/man1/${i##*/}{.1,-${PV}-${P}.1} || die 353 mv usr/share/man/man1/${i##*/}{.1,-${PV}-${P}.1} || die
275 fi 354 fi
276 done 355 done
277 popd > /dev/null 356 popd > /dev/null
278 fi 357 fi
279} 358}
359
360perl_set_eprefix() {
361 debug-print-function $FUNCNAME "$@"
362 case ${EAPI:-0} in
363 0|1|2)
364 if ! use prefix; then
365 EPREFIX=
366 ED=${D}
367 EROOT=${ROOT}
368 fi
369 ;;
370 esac
371}

Legend:
Removed from v.1.118  
changed lines
  Added in v.1.124

  ViewVC Help
Powered by ViewVC 1.1.20