From 06f1bad12e8d56a3d8273b4677a01e2e963cc590 Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Tue, 19 Sep 2023 14:43:21 -0600 Subject: [PATCH 1/3] config: Don't directly modify FEATURES Iterating on self.features returns items in a non-deterministic order, it also leaves self.features out of sync. If we instead use the `remove` method, the values get sorted and synchronized correctly. Bug: https://bugs.gentoo.org/914441 Signed-off-by: Raul E Rangel --- lib/portage/package/ebuild/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py index e07d27e8fc..3ee7fd65ed 100644 --- a/lib/portage/package/ebuild/config.py +++ b/lib/portage/package/ebuild/config.py @@ -2204,7 +2204,7 @@ def setcpv(self, mycpv, use_cache=None, mydb=None): # "test" is in IUSE and USE=test is masked, so execution # of src_test() probably is not reliable. Therefore, # temporarily disable FEATURES=test just for this package. - self["FEATURES"] = " ".join(x for x in self.features if x != "test") + self.features.remove("test") # Allow _* flags from USE_EXPAND wildcards to pass through here. use.difference_update( From aa20b8c0fa57e31d04b8467fcbfafccb0f7803c0 Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Wed, 9 Nov 2022 21:26:18 -0700 Subject: [PATCH 2/3] bin/phase-functions: Move du stats into subshell These variables are only used inside this subshell. This avoids polluting the environment. Apparently this calculation isn't hermetic. I'm not sure why: @@ -268,10 +268,10 @@ declare -x cros_setup_hooks_run="booya" declare -a exclude_hermetic=([0]="--exclude-non-hermetic") declare -- f -declare -a isz=([0]="264" [1]="/var/tmp/portage/dev-libs/libffi-3.1-r8/image/") -declare -a nsz=([0]="2803" [1]="/var/tmp/portage/dev-libs/libffi-3.1-r8/work") +declare -a isz=([0]="16" [1]="/var/tmp/portage/dev-libs/libffi-3.1-r8/image/") +declare -a nsz=([0]="2599" [1]="/var/tmp/portage/dev-libs/libffi-3.1-r8/work") declare -- phase_func __eapi6_src_install () Bug: https://bugs.gentoo.org/914441 Signed-off-by: Raul E Rangel --- bin/phase-functions.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 071941ff72..cd672a878c 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -620,12 +620,11 @@ __dyn_install() { # record build & installed size in build log if type -P du &>/dev/null; then - local nsz=( $(du -ks "${WORKDIR}") ) - local isz=( $(du -ks "${D}") ) - # subshell to avoid polluting the caller env with the helper # functions below ( + local nsz=( $(du -ks "${WORKDIR}") ) + local isz=( $(du -ks "${D}") ) # align $1 to the right to the width of the widest of $1 and $2 padl() { local s1=$1 From 05e7923ae9f289b1f8d55b90b33b82b89005e45f Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Wed, 11 Oct 2023 12:42:34 -0600 Subject: [PATCH 3/3] config: Sort USE_EXPAND variables Without the sort, we end up extending the USE_EXPAND variables with a non deterministic ordering. This makes binary package creation non hermetic. i.e., ``` -declare -x PYTHON_TARGETS="python3_8 python3_7 python3_6 python3_10 python3_9" +declare -x PYTHON_TARGETS="python3_8 python3_9 python3_10 python3_7 python3_6" ``` Assuming `PYTHON_TARGETS=python3_8` in make.conf, after this change we get: ``` declare -x PYTHON_TARGETS="python3_8 python3_10 python3_6 python3_7 python3_9" ``` Ideally we would completely sort the USE_EXPAND variables, but the LINGUAS variable appears to need a very specific ordering. Bug: https://bugs.gentoo.org/914441 Signed-off-by: Raul E Rangel --- lib/portage/package/ebuild/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py index 3ee7fd65ed..049c5fa169 100644 --- a/lib/portage/package/ebuild/config.py +++ b/lib/portage/package/ebuild/config.py @@ -1746,7 +1746,7 @@ def __getitem__(self, key): # Preserve the order of var_split because it can matter for things # like LINGUAS. var_split = [x for x in var_split if x in expand_flags] - var_split.extend(expand_flags.difference(var_split)) + var_split.extend(sorted(expand_flags.difference(var_split))) has_wildcard = "*" in expand_flags if has_wildcard: var_split = [x for x in var_split if x != "*"]