From 4715ed37726207a423b0a2dcfa625b636fb98b66 Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Thu, 21 Mar 2024 10:41:38 -0600 Subject: [PATCH 1/2] save-build-env: Strip out MAKEOPTS and NINJAOPTS MAKEOPTS and NINJAOPTS contains a host specific value. If the same package is built on a host with different core counts, the binpkgs will have different hashes. This change drops MAKEOPTS after src_install so that it's not included in final environment.gz. This change also adds them to the special_env_vars.py so that we always have the most up to date version of these variables. Bug: https://bugs.gentoo.org/914441 Bug: https://bugs.gentoo.org/736794 Signed-off-by: Raul E Rangel --- bin/save-ebuild-env.sh | 6 ++++++ lib/portage/package/ebuild/_config/special_env_vars.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index 3a2560aabf..faa29efe65 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -24,6 +24,12 @@ __save_ebuild_env() { unset PYTHONPATH fi fi + + # These variables contains build host specific configuration. We + # want binpkgs generated on different sized hosts to be + # identical, so strip them from the binpkg. It's also not needed + # for installing / removing a package. + unset MAKEOPTS NINJAOPTS fi # misc variables inherited from the calling environment diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py b/lib/portage/package/ebuild/_config/special_env_vars.py index 1a66192c96..8a234007a4 100644 --- a/lib/portage/package/ebuild/_config/special_env_vars.py +++ b/lib/portage/package/ebuild/_config/special_env_vars.py @@ -112,7 +112,9 @@ "FEATURES", "FILESDIR", "HOME", + "MAKEOPTS", "MERGE_TYPE", + "NINJAOPTS", "NOCOLOR", "NO_COLOR", "P", From 745a4df5274c146862819753ca13e62cfcd2a83e Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Wed, 24 Apr 2024 12:49:02 -0600 Subject: [PATCH 2/2] save-build-env: Strip out non-reproducible variables Bash provides access to the time and a random data via variables. We don't want to persist these values when generating a binpkg. Bug: https://bugs.gentoo.org/914441 Signed-off-by: Raul E Rangel --- bin/save-ebuild-env.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index faa29efe65..e941017c31 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -30,6 +30,10 @@ __save_ebuild_env() { # identical, so strip them from the binpkg. It's also not needed # for installing / removing a package. unset MAKEOPTS NINJAOPTS + + # These variables are constantly changing. Strip them so we + # don't introduce non-reproducible data into the binpkg. + unset EPOCHREALTIME EPOCHSECONDS SRANDOM fi # misc variables inherited from the calling environment