From 5b24e0a5a96096273b8b662edf3b2f7ff204c00c Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 30 Dec 2024 13:36:34 +0000 Subject: [PATCH] path.sh: More thorough gcc/gnat version check We were checking the shorthand version number, but the precise version numbers need to match. Also: when we searched $PATH/gnat-$gccver, we assumed that the full version would then match, without checking it, so now it is checked precisely. Signed-off-by: Leah Rowe --- include/path.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/include/path.sh b/include/path.sh index 56756bbd..98f536c1 100644 --- a/include/path.sh +++ b/include/path.sh @@ -4,27 +4,37 @@ # fix mismatching gcc/gnat versions on debian trixie/sid check_gnat_path() { - eval `setvars "" gccver gnatver gccdir` + eval `setvars "" gccver gccfull gnatver gnatfull gccdir` command -v gcc 1>/dev/null || $err "Command 'gcc' unavailable." for _util in gcc gnat; do eval "$_util --version 1>/dev/null 2>/dev/null || continue" eval "${_util}ver=\"`$_util --version 2>/dev/null | head -n1`\"" eval "${_util}ver=\"\${${_util}ver##* }\"" + eval "${_util}full=\"\${$_util}ver\"" eval "${_util}ver=\"\${${_util}ver%%.*}\"" done [ -z "$gccver" ] && $err "Cannot detect host GCC version" - [ "$gnatver" = "$gccver" ] && return 0 + [ "$gnatfull" = "$gccfull" ] && return 0 gccdir="$(dirname "$(command -v gcc)")" + [ -d "$gccdir" ] || $err "gcc PATH dir \"$gccdir\" does not exist." + for _gnatbin in "$gccdir/gnat-"*; do [ -f "$_gnatbin" ] || continue [ "${_gnatbin#"$gccdir/gnat-"}" = "$gccver" ] || continue gnatver="${_gnatbin#"$gccdir/gnat-"}" break done - [ "$gnatver" = "$gccver" ] || $err "GCC/GNAT versions do not match." + [ -x "$gccdir/gnat-$gccver" ] || \ + $err "$gccdir/gnat-$gccver not executable" + gnatfull="`"$gccdir/gnat-$gccver" --version | head -n1`" + gnatfull="${gnatfull##* }" + [ "${gnatfull%%.*}" = "$gnatver" ] || \ + $err "$gccdir/gnat-$gccver v${gnatfull%%.*}; expected v$gnatver" + + [ "$gnatfull" = "$gccfull" ] || $err "GCC/GNAT versions do not match." ( x_ cd xbmkpath