From d0f104991b9e6134f04bc674af115bc288c9e137 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Fri, 16 Apr 2021 16:34:56 -0500 Subject: Allow environment to specify a shell for running config.guess --- ChangeLog | 6 ++++++ runtest.exp | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index bfc175c..bd0955e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,12 @@ * configure.ac: Remove experimental support for propagating CONFIG_SHELL to scripts in the source directory. + * runtest.exp: Use CONFIG_SHELL or SHELL environment variable when + running config.guess. Check the result carefully and stop with an + error immediately if running config.guess does not produce + something that plausibly resembles a triplet. Advise the user + that SHELL or CONFIG_SHELL may need to be set in the environment. + 2021-04-15 Jacob Bachmeyer PR47382 diff --git a/runtest.exp b/runtest.exp index 3220485..93ae2ab 100644 --- a/runtest.exp +++ b/runtest.exp @@ -823,13 +823,52 @@ if {[expr {$build_triplet eq "" && $host_triplet eq ""}]} { send_error "ERROR: Couldn't find config.guess program.\n" exit 1 } - catch "exec $config_guess" build_triplet - switch -- $build_triplet { - "No uname command or uname output not recognized" - - "Unable to guess system type" { - verbose "WARNING: Uname output not recognized" - set build_triplet unknown + if { [info exists ::env(CONFIG_SHELL)] } { + if { [catch {exec $::env(CONFIG_SHELL) $config_guess} build_triplet] } { + if { [lindex $::errorCode 0] eq "CHILDSTATUS" } { + send_error "ERROR: Running config.guess with\ + CONFIG_SHELL=$::env(CONFIG_SHELL)\ + exited on code\ + [lindex $::errorCode 2].\n" + } else { + send_error "ERROR: Running config.guess with\ + CONFIG_SHELL=$::env(CONFIG_SHELL)\ + produced error:\n" + send_error " $::errorCode\n" + } + } + } elseif { [info exists ::env(SHELL)] } { + if { [catch {exec $::env(SHELL) $config_guess} build_triplet] } { + if { [lindex $::errorCode 0] eq "CHILDSTATUS" } { + send_error "ERROR: Running config.guess with\ + SHELL=$::env(SHELL)\ + exited on code\ + [lindex $::errorCode 2].\n" + } else { + send_error "ERROR: Running config.guess with\ + SHELL=$::env(SHELL)\ + produced error:\n" + send_error " $::errorCode\n" + } } + } else { + if { [catch {exec $config_guess} build_triplet] } { + if { [lindex $::errorCode 0] eq "CHILDSTATUS" } { + send_error "ERROR: Running config.guess exited on code\ + [lindex $::errorCode 2].\n" + } else { + send_error "ERROR: Running config.guess produced error:\n" + send_error " $::errorCode\n" + } + } + } + if { ![regexp -- {^[^-]+-[^-]+-[^-]+} $build_triplet] } { + send_error "ERROR: Running config.guess produced bogus build triplet:\n" + send_error " $build_triplet\n" + send_error " (Perhaps you need to set CONFIG_SHELL or\ + SHELL in your environment\n" + send_error " to the absolute file name of a POSIX shell?)\n" + exit 1 } verbose "Assuming build host is $build_triplet" if { $host_triplet eq "" } { -- cgit v1.1