/[gentoo-x86]/eclass/base.eclass
Gentoo

Diff of /eclass/base.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.32 Revision 1.55
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2011 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/base.eclass,v 1.32 2008/02/12 23:51:51 betelgeuse Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.55 2011/12/14 23:38:09 vapier Exp $
4# 4
5# Author Dan Armak <danarmak@gentoo.org> (nowadays retired) 5# @ECLASS: base.eclass
6# 6# @MAINTAINER:
7# QA Team <qa@gentoo.org>
8# @AUTHOR:
9# Original author: Dan Armak <danarmak@gentoo.org>
10# @BLURB: The base eclass defines some default functions and variables.
11# @DESCRIPTION:
7# The base eclass defines some default functions and variables. Nearly everything 12# The base eclass defines some default functions and variables. Nearly
8# else inherits from here. 13# everything else inherits from here.
14
15if [[ ${___ECLASS_ONCE_BASE} != "recur -_+^+_- spank" ]] ; then
16___ECLASS_ONCE_BASE="recur -_+^+_- spank"
9 17
10inherit eutils 18inherit eutils
11 19
12DESCRIPTION="Based on the $ECLASS eclass" 20BASE_EXPF="src_unpack src_compile src_install"
21case "${EAPI:-0}" in
22 2|3|4) BASE_EXPF+=" src_prepare src_configure" ;;
23 *) ;;
24esac
13 25
26EXPORT_FUNCTIONS ${BASE_EXPF}
27
28# @ECLASS-VARIABLE: DOCS
29# @DESCRIPTION:
30# Array containing documents passed to dodoc command.
31#
32# DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
33
34# @ECLASS-VARIABLE: HTML_DOCS
35# @DESCRIPTION:
36# Array containing documents passed to dohtml command.
37#
38# HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
39
40# @ECLASS-VARIABLE: PATCHES
41# @DESCRIPTION:
42# PATCHES array variable containing all various patches to be applied.
43# This variable is expected to be defined in global scope of ebuild.
44# Make sure to specify the full path. This variable is utilised in
45# src_unpack/src_prepare phase based on EAPI.
46#
47# NOTE: if using patches folders with special file suffixes you have to
48# define one additional variable EPATCH_SUFFIX="something"
49#
50# PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
51
52
53# @FUNCTION: base_src_unpack
54# @DESCRIPTION:
55# The base src_unpack function, which is exported.
56# Calls also src_prepare with eapi older than 2.
14base_src_unpack() { 57base_src_unpack() {
58 debug-print-function $FUNCNAME "$@"
15 59
16 debug-print-function $FUNCNAME $* 60 pushd "${WORKDIR}" > /dev/null
17 [ -z "$1" ] && base_src_unpack all
18 61
19 cd "${WORKDIR}" 62 [[ -n "${A}" ]] && unpack ${A}
63 has src_prepare ${BASE_EXPF} || base_src_prepare
20 64
21 while [ "$1" ]; do 65 popd > /dev/null
22
23 case $1 in
24 unpack)
25 debug-print-section unpack
26 unpack ${A}
27 ;;
28 patch)
29 debug-print-section patch
30 cd "${S}"
31 epatch "${FILESDIR}/${P}-gentoo.diff"
32 ;;
33 autopatch)
34 debug-print-section autopatch
35 debug-print "$FUNCNAME: autopatch: PATCHES=$PATCHES, PATCHES1=$PATCHES1"
36 cd "${S}"
37 for x in $PATCHES $PATCHES1; do
38 debug-print "$FUNCNAME: autopatch: patching from ${x}"
39 epatch ${x}
40 done
41 ;;
42 all)
43 debug-print-section all
44 base_src_unpack unpack autopatch
45 ;;
46 esac
47
48 shift
49 done
50
51} 66}
52 67
68# @FUNCTION: base_src_prepare
69# @DESCRIPTION:
70# The base src_prepare function, which is exported
71# EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
53base_src_compile() { 72base_src_prepare() {
73 debug-print-function $FUNCNAME "$@"
74 debug-print "$FUNCNAME: PATCHES=$PATCHES"
54 75
55 debug-print-function $FUNCNAME $* 76 local patches_failed=0
56 [ -z "$1" ] && base_src_compile all
57 77
58 cd "${S}" 78 pushd "${S}" > /dev/null
79 if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
80 for x in "${PATCHES[@]}"; do
81 debug-print "$FUNCNAME: applying patch from ${x}"
82 if [[ -d "${x}" ]]; then
83 # Use standardized names and locations with bulk patching
84 # Patch directory is ${WORKDIR}/patch
85 # See epatch() in eutils.eclass for more documentation
86 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
59 87
60 while [ "$1" ]; do 88 # in order to preserve normal EPATCH_SOURCE value that can
89 # be used other way than with base eclass store in local
90 # variable and restore later
91 oldval=${EPATCH_SOURCE}
92 EPATCH_SOURCE=${x}
93 EPATCH_FORCE=yes
94 epatch
95 EPATCH_SOURCE=${oldval}
96 elif [[ -f "${x}" ]]; then
97 epatch "${x}"
98 else
99 ewarn "QA: File or directory \"${x}\" does not exist."
100 ewarn "QA: Check your PATCHES array or add missing file/directory."
101 patches_failed=1
102 fi
103 done
104 [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages."
105 else
106 for x in ${PATCHES}; do
107 debug-print "$FUNCNAME: patching from ${x}"
108 epatch "${x}"
109 done
110 fi
61 111
62 case $1 in 112 # Apply user patches
63 configure) 113 debug-print "$FUNCNAME: applying user patches"
64 debug-print-section configure 114 epatch_user
65 econf || die "died running econf, $FUNCNAME:configure"
66 ;;
67 make)
68 debug-print-section make
69 emake || die "died running emake, $FUNCNAME:make"
70 ;;
71 all)
72 debug-print-section all
73 base_src_compile configure make
74 ;;
75 esac
76 115
77 shift 116 popd > /dev/null
78 done
79
80} 117}
81 118
82base_src_install() { 119# @FUNCTION: base_src_configure
120# @DESCRIPTION:
121# The base src_configure function, which is exported when
122# EAPI is greater or equal to 2. Runs basic econf.
123base_src_configure() {
124 debug-print-function $FUNCNAME "$@"
83 125
84 debug-print-function $FUNCNAME $* 126 # there is no pushd ${S} so we can override its place where to run
85 [ -z "$1" ] && base_src_install all 127 [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
86
87 cd "${S}"
88
89 while [ "$1" ]; do
90
91 case $1 in
92 make)
93 debug-print-section make
94 make DESTDIR="${D}" install || die "died running make install, $FUNCNAME:make"
95 ;;
96 all)
97 debug-print-section all
98 base_src_install make
99 ;;
100 esac
101
102 shift
103 done
104
105} 128}
106 129
107EXPORT_FUNCTIONS src_unpack src_compile src_install 130# @FUNCTION: base_src_compile
131# @DESCRIPTION:
132# The base src_compile function, calls src_configure with
133# EAPI older than 2.
134base_src_compile() {
135 debug-print-function $FUNCNAME "$@"
136
137 has src_configure ${BASE_EXPF} || base_src_configure
138 base_src_make "$@"
139}
140
141# @FUNCTION: base_src_make
142# @DESCRIPTION:
143# Actual function that runs emake command.
144base_src_make() {
145 debug-print-function $FUNCNAME "$@"
146
147 if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
148 emake "$@" || die "died running emake, $FUNCNAME"
149 fi
150}
151
152# @FUNCTION: base_src_install
153# @DESCRIPTION:
154# The base src_install function. Runs make install and
155# installs documents and html documents from DOCS and HTML_DOCS
156# arrays.
157base_src_install() {
158 debug-print-function $FUNCNAME "$@"
159
160 emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME"
161 base_src_install_docs
162}
163
164# @FUNCTION: base_src_install_docs
165# @DESCRIPTION:
166# Actual function that install documentation from
167# DOCS and HTML_DOCS arrays.
168base_src_install_docs() {
169 debug-print-function $FUNCNAME "$@"
170
171 local x
172
173 pushd "${S}" > /dev/null
174
175 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
176 for x in "${DOCS[@]}"; do
177 debug-print "$FUNCNAME: docs: creating document from ${x}"
178 dodoc "${x}" || die "dodoc failed"
179 done
180 fi
181 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
182 for x in "${HTML_DOCS[@]}"; do
183 debug-print "$FUNCNAME: docs: creating html document from ${x}"
184 dohtml -r "${x}" || die "dohtml failed"
185 done
186 fi
187
188 popd > /dev/null
189}
190
191fi

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.55

  ViewVC Help
Powered by ViewVC 1.1.20