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

Diff of /eclass/base.eclass

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

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

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.58

  ViewVC Help
Powered by ViewVC 1.1.20