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

Diff of /eclass/eutils.eclass

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

Revision 1.326 Revision 1.332
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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/eutils.eclass,v 1.326 2010/01/10 05:53:36 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.332 2010/02/17 02:22:43 reavertm Exp $
4 4
5# @ECLASS: eutils.eclass 5# @ECLASS: eutils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @BLURB: many extra (but common) functions that are used in ebuilds 8# @BLURB: many extra (but common) functions that are used in ebuilds
17 17
18inherit multilib portability 18inherit multilib portability
19 19
20DESCRIPTION="Based on the ${ECLASS} eclass" 20DESCRIPTION="Based on the ${ECLASS} eclass"
21 21
22if has "${EAPI:-0}" 0 1 2; then
23
22# @FUNCTION: epause 24# @FUNCTION: epause
23# @USAGE: [seconds] 25# @USAGE: [seconds]
24# @DESCRIPTION: 26# @DESCRIPTION:
25# Sleep for the specified number of seconds (default of 5 seconds). Useful when 27# Sleep for the specified number of seconds (default of 5 seconds). Useful when
26# printing a message the user should probably be reading and often used in 28# printing a message the user should probably be reading and often used in
27# conjunction with the ebeep function. If the EPAUSE_IGNORE env var is set, 29# conjunction with the ebeep function. If the EPAUSE_IGNORE env var is set,
28# don't wait at all. 30# don't wait at all. Defined in EAPIs 0 1 and 2.
29epause() { 31epause() {
30 [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5} 32 [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
31} 33}
32 34
33# @FUNCTION: ebeep 35# @FUNCTION: ebeep
34# @USAGE: [number of beeps] 36# @USAGE: [number of beeps]
35# @DESCRIPTION: 37# @DESCRIPTION:
36# Issue the specified number of beeps (default of 5 beeps). Useful when 38# Issue the specified number of beeps (default of 5 beeps). Useful when
37# printing a message the user should probably be reading and often used in 39# printing a message the user should probably be reading and often used in
38# conjunction with the epause function. If the EBEEP_IGNORE env var is set, 40# conjunction with the epause function. If the EBEEP_IGNORE env var is set,
39# don't beep at all. 41# don't beep at all. Defined in EAPIs 0 1 and 2.
40ebeep() { 42ebeep() {
41 local n 43 local n
42 if [[ -z ${EBEEP_IGNORE} ]] ; then 44 if [[ -z ${EBEEP_IGNORE} ]] ; then
43 for ((n=1 ; n <= ${1:-5} ; n++)) ; do 45 for ((n=1 ; n <= ${1:-5} ; n++)) ; do
44 echo -ne "\a" 46 echo -ne "\a"
47 sleep 1 49 sleep 1
48 done 50 done
49 fi 51 fi
50} 52}
51 53
54else
55
56ebeep() {
57 eqawarn "QA Notice: ebeep is not defined in EAPI=3, please file a bug at http://bugs.gentoo.org"
58}
59
60epause() {
61 eqawarn "QA Notice: epause is not defined in EAPI=3, please file a bug at http://bugs.gentoo.org"
62}
63
64fi
65
52# @FUNCTION: ecvs_clean 66# @FUNCTION: ecvs_clean
53# @USAGE: [list of dirs] 67# @USAGE: [list of dirs]
54# @DESCRIPTION: 68# @DESCRIPTION:
55# Remove CVS directories recursiveley. Useful when a source tarball contains 69# Remove CVS directories recursiveley. Useful when a source tarball contains
56# internal CVS directories. Defaults to $PWD. 70# internal CVS directories. Defaults to $PWD.
69 [[ -z $* ]] && set -- . 83 [[ -z $* ]] && set -- .
70 find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf 84 find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
71} 85}
72 86
73# @FUNCTION: eshopts_push 87# @FUNCTION: eshopts_push
74# @USAGE: [options to `set`] 88# @USAGE: [options to `set` or `shopt`]
75# @DESCRIPTION: 89# @DESCRIPTION:
76# Often times code will want to enable a shell option to change code behavior. 90# Often times code will want to enable a shell option to change code behavior.
77# Since changing shell options can easily break other pieces of code (which 91# Since changing shell options can easily break other pieces of code (which
78# assume the default state), eshopts_push is used to (1) push the current shell 92# assume the default state), eshopts_push is used to (1) push the current shell
79# options onto a stack and (2) pass the specified arguments to set. 93# options onto a stack and (2) pass the specified arguments to set.
94#
95# If the first argument is '-s' or '-u', we assume you want to call `shopt`
96# rather than `set` as there are some options only available via that.
80# 97#
81# A common example is to disable shell globbing so that special meaning/care 98# A common example is to disable shell globbing so that special meaning/care
82# may be used with variables/arguments to custom functions. That would be: 99# may be used with variables/arguments to custom functions. That would be:
83# @CODE 100# @CODE
84# eshopts_push -o noglob 101# eshopts_push -o noglob
92# @CODE 109# @CODE
93eshopts_push() { 110eshopts_push() {
94 # have to assume __ESHOPTS_SAVE__ isn't screwed with 111 # have to assume __ESHOPTS_SAVE__ isn't screwed with
95 # as a `declare -a` here will reset its value 112 # as a `declare -a` here will reset its value
96 local i=${#__ESHOPTS_SAVE__[@]} 113 local i=${#__ESHOPTS_SAVE__[@]}
114 if [[ $1 == -[su] ]] ; then
97 __ESHOPTS_SAVE__[$i]=$- 115 __ESHOPTS_SAVE__[$i]=$(shopt -p)
98 [[ $# -eq 0 ]] && return 0 116 [[ $# -eq 0 ]] && return 0
117 shopt "$@" || die "eshopts_push: bad options to shopt: $*"
118 else
119 __ESHOPTS_SAVE__[$i]=$-
120 [[ $# -eq 0 ]] && return 0
99 set "$@" || die "eshopts_push: bad options to set: $*" 121 set "$@" || die "eshopts_push: bad options to set: $*"
122 fi
100} 123}
101 124
102# @FUNCTION: eshopts_pop 125# @FUNCTION: eshopts_pop
103# @USAGE: 126# @USAGE:
104# @DESCRIPTION: 127# @DESCRIPTION:
108 [[ $# -ne 0 ]] && die "eshopts_pop takes no arguments" 131 [[ $# -ne 0 ]] && die "eshopts_pop takes no arguments"
109 local i=$(( ${#__ESHOPTS_SAVE__[@]} - 1 )) 132 local i=$(( ${#__ESHOPTS_SAVE__[@]} - 1 ))
110 [[ ${i} -eq -1 ]] && die "eshopts_{push,pop}: unbalanced pair" 133 [[ ${i} -eq -1 ]] && die "eshopts_{push,pop}: unbalanced pair"
111 local s=${__ESHOPTS_SAVE__[$i]} 134 local s=${__ESHOPTS_SAVE__[$i]}
112 unset __ESHOPTS_SAVE__[$i] 135 unset __ESHOPTS_SAVE__[$i]
136 if [[ ${s} == "shopt -"* ]] ; then
137 eval "${s}" || die "eshopts_pop: sanity: invalid shopt options: ${s}"
138 else
113 set +$- || die "eshopts_pop: sanity: invalid shell settings: $-" 139 set +$- || die "eshopts_pop: sanity: invalid shell settings: $-"
114 set -${s} || die "eshopts_pop: sanity: unable to restore saved shell settings: ${s}" 140 set -${s} || die "eshopts_pop: sanity: unable to restore saved shell settings: ${s}"
141 fi
115} 142}
116 143
117# @VARIABLE: EPATCH_SOURCE 144# @VARIABLE: EPATCH_SOURCE
118# @DESCRIPTION: 145# @DESCRIPTION:
119# Default directory to search for patches. 146# Default directory to search for patches.
265 # let people use globs in the exclude 292 # let people use globs in the exclude
266 eshopts_push -o noglob 293 eshopts_push -o noglob
267 294
268 local ex 295 local ex
269 for ex in ${EPATCH_EXCLUDE} ; do 296 for ex in ${EPATCH_EXCLUDE} ; do
270 [[ ${patchname} == ${ex} ]] && continue 297 if [[ ${patchname} == ${ex} ]] ; then
298 eshopts_pop
299 continue 2
300 fi
271 done 301 done
272 302
273 eshopts_pop 303 eshopts_pop
274 fi 304 fi
275 305
1740} 1770}
1741 1771
1742# @FUNCTION: built_with_use 1772# @FUNCTION: built_with_use
1743# @USAGE: [--hidden] [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags> 1773# @USAGE: [--hidden] [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags>
1744# @DESCRIPTION: 1774# @DESCRIPTION:
1775#
1776# Deprecated: Use EAPI 2 use deps in DEPEND|RDEPEND and with has_version calls.
1777#
1745# A temporary hack until portage properly supports DEPENDing on USE 1778# A temporary hack until portage properly supports DEPENDing on USE
1746# flags being enabled in packages. This will check to see if the specified 1779# flags being enabled in packages. This will check to see if the specified
1747# DEPEND atom was built with the specified list of USE flags. The 1780# DEPEND atom was built with the specified list of USE flags. The
1748# --missing option controls the behavior if called on a package that does 1781# --missing option controls the behavior if called on a package that does
1749# not actually support the defined USE flags (aka listed in IUSE). 1782# not actually support the defined USE flags (aka listed in IUSE).

Legend:
Removed from v.1.326  
changed lines
  Added in v.1.332

  ViewVC Help
Powered by ViewVC 1.1.20