From 8b351e51aa61c2091d7e4abbaf494c251e0c9c98 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 1 Oct 2025 07:42:10 +0100 Subject: tree.sh: break up check_gnu_path to subfunctions this whole check could probably be removed, honestly. it was only put in place during the debian trixie testing release cycle, before they finally updated gnat just before the stable release of trixie came out. Signed-off-by: Leah Rowe --- include/tree.sh | 59 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/tree.sh b/include/tree.sh index 9e4b13b3..c0802bfe 100644 --- a/include/tree.sh +++ b/include/tree.sh @@ -427,6 +427,7 @@ check_cross_compiler() # trixie/sid had gnat-13 as gnat and gcc-14 as gcc, but has gnat-14 in apt. in # some cases, gcc 13+14 and gnat-13 are present; or gnat-14 and gcc-14, but # gnat in PATH never resolves to gnat-14, because gnat-14 was "experimental" + check_gnu_path() { if ! command -v "$1" 1>/dev/null; then @@ -434,6 +435,20 @@ check_gnu_path() fi eval "`setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir`" + + if host_gcc_gnat_match "$@"; then + return 0 + fi + + if ! match_gcc_gnat_versions "$@"; then + return 1 + fi +} + +# check if gcc/gnat versions already match: + +host_gcc_gnat_match() +{ if ! gnu_setver "$1" "$1"; then err "Command '$1' unavailable." "check_gnu_path" "$@" fi @@ -441,12 +456,17 @@ check_gnu_path() eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\"" - if [ "$gnatfull" = "$gccfull" ]; then - # matching gcc/gnat versions + if [ "$gnatfull" != "$gccfull" ]; then + # non-matching gcc/gnat versions - return 0 + return 1 fi +} + +# find all gcc/gnat versions, matching them up in PATH: +match_gcc_gnat_versions() +{ eval "$1dir=\"$(dirname "$(command -v "$1")")\"" eval "_gnudir=\"\$$1dir\"" eval "_gnuver=\"\$$1ver\"" @@ -466,23 +486,32 @@ check_gnu_path() return 1 fi - ( - remkdir "$xbtmp/gnupath" + ( link_gcc_gnat_versions "$@" "$_gnudir" "$_gnuver" ) || \ + err "Can't link '$2-$_gnuver' '$_gnudir'" "check_gnu_path" "$@"; : +} - x_ cd "$xbtmp/gnupath" +# create symlinks in PATH, so that the GCC/GNAT versions match: - for _gnubin in "$_gnudir/$2"*"-$_gnuver" - do - _gnuutil="${_gnubin##*/}" - if [ -e "$_gnubin" ]; then - x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}" - fi - done +link_gcc_gnat_versions() +{ + _gnudir="$3" + _gnuver="$4" + + remkdir "$xbtmp/gnupath" + + x_ cd "$xbtmp/gnupath" - ) || err \ - "Can't link '$2-$_gnuver' '$_gnudir'" "check_gnu_path" "$@"; : + for _gnubin in "$_gnudir/$2"*"-$_gnuver" + do + _gnuutil="${_gnubin##*/}" + if [ -e "$_gnubin" ]; then + x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}" + fi + done } +# get the gcc/gnat version +# fail: return 1 if util not found gnu_setver() { eval "$2 --version 1>/dev/null 2>/dev/null || return 1" -- cgit v1.2.1