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

Diff of /eclass/eutils.eclass

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

Revision 1.273 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.273 2007/02/14 16:49:46 cardoe 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
1654 # injected or package.provided
1655 [[ ! -e ${USEFILE} ]] && die "Unable to determine what USE flags $PKG was built with"
1656
1657 # if the IUSE file doesn't exist, the read will error out, we need to handle 1660 # if the IUSE file doesn't exist, the read will error out, we need to handle
1658 # this gracefully 1661 # this gracefully
1659 if [[ ! -e ${IUSEFILE} ]] ; then 1662 if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]] ; then
1660 case ${missing_action} in 1663 case ${missing_action} in
1661 true) return 0;; 1664 true) return 0;;
1662 false) return 1;; 1665 false) return 1;;
1663 die) die "Unable to determine what USE flags $PKG was built with";; 1666 die) die "Unable to determine what USE flags $PKG was built with";;
1664 esac 1667 esac
1665 fi 1668 fi
1666 1669
1670 if [[ ${hidden} == "no" ]] ; then
1667 local IUSE_BUILT=$(<${IUSEFILE}) 1671 local IUSE_BUILT=$(<${IUSEFILE})
1668 # Don't check USE_EXPAND #147237 1672 # Don't check USE_EXPAND #147237
1669 local expand 1673 local expand
1670 for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do 1674 for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do
1671 if [[ $1 == ${expand}_* ]] ; then 1675 if [[ $1 == ${expand}_* ]] ; then
1672 expand="" 1676 expand=""
1673 break 1677 break
1674 fi 1678 fi
1675 done 1679 done
1676 if [[ -n ${expand} ]] ; then 1680 if [[ -n ${expand} ]] ; then
1677 if ! has $1 ${IUSE_BUILT} ; then 1681 if ! has $1 ${IUSE_BUILT} ; then
1678 case ${missing_action} in 1682 case ${missing_action} in
1679 true) return 0;; 1683 true) return 0;;
1680 false) return 1;; 1684 false) return 1;;
1681 die) die "$PKG does not actually support the $1 USE flag!";; 1685 die) die "$PKG does not actually support the $1 USE flag!";;
1682 esac 1686 esac
1687 fi
1683 fi 1688 fi
1684 fi 1689 fi
1685 1690
1686 local USE_BUILT=$(<${USEFILE}) 1691 local USE_BUILT=$(<${USEFILE})
1687 while [[ $# -gt 0 ]] ; do 1692 while [[ $# -gt 0 ]] ; do

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

  ViewVC Help
Powered by ViewVC 1.1.20