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.274 2007/02/17 00:11:42 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' |
1632 | built_with_use() { |
1633 | built_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 |
… | |
… | |
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 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 |
1654 | # this gracefully |
1661 | # this gracefully |
1655 | if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} ]] ; then |
1662 | if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]] ; then |
1656 | case ${missing_action} in |
1663 | case ${missing_action} in |
1657 | true) return 0;; |
1664 | true) return 0;; |
1658 | false) return 1;; |
1665 | false) return 1;; |
1659 | 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";; |
1660 | esac |
1667 | esac |
1661 | fi |
1668 | fi |
1662 | |
1669 | |
|
|
1670 | if [[ ${hidden} == "no" ]] ; then |
1663 | local IUSE_BUILT=$(<${IUSEFILE}) |
1671 | local IUSE_BUILT=$(<${IUSEFILE}) |
1664 | # Don't check USE_EXPAND #147237 |
1672 | # Don't check USE_EXPAND #147237 |
1665 | local expand |
1673 | local expand |
1666 | for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do |
1674 | for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do |
1667 | if [[ $1 == ${expand}_* ]] ; then |
1675 | if [[ $1 == ${expand}_* ]] ; then |
1668 | expand="" |
1676 | expand="" |
1669 | break |
1677 | break |
1670 | fi |
1678 | fi |
1671 | done |
1679 | done |
1672 | if [[ -n ${expand} ]] ; then |
1680 | if [[ -n ${expand} ]] ; then |
1673 | if ! has $1 ${IUSE_BUILT} ; then |
1681 | if ! has $1 ${IUSE_BUILT} ; then |
1674 | case ${missing_action} in |
1682 | case ${missing_action} in |
1675 | true) return 0;; |
1683 | true) return 0;; |
1676 | false) return 1;; |
1684 | false) return 1;; |
1677 | die) die "$PKG does not actually support the $1 USE flag!";; |
1685 | die) die "$PKG does not actually support the $1 USE flag!";; |
1678 | esac |
1686 | esac |
|
|
1687 | fi |
1679 | fi |
1688 | fi |
1680 | fi |
1689 | fi |
1681 | |
1690 | |
1682 | local USE_BUILT=$(<${USEFILE}) |
1691 | local USE_BUILT=$(<${USEFILE}) |
1683 | while [[ $# -gt 0 ]] ; do |
1692 | while [[ $# -gt 0 ]] ; do |