Add Rust lang

This commit is contained in:
Hannes Moser 2022-11-21 10:38:58 +01:00
parent 207a35971c
commit 2001e1f9f1
No known key found for this signature in database
GPG key ID: 6780A04E9672CA89
8 changed files with 72 additions and 1 deletions

42
scripts/install-rust Executable file
View file

@ -0,0 +1,42 @@
#!/bin/bash
set -xeou pipefail
INSTALL_RUST_VERSION=${1}
case "$TARGETARCH" in
"arm64")
RUST_TARGET="aarch64-unknown-linux-gnu"
;;
"amd64")
RUST_TARGET="x86_64-unknown-linux-gnu"
;;
*)
echo "target architecture not supported"
exit 1
;;
esac
RUST_DOWNLOAD_URL="https://static.rust-lang.org/rustup/dist/$RUST_TARGET/rustup-init"
RUSTUP_DEFAULT_TOOLCHAIN="$INSTALL_RUST_VERSION"
RUSTUP_HOME="/usr/local/rustup"
CARGO_HOME="/usr/local/cargo"
function build() {
curl --retry 3 --proto '=https' --tlsv1.2 -sSf "$RUST_DOWNLOAD_URL" > rustup-init
curl --retry 3 --proto '=https' --tlsv1.2 -sSf "$RUST_DOWNLOAD_URL.sha256" > rustup-init.sha256
# Remove "target/$RUST_TARGET/release/" string from rustup-init.sha256
sed -i "s:\*target/$RUST_TARGET/release/::" rustup-init.sha256
sha256sum -c rustup-init.sha256
chmod +x rustup-init
# Need rustfmt for bindgen doc parsing
./rustup-init --no-modify-path --default-toolchain "$RUSTUP_DEFAULT_TOOLCHAIN" --profile minimal --component rustfmt -y
rm rustup-init && rm rustup-init.sha256
chmod -R a+w "$RUSTUP_HOME" "$CARGO_HOME"
}
build "$@"

View file

@ -61,6 +61,18 @@ function print_golang_args() {
printf -- "--build-arg GOLANG_DOWNLOAD_SHA256=%q " "${GOLANG_DOWNLOAD_SHA256[*]}"
}
function print_rust_args() {
case "$1" in
1.65.0)
RUST_VERSION="1.65.0"
;;
*) fail "Unknown rust version $1" ;;
esac
printf -- "--build-arg RUST_VERSION=%s " "$RUST_VERSION"
}
# If you add a new minor version here, be sure to check that the
# Chrome versions can be found at https://www.ubuntuupdates.org/pm/google-chrome-stable.
# ChromeDriver supports this: https://sites.google.com/chromium.org/driver/downloads
@ -339,6 +351,7 @@ function parse_arguments() {
BUNDLER) print_bundler_args $version ;;
RUBYGEMS) print_rubygems_args $version ;;
GOLANG) print_golang_args $version ;;
RUST) print_rust_args $version ;;
CHROME) print_chrome_args $version ;;
DOCKER) print_docker_args $version ;;
BUILDX) print_buildx_args $version ;;

View file

@ -1,7 +1,7 @@
# Note: Check out https://wiki.bash-hackers.org/syntax/pe for documentation on
# various variable operations used in this script.
PATH_TOOLS=(DEBIAN OS UBI RUBY GOLANG NODE POSTGRESQL)
PATH_TOOLS=(DEBIAN OS UBI RUBY GOLANG RUST NODE POSTGRESQL)
TAG_TOOLS=(BUNDLER RUBYGEMS GIT LFS CHROME YARN GRAPHICSMAGICK BAZELISK DOCKER BUILDX GCLOUD KUBECTL HELM)
# Generate the docker image path using the components that were specified via
@ -10,6 +10,7 @@ TAG_TOOLS=(BUNDLER RUBYGEMS GIT LFS CHROME YARN GRAPHICSMAGICK BAZELISK DOCKER B
# OS: debian:bullseye
# RUBY: 2.7
# GOLANG: 1.19
# RUST: 1.65.0
# GIT: 2.33
# POSTGRESQL: 11
# With the above variables, this function will return
@ -44,6 +45,7 @@ function get_image_path() {
# OS: debian:bullseye
# RUBY: 2.7
# GOLANG: 1.19
# RUST: 1.65.0
# GIT: 2.33
# POSTGRESQL: 11
# For that job, this function will return