/[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.114 Revision 1.118
1# Copyright 1999-2004 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.114 2009/03/11 06:36:45 tove Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.118 2009/11/10 12:53:53 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:
11# @DESCRIPTION: 11# @DESCRIPTION:
12# 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
13# modules, and their incorporation into the Gentoo Linux system. 13# modules, and their incorporation into the Gentoo Linux system.
14 14
15inherit eutils base 15inherit eutils base
16[[ ${CATEGORY} == "perl-core" ]] && inherit alternatives
17
18PERL_EXPF="src_unpack src_compile src_test src_install"
16 19
17case "${EAPI:-0}" in 20case "${EAPI:-0}" in
18 0|1) 21 0|1)
19 EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm src_compile src_install src_test src_unpack 22 PERL_EXPF="${PERL_EXPF} pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm"
20 ;; 23 ;;
21 2) 24 2)
22 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install 25 PERL_EXPF="${PERL_EXPF} src_prepare src_configure"
26 [[ ${CATEGORY} == "perl-core" ]] && \
27 PERL_EXPF="${PERL_EXPF} pkg_postinst pkg_postrm"
23 28
24 case "${GENTOO_DEPEND_ON_PERL:-yes}" in 29 case "${GENTOO_DEPEND_ON_PERL:-yes}" in
25 yes) 30 yes)
26 DEPEND="dev-lang/perl[-build]" 31 DEPEND="dev-lang/perl[-build]"
27 RDEPEND="${DEPEND}" 32 RDEPEND="${DEPEND}"
28 ;; 33 ;;
29 esac 34 esac
30 ;; 35 ;;
31esac 36esac
32 37
38EXPORT_FUNCTIONS ${PERL_EXPF}
39
33DESCRIPTION="Based on the $ECLASS eclass" 40DESCRIPTION="Based on the $ECLASS eclass"
34 41
35LICENSE="${LICENSE:-|| ( Artistic GPL-2 )}" 42LICENSE="${LICENSE:-|| ( Artistic GPL-2 )}"
36 43
37[[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && MODULE_A="${MY_P:-${P}}.tar.gz" 44[[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && MODULE_A="${MY_P:-${P}}.tar.gz"
38[[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \ 45[[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
39 SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION}/${MODULE_A}" 46 SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION}/${MODULE_A}"
40[[ -z "${HOMEPAGE}" ]] && \ 47[[ -z "${HOMEPAGE}" ]] && \
41 HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}" 48 HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}/"
42 49
43SRC_PREP="no" 50SRC_PREP="no"
44SRC_TEST="skip" 51SRC_TEST="skip"
45PREFER_BUILDPL="yes" 52PREFER_BUILDPL="yes"
46 53
54pm_echovar="" 61pm_echovar=""
55perlinfo_done=false 62perlinfo_done=false
56 63
57perl-module_src_unpack() { 64perl-module_src_unpack() {
58 base_src_unpack unpack 65 base_src_unpack unpack
59 has "${EAPI:-0}" 0 1 && perl-module_src_prepare 66 has src_prepare ${PERL_EXPF} || perl-module_src_prepare
60} 67}
61 68
62perl-module_src_prepare() { 69perl-module_src_prepare() {
63 if [[ -n ${PATCHES} ]] ; then 70 if [[ -n ${PATCHES} ]] ; then
64 base_src_unpack autopatch 71 base_src_unpack autopatch
69perl-module_src_configure() { 76perl-module_src_configure() {
70 perl-module_src_prep 77 perl-module_src_prep
71} 78}
72 79
73perl-module_src_prep() { 80perl-module_src_prep() {
74 [[ "${SRC_PREP}" = "yes" ]] && return 0 81 [[ ${SRC_PREP} = yes ]] && return 0
75 SRC_PREP="yes" 82 SRC_PREP="yes"
76 83
77 ${perlinfo_done} || perlinfo 84 ${perlinfo_done} || perlinfo
78 85
79 export PERL_MM_USE_DEFAULT=1 86 export PERL_MM_USE_DEFAULT=1
80 # Disable ExtUtils::AutoInstall from prompting 87 # Disable ExtUtils::AutoInstall from prompting
81 export PERL_EXTUTILS_AUTOINSTALL="--skipdeps" 88 export PERL_EXTUTILS_AUTOINSTALL="--skipdeps"
82 89
83 if [[ "${PREFER_BUILDPL}" == "yes" && -f Build.PL ]] ; then 90 if [[ ${PREFER_BUILDPL} == yes && -f Build.PL ]] ; then
84 einfo "Using Module::Build" 91 einfo "Using Module::Build"
85 perl Build.PL \ 92 perl Build.PL \
86 --installdirs=vendor \ 93 --installdirs=vendor \
87 --libdoc= \ 94 --libdoc= \
88 --destdir="${D}" \ 95 --destdir="${D}" \
89 --create_packlist=0 \ 96 --create_packlist=0 \
90 --extra_linker_flags="${LDFLAGS}" \
91 ${myconf} \ 97 ${myconf} \
92 <<< ${pm_echovar} \ 98 <<< "${pm_echovar}" \
93 || die "Unable to build! (are you using USE=\"build\"?)" 99 || die "Unable to build! (are you using USE=\"build\"?)"
94 elif [[ -f Makefile.PL ]] ; then 100 elif [[ -f Makefile.PL ]] ; then
95 einfo "Using ExtUtils::MakeMaker" 101 einfo "Using ExtUtils::MakeMaker"
96 perl Makefile.PL \ 102 perl Makefile.PL \
97 PREFIX=/usr \ 103 PREFIX=/usr \
98 INSTALLDIRS=vendor \ 104 INSTALLDIRS=vendor \
99 INSTALLMAN3DIR='none' \ 105 INSTALLMAN3DIR='none' \
100 DESTDIR="${D}" \ 106 DESTDIR="${D}" \
101 ${myconf} \ 107 ${myconf} \
102 <<< ${pm_echovar} \ 108 <<< "${pm_echovar}" \
103 || die "Unable to build! (are you using USE=\"build\"?)" 109 || die "Unable to build! (are you using USE=\"build\"?)"
104 fi 110 fi
105 if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then 111 if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then
106 einfo "No Make or Build file detected..." 112 einfo "No Make or Build file detected..."
107 return 113 return
109} 115}
110 116
111perl-module_src_compile() { 117perl-module_src_compile() {
112 ${perlinfo_done} || perlinfo 118 ${perlinfo_done} || perlinfo
113 119
114 has "${EAPI:-0}" 0 1 && perl-module_src_prep 120 has src_configure ${PERL_EXPF} || perl-module_src_prep
115 121
116 if [[ -f Build ]] ; then 122 if [[ -f Build ]] ; then
117 ./Build build \ 123 ./Build build \
118 || die "compilation failed" 124 || die "compilation failed"
119 elif [[ -f Makefile ]] ; then 125 elif [[ -f Makefile ]] ; then
123 || die "compilation failed" 129 || die "compilation failed"
124# OPTIMIZE="${CFLAGS}" \ 130# OPTIMIZE="${CFLAGS}" \
125 fi 131 fi
126} 132}
127 133
134# For testers:
135# This code attempts to work out your threadingness from MAKEOPTS
136# and apply them to Test::Harness.
137#
138# If you want more verbose testing, set TEST_VERBOSE=1
139# in your bashrc | /etc/make.conf | ENV
140#
141# For ebuild writers:
142# If you wish to enable default tests w/ 'make test' ,
143#
144# SRC_TEST="do"
145#
146# If you wish to have threads run in parallel ( using the users makeopts )
147# all of the following have been tested to work.
148#
149# SRC_TEST="do parallel"
150# SRC_TEST="parallel"
151# SRC_TEST="parallel do"
152# SRC_TEST=parallel
153#
154
128perl-module_src_test() { 155perl-module_src_test() {
129 if [[ "${SRC_TEST}" == "do" ]] ; then 156 if has 'do' ${SRC_TEST} || has 'parallel' ${SRC_TEST} ; then
157 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/" )
159 einfo "Test::Harness Jobs=${HARNESS_OPTIONS}"
160 fi
130 ${perlinfo_done} || perlinfo 161 ${perlinfo_done} || perlinfo
131 if [[ -f Build ]] ; then 162 if [[ -f Build ]] ; then
132 ./Build test || die "test failed" 163 ./Build test verbose=${TEST_VERBOSE:-0} || die "test failed"
133 elif [[ -f Makefile ]] ; then 164 elif [[ -f Makefile ]] ; then
134 emake test || die "test failed" 165 emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test failed"
135 fi 166 fi
136 fi 167 fi
137} 168}
138 169
139perl-module_src_install() { 170perl-module_src_install() {
153 elif [[ -f Makefile ]] ; then 184 elif [[ -f Makefile ]] ; then
154 emake ${myinst} ${mytargets} \ 185 emake ${myinst} ${mytargets} \
155 || die "emake ${myinst} ${mytargets} failed" 186 || die "emake ${myinst} ${mytargets} failed"
156 fi 187 fi
157 188
189 if [[ -d "${D}"/usr/share/man ]] ; then
158# einfo "Cleaning out stray man files" 190# einfo "Cleaning out stray man files"
159 find "${D}" -type f -name "*.3pm" -delete 191 find "${D}"/usr/share/man -type f -name "*.3pm" -delete
160 find "${D}"/usr/share/man -depth -type d -empty -delete 2>/dev/null 192 find "${D}"/usr/share/man -depth -type d -empty -delete
193 fi
161 194
162 fixlocalpod 195 fixlocalpod
163 196
164 for f in Change* CHANGES README* ${mydoc}; do 197 for f in Change* CHANGES README* TODO ${mydoc}; do
165 [[ -s "${f}" ]] && dodoc ${f} 198 [[ -s ${f} ]] && dodoc ${f}
166 done 199 done
167 200
201 if [[ -d ${D}/${VENDOR_LIB} ]] ; then
168 find "${D}/${VENDOR_LIB}" -type f -a \( -name .packlist \ 202 find "${D}/${VENDOR_LIB}" -type f -a \( -name .packlist \
169 -o \( -name '*.bs' -a -empty \) \) -delete 203 -o \( -name '*.bs' -a -empty \) \) -delete
170 find "${D}/${VENDOR_LIB}" -depth -mindepth 1 -type d -empty -delete 204 find "${D}/${VENDOR_LIB}" -depth -mindepth 1 -type d -empty -delete
205 fi
171 206
172 find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do 207 find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
173 if file "${f}" | grep -q -i " text" ; then 208 if file "${f}" | grep -q -i " text" ; then
174if grep -q "${D}" "${f}" ; then ewarn "QA: File contains a temporary path ${f}" ;fi 209 grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
175 sed -i -e "s:${D}:/:g" "${f}" 210 sed -i -e "s:${D}:/:g" "${f}"
176 fi 211 fi
177 done 212 done
213
214 linkduallifescripts
178} 215}
179 216
180perl-module_pkg_setup() { 217perl-module_pkg_setup() {
181 ${perlinfo_done} || perlinfo 218 ${perlinfo_done} || perlinfo
182} 219}
183 220
184perl-module_pkg_preinst() { 221perl-module_pkg_preinst() {
185 ${perlinfo_done} || perlinfo 222 ${perlinfo_done} || perlinfo
186} 223}
187 224
188perl-module_pkg_postinst() { : ; } 225perl-module_pkg_postinst() {
189# einfo "Man pages are not installed for most modules now." 226 linkduallifescripts
190# einfo "Please use perldoc instead." 227}
191#}
192 228
193perl-module_pkg_prerm() { : ; } 229perl-module_pkg_prerm() { : ; }
194 230
195perl-module_pkg_postrm() { : ; } 231perl-module_pkg_postrm() {
232 linkduallifescripts
233}
196 234
197perlinfo() { 235perlinfo() {
198 perlinfo_done=true 236 perlinfo_done=true
199 237
200 local f version install{site{arch,lib},archlib,vendor{arch,lib}} 238 local f version install{{site,vendor}{arch,lib},archlib}
201 for f in version install{site{arch,lib},archlib,vendor{arch,lib}} ; do 239 for f in version install{{site,vendor}{arch,lib},archlib} ; do
202 eval "$(perl -V:${f} )" 240 eval "$(perl -V:${f} )"
203 done 241 done
204 PERL_VERSION=${version} 242 PERL_VERSION=${version}
205 SITE_ARCH=${installsitearch} 243 SITE_ARCH=${installsitearch}
206 SITE_LIB=${installsitelib} 244 SITE_LIB=${installsitelib}
211 249
212fixlocalpod() { 250fixlocalpod() {
213 find "${D}" -type f -name perllocal.pod -delete 251 find "${D}" -type f -name perllocal.pod -delete
214 find "${D}" -depth -mindepth 1 -type d -empty -delete 252 find "${D}" -depth -mindepth 1 -type d -empty -delete
215} 253}
254
255linkduallifescripts() {
256 if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.10.1" ; then
257 return 0
258 fi
259
260 local i ff
261 if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
262 for i in "${DUALLIFESCRIPTS[@]}" ; do
263 alternatives_auto_makesym "/usr/bin/${i}" "/usr/bin/${i}-[0-9]*"
264 ff=`echo "${ROOT}"/usr/share/man/man1/${i}-${PV}-${P}.1*`
265 ff=${ff##*.1}
266 alternatives_auto_makesym "/usr/share/man/man1/${i}.1${ff}" "/usr/share/man/man1/${i}-[0-9]*"
267 done
268 else
269 pushd "${D}" > /dev/null
270 for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
271 mv ${i}{,-${PV}-${P}} || die
272 DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
273 if [[ -f usr/share/man/man1/${i##*/}.1 ]] ; then
274 mv usr/share/man/man1/${i##*/}{.1,-${PV}-${P}.1} || die
275 fi
276 done
277 popd > /dev/null
278 fi
279}

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

  ViewVC Help
Powered by ViewVC 1.1.20