1 |
scarabeus 10/01/11 16:57:46 |
2 |
|
3 |
Modified: base.eclass |
4 |
Log: |
5 |
Update maintainership to be qa@g.o |
6 |
Features information: |
7 |
PATCHES now accept also folders as their argument. |
8 |
New arrays DOCS and HTML_DOCS, also bash arrays as patches. |
9 |
src_install calls emake and not make. |
10 |
switched from "function argument" layout to separate functions. |
11 |
Review request submited: http://archives.gentoo.org/gentoo-dev/msg_254665435d58a97bcc5a952e5e005cd1.xml |
12 |
|
13 |
Revision Changes Path |
14 |
1.41 eclass/base.eclass |
15 |
|
16 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/base.eclass?rev=1.41&view=markup |
17 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/base.eclass?rev=1.41&content-type=text/plain |
18 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/base.eclass?r1=1.40&r2=1.41 |
19 |
|
20 |
Index: base.eclass |
21 |
=================================================================== |
22 |
RCS file: /var/cvsroot/gentoo-x86/eclass/base.eclass,v |
23 |
retrieving revision 1.40 |
24 |
retrieving revision 1.41 |
25 |
diff -u -r1.40 -r1.41 |
26 |
--- base.eclass 3 Jan 2010 21:07:32 -0000 1.40 |
27 |
+++ base.eclass 11 Jan 2010 16:57:46 -0000 1.41 |
28 |
@@ -1,227 +1,173 @@ |
29 |
# Copyright 1999-2008 Gentoo Foundation |
30 |
# Distributed under the terms of the GNU General Public License v2 |
31 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.40 2010/01/03 21:07:32 mr_bones_ Exp $ |
32 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.41 2010/01/11 16:57:46 scarabeus Exp $ |
33 |
|
34 |
# @ECLASS: base.eclass |
35 |
# @MAINTAINER: |
36 |
-# Peter Alfredsen <loki_val@g.o> |
37 |
+# QA Team <qa@g.o> |
38 |
# |
39 |
# Original author Dan Armak <danarmak@g.o> |
40 |
# @BLURB: The base eclass defines some default functions and variables. |
41 |
# @DESCRIPTION: |
42 |
# The base eclass defines some default functions and variables. Nearly |
43 |
# everything else inherits from here. |
44 |
-# |
45 |
-# NOTE: You must define EAPI before inheriting from base, or the wrong functions |
46 |
-# may be exported. |
47 |
- |
48 |
|
49 |
inherit eutils |
50 |
|
51 |
+BASE_EXPF="src_unpack src_compile src_install" |
52 |
case "${EAPI:-0}" in |
53 |
- 2) |
54 |
- EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install |
55 |
- ;; |
56 |
- *) |
57 |
- EXPORT_FUNCTIONS src_unpack src_compile src_install |
58 |
- ;; |
59 |
+ 2|3|4) BASE_EXPF="src_prepare src_configure" ;; |
60 |
+ *) ;; |
61 |
esac |
62 |
|
63 |
-DESCRIPTION="Based on the $ECLASS eclass" |
64 |
+EXPORT_FUNCTIONS ${BASE_EXPF} |
65 |
|
66 |
-# @FUNCTION: base_src_unpack |
67 |
-# @USAGE: [ unpack ] [ patch ] [ autopatch ] [ all ] |
68 |
+# @ECLASS-VARIABLE: DOCS |
69 |
+# @USAGE: DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" ) |
70 |
# @DESCRIPTION: |
71 |
-# The base src_unpack function, which is exported. If no argument is given, |
72 |
-# "all" is assumed if EAPI!=2, "unpack" if EAPI=2. |
73 |
-base_src_unpack() { |
74 |
+# Array containing documents passed to dodoc command. |
75 |
|
76 |
- debug-print-function $FUNCNAME "$@" |
77 |
- |
78 |
- if [ -z "$1" ] ; then |
79 |
- case "${EAPI:-0}" in |
80 |
- 2) |
81 |
- base_src_util unpack |
82 |
- ;; |
83 |
- *) |
84 |
- base_src_util all |
85 |
- ;; |
86 |
- esac |
87 |
- else |
88 |
- base_src_util $@ |
89 |
- fi |
90 |
-} |
91 |
+# @ECLASS-VARIABLE: HTML_DOCS |
92 |
+# @USAGE: HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" ) |
93 |
+# @DESCRIPTION: |
94 |
+# Array containing documents passed to dohtml command. |
95 |
|
96 |
-# @FUNCTION: base_src_prepare |
97 |
+# @ECLASS-VARIABLE: PATCHES |
98 |
+# @USAGE: PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" ) |
99 |
# @DESCRIPTION: |
100 |
-# The base src_prepare function, which is exported when EAPI=2. Performs |
101 |
-# "base_src_util autopatch". |
102 |
-base_src_prepare() { |
103 |
+# PATCHES array variable containing all various patches to be applied. |
104 |
+# This variable is expected to be defined in global scope of ebuild. |
105 |
+# Make sure to specify the full path. This variable is utilised in |
106 |
+# src_unpack/src_prepare phase based on EAPI. |
107 |
+# NOTE: if using patches folders with special file suffixes you have to |
108 |
+# define one additional variable EPATCH_SUFFIX="something" |
109 |
+ |
110 |
|
111 |
+# @FUNCTION: base_src_unpack |
112 |
+# @DESCRIPTION: |
113 |
+# The base src_unpack function, which is exported. |
114 |
+# Calls also src_prepare with eapi older than 2. |
115 |
+base_src_unpack() { |
116 |
debug-print-function $FUNCNAME "$@" |
117 |
|
118 |
- base_src_util autopatch |
119 |
+ pushd "${WORKDIR}" > /dev/null |
120 |
+ |
121 |
+ [[ -n "${A}" ]] && unpack ${A} |
122 |
+ has src_prepare ${BASE_EXPF} || base_src_prepare |
123 |
+ |
124 |
+ popd > /dev/null |
125 |
} |
126 |
|
127 |
-# @FUNCTION: base_src_util |
128 |
-# @USAGE: [ unpack ] [ patch ] [ autopatch ] [ all ] |
129 |
+# @FUNCTION: base_src_prepare |
130 |
# @DESCRIPTION: |
131 |
-# The base_src_util function is the grunt function for base src_unpack |
132 |
-# and base src_prepare. |
133 |
-base_src_util() { |
134 |
- local x |
135 |
- |
136 |
+# The base src_prepare function, which is exported |
137 |
+# EAPI is greater or equal to 2. |
138 |
+base_src_prepare() { |
139 |
debug-print-function $FUNCNAME "$@" |
140 |
+ debug-print "$FUNCNAME: PATCHES=$PATCHES" |
141 |
|
142 |
- cd "${WORKDIR}" |
143 |
- |
144 |
- while [ "$1" ]; do |
145 |
- |
146 |
- case $1 in |
147 |
- unpack) |
148 |
- debug-print-section unpack |
149 |
- if [ ! -z "$A" ] ; then |
150 |
- unpack ${A} |
151 |
- fi |
152 |
- ;; |
153 |
- patch) |
154 |
- debug-print-section patch |
155 |
- cd "${S}" |
156 |
- epatch "${FILESDIR}/${P}-gentoo.diff" |
157 |
- ;; |
158 |
- autopatch) |
159 |
- debug-print-section autopatch |
160 |
- debug-print "$FUNCNAME: autopatch: PATCHES=$PATCHES, PATCHES1=$PATCHES1" |
161 |
- cd "${S}" |
162 |
- if [[ ${#PATCHES[@]} -gt 1 ]] ; then |
163 |
- for x in "${PATCHES[@]}"; do |
164 |
- debug-print "$FUNCNAME: autopatch: patching from ${x}" |
165 |
- epatch "${x}" |
166 |
- done |
167 |
- else |
168 |
- for x in ${PATCHES} ${PATCHES1}; do |
169 |
- debug-print "$FUNCNAME: autopatch: patching from ${x}" |
170 |
- epatch "${x}" |
171 |
- done |
172 |
+ pushd "${S}" > /dev/null |
173 |
+ if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
174 |
+ for x in "${PATCHES[@]}"; do |
175 |
+ debug-print "$FUNCNAME: applying patch from ${x}" |
176 |
+ [[ -f "${x}" ]] && epatch "${x}" |
177 |
+ if [[ -d "${x}" ]]; then |
178 |
+ # Use standardized names and locations with bulk patching |
179 |
+ # Patch directory is ${WORKDIR}/patch |
180 |
+ # See epatch() in eutils.eclass for more documentation |
181 |
+ EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch} |
182 |
+ |
183 |
+ # in order to preserve normal EPATCH_SOURCE value that can |
184 |
+ # be used other way than with base eclass store in local |
185 |
+ # variable and restore later |
186 |
+ oldval=${EPATCH_SOURCE} |
187 |
+ EPATCH_SOURCE=${x} |
188 |
+ epatch |
189 |
+ EPATCH_SOURCE=${oldval} |
190 |
fi |
191 |
- ;; |
192 |
- all) |
193 |
- debug-print-section all |
194 |
- base_src_util unpack autopatch |
195 |
- ;; |
196 |
- esac |
197 |
+ done |
198 |
+ else |
199 |
+ for x in ${PATCHES}; do |
200 |
+ debug-print "$FUNCNAME: patching from ${x}" |
201 |
+ epatch "${x}" |
202 |
+ done |
203 |
+ fi |
204 |
|
205 |
- shift |
206 |
- done |
207 |
+ # Apply user patches |
208 |
+ debug-print "$FUNCNAME: applying user patches" |
209 |
+ epatch_user |
210 |
|
211 |
+ popd > /dev/null |
212 |
} |
213 |
|
214 |
# @FUNCTION: base_src_configure |
215 |
# @DESCRIPTION: |
216 |
-# The base src_prepare function, which is exported when EAPI=2. Performs |
217 |
-# "base_src_work configure". |
218 |
+# The base src_configure function, which is exported when |
219 |
+# EAPI is greater or equal to 2. Runs basic econf. |
220 |
base_src_configure() { |
221 |
- |
222 |
debug-print-function $FUNCNAME "$@" |
223 |
|
224 |
- base_src_work configure |
225 |
+ # there is no pushd ${S} so we can override its place where to run |
226 |
+ [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf |
227 |
} |
228 |
|
229 |
# @FUNCTION: base_src_compile |
230 |
-# @USAGE: [ configure ] [ make ] [ all ] |
231 |
# @DESCRIPTION: |
232 |
-# The base src_compile function, which is exported. If no argument is given, |
233 |
-# "all" is assumed if EAPI!=2, "make" if EAPI=2. |
234 |
+# The base src_compile function, calls src_configure with |
235 |
+# EAPI older than 2. |
236 |
base_src_compile() { |
237 |
- |
238 |
debug-print-function $FUNCNAME "$@" |
239 |
|
240 |
- if [ -z "$1" ] |
241 |
- then |
242 |
- case "${EAPI:-0}" in |
243 |
- 2) |
244 |
- base_src_work make |
245 |
- ;; |
246 |
- *) |
247 |
- base_src_work all |
248 |
- ;; |
249 |
- esac |
250 |
- else |
251 |
- base_src_work $@ |
252 |
- fi |
253 |
+ has src_configure ${BASE_EXPF} || base_src_configure |
254 |
+ base_src_make $@ |
255 |
} |
256 |
|
257 |
-# placeholder for future api so eclasses can be migrated now. |
258 |
+# @FUNCTION: base_src_make |
259 |
+# @DESCRIPTION: |
260 |
+# Actual function that runs emake command. |
261 |
base_src_make() { |
262 |
debug-print-function $FUNCNAME "$@" |
263 |
- base_src_work make |
264 |
+ |
265 |
+ if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then |
266 |
+ emake $@ || die "died running emake, $FUNCNAME:make" |
267 |
+ fi |
268 |
} |
269 |
|
270 |
-# @FUNCTION: base_src_work |
271 |
-# @USAGE: [ configure ] [ make ] [ all ] |
272 |
+# @FUNCTION: base_src_install |
273 |
# @DESCRIPTION: |
274 |
-# The base_src_work function is the grunt function for base src_configure |
275 |
-# and base src_compile. |
276 |
-base_src_work() { |
277 |
- |
278 |
+# The base src_install function. Runs make install and |
279 |
+# installs documents and html documents from DOCS and HTML_DOCS |
280 |
+# arrays. |
281 |
+base_src_install() { |
282 |
debug-print-function $FUNCNAME "$@" |
283 |
|
284 |
- cd "${S}" |
285 |
- |
286 |
- while [ "$1" ]; do |
287 |
- |
288 |
- case $1 in |
289 |
- configure) |
290 |
- debug-print-section configure |
291 |
- if [[ -x ${ECONF_SOURCE:-.}/configure ]] |
292 |
- then |
293 |
- econf || die "died running econf, $FUNCNAME:configure" |
294 |
- fi |
295 |
- ;; |
296 |
- make) |
297 |
- debug-print-section make |
298 |
- if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ] |
299 |
- then |
300 |
- emake || die "died running emake, $FUNCNAME:make" |
301 |
- fi |
302 |
- ;; |
303 |
- all) |
304 |
- debug-print-section all |
305 |
- base_src_work configure make |
306 |
- ;; |
307 |
- esac |
308 |
- |
309 |
- shift |
310 |
- done |
311 |
- |
312 |
+ emake DESTDIR="${D}" $@ install || die "died running make install, $FUNCNAME:make" |
313 |
+ base_src_install_docs |
314 |
} |
315 |
|
316 |
-# @FUNCTION: base_src_install |
317 |
-# @USAGE: [ make ] [ all ] |
318 |
+# @FUNCTION: base_src_install_docs |
319 |
# @DESCRIPTION: |
320 |
-# The base src_install function, which is exported. If no argument is given, |
321 |
-# "all" is assumed. |
322 |
-base_src_install() { |
323 |
- |
324 |
+# Actual function that install documentation from |
325 |
+# DOCS and HTML_DOCS arrays. |
326 |
+base_src_install_docs() { |
327 |
debug-print-function $FUNCNAME "$@" |
328 |
- [ -z "$1" ] && base_src_install all |
329 |
- |
330 |
- cd "${S}" |
331 |
|
332 |
- while [ "$1" ]; do |
333 |
+ local x |
334 |
|
335 |
- case $1 in |
336 |
- make) |
337 |
- debug-print-section make |
338 |
- make DESTDIR="${D}" install || die "died running make install, $FUNCNAME:make" |
339 |
- ;; |
340 |
- all) |
341 |
- debug-print-section all |
342 |
- base_src_install make |
343 |
- ;; |
344 |
- esac |
345 |
+ pushd "${S}" > /dev/null |
346 |
|
347 |
- shift |
348 |
- done |
349 |
+ if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
350 |
+ for x in "${DOCS[@]}"; do |
351 |
+ debug-print "$FUNCNAME: docs: creating document from ${x}" |
352 |
+ dodoc -r "${x}" || die "dodoc failed" |
353 |
+ done |
354 |
+ fi |
355 |
+ if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
356 |
+ for x in "${HTML_DOCS[@]}"; do |
357 |
+ debug-print "$FUNCNAME: docs: creating html document from ${x}" |
358 |
+ dohtml -r "${x}" || die "dohtml failed" |
359 |
+ done |
360 |
+ fi |
361 |
|
362 |
+ popd > /dev/null |
363 |
} |