path.sh: Further cleanup
Remove all symlinks each time, to ensure that no stragglers are left behind, since they are being re-generated each time anyway. The code for determining version numbers has now been unified under gnu_setver() Signed-off-by: Leah Rowe <leah@libreboot.org>master
parent
5b24e0a5a9
commit
295463d281
|
@ -95,7 +95,7 @@ if [ -z "${TMPDIR+x}" ]; then
|
||||||
export TMPDIR="/tmp"
|
export TMPDIR="/tmp"
|
||||||
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
|
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
|
||||||
touch lock || $err "cannot create 'lock' file"
|
touch lock || $err "cannot create 'lock' file"
|
||||||
rm -Rf xbmkpath || $err "cannot create xbmkpath"
|
rm -Rf xbmkpath || $err "cannot remove xbmkpath"
|
||||||
mkdir -p xbmkpath || $err "cannot create xbmkpath"
|
mkdir -p xbmkpath || $err "cannot create xbmkpath"
|
||||||
export PATH="$PWD/xbmkpath:$PATH" || $err "Can't create xbmkpath"
|
export PATH="$PWD/xbmkpath:$PATH" || $err "Can't create xbmkpath"
|
||||||
xbmk_parent="y"
|
xbmk_parent="y"
|
||||||
|
|
|
@ -1,48 +1,43 @@
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
# Copyright (c) 2024 Leah Rowe <leah@libreboot.org>
|
# Copyright (c) 2024 Leah Rowe <leah@libreboot.org>
|
||||||
|
|
||||||
|
eval `setvars "" gccver gccfull gnatver gnatfull gccdir`
|
||||||
|
|
||||||
# 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 gccfull gnatver gnatfull gccdir`
|
rm -f xbmkpath/* || $err "Cannot clear xbmkpath/"
|
||||||
command -v gcc 1>/dev/null || $err "Command 'gcc' unavailable."
|
|
||||||
|
|
||||||
for _util in gcc gnat; do
|
eval `setvars "" gccver gccfull gnatver gnatfull gccdir`
|
||||||
eval "$_util --version 1>/dev/null 2>/dev/null || continue"
|
gnu_setver gcc gcc || $err "Command 'gcc' unavailable."
|
||||||
eval "${_util}ver=\"`$_util --version 2>/dev/null | head -n1`\""
|
gnu_setver gnat gnat || :
|
||||||
eval "${_util}ver=\"\${${_util}ver##* }\""
|
|
||||||
eval "${_util}full=\"\${$_util}ver\""
|
|
||||||
eval "${_util}ver=\"\${${_util}ver%%.*}\""
|
|
||||||
done
|
|
||||||
|
|
||||||
[ -z "$gccver" ] && $err "Cannot detect host GCC version"
|
[ -z "$gccver" ] && $err "Cannot detect host GCC version"
|
||||||
[ "$gnatfull" = "$gccfull" ] && 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
|
||||||
[ -x "$gccdir/gnat-$gccver" ] || \
|
gnu_setver "gnat" "$gccdir/gnat-$gccver" || $err "Unknown gnat version"
|
||||||
$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."
|
[ "$gnatfull" = "$gccfull" ] || $err "GCC/GNAT versions do not match."
|
||||||
|
|
||||||
(
|
(
|
||||||
x_ cd xbmkpath
|
x_ cd xbmkpath
|
||||||
for _gnatbin in "$gccdir/gnat"*"-$gccver"; do
|
for _gnatbin in "$gccdir/gnat"*"-$gccver"; do
|
||||||
[ -e "$_gnatbin" ] || continue
|
[ -e "$_gnatbin" ] || continue; _gnatutil="${_gnatbin##*/}"
|
||||||
_gnatutil="${_gnatbin##*/}"
|
x_ ln -s "$_gnatbin" "${_gnatutil%"-$gccver"}"
|
||||||
ln -s "$_gnatbin" "${_gnatutil%"-$gccver"}" || \
|
|
||||||
$err "E: ln -s \"$_gnatbin\" \"${_gnatutil%"-$gccver"}\""
|
|
||||||
done
|
done
|
||||||
) || $err "Cannot create gnat-$gccver link in $gccdir"
|
) || $err "Cannot create gnat-$gccver link in $gccdir"; :
|
||||||
|
}
|
||||||
|
|
||||||
|
gnu_setver()
|
||||||
|
{
|
||||||
|
eval "$2 --version 1>/dev/null 2>/dev/null || return 1"
|
||||||
|
eval "${1}ver=\"`$2 --version 2>/dev/null | head -n1`\""
|
||||||
|
eval "${1}ver=\"\${${1}ver##* }\""
|
||||||
|
eval "${1}full=\"\${$1}ver\""
|
||||||
|
eval "${1}ver=\"\${${1}ver%%.*}\""; :
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue