| 1 | # Copyright 1999-2003 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.53 2003/10/19 11:50:36 lanius Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.113 2009/03/06 11:42:41 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 |
|
|
8 | # @MAINTAINER: |
|
|
9 | # perl@gentoo.org |
|
|
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 | |
| 10 | ECLASS=perl-module |
15 | inherit eutils base |
| 11 | INHERITED="${INHERITED} ${ECLASS}" |
|
|
| 12 | |
16 | |
|
|
17 | case "${EAPI:-0}" in |
|
|
18 | 0|1) |
| 13 | EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm \ |
19 | EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm src_compile src_install src_test src_unpack |
| 14 | src_compile src_install src_test \ |
20 | ;; |
| 15 | perlinfo updatepod |
21 | 2) |
|
|
22 | EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install |
| 16 | |
23 | |
| 17 | eval `perl '-V:version'` |
24 | case "${GENTOO_DEPEND_ON_PERL:-yes}" in |
| 18 | newdepend ">=dev-lang/perl-5.8.0-r12" |
25 | yes) |
|
|
26 | DEPEND="dev-lang/perl[-build]" |
|
|
27 | RDEPEND="${DEPEND}" |
|
|
28 | ;; |
|
|
29 | esac |
|
|
30 | ;; |
|
|
31 | esac |
|
|
32 | |
|
|
33 | DESCRIPTION="Based on the $ECLASS eclass" |
|
|
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 | |
| 19 | SRC_PREP="no" |
43 | SRC_PREP="no" |
|
|
44 | SRC_TEST="skip" |
|
|
45 | PREFER_BUILDPL="yes" |
| 20 | |
46 | |
|
|
47 | PERL_VERSION="" |
|
|
48 | SITE_ARCH="" |
| 21 | SITE_LIB="" |
49 | SITE_LIB="" |
| 22 | ARCH_LIB="" |
50 | ARCH_LIB="" |
| 23 | POD_DIR="" |
51 | VENDOR_ARCH="" |
|
|
52 | VENDOR_LIB="" |
| 24 | |
53 | |
| 25 | # handling of DESTDIR changed in makemaker 6.11 |
54 | pm_echovar="" |
| 26 | MMSIXELEVEN=`perl -e 'use ExtUtils::MakeMaker; print( $ExtUtils::MakeMaker::VERSION gt "6.11" )'` |
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 | } |
| 27 | |
72 | |
| 28 | perl-module_src_prep() { |
73 | perl-module_src_prep() { |
| 29 | |
74 | [[ "${SRC_PREP}" = "yes" ]] && return 0 |
| 30 | SRC_PREP="yes" |
75 | SRC_PREP="yes" |
| 31 | if [ "${style}" == "builder" ]; then |
76 | |
| 32 | perl ${S}/Build.PL installdirs=vendor destdir=${D} |
77 | ${perlinfo_done} || perlinfo |
| 33 | else |
78 | |
| 34 | if [ "${MMSIXELEVEN}" ]; then |
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" |
| 35 | perl Makefile.PL ${myconf} \ |
96 | perl Makefile.PL \ |
| 36 | PREFIX=/usr INSTALLDIRS=vendor DESTDIR=${D} |
97 | PREFIX=/usr \ |
| 37 | else |
98 | INSTALLDIRS=vendor \ |
| 38 | perl Makefile.PL ${myconf} \ |
99 | INSTALLMAN3DIR='none' \ |
| 39 | PREFIX=${D}/usr INSTALLDIRS=vendor |
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 \ |
|
|
118 | || die "compilation failed" |
|
|
119 | elif [[ -f Makefile ]] ; then |
|
|
120 | emake \ |
|
|
121 | OTHERLDFLAGS="${LDFLAGS}" \ |
|
|
122 | ${mymake} \ |
|
|
123 | || die "compilation failed" |
|
|
124 | # OPTIMIZE="${CFLAGS}" \ |
|
|
125 | fi |
|
|
126 | } |
|
|
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" |
| 40 | fi |
135 | fi |
| 41 | fi |
136 | fi |
| 42 | |
|
|
| 43 | } |
|
|
| 44 | |
|
|
| 45 | perl-module_src_compile() { |
|
|
| 46 | |
|
|
| 47 | [ "${SRC_PREP}" != "yes" ] && perl-module_src_prep |
|
|
| 48 | if [ "${style}" != "builder" ]; then |
|
|
| 49 | make ${mymake} || die "compilation failed" |
|
|
| 50 | fi |
|
|
| 51 | |
|
|
| 52 | } |
|
|
| 53 | |
|
|
| 54 | perl-module_src_test() { |
|
|
| 55 | if [ "${style}" == "builder" ]; then |
|
|
| 56 | perl ${S}/Build test |
|
|
| 57 | else |
|
|
| 58 | make test |
|
|
| 59 | fi |
|
|
| 60 | |
|
|
| 61 | } |
137 | } |
| 62 | |
138 | |
| 63 | perl-module_src_install() { |
139 | perl-module_src_install() { |
| 64 | |
140 | local f |
| 65 | perlinfo |
141 | ${perlinfo_done} || perlinfo |
| 66 | dodir ${POD_DIR} |
142 | |
| 67 | |
|
|
| 68 | test -z ${mytargets} && mytargets="install" |
143 | [[ -z ${mytargets} ]] && mytargets="pure_install" |
| 69 | eval `perl '-V:installsitearch'` |
144 | |
|
|
145 | if [[ -f Build ]] ; then |
|
|
146 | ./Build ${mytargets} \ |
|
|
147 | || die "./Build ${mytargets} failed" |
|
|
148 | elif [[ -f Makefile ]] ; then |
|
|
149 | emake ${myinst} ${mytargets} \ |
|
|
150 | || die "emake ${myinst} ${mytargets} failed" |
|
|
151 | fi |
|
|
152 | |
|
|
153 | # einfo "Cleaning out stray man files" |
|
|
154 | find "${D}" -type f -name "*.3pm" -delete |
|
|
155 | find "${D}"/usr/share/man -depth -type d -empty -delete 2>/dev/null |
|
|
156 | |
|
|
157 | fixlocalpod |
|
|
158 | |
|
|
159 | for f in Change* CHANGES README* ${mydoc}; do |
|
|
160 | [[ -s "${f}" ]] && dodoc ${f} |
|
|
161 | done |
|
|
162 | |
|
|
163 | find "${D}/${VENDOR_LIB}" -type f -a \( -name .packlist \ |
|
|
164 | -o \( -name '*.bs' -a -empty \) \) -delete |
|
|
165 | find "${D}/${VENDOR_LIB}" -depth -mindepth 1 -type d -empty -delete |
|
|
166 | |
|
|
167 | find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do |
|
|
168 | if file "${f}" | grep -q -i " text" ; then |
|
|
169 | if grep -q "${D}" "${f}" ; then ewarn "QA: File contains a temporary path ${f}" ;fi |
|
|
170 | sed -i -e "s:${D}:/:g" "${f}" |
|
|
171 | fi |
|
|
172 | done |
|
|
173 | } |
|
|
174 | |
|
|
175 | perl-module_pkg_setup() { |
|
|
176 | ${perlinfo_done} || perlinfo |
|
|
177 | } |
|
|
178 | |
|
|
179 | perl-module_pkg_preinst() { |
|
|
180 | ${perlinfo_done} || perlinfo |
|
|
181 | } |
|
|
182 | |
|
|
183 | perl-module_pkg_postinst() { : ; } |
|
|
184 | # einfo "Man pages are not installed for most modules now." |
|
|
185 | # einfo "Please use perldoc instead." |
|
|
186 | #} |
|
|
187 | |
|
|
188 | perl-module_pkg_prerm() { : ; } |
|
|
189 | |
|
|
190 | perl-module_pkg_postrm() { : ; } |
|
|
191 | |
|
|
192 | perlinfo() { |
|
|
193 | perlinfo_done=true |
|
|
194 | |
|
|
195 | local f version install{site{arch,lib},archlib,vendor{arch,lib}} |
|
|
196 | for f in version install{site{arch,lib},archlib,vendor{arch,lib}} ; do |
|
|
197 | eval "$(perl -V:${f} )" |
|
|
198 | done |
|
|
199 | PERL_VERSION=${version} |
| 70 | SITE_ARCH=${installsitearch} |
200 | SITE_ARCH=${installsitearch} |
| 71 | eval `perl '-V:installarchlib'` |
201 | SITE_LIB=${installsitelib} |
| 72 | ARCH_LIB=${installarchlib} |
202 | ARCH_LIB=${installarchlib} |
| 73 | |
203 | VENDOR_LIB=${installvendorlib} |
| 74 | if [ "${style}" == "builder" ]; then |
204 | VENDOR_ARCH=${installvendorarch} |
| 75 | perl ${S}/Build install |
|
|
| 76 | else |
|
|
| 77 | if [ "${MMSIXELEVEN}" ]; then |
|
|
| 78 | make ${myinst} ${mytargets} || die |
|
|
| 79 | else |
|
|
| 80 | make \ |
|
|
| 81 | PREFIX=${D}/usr \ |
|
|
| 82 | INSTALLMAN1DIR=${D}/usr/share/man/man1 \ |
|
|
| 83 | INSTALLMAN2DIR=${D}/usr/share/man/man2 \ |
|
|
| 84 | INSTALLMAN3DIR=${D}/usr/share/man/man3 \ |
|
|
| 85 | INSTALLMAN4DIR=${D}/usr/share/man/man4 \ |
|
|
| 86 | INSTALLMAN5DIR=${D}/usr/share/man/man5 \ |
|
|
| 87 | INSTALLMAN6DIR=${D}/usr/share/man/man6 \ |
|
|
| 88 | INSTALLMAN7DIR=${D}/usr/share/man/man7 \ |
|
|
| 89 | INSTALLMAN8DIR=${D}/usr/share/man/man8 \ |
|
|
| 90 | INSTALLSITEMAN1DIR=${D}/usr/share/man/man1 \ |
|
|
| 91 | INSTALLSITEMAN2DIR=${D}/usr/share/man/man2 \ |
|
|
| 92 | INSTALLSITEMAN3DIR=${D}/usr/share/man/man3 \ |
|
|
| 93 | INSTALLSITEMAN4DIR=${D}/usr/share/man/man4 \ |
|
|
| 94 | INSTALLSITEMAN5DIR=${D}/usr/share/man/man5 \ |
|
|
| 95 | INSTALLSITEMAN6DIR=${D}/usr/share/man/man6 \ |
|
|
| 96 | INSTALLSITEMAN7DIR=${D}/usr/share/man/man7 \ |
|
|
| 97 | INSTALLSITEMAN8DIR=${D}/usr/share/man/man8 \ |
|
|
| 98 | INSTALLVENDORMAN3DIR=${D}/usr/share/man/man3 \ |
|
|
| 99 | INSTALLSITEARCH=${D}/${SITE_ARCH} \ |
|
|
| 100 | INSTALLSCRIPT=${D}/usr/bin \ |
|
|
| 101 | ${myinst} \ |
|
|
| 102 | ${mytargets} || die |
|
|
| 103 | fi |
|
|
| 104 | fi |
|
|
| 105 | |
|
|
| 106 | if [ -f ${D}${ARCH_LIB}/perllocal.pod ]; |
|
|
| 107 | then |
|
|
| 108 | touch ${D}/${POD_DIR}/${P}.pod |
|
|
| 109 | sed -e "s:${D}::g" \ |
|
|
| 110 | ${D}${ARCH_LIB}/perllocal.pod >> ${D}/${POD_DIR}/${P}.pod |
|
|
| 111 | touch ${D}/${POD_DIR}/${P}.pod.arch |
|
|
| 112 | cat ${D}/${POD_DIR}/${P}.pod >>${D}/${POD_DIR}/${P}.pod.arch |
|
|
| 113 | rm -f ${D}/${ARCH_LIB}/perllocal.pod |
|
|
| 114 | fi |
|
|
| 115 | |
|
|
| 116 | if [ -f ${D}${SITE_LIB}/perllocal.pod ]; |
|
|
| 117 | then |
|
|
| 118 | touch ${D}/${POD_DIR}/${P}.pod |
|
|
| 119 | sed -e "s:${D}::g" \ |
|
|
| 120 | ${D}${SITE_LIB}/perllocal.pod >> ${D}/${POD_DIR}/${P}.pod |
|
|
| 121 | touch ${D}/${POD_DIR}/${P}.pod.site |
|
|
| 122 | cat ${D}/${POD_DIR}/${P}.pod >>${D}/${POD_DIR}/${P}.pod.site |
|
|
| 123 | rm -f ${D}/${SITE_LIB}/perllocal.pod |
|
|
| 124 | fi |
|
|
| 125 | |
|
|
| 126 | for FILE in `find ${D} -type f -name "*.html" -o -name ".packlist"`; do |
|
|
| 127 | sed -i -e "s:${D}:/:g" ${FILE} |
|
|
| 128 | done |
|
|
| 129 | |
|
|
| 130 | for doc in Change* MANIFEST* README*; do |
|
|
| 131 | [ -s "$doc" ] && dodoc $doc |
|
|
| 132 | done |
|
|
| 133 | dodoc ${mydoc} |
|
|
| 134 | } |
205 | } |
| 135 | |
206 | |
| 136 | |
207 | fixlocalpod() { |
| 137 | perl-module_pkg_setup() { |
208 | find "${D}" -type f -name perllocal.pod -delete |
| 138 | |
209 | find "${D}" -depth -mindepth 1 -type d -empty -delete |
| 139 | perlinfo |
|
|
| 140 | } |
210 | } |
| 141 | |
|
|
| 142 | |
|
|
| 143 | perl-module_pkg_preinst() { |
|
|
| 144 | |
|
|
| 145 | perlinfo |
|
|
| 146 | } |
|
|
| 147 | |
|
|
| 148 | perl-module_pkg_postinst() { |
|
|
| 149 | |
|
|
| 150 | updatepod |
|
|
| 151 | } |
|
|
| 152 | |
|
|
| 153 | perl-module_pkg_prerm() { |
|
|
| 154 | |
|
|
| 155 | updatepod |
|
|
| 156 | } |
|
|
| 157 | |
|
|
| 158 | perl-module_pkg_postrm() { |
|
|
| 159 | |
|
|
| 160 | updatepod |
|
|
| 161 | } |
|
|
| 162 | |
|
|
| 163 | perlinfo() { |
|
|
| 164 | |
|
|
| 165 | if [ -f /usr/bin/perl ] |
|
|
| 166 | then |
|
|
| 167 | eval `perl '-V:installarchlib'` |
|
|
| 168 | eval `perl '-V:installsitearch'` |
|
|
| 169 | ARCH_LIB=${installarchlib} |
|
|
| 170 | SITE_LIB=${installsitearch} |
|
|
| 171 | |
|
|
| 172 | eval `perl '-V:version'` |
|
|
| 173 | POD_DIR="/usr/share/perl/gentoo-pods/${version}" |
|
|
| 174 | fi |
|
|
| 175 | |
|
|
| 176 | } |
|
|
| 177 | |
|
|
| 178 | updatepod() { |
|
|
| 179 | perlinfo |
|
|
| 180 | |
|
|
| 181 | if [ -d "${POD_DIR}" ] |
|
|
| 182 | then |
|
|
| 183 | for FILE in `find ${POD_DIR} -type f -name "*.pod.arch"`; do |
|
|
| 184 | cat ${FILE} >> ${ARCH_LIB}/perllocal.pod |
|
|
| 185 | rm -f ${FILE} |
|
|
| 186 | done |
|
|
| 187 | for FILE in `find ${POD_DIR} -type f -name "*.pod.site"`; do |
|
|
| 188 | cat ${FILE} >> ${SITE_LIB}/perllocal.pod |
|
|
| 189 | rm -f ${FILE} |
|
|
| 190 | done |
|
|
| 191 | fi |
|
|
| 192 | } |
|
|