| 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.279 2007/04/25 09:14:35 carlo 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! |
| … | |
… | |
| 916 | # doesn't corrupt the env of the caller |
916 | # doesn't corrupt the env of the caller |
| 917 | insinto /usr/share/applications |
917 | insinto /usr/share/applications |
| 918 | doins "${desktop}" |
918 | doins "${desktop}" |
| 919 | ) |
919 | ) |
| 920 | } |
920 | } |
|
|
921 | |
|
|
922 | |
|
|
923 | # Validate desktop entries using desktop-file-utils |
|
|
924 | # Carsten Lohrke <carlo@gentoo.org> |
|
|
925 | # |
|
|
926 | # Usage: validate_desktop_entries [directory ...] |
|
|
927 | |
|
|
928 | validate_desktop_entries() { |
|
|
929 | if [[ -x /usr/bin/desktop-file-validate ]] ; then |
|
|
930 | einfo "Checking desktop entry validity" |
|
|
931 | local directories="" |
|
|
932 | for d in /usr/share/applications $@ ; do |
|
|
933 | [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}" |
|
|
934 | done |
|
|
935 | if [[ -n ${directories} ]] ; then |
|
|
936 | for FILE in $(find ${directories} -name "*\.desktop" \ |
|
|
937 | -not -path '*.hidden*' | sort -u 2>/dev/null) |
|
|
938 | do |
|
|
939 | local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | \ |
|
|
940 | sed -e "s|error: ||" -e "s|${FILE}:|--|g" ) |
|
|
941 | [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:} |
|
|
942 | done |
|
|
943 | fi |
|
|
944 | echo "" |
|
|
945 | else |
|
|
946 | einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo." |
|
|
947 | fi |
|
|
948 | } |
|
|
949 | |
| 921 | |
950 | |
| 922 | # Make a GDM/KDM Session file |
951 | # Make a GDM/KDM Session file |
| 923 | # |
952 | # |
| 924 | # make_session_desktop(<title>, <command>) |
953 | # make_session_desktop(<title>, <command>) |
| 925 | # title: File to execute to start the Window Manager |
954 | # title: File to execute to start the Window Manager |
| … | |
… | |
| 1581 | # } |
1610 | # } |
| 1582 | |
1611 | |
| 1583 | preserve_old_lib() { |
1612 | preserve_old_lib() { |
| 1584 | if [[ ${EBUILD_PHASE} != "preinst" ]] ; then |
1613 | if [[ ${EBUILD_PHASE} != "preinst" ]] ; then |
| 1585 | eerror "preserve_old_lib() must be called from pkg_preinst() only" |
1614 | eerror "preserve_old_lib() must be called from pkg_preinst() only" |
| 1586 | # die "Invalid preserve_old_lib() usage" |
1615 | die "Invalid preserve_old_lib() usage" |
| 1587 | fi |
1616 | fi |
| 1588 | [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]" |
1617 | [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]" |
| 1589 | |
1618 | |
| 1590 | local lib dir |
1619 | local lib dir |
| 1591 | for lib in "$@" ; do |
1620 | for lib in "$@" ; do |
| … | |
… | |
| 1598 | } |
1627 | } |
| 1599 | |
1628 | |
| 1600 | preserve_old_lib_notify() { |
1629 | preserve_old_lib_notify() { |
| 1601 | if [[ ${EBUILD_PHASE} != "postinst" ]] ; then |
1630 | if [[ ${EBUILD_PHASE} != "postinst" ]] ; then |
| 1602 | eerror "preserve_old_lib_notify() must be called from pkg_postinst() only" |
1631 | eerror "preserve_old_lib_notify() must be called from pkg_postinst() only" |
| 1603 | # die "Invalid preserve_old_lib_notify() usage" |
1632 | die "Invalid preserve_old_lib_notify() usage" |
| 1604 | fi |
1633 | fi |
| 1605 | |
1634 | |
| 1606 | local lib notice=0 |
1635 | local lib notice=0 |
| 1607 | for lib in "$@" ; do |
1636 | for lib in "$@" ; do |
| 1608 | [[ -e ${ROOT}/${lib} ]] || continue |
1637 | [[ -e ${ROOT}/${lib} ]] || continue |
| … | |
… | |
| 1623 | # certain USE flags |
1652 | # certain USE flags |
| 1624 | # |
1653 | # |
| 1625 | # Usage: built_with_use [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags> |
1654 | # Usage: built_with_use [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags> |
| 1626 | # ex: built_with_use xchat gtk2 |
1655 | # ex: built_with_use xchat gtk2 |
| 1627 | # |
1656 | # |
| 1628 | # Flags: -a all USE flags should be utilized |
1657 | # Flags: -a all USE flags should be utilized |
| 1629 | # -o at least one USE flag should be utilized |
1658 | # -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) |
1659 | # --missing peform the specified action if the flag is not in IUSE (true/false/die) |
|
|
1660 | # --hidden USE flag we're checking is hidden expanded so it isnt in IUSE |
| 1631 | # Note: the default flag is '-a' |
1661 | # Note: the default flag is '-a' |
| 1632 | built_with_use() { |
1662 | built_with_use() { |
|
|
1663 | local hidden="no" |
|
|
1664 | if [[ $1 == "--hidden" ]] ; then |
|
|
1665 | hidden="yes" |
|
|
1666 | shift |
|
|
1667 | fi |
|
|
1668 | |
| 1633 | local missing_action="die" |
1669 | local missing_action="die" |
| 1634 | if [[ $1 == "--missing" ]] ; then |
1670 | if [[ $1 == "--missing" ]] ; then |
| 1635 | missing_action=$2 |
1671 | missing_action=$2 |
| 1636 | shift ; shift |
1672 | shift ; shift |
| 1637 | case ${missing_action} in |
1673 | case ${missing_action} in |
| … | |
… | |
| 1648 | shift |
1684 | shift |
| 1649 | |
1685 | |
| 1650 | local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE |
1686 | local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE |
| 1651 | local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE |
1687 | local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE |
| 1652 | |
1688 | |
| 1653 | # if the USE file doesnt exist, assume the $PKG is either |
1689 | # if the IUSE file doesn't exist, the read will error out, we need to handle |
| 1654 | # injected or package.provided |
1690 | # this gracefully |
|
|
1691 | if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]] ; then |
|
|
1692 | case ${missing_action} in |
|
|
1693 | true) return 0;; |
|
|
1694 | false) return 1;; |
| 1655 | [[ ! -e ${USEFILE} ]] && die "Unable to determine what USE flags $PKG was built with" |
1695 | die) die "Unable to determine what USE flags $PKG was built with";; |
|
|
1696 | esac |
|
|
1697 | fi |
| 1656 | |
1698 | |
|
|
1699 | if [[ ${hidden} == "no" ]] ; then |
| 1657 | local IUSE_BUILT=$(<${IUSEFILE}) |
1700 | local IUSE_BUILT=$(<${IUSEFILE}) |
| 1658 | # Don't check USE_EXPAND #147237 |
1701 | # Don't check USE_EXPAND #147237 |
| 1659 | local expand |
1702 | local expand |
| 1660 | for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do |
1703 | for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do |
| 1661 | if [[ $1 == ${expand}_* ]] ; then |
1704 | if [[ $1 == ${expand}_* ]] ; then |
| 1662 | expand="" |
1705 | expand="" |
| 1663 | break |
1706 | break |
| 1664 | fi |
1707 | fi |
| 1665 | done |
1708 | done |
| 1666 | if [[ -n ${expand} ]] ; then |
1709 | if [[ -n ${expand} ]] ; then |
| 1667 | if ! has $1 ${IUSE_BUILT} ; then |
1710 | if ! has $1 ${IUSE_BUILT} ; then |
| 1668 | case ${missing_action} in |
1711 | case ${missing_action} in |
| 1669 | true) return 0;; |
1712 | true) return 0;; |
| 1670 | false) return 1;; |
1713 | false) return 1;; |
| 1671 | die) die "$PKG does not actually support the $1 USE flag!";; |
1714 | die) die "$PKG does not actually support the $1 USE flag!";; |
| 1672 | esac |
1715 | esac |
|
|
1716 | fi |
| 1673 | fi |
1717 | fi |
| 1674 | fi |
1718 | fi |
| 1675 | |
1719 | |
| 1676 | local USE_BUILT=$(<${USEFILE}) |
1720 | local USE_BUILT=$(<${USEFILE}) |
| 1677 | while [[ $# -gt 0 ]] ; do |
1721 | while [[ $# -gt 0 ]] ; do |