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>
This commit is contained in:
Jordan Petridis 2024-10-31 21:48:09 +02:00 committed by GStreamer Marge Bot
parent 2ce8a1aea9
commit 17cf7226f4
2 changed files with 8 additions and 0 deletions

View File

@ -112,6 +112,12 @@ build_container() {
buildah run $build_cntr -- bash -c "echo $name ALL=\(ALL\) NOPASSWD:ALL > /etc/sudoers.d/$name"
buildah run $build_cntr -- chmod 0440 /etc/sudoers.d/$name
buildah config \
--env RUSTUP_HOME="/usr/local/rustup" \
--env CARGO_HOME="/usr/local/cargo/" \
--env PATH="$PATH:/usr/local/cargo/bin/" \
$build_cntr
# Remove the hardcoded HOME env var that ci-templates adds
# https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2433#note_2243222
# Also add the OCI labels that toolbox expects, to advertize that image is compatible

View File

@ -17,6 +17,8 @@ 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