commit:     152225235e4f52ccb1cd6e9e39f0d724b45385b7
Author:     Paul Walker <paulwalker <AT> paulwalker <DOT> dev>
AuthorDate: Wed Dec  3 15:29:22 2025 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Dec  3 17:32:00 2025 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=15222523

scripts/bootstrap-prefix: don't create invalid symlinks

Check if ${ROOT}/bin and ${ROOT}/lib exist before creating symlinks to
${ROOT}/usr.

Signed-off-by: Paul Walker <paulwalker <AT> paulwalker.dev>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

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

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index 0f8fbcc7c3..d815b580af 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -619,7 +619,7 @@ bootstrap_startscript() {
 prepare_portage() {
        # see bootstrap_portage for explanations.
        mkdir -p "${ROOT}"/usr/bin/. "${ROOT}"/var/log
-       ln -sf usr/bin "${ROOT}"/bin
+       [[ -x ${ROOT}/bin ]] || ln -s usr/bin "${ROOT}"/bin
        [[ -x ${ROOT}/bin/bash ]] || ln -s "${ROOT}"{/tmp,}/bin/bash || return 1
        [[ -x ${ROOT}/bin/sh ]] || ln -s bash "${ROOT}"/bin/sh || return 1
 }
@@ -2374,7 +2374,7 @@ bootstrap_stage3() {
        # than to fake it here for the time being like in stage2.
        if [[ ! -e "${ROOT}"/lib/gentoo/functions.sh ]] ; then
                mkdir -p "${ROOT}"/usr/lib/gentoo
-               ln -sf usr/lib "${ROOT}"/lib
+               [[ -x ${ROOT}/lib ]] || ln -s usr/lib "${ROOT}"/lib
                cp "${ROOT}"/tmp/lib/gentoo/functions.sh \
                        "${ROOT}"/lib/gentoo/functions.sh
        fi

Reply via email to