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

Diff of /eclass/eutils.eclass

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

Revision 1.427 Revision 1.428
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 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.427 2013/09/14 19:00:10 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.428 2013/12/03 08:09:49 vapier Exp $
4 4
5# @ECLASS: eutils.eclass 5# @ECLASS: eutils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @BLURB: many extra (but common) functions that are used in ebuilds 8# @BLURB: many extra (but common) functions that are used in ebuilds
946 insinto /usr/share/applications 946 insinto /usr/share/applications
947 doins "${desktop}" 947 doins "${desktop}"
948 ) || die "installing desktop file failed" 948 ) || die "installing desktop file failed"
949} 949}
950 950
951# @FUNCTION: _eutils_eprefix_init
952# @INTERNAL
953# @DESCRIPTION:
954# Initialized prefix variables for EAPI<3.
955_eutils_eprefix_init() {
956 has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
957}
958
951# @FUNCTION: validate_desktop_entries 959# @FUNCTION: validate_desktop_entries
952# @USAGE: [directories] 960# @USAGE: [directories]
953# @MAINTAINER: 961# @MAINTAINER:
954# Carsten Lohrke <carlo@gentoo.org> 962# Carsten Lohrke <carlo@gentoo.org>
955# @DESCRIPTION: 963# @DESCRIPTION:
956# Validate desktop entries using desktop-file-utils 964# Validate desktop entries using desktop-file-utils
957validate_desktop_entries() { 965validate_desktop_entries() {
966 _eutils_eprefix_init
958 if [[ -x /usr/bin/desktop-file-validate ]] ; then 967 if [[ -x "${EPREFIX}"/usr/bin/desktop-file-validate ]] ; then
959 einfo "Checking desktop entry validity" 968 einfo "Checking desktop entry validity"
960 local directories="" 969 local directories=""
961 for d in /usr/share/applications $@ ; do 970 for d in /usr/share/applications $@ ; do
962 [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}" 971 [[ -d ${ED}${d} ]] && directories="${directories} ${ED}${d}"
963 done 972 done
964 if [[ -n ${directories} ]] ; then 973 if [[ -n ${directories} ]] ; then
965 for FILE in $(find ${directories} -name "*\.desktop" \ 974 for FILE in $(find ${directories} -name "*\.desktop" \
966 -not -path '*.hidden*' | sort -u 2>/dev/null) 975 -not -path '*.hidden*' | sort -u 2>/dev/null)
967 do 976 do
968 local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | \ 977 local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | \
969 sed -e "s|error: ||" -e "s|${FILE}:|--|g" ) 978 sed -e "s|error: ||" -e "s|${FILE}:|--|g" )
970 [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:} 979 [[ -n $temp ]] && elog ${temp/--/${FILE/${ED}/}:}
971 done 980 done
972 fi 981 fi
973 echo "" 982 echo ""
974 else 983 else
975 einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo." 984 einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo."
1225# would break packages that link against it. Most people get around this 1234# would break packages that link against it. Most people get around this
1226# by using the portage SLOT mechanism, but that is not always a relevant 1235# by using the portage SLOT mechanism, but that is not always a relevant
1227# solution, so instead you can call this from pkg_preinst. See also the 1236# solution, so instead you can call this from pkg_preinst. See also the
1228# preserve_old_lib_notify function. 1237# preserve_old_lib_notify function.
1229preserve_old_lib() { 1238preserve_old_lib() {
1239 _eutils_eprefix_init
1230 if [[ ${EBUILD_PHASE} != "preinst" ]] ; then 1240 if [[ ${EBUILD_PHASE} != "preinst" ]] ; then
1231 eerror "preserve_old_lib() must be called from pkg_preinst() only" 1241 eerror "preserve_old_lib() must be called from pkg_preinst() only"
1232 die "Invalid preserve_old_lib() usage" 1242 die "Invalid preserve_old_lib() usage"
1233 fi 1243 fi
1234 [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]" 1244 [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]"
1236 # let portage worry about it 1246 # let portage worry about it
1237 has preserve-libs ${FEATURES} && return 0 1247 has preserve-libs ${FEATURES} && return 0
1238 1248
1239 local lib dir 1249 local lib dir
1240 for lib in "$@" ; do 1250 for lib in "$@" ; do
1241 [[ -e ${ROOT}/${lib} ]] || continue 1251 [[ -e ${EROOT}/${lib} ]] || continue
1242 dir=${lib%/*} 1252 dir=${lib%/*}
1243 dodir ${dir} || die "dodir ${dir} failed" 1253 dodir ${dir} || die "dodir ${dir} failed"
1244 cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed" 1254 cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed"
1245 touch "${D}"/${lib} 1255 touch "${ED}"/${lib}
1246 done 1256 done
1247} 1257}
1248 1258
1249# @FUNCTION: preserve_old_lib_notify 1259# @FUNCTION: preserve_old_lib_notify
1250# @USAGE: <libs to notify> [more libs] 1260# @USAGE: <libs to notify> [more libs]
1257 fi 1267 fi
1258 1268
1259 # let portage worry about it 1269 # let portage worry about it
1260 has preserve-libs ${FEATURES} && return 0 1270 has preserve-libs ${FEATURES} && return 0
1261 1271
1272 _eutils_eprefix_init
1273
1262 local lib notice=0 1274 local lib notice=0
1263 for lib in "$@" ; do 1275 for lib in "$@" ; do
1264 [[ -e ${ROOT}/${lib} ]] || continue 1276 [[ -e ${EROOT}/${lib} ]] || continue
1265 if [[ ${notice} -eq 0 ]] ; then 1277 if [[ ${notice} -eq 0 ]] ; then
1266 notice=1 1278 notice=1
1267 ewarn "Old versions of installed libraries were detected on your system." 1279 ewarn "Old versions of installed libraries were detected on your system."
1268 ewarn "In order to avoid breaking packages that depend on these old libs," 1280 ewarn "In order to avoid breaking packages that depend on these old libs,"
1269 ewarn "the libraries are not being removed. You need to run revdep-rebuild" 1281 ewarn "the libraries are not being removed. You need to run revdep-rebuild"
1295# in IUSE like normal USE flags. 1307# in IUSE like normal USE flags.
1296# 1308#
1297# Remember that this function isn't terribly intelligent so order of optional 1309# Remember that this function isn't terribly intelligent so order of optional
1298# flags matter. 1310# flags matter.
1299built_with_use() { 1311built_with_use() {
1312 _eutils_eprefix_init
1300 local hidden="no" 1313 local hidden="no"
1301 if [[ $1 == "--hidden" ]] ; then 1314 if [[ $1 == "--hidden" ]] ; then
1302 hidden="yes" 1315 hidden="yes"
1303 shift 1316 shift
1304 fi 1317 fi
1318 1331
1319 local PKG=$(best_version $1) 1332 local PKG=$(best_version $1)
1320 [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package" 1333 [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package"
1321 shift 1334 shift
1322 1335
1323 local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE 1336 local USEFILE=${EROOT}/var/db/pkg/${PKG}/USE
1324 local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE 1337 local IUSEFILE=${EROOT}/var/db/pkg/${PKG}/IUSE
1325 1338
1326 # if the IUSE file doesn't exist, the read will error out, we need to handle 1339 # if the IUSE file doesn't exist, the read will error out, we need to handle
1327 # this gracefully 1340 # this gracefully
1328 if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]] ; then 1341 if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]] ; then
1329 case ${missing_action} in 1342 case ${missing_action} in
1399# Create a shell wrapper script named wrapper in installpath 1412# Create a shell wrapper script named wrapper in installpath
1400# (defaults to the bindir) to execute target (default of wrapper) by 1413# (defaults to the bindir) to execute target (default of wrapper) by
1401# first optionally setting LD_LIBRARY_PATH to the colon-delimited 1414# first optionally setting LD_LIBRARY_PATH to the colon-delimited
1402# libpaths followed by optionally changing directory to chdir. 1415# libpaths followed by optionally changing directory to chdir.
1403make_wrapper() { 1416make_wrapper() {
1417 _eutils_eprefix_init
1404 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5 1418 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5
1405 local tmpwrapper=$(emktemp) 1419 local tmpwrapper=$(emktemp)
1406 1420
1407 ( 1421 (
1408 echo '#!/bin/sh' 1422 echo '#!/bin/sh'
1409 [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${chdir}" 1423 [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${EPREFIX}${chdir}"
1410 if [[ -n ${libdir} ]] ; then 1424 if [[ -n ${libdir} ]] ; then
1425 local var
1426 if [[ ${CHOST} == *-darwin* ]] ; then
1427 var=DYLD_LIBRARY_PATH
1428 else
1429 var=LD_LIBRARY_PATH
1430 fi
1411 cat <<-EOF 1431 cat <<-EOF
1412 if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then 1432 if [ "\${${var}+set}" = "set" ] ; then
1413 export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}" 1433 export ${var}="\${${var}}:${EPREFIX}${libdir}"
1414 else 1434 else
1415 export LD_LIBRARY_PATH="${libdir}" 1435 export ${var}="${EPREFIX}${libdir}"
1416 fi 1436 fi
1417 EOF 1437 EOF
1418 fi 1438 fi
1419 # We don't want to quote ${bin} so that people can pass complex 1439 # We don't want to quote ${bin} so that people can pass complex
1420 # things as ${bin} ... "./someprog --args" 1440 # things as ${bin} ... "./someprog --args"
1421 printf 'exec %s "$@"\n' "${bin}" 1441 printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}\/}"
1422 ) > "${tmpwrapper}" 1442 ) > "${tmpwrapper}"
1423 chmod go+rx "${tmpwrapper}" 1443 chmod go+rx "${tmpwrapper}"
1424 1444
1425 if [[ -n ${path} ]] ; then 1445 if [[ -n ${path} ]] ; then
1426 ( 1446 (
1527# pkg-config to your DEPEND. 1547# pkg-config to your DEPEND.
1528prune_libtool_files() { 1548prune_libtool_files() {
1529 debug-print-function ${FUNCNAME} "$@" 1549 debug-print-function ${FUNCNAME} "$@"
1530 1550
1531 local removing_all removing_modules opt 1551 local removing_all removing_modules opt
1552 _eutils_eprefix_init
1532 for opt; do 1553 for opt; do
1533 case "${opt}" in 1554 case "${opt}" in
1534 --all) 1555 --all)
1535 removing_all=1 1556 removing_all=1
1536 removing_modules=1 1557 removing_modules=1
1636 1657
1637 if [[ ${reason} ]]; then 1658 if [[ ${reason} ]]; then
1638 einfo "Removing unnecessary ${f#${D%/}} (${reason})" 1659 einfo "Removing unnecessary ${f#${D%/}} (${reason})"
1639 queue+=( "${f}" ) 1660 queue+=( "${f}" )
1640 fi 1661 fi
1641 done < <(find "${D}" -xtype f -name '*.la' -print0) 1662 done < <(find "${ED}" -xtype f -name '*.la' -print0)
1642 1663
1643 if [[ ${queue[@]} ]]; then 1664 if [[ ${queue[@]} ]]; then
1644 rm -f "${queue[@]}" 1665 rm -f "${queue[@]}"
1645 fi 1666 fi
1646} 1667}

Legend:
Removed from v.1.427  
changed lines
  Added in v.1.428

  ViewVC Help
Powered by ViewVC 1.1.20