`ebuild` tool preserves environment between pkg_pretend() and pkg_setup(), which is incorrect. `emerge` behaves correctly. Ebuild: EAPI="5" SLOT="0" KEYWORDS="*" pkg_pretend() { MY_VAR="123" declare -p EBUILD_PHASE MY_VAR } pkg_setup() { declare -p EBUILD_PHASE MY_VAR } Output from `emerge ${package}`: declare -rx EBUILD_PHASE="pretend" declare -- MY_VAR="123" ... declare -rx EBUILD_PHASE="setup" ${EBUILD}: line 9: declare: MY_VAR: not found Output from `ebuild ${EBUILD} setup`: declare -rx EBUILD_PHASE="pretend" declare -- MY_VAR="123" ... declare -rx EBUILD_PHASE="setup" declare -- MY_VAR="123"
I have a patch in this branch: https://github.com/zmedico/portage/tree/bug_528274 I've posted it for review here: http://thread.gmane.org/gmane.linux.gentoo.portage.devel/4751
This is in the master branch now: https://github.com/gentoo/portage/commit/743b3337644fbb3ea461d3a9137c9ac85e163f03
(In reply to Zac Medico from comment #2) > This is in the master branch now: > > https://github.com/gentoo/portage/commit/ > 743b3337644fbb3ea461d3a9137c9ac85e163f03 This broke pkg_setup environment handling for binary packages. I've posted a fix for review here: http://thread.gmane.org/gmane.linux.gentoo.portage.devel/4860
(In reply to Zac Medico from comment #3) > This broke pkg_setup environment handling for binary packages. I've posted a > fix for review here: > > http://thread.gmane.org/gmane.linux.gentoo.portage.devel/4860 This is in the master branch now: https://github.com/gentoo/portage/commit/58c27aec81262d6840e36f2f56c32bec68c414c1
Fixed in Portage 2.2.15.