| 1 | # Copyright 2002 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2004 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.115 2009/03/26 17:40:23 tove Exp $ |
|
|
4 | # |
| 3 | # Author: Seemant Kulleen <seemant@gentoo.org> |
5 | # Author: Seemant Kulleen <seemant@gentoo.org> |
| 4 | # $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.8 2002/05/06 14:34:55 seemant Exp $ |
6 | |
|
|
7 | # @ECLASS: perl-module.eclass |
|
|
8 | # @MAINTAINER: |
|
|
9 | # perl@gentoo.org |
|
|
10 | # @BLURB: eclass for perl modules |
|
|
11 | # @DESCRIPTION: |
| 5 | # 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 |
| 6 | # modules, and their incorporation into the Gentoo Linux system. |
13 | # modules, and their incorporation into the Gentoo Linux system. |
| 7 | |
14 | |
| 8 | #first inherit the pkg_postinst() and pkg_postrm() functions |
15 | inherit eutils base |
| 9 | . /usr/portage/eclass/inherit.eclass || die |
|
|
| 10 | inherit perl-post |
|
|
| 11 | |
16 | |
| 12 | ECLASS=base |
17 | case "${EAPI:-0}" in |
| 13 | EXPORT_FUNCTIONS src_compile src_install src_test |
18 | 0|1) |
|
|
19 | EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm src_compile src_install src_test src_unpack |
|
|
20 | ;; |
|
|
21 | 2) |
|
|
22 | EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install |
| 14 | |
23 | |
| 15 | newdepend ">=sys-devel/perl-5" |
24 | case "${GENTOO_DEPEND_ON_PERL:-yes}" in |
|
|
25 | yes) |
|
|
26 | DEPEND="dev-lang/perl[-build]" |
|
|
27 | RDEPEND="${DEPEND}" |
|
|
28 | ;; |
|
|
29 | esac |
|
|
30 | ;; |
|
|
31 | esac |
| 16 | |
32 | |
| 17 | base_src_compile() { |
33 | DESCRIPTION="Based on the $ECLASS eclass" |
| 18 | |
34 | |
|
|
35 | LICENSE="${LICENSE:-|| ( Artistic GPL-2 )}" |
|
|
36 | |
|
|
37 | [[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && MODULE_A="${MY_P:-${P}}.tar.gz" |
|
|
38 | [[ -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}" |
|
|
40 | [[ -z "${HOMEPAGE}" ]] && \ |
|
|
41 | HOMEPAGE="http://search.cpan.org/dist/${MY_PN:-${PN}}" |
|
|
42 | |
|
|
43 | SRC_PREP="no" |
|
|
44 | SRC_TEST="skip" |
|
|
45 | PREFER_BUILDPL="yes" |
|
|
46 | |
|
|
47 | PERL_VERSION="" |
|
|
48 | SITE_ARCH="" |
|
|
49 | SITE_LIB="" |
|
|
50 | ARCH_LIB="" |
|
|
51 | VENDOR_ARCH="" |
|
|
52 | VENDOR_LIB="" |
|
|
53 | |
|
|
54 | pm_echovar="" |
|
|
55 | perlinfo_done=false |
|
|
56 | |
|
|
57 | perl-module_src_unpack() { |
|
|
58 | base_src_unpack unpack |
|
|
59 | has "${EAPI:-0}" 0 1 && perl-module_src_prepare |
|
|
60 | } |
|
|
61 | |
|
|
62 | perl-module_src_prepare() { |
|
|
63 | if [[ -n ${PATCHES} ]] ; then |
|
|
64 | base_src_unpack autopatch |
|
|
65 | fi |
|
|
66 | esvn_clean |
|
|
67 | } |
|
|
68 | |
|
|
69 | perl-module_src_configure() { |
|
|
70 | perl-module_src_prep |
|
|
71 | } |
|
|
72 | |
|
|
73 | perl-module_src_prep() { |
|
|
74 | [[ "${SRC_PREP}" = "yes" ]] && return 0 |
|
|
75 | SRC_PREP="yes" |
|
|
76 | |
|
|
77 | ${perlinfo_done} || perlinfo |
|
|
78 | |
|
|
79 | export PERL_MM_USE_DEFAULT=1 |
|
|
80 | # Disable ExtUtils::AutoInstall from prompting |
|
|
81 | export PERL_EXTUTILS_AUTOINSTALL="--skipdeps" |
|
|
82 | |
|
|
83 | if [[ "${PREFER_BUILDPL}" == "yes" && -f Build.PL ]] ; then |
|
|
84 | einfo "Using Module::Build" |
|
|
85 | perl Build.PL \ |
|
|
86 | --installdirs=vendor \ |
|
|
87 | --libdoc= \ |
|
|
88 | --destdir="${D}" \ |
|
|
89 | --create_packlist=0 \ |
|
|
90 | --extra_linker_flags="${LDFLAGS}" \ |
|
|
91 | ${myconf} \ |
|
|
92 | <<< "${pm_echovar}" \ |
|
|
93 | || die "Unable to build! (are you using USE=\"build\"?)" |
|
|
94 | elif [[ -f Makefile.PL ]] ; then |
|
|
95 | einfo "Using ExtUtils::MakeMaker" |
| 19 | perl Makefile.PL ${myconf} |
96 | perl Makefile.PL \ |
|
|
97 | PREFIX=/usr \ |
|
|
98 | INSTALLDIRS=vendor \ |
|
|
99 | INSTALLMAN3DIR='none' \ |
|
|
100 | DESTDIR="${D}" \ |
|
|
101 | ${myconf} \ |
|
|
102 | <<< "${pm_echovar}" \ |
|
|
103 | || die "Unable to build! (are you using USE=\"build\"?)" |
|
|
104 | fi |
|
|
105 | if [[ ! -f Build.PL && ! -f Makefile.PL ]] ; then |
|
|
106 | einfo "No Make or Build file detected..." |
|
|
107 | return |
|
|
108 | fi |
|
|
109 | } |
|
|
110 | |
|
|
111 | perl-module_src_compile() { |
|
|
112 | ${perlinfo_done} || perlinfo |
|
|
113 | |
|
|
114 | has "${EAPI:-0}" 0 1 && perl-module_src_prep |
|
|
115 | |
|
|
116 | if [[ -f Build ]] ; then |
|
|
117 | ./Build build \ |
| 20 | make ${mymake} || die "compilation failed" |
118 | || die "compilation failed" |
| 21 | } |
119 | elif [[ -f Makefile ]] ; then |
| 22 | |
|
|
| 23 | base_src_test() { |
|
|
| 24 | |
|
|
| 25 | make test || die |
|
|
| 26 | } |
|
|
| 27 | |
|
|
| 28 | base_src_install() { |
|
|
| 29 | |
|
|
| 30 | dodir ${POD_DIR} |
|
|
| 31 | |
|
|
| 32 | make \ |
120 | emake \ |
| 33 | PREFIX=${D}/usr \ |
121 | OTHERLDFLAGS="${LDFLAGS}" \ |
| 34 | INSTALLMAN1DIR=${D}/usr/share/man/man1 \ |
122 | ${mymake} \ |
| 35 | INSTALLMAN2DIR=${D}/usr/share/man/man2 \ |
123 | || die "compilation failed" |
| 36 | INSTALLMAN3DIR=${D}/usr/share/man/man3 \ |
124 | # OPTIMIZE="${CFLAGS}" \ |
| 37 | INSTALLMAN4DIR=${D}/usr/share/man/man4 \ |
125 | fi |
| 38 | INSTALLMAN5DIR=${D}/usr/share/man/man5 \ |
126 | } |
| 39 | INSTALLMAN6DIR=${D}/usr/share/man/man6 \ |
|
|
| 40 | INSTALLMAN7DIR=${D}/usr/share/man/man7 \ |
|
|
| 41 | INSTALLMAN8DIR=${D}/usr/share/man/man8 \ |
|
|
| 42 | ${myinst} \ |
|
|
| 43 | install || die |
|
|
| 44 | |
127 | |
|
|
128 | perl-module_src_test() { |
|
|
129 | if [[ "${SRC_TEST}" == "do" ]] ; then |
|
|
130 | ${perlinfo_done} || perlinfo |
|
|
131 | if [[ -f Build ]] ; then |
|
|
132 | ./Build test || die "test failed" |
|
|
133 | elif [[ -f Makefile ]] ; then |
|
|
134 | emake test || die "test failed" |
|
|
135 | fi |
|
|
136 | fi |
|
|
137 | } |
|
|
138 | |
|
|
139 | perl-module_src_install() { |
|
|
140 | local f |
|
|
141 | ${perlinfo_done} || perlinfo |
|
|
142 | |
|
|
143 | if [[ -z ${mytargets} ]] ; then |
|
|
144 | case "${CATEGORY}" in |
|
|
145 | dev-perl|perl-core) mytargets="pure_install" ;; |
|
|
146 | *) mytargets="install" ;; |
|
|
147 | esac |
|
|
148 | fi |
|
|
149 | |
|
|
150 | if [[ -f Build ]] ; then |
|
|
151 | ./Build ${mytargets} \ |
|
|
152 | || die "./Build ${mytargets} failed" |
|
|
153 | elif [[ -f Makefile ]] ; then |
|
|
154 | emake ${myinst} ${mytargets} \ |
|
|
155 | || die "emake ${myinst} ${mytargets} failed" |
|
|
156 | fi |
|
|
157 | |
|
|
158 | if [[ -d "${D}"/usr/share/man ]] ; then |
|
|
159 | # einfo "Cleaning out stray man files" |
|
|
160 | find "${D}"/usr/share/man -type f -name "*.3pm" -delete |
|
|
161 | find "${D}"/usr/share/man -depth -type d -empty -delete |
|
|
162 | fi |
|
|
163 | |
|
|
164 | fixlocalpod |
|
|
165 | |
|
|
166 | for f in Change* CHANGES README* ${mydoc}; do |
|
|
167 | [[ -s "${f}" ]] && dodoc ${f} |
|
|
168 | done |
|
|
169 | |
|
|
170 | if [[ -d "${D}/${VENDOR_LIB}" ]] ; then |
|
|
171 | find "${D}/${VENDOR_LIB}" -type f -a \( -name .packlist \ |
|
|
172 | -o \( -name '*.bs' -a -empty \) \) -delete |
|
|
173 | find "${D}/${VENDOR_LIB}" -depth -mindepth 1 -type d -empty -delete |
|
|
174 | fi |
|
|
175 | |
|
|
176 | find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do |
|
|
177 | if file "${f}" | grep -q -i " text" ; then |
|
|
178 | if grep -q "${D}" "${f}" ; then ewarn "QA: File contains a temporary path ${f}" ;fi |
| 45 | sed -e "s:${D}::g" \ |
179 | sed -i -e "s:${D}:/:g" "${f}" |
| 46 | ${D}/${ARCH_LIB}/perllocal.pod \ |
180 | fi |
| 47 | > ${D}/${POD_DIR}/${P}.pod |
181 | done |
| 48 | |
|
|
| 49 | rm -f ${D}/${ARCH_LIB}/perllocal.pod |
|
|
| 50 | |
|
|
| 51 | dodoc Change* MANIFEST README* ${mydoc} |
|
|
| 52 | } |
182 | } |
|
|
183 | |
|
|
184 | perl-module_pkg_setup() { |
|
|
185 | ${perlinfo_done} || perlinfo |
|
|
186 | } |
|
|
187 | |
|
|
188 | perl-module_pkg_preinst() { |
|
|
189 | ${perlinfo_done} || perlinfo |
|
|
190 | } |
|
|
191 | |
|
|
192 | perl-module_pkg_postinst() { : ; } |
|
|
193 | # einfo "Man pages are not installed for most modules now." |
|
|
194 | # einfo "Please use perldoc instead." |
|
|
195 | #} |
|
|
196 | |
|
|
197 | perl-module_pkg_prerm() { : ; } |
|
|
198 | |
|
|
199 | perl-module_pkg_postrm() { : ; } |
|
|
200 | |
|
|
201 | perlinfo() { |
|
|
202 | perlinfo_done=true |
|
|
203 | |
|
|
204 | local f version install{site{arch,lib},archlib,vendor{arch,lib}} |
|
|
205 | for f in version install{site{arch,lib},archlib,vendor{arch,lib}} ; do |
|
|
206 | eval "$(perl -V:${f} )" |
|
|
207 | done |
|
|
208 | PERL_VERSION=${version} |
|
|
209 | SITE_ARCH=${installsitearch} |
|
|
210 | SITE_LIB=${installsitelib} |
|
|
211 | ARCH_LIB=${installarchlib} |
|
|
212 | VENDOR_LIB=${installvendorlib} |
|
|
213 | VENDOR_ARCH=${installvendorarch} |
|
|
214 | } |
|
|
215 | |
|
|
216 | fixlocalpod() { |
|
|
217 | find "${D}" -type f -name perllocal.pod -delete |
|
|
218 | find "${D}" -depth -mindepth 1 -type d -empty -delete |
|
|
219 | } |