From: Mike Frysinger Date: Fri, 19 Jan 2007 05:29:18 +0000 (+0000) Subject: implement --missing flag for user-control over IUSE-missing behavior X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9534e72880a7d7c1557db944ed625070608b50a8;p=gentoo.git implement --missing flag for user-control over IUSE-missing behavior --- diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass index 57bcfb9b25cc..2d413f185234 100644 --- a/eclass/eutils.eclass +++ b/eclass/eutils.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.268 2007/01/13 19:36:14 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.269 2007/01/19 05:29:18 vapier Exp $ # # This eclass is for general purpose functions that most ebuilds # have to implement themselves. @@ -1592,13 +1592,24 @@ preserve_old_lib_notify() { # Hack for people to figure out if a package was built with # certain USE flags # -# Usage: built_with_use [-a|-o] +# Usage: built_with_use [--missing ] [-a|-o] # ex: built_with_use xchat gtk2 # -# Flags: -a all USE flags should be utilized -# -o at least one USE flag should be utilized +# Flags: -a all USE flags should be utilized +# -o at least one USE flag should be utilized +# --missing peform the specified action if the flag is not in IUSE (true/false/die) # Note: the default flag is '-a' built_with_use() { + local missing_action="die" + if [[ $1 == "--missing" ]] ; then + missing_action=$2 + shift ; shift + case ${missing_action} in + true|false|die) ;; + *) die "unknown action '${missing_action}'";; + esac + fi + local opt=$1 [[ ${opt:0:1} = "-" ]] && shift || opt="-a" @@ -1623,7 +1634,13 @@ built_with_use() { fi done if [[ -n ${expand} ]] ; then - has $1 ${IUSE_BUILT} || die "$PKG does not actually support the $1 USE flag!" + if ! has $1 ${IUSE_BUILT} ; then + case ${missing_action} in + true) return 0;; + false) return 1;; + die) die "$PKG does not actually support the $1 USE flag!";; + esac + fi fi local USE_BUILT=$(<${USEFILE})