Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: Do not export A #1357

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bin/ebuild.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Copyright 1999-2021 Gentoo Authors
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Prevent aliases from causing portage to act inappropriately.
Expand All @@ -10,6 +10,11 @@ unalias -a
unset BASH_COMPAT
declare -F ___in_portage_iuse >/dev/null && export -n -f ___in_portage_iuse

if [[ -v PORTAGE_EBUILD_EXTRA_SOURCE ]]; then
source "${PORTAGE_EBUILD_EXTRA_SOURCE}" || exit 1
unset PORTAGE_EBUILD_EXTRA_SOURCE
fi

Flowdalic marked this conversation as resolved.
Show resolved Hide resolved
source "${PORTAGE_BIN_PATH}/isolated-functions.sh" || exit 1

# Set up the bash version compatibility level. This does not disable
Expand Down Expand Up @@ -114,7 +119,7 @@ export PORTAGE_BZIP2_COMMAND=${PORTAGE_BZIP2_COMMAND:-bzip2}

# These two functions wrap sourcing and calling respectively. At present they
# perform a qa check to make sure eclasses and ebuilds and profiles don't mess
# with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them
# with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them
# when they are done.

__qa_source() {
Expand Down
33 changes: 32 additions & 1 deletion lib/portage/package/ebuild/doebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -2131,9 +2131,40 @@ def spawn(
logname_backup = mysettings.configdict["env"].get("LOGNAME")
mysettings.configdict["env"]["LOGNAME"] = logname

eapi = mysettings["EAPI"]

# TODO: Move into eapi.py
def eapi_does_not_export_a(eapi):
return eapi == "9"

dont_export_a = "dont-export-a" in mysettings.features or eapi_does_not_export_a(
eapi
)

if dont_export_a:
orig_env = mysettings.environ()
# Copy since we are potentially removing keys from the dict.
env = orig_env.copy()

t = env["T"]
if not os.path.isdir(t):
os.makedirs(t)

ebuildExtraSource = os.path.join(t, "portage-ebuild-extra-source")
with open(ebuildExtraSource, mode="w") as f:
for name, value in orig_env.items():
if name != "A":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that this is not optimal, but that's a leftover from a previous implementation where everything was passed via file and not via env. This should be changed once this PR leaves the PoC stage.

continue
f.write(f"{name}='{value}'\n")
del env[name]

env["PORTAGE_EBUILD_EXTRA_SOURCE"] = str(ebuildExtraSource)
else:
env = mysettings.environ()

try:
if keywords.get("returnpid") or keywords.get("returnproc"):
return spawn_func(mystring, env=mysettings.environ(), **keywords)
return spawn_func(mystring, env=env, **keywords)

proc = EbuildSpawnProcess(
background=False,
Expand Down