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 <leah@libreboot.org>master
parent
7849a07588
commit
5b24e0a5a9
|
@ -4,27 +4,37 @@
|
||||||
# fix mismatching gcc/gnat versions on debian trixie/sid
|
# fix mismatching gcc/gnat versions on debian trixie/sid
|
||||||
check_gnat_path()
|
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."
|
command -v gcc 1>/dev/null || $err "Command 'gcc' unavailable."
|
||||||
|
|
||||||
for _util in gcc gnat; do
|
for _util in gcc gnat; do
|
||||||
eval "$_util --version 1>/dev/null 2>/dev/null || continue"
|
eval "$_util --version 1>/dev/null 2>/dev/null || continue"
|
||||||
eval "${_util}ver=\"`$_util --version 2>/dev/null | head -n1`\""
|
eval "${_util}ver=\"`$_util --version 2>/dev/null | head -n1`\""
|
||||||
eval "${_util}ver=\"\${${_util}ver##* }\""
|
eval "${_util}ver=\"\${${_util}ver##* }\""
|
||||||
|
eval "${_util}full=\"\${$_util}ver\""
|
||||||
eval "${_util}ver=\"\${${_util}ver%%.*}\""
|
eval "${_util}ver=\"\${${_util}ver%%.*}\""
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -z "$gccver" ] && $err "Cannot detect host GCC version"
|
[ -z "$gccver" ] && $err "Cannot detect host GCC version"
|
||||||
[ "$gnatver" = "$gccver" ] && return 0
|
[ "$gnatfull" = "$gccfull" ] && return 0
|
||||||
|
|
||||||
gccdir="$(dirname "$(command -v gcc)")"
|
gccdir="$(dirname "$(command -v gcc)")"
|
||||||
|
[ -d "$gccdir" ] || $err "gcc PATH dir \"$gccdir\" does not exist."
|
||||||
|
|
||||||
for _gnatbin in "$gccdir/gnat-"*; do
|
for _gnatbin in "$gccdir/gnat-"*; do
|
||||||
[ -f "$_gnatbin" ] || continue
|
[ -f "$_gnatbin" ] || continue
|
||||||
[ "${_gnatbin#"$gccdir/gnat-"}" = "$gccver" ] || continue
|
[ "${_gnatbin#"$gccdir/gnat-"}" = "$gccver" ] || continue
|
||||||
gnatver="${_gnatbin#"$gccdir/gnat-"}"
|
gnatver="${_gnatbin#"$gccdir/gnat-"}"
|
||||||
break
|
break
|
||||||
done
|
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
|
x_ cd xbmkpath
|
||||||
|
|
Loading…
Reference in New Issue