summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2011-09-21 21:46:49 +0000
committerMichał Górny <mgorny@gentoo.org>2011-09-21 21:46:49 +0000
commit415aaebf0027a36162e21c23efd19c62c04dfaa6 (patch)
treed1f7b0af83f5f73ed23c625c34024cead706ccc3 /eclass
parentAlso rename macros in new minizip headers. (diff)
downloadhistorical-415aaebf0027a36162e21c23efd19c62c04dfaa6.tar.gz
historical-415aaebf0027a36162e21c23efd19c62c04dfaa6.tar.bz2
historical-415aaebf0027a36162e21c23efd19c62c04dfaa6.zip
Introduce in_iuse() for IUSE checks.
Such checks are used at least in autotools-utils & kde* eclasses, and are done wrong there. Thus, I've created a little reusable snippet suitable for eutils.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/eutils.eclass19
1 files changed, 18 insertions, 1 deletions
diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index cd1f9ff17cec..d202031b8f98 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.363 2011/09/12 20:44:01 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.364 2011/09/21 21:46:49 mgorny Exp $
# @ECLASS: eutils.eclass
# @MAINTAINER:
@@ -2028,3 +2028,20 @@ path_exists() {
-o) return $(( r == $# )) ;;
esac
}
+
+# @FUNCTION: in_iuse
+# @USAGE: <flag>
+# @DESCRIPTION:
+# Determines whether the given flag is in IUSE. Strips IUSE default prefixes
+# as necessary.
+#
+# Note that this function should not be used in the global scope.
+in_iuse() {
+ debug-print-function ${FUNCNAME} "${@}"
+ [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()"
+
+ local flag=${1}
+ local liuse=( ${IUSE} )
+
+ has "${flag}" "${liuse[@]#[+-]}"
+}