diff options
author | Leah Rowe <leah@libreboot.org> | 2025-10-01 07:42:10 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-10-01 07:43:12 +0100 |
commit | 8b351e51aa61c2091d7e4abbaf494c251e0c9c98 (patch) | |
tree | d4648bf65225a5b9e22aac87ef14f2cc97c17b03 /include | |
parent | 3b6d2b799ccff1f1803401d7e2ff64aa21a26b3b (diff) |
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 <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/tree.sh | 59 |
1 files changed, 44 insertions, 15 deletions
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" |