Gentoo Archives: gentoo-dev

From: Torsten Veller <ml-en@××××××.net>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] perl eclass review - EAPI=3 + new helper eclass
Date: Tue, 30 Mar 2010 11:12:46
Message-Id: 20100330111154.GA28735@veller.net
1 The perl-module.eclass must be updated to support EAPI=3 [1] and
2 a new eclass will be added which does contain some (more or less) useful
3 stand-alone functions split from the old perl-module.eclass without
4 exporting phase functions.
5 Functions used in ebuilds that don't need the exported default phases
6 are perlinfo() and fixlocalpod().
7
8
9 Below is the new eclass, working title is perl-helper.eclass.
10 A diff between the the current and the new perl-module.eclass can be
11 found at [2]. Both are in use in the perl-experimental overlay [3].
12
13
14 Please review! If someone can come up with better names, either the
15 perl-helper.eclass or the functions named perl_*, please tell me.
16 I tried to make the perl-helper functions more unique but the
17 meaningfulness is open to question.
18
19
20 Thanks
21
22
23 [1] https://bugs.gentoo.org/310453
24 [2] http://dev.gentoo.org/~tove/files/perl-module.diff
25 [3] http://git.overlays.gentoo.org/gitweb/?p=proj/perl-overlay.git;a=tree;f=eclass;hb=HEAD
26
27
28
29 # Copyright 1999-2010 Gentoo Foundation
30 # Distributed under the terms of the GNU General Public License v2
31 # $Header: $
32
33 [[ ${CATEGORY} == "perl-core" ]] && inherit alternatives
34
35 perlinfo() {
36 debug-print-function $FUNCNAME "$@"
37 perl_set_version
38 }
39
40 perl_set_version() {
41 debug-print-function $FUNCNAME "$@"
42 debug-print "$FUNCNAME: perlinfo_done=${perlinfo_done}"
43 ${perlinfo_done} && return 0
44 perlinfo_done=true
45
46 local f version install{{site,vendor}{arch,lib},archlib}
47 eval "$(perl -V:{version,install{{site,vendor}{arch,lib},archlib}} )"
48 PERL_VERSION=${version}
49 SITE_ARCH=${installsitearch}
50 SITE_LIB=${installsitelib}
51 ARCH_LIB=${installarchlib}
52 VENDOR_LIB=${installvendorlib}
53 VENDOR_ARCH=${installvendorarch}
54 }
55
56 fixlocalpod() {
57 debug-print-function $FUNCNAME "$@"
58 perl_delete_localpod
59 }
60
61 perl_delete_localpod() {
62 debug-print-function $FUNCNAME "$@"
63
64 find "${D}" -type f -name perllocal.pod -delete
65 find "${D}" -depth -mindepth 1 -type d -empty -delete
66 }
67
68 perl_fix_osx_extra() {
69 debug-print-function $FUNCNAME "$@"
70
71 # Remove "AppleDouble encoded Macintosh file"
72 local f
73 find "${S}" -type f -name "._*" -print0 | while read -rd '' f ; do
74 einfo "Removing AppleDouble encoded Macintosh file: ${f#${S}/}"
75 rm -f "${f}"
76 f=${f#${S}/}
77 # f=${f//\//\/}
78 # f=${f//\./\.}
79 # sed -i "/${f}/d" "${S}"/MANIFEST || die
80 grep -q "${f}" "${S}"/MANIFEST && \
81 elog "AppleDouble encoded Macintosh file in MANIFEST: ${f#${S}/}"
82 done
83 }
84
85 perl_delete_module_manpages() {
86 debug-print-function $FUNCNAME "$@"
87
88 perl_set_eprefix
89
90 if [[ -d "${ED}"/usr/share/man ]] ; then
91 # einfo "Cleaning out stray man files"
92 find "${ED}"/usr/share/man -type f -name "*.3pm" -delete
93 find "${ED}"/usr/share/man -depth -type d -empty -delete
94 fi
95 }
96
97 perl_delete_packlist() {
98 debug-print-function $FUNCNAME "$@"
99 perl_set_version
100 if [[ -d ${D}/${VENDOR_LIB} ]] ; then
101 find "${D}/${VENDOR_LIB}" -type f -a \( -name .packlist \
102 -o \( -name '*.bs' -a -empty \) \) -delete
103 find "${D}/${VENDOR_LIB}" -depth -mindepth 1 -type d -empty -delete
104 fi
105 }
106
107 perl_remove_temppath() {
108 debug-print-function $FUNCNAME "$@"
109
110 find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
111 if file "${f}" | grep -q -i " text" ; then
112 grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
113 sed -i -e "s:${D}:/:g" "${f}"
114 fi
115 done
116 }
117
118 perl_link_duallife_scripts() {
119 debug-print-function $FUNCNAME "$@"
120 if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; then
121 return 0
122 fi
123
124 perl_set_eprefix
125
126 local i ff
127 if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
128 for i in "${DUALLIFESCRIPTS[@]}" ; do
129 alternatives_auto_makesym "/usr/bin/${i}" "/usr/bin/${i}-[0-9]*"
130 ff=`echo "${EROOT}"/usr/share/man/man1/${i}-${PV}-${P}.1*`
131 ff=${ff##*.1}
132 alternatives_auto_makesym "/usr/share/man/man1/${i}.1${ff}" "/usr/share/man/man1/${i}-[0-9]*"
133 done
134 else
135 pushd "${ED}" > /dev/null
136 for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
137 mv ${i}{,-${PV}-${P}} || die
138 DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
139 if [[ -f usr/share/man/man1/${i##*/}.1 ]] ; then
140 mv usr/share/man/man1/${i##*/}{.1,-${PV}-${P}.1} || die
141 fi
142 done
143 popd > /dev/null
144 fi
145 }
146
147 perl_set_eprefix() {
148 debug-print-function $FUNCNAME "$@"
149 case ${EAPI:-0} in
150 0|1|2)
151 if ! use prefix; then
152 EPREFIX=
153 ED=${D}
154 EROOT=${ROOT}
155 fi
156 ;;
157 esac
158 }

Replies