commit:     b2689697a73a247dcbfd77d69cf73bb2059df118
Author:     Arsen Arsenović <arsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 27 18:19:10 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jul 28 08:02:39 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=b2689697

scripts/bootstrap-prefix: ensure stage2 is in path

Signed-off-by: Arsen Arsenović <arsen <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 scripts/bootstrap-prefix.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index d1387391d9..6f7f3f5fdd 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -1898,11 +1898,26 @@ bootstrap_stage2_log() {
 bootstrap_stage3() {
        export PORTAGE_CONFIGROOT="${ROOT}"
 
+       # We need the stage2 in PATH for bootstrapping.  We rely on
+       # emerge running on some benign package before running anything
+       # that would rely on 98stage2 coming before 99host
+       mkdir -p "${ROOT}"/etc/env.d/
+       cat > "${ROOT}"/etc/env.d/98stage2 <<-EOF
+               PATH="$(unset PATH;
+                       source "${ROOT}"/tmp/etc/profile.env;
+                       echo "$PATH")"
+       EOF
+
        if ! type -P emerge > /dev/null ; then
                eerror "emerge not found, did you bootstrap stage1?"
                return 1
        fi
 
+       # At this point, we should have a proper GCC, and don't need to
+       # rely on the system wrappers.  Let's get rid of them, so that
+       # they stop mucking up builds.
+       rm -f "${ROOT}"/tmp/usr/local/bin/*
+
        configure_toolchain || return 1
 
        if [[ ${compiler_type} == clang ]] ; then
@@ -2204,6 +2219,10 @@ bootstrap_stage3() {
        # (--depclean may fail, which is ok)
        sed -i -e 's/resume/cleared/' "${ROOT}"/var/cache/edb/mtimedb
 
+       # Remove the stage2 hack from above.  A future emerge run will
+       # get env-update to happen.
+       rm "${ROOT}"/etc/env.d/98stage2
+
        estatus "stage3 finished"
        einfo "stage3 successfully finished"
 }

Reply via email to