--- /usr/portage/eclass/eutils.eclass 2013-09-14 13:01:16.000000000 -0600 +++ eutils.eclass 2013-12-01 12:47:25.934528581 -0700 @@ -948,6 +948,14 @@ ) || die "installing desktop file failed" } +# @FUNCTION: _eutils_eprefix_init +# @USAGE: +# @DESCRIPTION: +# Initialized prefix variables for EAPI<3. +_eutils_eprefix_init() { + has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}} +} + # @FUNCTION: validate_desktop_entries # @USAGE: [directories] # @MAINTAINER: @@ -955,11 +963,12 @@ # @DESCRIPTION: # Validate desktop entries using desktop-file-utils validate_desktop_entries() { - if [[ -x /usr/bin/desktop-file-validate ]] ; then + _eutils_eprefix_init + if [[ -x "${EPREFIX}"/usr/bin/desktop-file-validate ]] ; then einfo "Checking desktop entry validity" local directories="" for d in /usr/share/applications $@ ; do - [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}" + [[ -d ${ED}${d} ]] && directories="${directories} ${ED}${d}" done if [[ -n ${directories} ]] ; then for FILE in $(find ${directories} -name "*\.desktop" \ @@ -967,7 +976,7 @@ do local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | \ sed -e "s|error: ||" -e "s|${FILE}:|--|g" ) - [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:} + [[ -n $temp ]] && elog ${temp/--/${FILE/${ED}/}:} done fi echo "" @@ -1227,6 +1236,7 @@ # solution, so instead you can call this from pkg_preinst. See also the # preserve_old_lib_notify function. preserve_old_lib() { + _eutils_eprefix_init if [[ ${EBUILD_PHASE} != "preinst" ]] ; then eerror "preserve_old_lib() must be called from pkg_preinst() only" die "Invalid preserve_old_lib() usage" @@ -1238,11 +1248,11 @@ local lib dir for lib in "$@" ; do - [[ -e ${ROOT}/${lib} ]] || continue + [[ -e ${EROOT}/${lib} ]] || continue dir=${lib%/*} dodir ${dir} || die "dodir ${dir} failed" - cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed" - touch "${D}"/${lib} + cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed" + touch "${ED}"/${lib} done } @@ -1259,9 +1269,11 @@ # let portage worry about it has preserve-libs ${FEATURES} && return 0 + _eutils_eprefix_init + local lib notice=0 for lib in "$@" ; do - [[ -e ${ROOT}/${lib} ]] || continue + [[ -e ${EROOT}/${lib} ]] || continue if [[ ${notice} -eq 0 ]] ; then notice=1 ewarn "Old versions of installed libraries were detected on your system." @@ -1297,6 +1309,7 @@ # Remember that this function isn't terribly intelligent so order of optional # flags matter. built_with_use() { + _eutils_eprefix_init local hidden="no" if [[ $1 == "--hidden" ]] ; then hidden="yes" @@ -1320,8 +1333,8 @@ [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package" shift - local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE - local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE + local USEFILE="${EROOT}"/var/db/pkg/${PKG}/USE + local IUSEFILE="${EROOT}"/var/db/pkg/${PKG}/IUSE # if the IUSE file doesn't exist, the read will error out, we need to handle # this gracefully @@ -1401,6 +1414,7 @@ # first optionally setting LD_LIBRARY_PATH to the colon-delimited # libpaths followed by optionally changing directory to chdir. make_wrapper() { + _eutils_eprefix_init local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5 local tmpwrapper=$(emktemp) @@ -1408,17 +1422,22 @@ echo '#!/bin/sh' [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${chdir}" if [[ -n ${libdir} ]] ; then + if [[ ${CHOST} == *-darwin* ]] ; then + var=DYLD_LIBRARY_PATH + else + var=LD_LIBRARY_PATH + fi cat <<-EOF - if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then - export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}" + if [ "\${${var}+set}" = "set" ] ; then + export ${var}="\${${var}}:${EPREFIX}${libdir}" else - export LD_LIBRARY_PATH="${libdir}" + export ${var}="${EPREFIX}${libdir}" fi EOF fi # We don't want to quote ${bin} so that people can pass complex # things as ${bin} ... "./someprog --args" - printf 'exec %s "$@"\n' "${bin}" + printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}\/}" ) > "${tmpwrapper}" chmod go+rx "${tmpwrapper}" @@ -1529,6 +1548,7 @@ debug-print-function ${FUNCNAME} "$@" local removing_all removing_modules opt + _eutils_eprefix_init for opt; do case "${opt}" in --all) @@ -1638,7 +1658,7 @@ einfo "Removing unnecessary ${f#${D%/}} (${reason})" queue+=( "${f}" ) fi - done < <(find "${D}" -xtype f -name '*.la' -print0) + done < <(find "${ED}" -xtype f -name '*.la' -print0) if [[ ${queue[@]} ]]; then rm -f "${queue[@]}"