packaging/shim-v2: Install the target depending on the arch/libc

In the `install_go_rust.sh` file we're adding a
x86_64-unknown-linux-musl target unconditionally.  That should be,
instead, based in the ARCH of the host and the appropriate LIBC to be
used with that host.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2023-02-16 09:12:05 +01:00
parent c1602c848a
commit 47c058599a

View File

@ -50,12 +50,37 @@ EOF
trap finish EXIT
go_version=${1:-}
rust_version=${2:-}
ARCH=${ARCH:-$(uname -m)}
LIBC=${LIBC:-musl}
case "${ARCH}" in
aarch64)
goarch=arm64
LIBC=musl
;;
ppc64le)
goarch=${ARCH}
ARCH=powerpc64le
LIBC=gnu
;;
s390x)
goarch=${ARCH}
LIBC=gnu
;;
x86_64)
goarch=amd64
LIBC=musl
;;
*)
echo "unsupported architecture $(uname -m)"
exit 1
;;
esac
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSLf | sh -s -- -y --default-toolchain ${rust_version} -t ${ARCH}-unknown-linux-${LIBC}
source /root/.cargo/env
rustup target add x86_64-unknown-linux-musl
rustup target add ${ARCH}-unknown-linux-${LIBC}
pushd "${tmp_dir}"
@ -70,9 +95,6 @@ done
shift $(( $OPTIND - 1 ))
go_version=${1:-}
if [ -z "$go_version" ];then
echo "Missing go"
usage 1
@ -90,14 +112,6 @@ if command -v go; then
fi
fi
case "$(uname -m)" in
aarch64) goarch="arm64";;
ppc64le) goarch="ppc64le";;
x86_64) goarch="amd64";;
s390x) goarch="s390x";;
*) echo "unsupported architecture: $(uname -m)"; exit 1;;
esac
info "Download go version ${go_version}"
kernel_name=$(uname -s)
curl -OL "https://storage.googleapis.com/golang/go${go_version}.${kernel_name,,}-${goarch}.tar.gz"