--- ebuild.sh.orig 2008-03-04 17:21:45 +0100 +++ ebuild.sh 2008-03-05 12:02:08 +0100 @@ -46,7 +46,7 @@ qa_call() { local shopts=$(shopt) OLDIFS="$IFS" local retval - "$@" + call-ebuildshell "$@" retval=$? [[ $shopts != $(shopt) ]] && eqawarn "QA Notice: Global shell options changed and were not restored while calling '$*'" @@ -55,6 +55,53 @@ return $retval } +call-ebuildshell() { + if ! hasq ebuildshell ${FEATURES}; then + "$@" + return $? + fi + + ( + umask 002 + ( + echo 'unset ENV' + echo 'unset BASH_ENV' + set + export -p | sed -e 's:declare -rx:export:' + shopt -p + echo "export PS1='EBUILD ${PN} $1 \$ '" + echo 'unset ENV' + echo "type $1" + echo "echo WANTED: $@" + echo "source '${PORTAGE_BIN_PATH}/isolated-functions.sh' &>/dev/null" + # 'declare -x VAR=val' does not work when called within bash function, + # it needs to be 'export VAR=val'. + # is this a bash-bug or intentional ? + echo "trap '" + echo "umask 002" + echo "save_ebuild_env | filter_readonly_variables |" + echo -n "egrep -v \"^(" + sep='' + for v in ${READONLY_EBUILD_METADATA}; do + echo -n "${sep}${v}" + sep='|' + done + echo ")=\" > ${T}/ebuildshell-environment-outcome' 0" + ) | filter_readonly_variables > ${T}/ebuildshell-environment + chown portage:portage "${T}/ebuildshell-environment" &>/dev/null + chmod g+w "${T}/ebuildshell-environment" &>/dev/null + ) + + rm -f "${T}/ebuildshell-environment-outcome" >&/dev/null + + unset BASH_ENV + ${BASH} --rcfile "${T}/ebuildshell-environment" -i || die + + chown portage:portage "${T}/ebuildshell-environment-outcome" &>/dev/null + chown g+w "${T}/ebuildshell-environment-outcome" &>/dev/null + source "${T}/ebuildshell-environment-outcome" &>/dev/null +} + # subshell die support EBUILD_MASTER_PID=$$ trap 'exit 1' SIGTERM