Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 944198 - sys-apps/portage ignores external environment variables when installing binary packages
Summary: sys-apps/portage ignores external environment variables when installing binar...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Binary packages support (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-20 18:27 UTC by Michał Górny
Modified: 2024-11-20 20:35 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-11-20 18:27:47 UTC
Consider this sample ebuild:

EAPI=8
SLOT=0
KEYWORDS="~amd64"

pkg_pretend() {
	einfo "NO_DIE_MAN=${NO_DIE_MAN}"
	if [[ ! ${NO_DIE_MAN} ]]; then
		die "I die"
	fi
}

pkg_setup() {
	unset NO_DIE_MAN
}



If I build a binary package via:

  NO_DIE_MAN=1 emerge -vB dummy

it correctly creates a package without "NO_DIE_MAN" in its environment.bz2.  However, if I try to install it afterwards:

  NO_DIE_MAN=1 emerge -vk dummy

it fails because Portage apparently ignores NO_DIE_MAN from the calling environment, even though it is not overwritten by environment.bz2.  This certainly goes against the principle of the least surprise.
Comment 1 Zac Medico gentoo-dev 2024-11-20 20:35:57 UTC
I think there's a similar bug report about similar behavior for emerge --config. The build time environment is frozen, but it can be modified vi /etc/portage/bashrc. We need to be careful not to violate PMS section 11.2 "The state of variables between functions" here.