commit:     43f01d356a8fd347a19d7583eab92d01bee35f9f
Author:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 23 19:11:09 2024 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Sat Mar 23 19:27:11 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=43f01d35

profiles: releases/23.0: Fix bashrc safety guard

The previous version relied on an environment variable, which was
*not* saved in binary packages and also not re-sourced from the
profile. It always became unset, which meant "merged-usr".

With that, not the local profile and the local filesystem were
compared, but "merged-usr" and the local filesystem -- which
obviously fails for any split-usr installation.

Closes: https://bugs.gentoo.org/927631
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 profiles/releases/23.0/profile.bashrc | 43 ++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/profiles/releases/23.0/profile.bashrc 
b/profiles/releases/23.0/profile.bashrc
index 6c178b086158..ae82a4b3216e 100644
--- a/profiles/releases/23.0/profile.bashrc
+++ b/profiles/releases/23.0/profile.bashrc
@@ -1,5 +1,40 @@
-if [[ "${EBUILD_PHASE}" == "setup" ]] && [[ -e "${EROOT%/}/bin" ]] ; then
-       if [[ ! -h "${EROOT%/}/bin" ]] && [[ "${PROFILE_23_USRTYPE}" != 
"split-usr" ]] ; then
+
+__gentoo_get_disk_splitmerge() {
+       # does /bin exist? important for baselayout
+       if [[ -e "${EROOT%/}/bin" ]] ; then
+               # is /bin a symlink?
+               if [[ -h "${EROOT%/}/bin" ]] ; then
+                       echo -n merged
+               else
+                       echo -n split
+               fi
+       else
+               echo -n unknown
+       fi
+}
+
+__gentoo_get_profile_splitmerge() {
+       # does /etc/portage/make.profile exist and is a symlink?
+       if [[ -h "${EROOT%/}/etc/portage/make.profile" ]] ; then
+               local linktarget=$(readlink 
"${EROOT%/}/etc/portage/make.profile")
+
+               # 23.0 profile?
+               if [[ "${linktarget}" == */23.0* ]] ; then
+                       if [[ "${linktarget}" == *split-usr* ]] ; then
+                               echo -n split
+                       else
+                               echo -n merged
+                       fi
+               else
+                       echo -n unknown
+               fi
+       else
+               echo -n unknown
+       fi
+}
+
+if [[ "${EBUILD_PHASE}" == "setup" ]] ; then
+       if [[ $(__gentoo_get_disk_splitmerge) == "split" ]] && [[ 
$(__gentoo_get_profile_splitmerge) == "merged" ]] ; then
                eerror ""
                eerror "Your profile is of type merged-usr, but your 
directories"
                eerror "on-disk are of type split-usr."
@@ -8,7 +43,7 @@ if [[ "${EBUILD_PHASE}" == "setup" ]] && [[ -e 
"${EROOT%/}/bin" ]] ; then
                eerror ""
                die "ERROR: 23.0 merged-usr profile, but disk is split-usr"
        fi
-       if [[ -h "${EROOT%/}/bin" ]] && [[ "${PROFILE_23_USRTYPE}" == 
"split-usr" ]] ; then
+       if [[ $(__gentoo_get_disk_splitmerge) == "merged" ]] && [[ 
$(__gentoo_get_profile_splitmerge) == "split" ]] ; then
                eerror ""
                eerror "Your profile is of type split-usr, but your directories"
                eerror "on-disk are of type merged-usr."
@@ -18,3 +53,5 @@ if [[ "${EBUILD_PHASE}" == "setup" ]] && [[ -e 
"${EROOT%/}/bin" ]] ; then
                die "ERROR: 23.0 split-usr profile, but disk is merged-usr"
        fi
 fi
+
+unset -f __gentoo_get_disk_splitmerge __gentoo_get_profile_splitmerge

Reply via email to