| 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.113 2009/03/06 11:42:41 tove Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.119 2009/11/14 08:58:50 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 | |
| 15 | inherit eutils base |
15 | inherit eutils base |
|
|
16 | [[ ${CATEGORY} == "perl-core" ]] && inherit alternatives |
|
|
17 | |
|
|
18 | PERL_EXPF="src_unpack src_compile src_test src_install" |
| 16 | |
19 | |
| 17 | case "${EAPI:-0}" in |
20 | case "${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 | ;; |
| 31 | esac |
36 | esac |
| 32 | |
37 | |
|
|
38 | EXPORT_FUNCTIONS ${PERL_EXPF} |
|
|
39 | |
| 33 | DESCRIPTION="Based on the $ECLASS eclass" |
40 | DESCRIPTION="Based on the $ECLASS eclass" |
| 34 | |
41 | |
| 35 | LICENSE="${LICENSE:-|| ( Artistic GPL-2 )}" |
42 | LICENSE="${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 | |
| 43 | SRC_PREP="no" |
50 | SRC_PREP="no" |
| 44 | SRC_TEST="skip" |
51 | SRC_TEST="skip" |
| 45 | PREFER_BUILDPL="yes" |
52 | PREFER_BUILDPL="yes" |
| 46 | |
53 | |
| … | |
… | |
| 54 | pm_echovar="" |
61 | pm_echovar="" |
| 55 | perlinfo_done=false |
62 | perlinfo_done=false |
| 56 | |
63 | |
| 57 | perl-module_src_unpack() { |
64 | perl-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 | |
| 62 | perl-module_src_prepare() { |
69 | perl-module_src_prepare() { |
| 63 | if [[ -n ${PATCHES} ]] ; then |
70 | if [[ -n ${PATCHES} ]] ; then |
| 64 | base_src_unpack autopatch |
71 | base_src_unpack autopatch |
| … | |
… | |
| 69 | perl-module_src_configure() { |
76 | perl-module_src_configure() { |
| 70 | perl-module_src_prep |
77 | perl-module_src_prep |
| 71 | } |
78 | } |
| 72 | |
79 | |
| 73 | perl-module_src_prep() { |
80 | perl-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 | |
| 111 | perl-module_src_compile() { |
117 | perl-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 | |
| 128 | perl-module_src_test() { |
155 | perl-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 | |
| 139 | perl-module_src_install() { |
170 | perl-module_src_install() { |
| 140 | local f |
171 | local f |
| 141 | ${perlinfo_done} || perlinfo |
172 | ${perlinfo_done} || perlinfo |
| 142 | |
173 | |
| 143 | [[ -z ${mytargets} ]] && mytargets="pure_install" |
174 | if [[ -z ${mytargets} ]] ; then |
|
|
175 | case "${CATEGORY}" in |
|
|
176 | dev-perl|perl-core) mytargets="pure_install" ;; |
|
|
177 | *) mytargets="install" ;; |
|
|
178 | esac |
|
|
179 | fi |
| 144 | |
180 | |
| 145 | if [[ -f Build ]] ; then |
181 | if [[ -f Build ]] ; then |
| 146 | ./Build ${mytargets} \ |
182 | ./Build ${mytargets} \ |
| 147 | || die "./Build ${mytargets} failed" |
183 | || die "./Build ${mytargets} failed" |
| 148 | elif [[ -f Makefile ]] ; then |
184 | elif [[ -f Makefile ]] ; then |
| 149 | emake ${myinst} ${mytargets} \ |
185 | emake ${myinst} ${mytargets} \ |
| 150 | || die "emake ${myinst} ${mytargets} failed" |
186 | || die "emake ${myinst} ${mytargets} failed" |
| 151 | fi |
187 | fi |
| 152 | |
188 | |
|
|
189 | if [[ -d "${D}"/usr/share/man ]] ; then |
| 153 | # einfo "Cleaning out stray man files" |
190 | # einfo "Cleaning out stray man files" |
| 154 | find "${D}" -type f -name "*.3pm" -delete |
191 | find "${D}"/usr/share/man -type f -name "*.3pm" -delete |
| 155 | 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 |
| 156 | |
194 | |
| 157 | fixlocalpod |
195 | fixlocalpod |
| 158 | |
196 | |
| 159 | for f in Change* CHANGES README* ${mydoc}; do |
197 | for f in Change* CHANGES README* TODO ${mydoc}; do |
| 160 | [[ -s "${f}" ]] && dodoc ${f} |
198 | [[ -s ${f} ]] && dodoc ${f} |
| 161 | done |
199 | done |
| 162 | |
200 | |
|
|
201 | if [[ -d ${D}/${VENDOR_LIB} ]] ; then |
| 163 | find "${D}/${VENDOR_LIB}" -type f -a \( -name .packlist \ |
202 | find "${D}/${VENDOR_LIB}" -type f -a \( -name .packlist \ |
| 164 | -o \( -name '*.bs' -a -empty \) \) -delete |
203 | -o \( -name '*.bs' -a -empty \) \) -delete |
| 165 | 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 |
| 166 | |
206 | |
| 167 | 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 |
| 168 | if file "${f}" | grep -q -i " text" ; then |
208 | if file "${f}" | grep -q -i " text" ; then |
| 169 | if 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}" |
| 170 | sed -i -e "s:${D}:/:g" "${f}" |
210 | sed -i -e "s:${D}:/:g" "${f}" |
| 171 | fi |
211 | fi |
| 172 | done |
212 | done |
|
|
213 | |
|
|
214 | linkduallifescripts |
| 173 | } |
215 | } |
| 174 | |
216 | |
| 175 | perl-module_pkg_setup() { |
217 | perl-module_pkg_setup() { |
| 176 | ${perlinfo_done} || perlinfo |
218 | ${perlinfo_done} || perlinfo |
| 177 | } |
219 | } |
| 178 | |
220 | |
| 179 | perl-module_pkg_preinst() { |
221 | perl-module_pkg_preinst() { |
| 180 | ${perlinfo_done} || perlinfo |
222 | ${perlinfo_done} || perlinfo |
| 181 | } |
223 | } |
| 182 | |
224 | |
| 183 | perl-module_pkg_postinst() { : ; } |
225 | perl-module_pkg_postinst() { |
| 184 | # einfo "Man pages are not installed for most modules now." |
226 | linkduallifescripts |
| 185 | # einfo "Please use perldoc instead." |
227 | } |
| 186 | #} |
|
|
| 187 | |
228 | |
| 188 | perl-module_pkg_prerm() { : ; } |
229 | perl-module_pkg_prerm() { : ; } |
| 189 | |
230 | |
| 190 | perl-module_pkg_postrm() { : ; } |
231 | perl-module_pkg_postrm() { |
|
|
232 | linkduallifescripts |
|
|
233 | } |
| 191 | |
234 | |
| 192 | perlinfo() { |
235 | perlinfo() { |
| 193 | perlinfo_done=true |
236 | perlinfo_done=true |
| 194 | |
237 | |
| 195 | local f version install{site{arch,lib},archlib,vendor{arch,lib}} |
238 | local f version install{{site,vendor}{arch,lib},archlib} |
| 196 | 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 |
| 197 | eval "$(perl -V:${f} )" |
240 | eval "$(perl -V:${f} )" |
| 198 | done |
241 | done |
| 199 | PERL_VERSION=${version} |
242 | PERL_VERSION=${version} |
| 200 | SITE_ARCH=${installsitearch} |
243 | SITE_ARCH=${installsitearch} |
| 201 | SITE_LIB=${installsitelib} |
244 | SITE_LIB=${installsitelib} |
| … | |
… | |
| 206 | |
249 | |
| 207 | fixlocalpod() { |
250 | fixlocalpod() { |
| 208 | find "${D}" -type f -name perllocal.pod -delete |
251 | find "${D}" -type f -name perllocal.pod -delete |
| 209 | find "${D}" -depth -mindepth 1 -type d -empty -delete |
252 | find "${D}" -depth -mindepth 1 -type d -empty -delete |
| 210 | } |
253 | } |
|
|
254 | |
|
|
255 | linkduallifescripts() { |
|
|
256 | if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; 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 | } |