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

Diff of /eclass/eutils.eclass

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

Revision 1.272 Revision 1.275
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2006 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.272 2007/01/31 04:40:31 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.275 2007/02/17 00:17:39 vapier Exp $
4# 4#
5# This eclass is for general purpose functions that most ebuilds 5# This eclass is for general purpose functions that most ebuilds
6# have to implement themselves. 6# have to implement themselves.
7# 7#
8# NB: If you add anything, please comment it! 8# NB: If you add anything, please comment it!
1623# certain USE flags 1623# certain USE flags
1624# 1624#
1625# Usage: built_with_use [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags> 1625# Usage: built_with_use [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags>
1626# ex: built_with_use xchat gtk2 1626# ex: built_with_use xchat gtk2
1627# 1627#
1628# Flags: -a all USE flags should be utilized 1628# Flags: -a all USE flags should be utilized
1629# -o at least one USE flag should be utilized 1629# -o at least one USE flag should be utilized
1630# --missing peform the specified action if the flag is not in IUSE (true/false/die) 1630# --missing peform the specified action if the flag is not in IUSE (true/false/die)
1631# --hidden USE flag we're checking is hidden expanded so it isnt in IUSE
1631# Note: the default flag is '-a' 1632# Note: the default flag is '-a'
1632built_with_use() { 1633built_with_use() {
1634 local hidden="no"
1635 if [[ $1 == "--hidden" ]] ; then
1636 hidden="yes"
1637 shift
1638 fi
1639
1633 local missing_action="die" 1640 local missing_action="die"
1634 if [[ $1 == "--missing" ]] ; then 1641 if [[ $1 == "--missing" ]] ; then
1635 missing_action=$2 1642 missing_action=$2
1636 shift ; shift 1643 shift ; shift
1637 case ${missing_action} in 1644 case ${missing_action} in
1648 shift 1655 shift
1649 1656
1650 local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE 1657 local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE
1651 local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE 1658 local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE
1652 1659
1653 # if the USE file doesnt exist, assume the $PKG is either 1660 # if the IUSE file doesn't exist, the read will error out, we need to handle
1654 # injected or package.provided 1661 # this gracefully
1662 if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]] ; then
1663 case ${missing_action} in
1664 true) return 0;;
1665 false) return 1;;
1655 [[ ! -e ${USEFILE} ]] && die "Unable to determine what USE flags $PKG was built with" 1666 die) die "Unable to determine what USE flags $PKG was built with";;
1667 esac
1668 fi
1656 1669
1670 if [[ ${hidden} == "no" ]] ; then
1657 local IUSE_BUILT=$(<${IUSEFILE}) 1671 local IUSE_BUILT=$(<${IUSEFILE})
1658 # Don't check USE_EXPAND #147237 1672 # Don't check USE_EXPAND #147237
1659 local expand 1673 local expand
1660 for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do 1674 for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do
1661 if [[ $1 == ${expand}_* ]] ; then 1675 if [[ $1 == ${expand}_* ]] ; then
1662 expand="" 1676 expand=""
1663 break 1677 break
1664 fi 1678 fi
1665 done 1679 done
1666 if [[ -n ${expand} ]] ; then 1680 if [[ -n ${expand} ]] ; then
1667 if ! has $1 ${IUSE_BUILT} ; then 1681 if ! has $1 ${IUSE_BUILT} ; then
1668 case ${missing_action} in 1682 case ${missing_action} in
1669 true) return 0;; 1683 true) return 0;;
1670 false) return 1;; 1684 false) return 1;;
1671 die) die "$PKG does not actually support the $1 USE flag!";; 1685 die) die "$PKG does not actually support the $1 USE flag!";;
1672 esac 1686 esac
1687 fi
1673 fi 1688 fi
1674 fi 1689 fi
1675 1690
1676 local USE_BUILT=$(<${USEFILE}) 1691 local USE_BUILT=$(<${USEFILE})
1677 while [[ $# -gt 0 ]] ; do 1692 while [[ $# -gt 0 ]] ; do

Legend:
Removed from v.1.272  
changed lines
  Added in v.1.275

  ViewVC Help
Powered by ViewVC 1.1.20