Files
kata-containers/tests/install_rust.sh
Markus Rudy 369124b180 ci: build genpolicy on darwin
genpolicy is a developer tool that should be usable on MacOS. Adding it
to the darwin CI job ensures that it can still be built after changes.

On an Apple M2, the output of `uname -m` is `arm64`, which is why a new
case is needed in the arch_to_* functions.

We're not going to cross-compile binaries on darwin, so don't install
any additional Rust targets.

Fixes: #11635

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2025-09-29 09:48:32 +02:00

47 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2019 Ant Financial
#
# SPDX-License-Identifier: Apache-2.0
set -o errexit
set -o nounset
set -o pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/common.bash"
rustarch=$(arch_to_rust)
version="${1:-""}"
if [[ -z "${version}" ]]; then
version=$(get_from_kata_deps ".languages.rust.meta.newest-version")
fi
echo "Install rust ${version}"
if ! command -v rustup > /dev/null; then
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain "${version}"
fi
export PATH="${PATH}:${HOME}/.cargo/bin"
## Still try to install the target version of toolchain,
## in case that the rustup has been installed but
## with a different version toolchain.
## Even though the target version toolchain has been installed,
## this command will not take too long to run.
rustup toolchain install "${version}"
rustup default "${version}"
if [[ "${rustarch}" == "x86_64" || "${rustarch}" == "aarch64" ]] ; then
if [[ "$(uname -s)" != "Darwin" ]]; then
rustup target add "${rustarch}-unknown-linux-musl"
$([[ "$(whoami)" != "root" ]] && echo sudo) ln -sf /usr/bin/g++ /bin/musl-g++
fi
else
rustup target add "${rustarch}-unknown-linux-gnu"
fi
rustup component add rustfmt
rustup component add clippy