Files
runner-images/images/linux/scripts/installers/rust.sh
T

60 lines
2.2 KiB
Bash
Raw Normal View History

#!/bin/bash
################################################################################
## File: rust.sh
## Desc: Installs Rust
################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
source $HELPER_SCRIPTS/document.sh
export RUSTUP_HOME=/usr/share/rust/.rustup
export CARGO_HOME=/usr/share/rust/.cargo
2020-03-23 07:54:11 +07:00
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable --profile=minimal
# Initialize environment variables
source $CARGO_HOME/env
# Install common tools
2020-03-23 07:54:11 +07:00
rustup component add rustfmt clippy
cargo install bindgen cbindgen
2020-07-07 11:38:29 +03:00
cargo install cargo-audit
cargo install cargo-outdated
echo "Test installation of the Rust toochain"
# Permissions
chmod -R 777 $(dirname $RUSTUP_HOME)
2020-07-07 11:38:29 +03:00
for cmd in rustup rustc rustdoc cargo rustfmt cargo-clippy bindgen cbindgen 'cargo audit' 'cargo outdated'; do
if ! command -v $cmd --version; then
echo "$cmd was not installed or is not found on the path"
exit 1
fi
done
2020-05-25 12:25:41 +03:00
# Cleanup Cargo cache
2020-07-13 12:16:14 +03:00
rm -rf ${CARGO_HOME}/registry/*
2020-05-25 12:25:41 +03:00
# Update /etc/environemnt
prependEtcEnvironmentPath "${CARGO_HOME}/bin"
# Rust Symlinks are added to a default profile /etc/skel
pushd /etc/skel
ln -sf $RUSTUP_HOME .rustup
ln -sf $CARGO_HOME .cargo
popd
# Document what was added to the image
echo "Lastly, document what was added to the metadata file"
DocumentInstalledItem "rustup ($(rustup --version 2>&1 | cut -d ' ' -f 2))"
DocumentInstalledItem "rust ($(rustc --version 2>&1 | cut -d ' ' -f 2))"
DocumentInstalledItem "cargo ($(cargo --version 2>&1 | cut -d ' ' -f 2))"
DocumentInstalledItem "rustfmt ($(rustfmt --version 2>&1 | cut -d ' ' -f 2))"
DocumentInstalledItem "clippy ($(cargo-clippy --version 2>&1 | cut -d ' ' -f 2))"
DocumentInstalledItem "rustdoc ($(rustdoc --version 2>&1 | cut -d ' ' -f 2))"
DocumentInstalledItem "bindgen ($(bindgen --version 2>&1 | cut -d ' ' -f 2))"
DocumentInstalledItem "cbindgen ($(cbindgen --version 2>&1 | cut -d ' ' -f 2))"
2020-07-07 11:38:29 +03:00
DocumentInstalledItem "cargo audit ($(cargo audit --version 2>&1 | cut -d ' ' -f 2))"
DocumentInstalledItem "cargo outdated ($(cargo outdated --version 2>&1 | cut -d ' ' -f 2))"