Jordan Petridis 17cf7226f4 build-toolbox-image.sh: Hardcode the RUSTUP/CARGO_HOME env vars
We install the rust toolchain, but then we have to manually
source it in CI since the headless containers skip over
the shell profiles that rustup typically uses.

Ideally we'd set these as variables in the main image, but
we don't have access to the buildah instance used in
ci-templates/cbuild.

However adding them to the toolbox image is good enough to
have the toolbox setup work ootb even if it doesn't call the
ci/scripts/source_image_env.sh script like the gitlab-ci jobs
will do.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7816>
2025-04-12 10:11:28 +00:00

34 lines
868 B
Bash

#! /bin/bash
set -eux
# Install Rust
RUSTUP_VERSION=1.28.1
RUST_VERSION=1.86.0
RUST_ARCH="x86_64-unknown-linux-gnu"
RUSTUP_URL=https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/$RUST_ARCH/rustup-init
curl -o rustup-init $RUSTUP_URL
export RUSTUP_HOME="/usr/local/rustup"
export CARGO_HOME="/usr/local/cargo"
export PATH="/usr/local/cargo/bin:$PATH"
chmod +x rustup-init;
./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION;
rm rustup-init;
# We are root while creating the directory, but we want it to
# be accessible to all users
chmod -R a+w $RUSTUP_HOME $CARGO_HOME
cargo install --locked cargo-c --version 0.10.12+cargo-0.87.0
rustup --version
cargo --version
rustc --version
cargo cinstall --version
# Cleanup the registry after install
# so we don't have to save 200mb of the index in the ci image
rm -rf "$CARGO_HOME/registry"