From 17cf7226f4273c350cf383fcc48634ffc75fe8ac Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Thu, 31 Oct 2024 21:48:09 +0200 Subject: [PATCH] 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: --- ci/scripts/build-toolbox-image.sh | 6 ++++++ ci/scripts/install-rust.sh | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ci/scripts/build-toolbox-image.sh b/ci/scripts/build-toolbox-image.sh index 26ee6468f6..5a5ef58e4e 100644 --- a/ci/scripts/build-toolbox-image.sh +++ b/ci/scripts/build-toolbox-image.sh @@ -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 diff --git a/ci/scripts/install-rust.sh b/ci/scripts/install-rust.sh index 25d46a2291..5604d03f42 100644 --- a/ci/scripts/install-rust.sh +++ b/ci/scripts/install-rust.sh @@ -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