commit:     66a225e59ff82200ec3497c92b378d37b70b1b2c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 20 09:07:17 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jun 20 09:07:17 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=66a225e5

scripts/bootstrap-prefix: add some identification for bug analysis

Use identification used by auto-bootstraps in error logs so we can
easily see some info like distro and RAP usage.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 scripts/auto-bootstraps/dobootstrap | 33 ++-----------------
 scripts/bootstrap-prefix.sh         | 63 +++++++++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 33 deletions(-)

diff --git a/scripts/auto-bootstraps/dobootstrap 
b/scripts/auto-bootstraps/dobootstrap
index 8b8eb48bed..983cf65977 100755
--- a/scripts/auto-bootstraps/dobootstrap
+++ b/scripts/auto-bootstraps/dobootstrap
@@ -143,37 +143,8 @@ do_prepare() {
        if [[ -n ${DOPUBLISH} ]] ; then
                echo $((endtime - starttime)) > elapsedtime
 
-               # massage CHOST on Linux systems
-               if [[ ${chost} == *-linux-* ]] ; then
-                       # two choices here: x86_64_ubuntu16-linux-gnu
-                       #                   x86_64-pc-linux-ubuntu16
-                       # I choose the latter because it is compatible with most
-                       # UNIX vendors
-                       local dist=$(lsb_release -si)
-                       local rel=$(lsb_release -sr)
-                       if [[ -z ${dist} ]] || [[ -z ${rel} ]] ; then
-                               source /etc/os-release  # this may fail if the 
file isn't there
-                               [[ -z ${dist} ]] && dist=${NAME}
-                               [[ -z ${dist} ]] && dist=${ID}
-                               [[ -z ${rel} ]] && rel=${VERSION_ID}
-
-                               # Gentoo's versioning isn't really relevant, 
since it is
-                               # a rolling distro
-                               if [[ ${dist,,} == "gentoo" ]] ; then
-                                       rel=
-                                       [[ ${chost##*-} == "musl" ]] && 
rel="musl"
-                               fi
-                       fi
-                       [[ -z ${dist} ]] && dist=linux
-                       # leave rel unset/empty if we don't know about it
-                       while [[ ${rel} == *.*.* ]] ; do
-                               rel=${rel%.*}
-                       done
-                       local platform=pc
-                       # this is the logic used in bootstrap-prefix.sh
-                       [[ ${PREFIX_DISABLE_RAP} != "yes" ]] && platform=rap
-                       chost=${chost%%-*}-${platform}-linux-${dist,,}${rel}
-               fi
+               # get identification of host that includes Linux distro, RAP, 
...
+               chost=$(${BASH} ${bootstrap} chost.identify x)
 
                rsync -q /dev/null ${UPLOAD}/${HOSTNAME}-$$/
                rsync -q /dev/null ${UPLOAD}/${HOSTNAME}-$$/${chost}/

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index 8e53e57705..c50340fb91 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -2842,6 +2842,9 @@ but that failed :(  I have no clue, really.  Please find 
friendly folks
 in #gentoo-prefix on irc.gentoo.org, [email protected] mailing list,
 or file a bug at bugs.gentoo.org under Gentoo/Alt, Prefix Support.
 Sorry that I have failed you master.  I shall now return to my humble cave.
+
+  CHOST:     ${CHOST}
+  IDENT:     ${CHOST_IDENTIFY}
 EOF
                        exit 1
                fi
@@ -2877,6 +2880,9 @@ in #gentoo-prefix on irc.gentoo.org, 
[email protected] mailing list,
 or file a bug at bugs.gentoo.org under Gentoo/Alt, Prefix Support.
 Sorry that I have failed you master.  I shall now return to my humble cave.
 You can find a log of what happened in ${EPREFIX}/stage1.log
+
+  CHOST:     ${CHOST}
+  IDENT:     ${CHOST_IDENTIFY}
 EOF
                exit 1
        fi
@@ -2928,6 +2934,9 @@ I have no clue, really.  Please find friendly folks in 
#gentoo-prefix on
 irc.gentoo.org, [email protected] mailing list, or file a bug
 at bugs.gentoo.org under Gentoo/Alt, Prefix Support.
 Remember you might find some clues in ${EPREFIX}/stage2.log
+
+  CHOST:     ${CHOST}
+  IDENT:     ${CHOST_IDENTIFY}
 EOF
                exit 1
        fi
@@ -2968,6 +2977,9 @@ irc.gentoo.org, [email protected] mailing list, 
or file a bug
 at bugs.gentoo.org under Gentoo/Alt, Prefix Support.  This is most
 inconvenient, and it crushed my ego.  Sorry, I give up.
 Should you want to give it a try, there is ${EPREFIX}/stage3.log
+
+  CHOST:     ${CHOST}
+  IDENT:     ${CHOST_IDENTIFY}
 EOF
                exit 1
        fi
@@ -3008,6 +3020,9 @@ irc.gentoo.org, [email protected] mailing list, 
or file a bug
 at bugs.gentoo.org under Gentoo/Alt, Prefix Support.
 You know, I got the feeling you just started to like me, but I guess
 that's all gone now.  I'll bother you no longer.
+
+  CHOST:     ${CHOST}
+  IDENT:     ${CHOST_IDENTIFY}
 EOF
                exit 1
        fi
@@ -3020,7 +3035,7 @@ Ok, let's be honest towards each other.  If
   $(type -P bash) ${BASH_SOURCE[0]} "${EPREFIX}" startscript
 fails, then who cheated on who?  Either you use an obscure shell, or
 your PATH isn't really sane afterall.  Despite, I can't really
-congratulate you here, you basically made it to the end.
+congratulate you here, but you basically made it to the end.
 Please find friendly folks in #gentoo-prefix on irc.gentoo.org,
 [email protected] mailing list, or file a bug at
 bugs.gentoo.org under Gentoo/Alt, Prefix Support.
@@ -3119,6 +3134,41 @@ if [[ -z ${CHOST} ]]; then
        fi
 fi
 
+CHOST_IDENTIFY=${CHOST}
+# massage CHOST on Linux systems
+if [[ ${CHOST} == *-linux-* ]] ; then
+       # two choices here: x86_64_ubuntu16-linux-gnu
+       #                   x86_64-pc-linux-ubuntu16
+       # I choose the latter because it is compatible with most
+       # UNIX vendors and it allows to fit RAP into platform
+       dist=$(lsb_release -si)
+       rel=$(lsb_release -sr)
+       if [[ -z ${dist} ]] || [[ -z ${rel} ]] ; then
+               source /etc/os-release  # this may fail if the file isn't there
+               [[ -z ${dist} ]] && dist=${NAME}
+               [[ -z ${dist} ]] && dist=${ID}
+               [[ -z ${rel} ]] && rel=${VERSION_ID}
+
+       fi
+       [[ -z ${dist} ]] && dist=linux
+
+       # Gentoo's versioning isn't really relevant, since it is
+       # a rolling distro
+       if [[ ${dist,,} == "gentoo" ]] ; then
+               rel=
+               [[ ${chost##*-} == "musl" ]] && rel="musl"
+       fi
+
+       # leave rel unset/empty if we don't know about it
+       while [[ ${rel} == *.*.* ]] ; do
+               rel=${rel%.*}
+       done
+
+       platform=${CHOST#*-}; platform=${platform%%-*}
+       platform=$(rapx rap ${platform})
+       CHOST_IDENTIFY=${CHOST%%-*}-${platform}-linux-${dist,,}${rel}
+fi
+
 # Now based on the CHOST set some required variables.  Doing it here
 # allows for user set CHOST still to result in the appropriate variables
 # being set.
@@ -3206,7 +3256,15 @@ case $ROOT in
        chost.guess)
                # undocumented feature that sort of is our own config.guess, if
                # CHOST was unset, it now contains the guessed CHOST
-               echo "$CHOST"
+               echo "${CHOST}"
+               exit 0
+       ;;
+       chost.identify)
+               # another undocumented feature, produces a pseudo CHOST that
+               # identifies the system for bootstraps, currently only Linux is
+               # different from CHOST
+
+               echo "${CHOST_IDENTIFY}"
                exit 0
        ;;
        /*) ;;
@@ -3219,6 +3277,7 @@ esac
 
 einfo "Bootstrapping Gentoo prefixed portage installation using"
 einfo "host:   ${CHOST}"
+einfo "ident:  ${CHOST_IDENTIFY}"
 einfo "prefix: ${ROOT}"
 
 TODO=${2}

Reply via email to