Index: pym/portage.py =================================================================== --- pym/portage.py (revision 2823) +++ pym/portage.py (working copy) @@ -2429,6 +2429,13 @@ mysettings.reset(use_cache=use_cache) mysettings.setcpv(mycpv,use_cache=use_cache) + if tree=="vartree": + mysettings["PORTAGE_SAVED_ENV"] = pkg_dir+"/environment" + elif tree=="bintree": + mysettings["PORTAGE_SAVED_ENV"] = pkg_dir+"/environment.bz2" + else: # porttree + mysettings["PORTAGE_SAVED_ENV"] = "no" + validcommands = ["help","clean","prerm","postrm","preinst","postinst", "config","setup","depend","fetch","digest", "unpack","compile","test","install","rpm","qmerge","merge", @@ -2462,7 +2469,6 @@ mysettings["FILESDIR"] = pkg_dir+"/files" mysettings["PF"] = mypv - mysettings["ECLASSDIR"] = mysettings["PORTDIR"]+"/eclass" mysettings["SANDBOX_LOG"] = mycpv.replace("/", "_-_") mysettings["PROFILE_PATHS"] = string.join(mysettings.profiles,"\n")+"\n"+CUSTOM_PROFILE_PATH Index: bin/ebuild.sh =================================================================== --- bin/ebuild.sh (revision 2823) +++ bin/ebuild.sh (working copy) @@ -674,6 +674,7 @@ } dyn_setup() { + [[ -n ${GLOBAL_ELIBS} ]] && elib ${GLOBAL_ELIBS} [ "$(type -t pre_pkg_setup)" == "function" ] && pre_pkg_setup pkg_setup [ "$(type -t post_pkg_setup)" == "function" ] && post_pkg_setup @@ -1550,6 +1551,34 @@ debug-print "now in section $*" } +elib() { + # we're called in global scope: postpone execution until just before pre_pkg_setup + if [[ ${FUNCNAME[1]} == "source" ]] && \ + [[ ${BASH_SOURCE[1]%.ebuild} != ${BASH_SOURCE[1]} ]]; then + GLOBAL_ELIBS=${@} + return + fi + + local location + while [ "$1" ]; do + if ! hasq ${1} ${LOADED_ELIBS} ; then + location="${PORTDIR}/include/elib/${1}.eclass" + if [[ -n ${PORTDIR_OVERLAY} ]]; then + local overlay + for overlay in ${PORTDIR_OVERLAY}; do + olocation="${overlay}/include/elib/${1}.eclass" + if [[ -e ${olocation} ]]; then + location="${olocation}" + fi + done + fi + source ${location} || die "elib: sourcing ${location} failed" + LOADED_ELIBS="${LOADED_ELIBS} ${1}" + fi + shift + done +} + # Sources all eclasses in parameters declare -ix ECLASS_DEPTH=0 inherit() { @@ -1559,6 +1588,7 @@ fi local location + local eclassdir local PECLASS local B_IUSE @@ -1566,7 +1596,13 @@ local B_RDEPEND local B_PDEPEND while [ "$1" ]; do - location="${ECLASSDIR}/${1}.eclass" + if [[ "${1/\/}" == "${1}" ]] ; then + eclassdir="eclass" + else + eclassdir="include/eclass" + fi + + location="${PORTDIR}/${eclassdir}/${1}.eclass" # PECLASS is used to restore the ECLASS var after recursion. PECLASS="$ECLASS" @@ -1584,7 +1620,7 @@ if [ -n "$PORTDIR_OVERLAY" ]; then local overlay for overlay in ${PORTDIR_OVERLAY}; do - olocation="${overlay}/eclass/${1}.eclass" + olocation="${overlay}/${eclassdir}/${1}.eclass" if [ -e "$olocation" ]; then location="${olocation}" debug-print " eclass exists: ${location}" @@ -1852,7 +1888,19 @@ # this can be left out of ebd variants, since they're unaffected. unset EBUILD_DEATH_HOOKS -source ${EBUILD} || die "error sourcing ebuild" +if [[ ${PORTAGE_SAVED_ENV} == no ]] ; then + source ${EBUILD} || die "error sourcing ebuild" +else + if [[ "${PORTAGE_SAVED_ENV%.bz2}" != "${PORTAGE_SAVED_ENV}" ]]; then + if ! [[ -e ${PORTAGE_SAVED_ENV%.bz2} ]]; then + bzcat ${PORTAGE_SAVED_ENV} > ${PORTAGE_SAVED_ENV%.bz2} || die "error unpacking env" + fi + source ${PORTAGE_SAVED_ENV%.bz2} 2>/dev/null || die "error sourcing env" + else + source ${PORTAGE_SAVED_ENV} 2>/dev/null || die "error sourcing env" + fi +fi + if ! hasq depend $EBUILD_PHASE; then RESTRICT="${PORTAGE_RESTRICT}" unset PORTAGE_RESTRICT