diff --git a/images/linux/post-generation/rust-permissions.sh b/images/linux/post-generation/rust-permissions.sh deleted file mode 100644 index aff56ca17..000000000 --- a/images/linux/post-generation/rust-permissions.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Fix permissions for the Rust folder -# https://github.com/actions/virtual-environments/issues/572 - -rust_folder="/usr/share/rust" -rust_user=$(cut -d: -f1 /etc/passwd | tail -1) - -if [ -d "$rust_folder" ]; then - rust_folder_owner=$(ls -ld $rust_folder | awk '{print $3}') - if [ "$rust_user" != "$rust_folder_owner" ]; then - chown "$rust_user":docker -R $rust_folder - fi -fi diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 index f5f25a393..a556bf4c8 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 @@ -1,6 +1,7 @@ function Initialize-RustEnvironment { - ln -sf "/usr/share/rust/.rustup" $HOME/.rustup - ln -sf "/usr/share/rust/.cargo" $HOME/.cargo + $env:PATH = "/etc/skel/.cargo/bin:/etc/skel/.rustup/bin:$($env:PATH)" + $env:RUSTUP_HOME = "/etc/skel/.rustup" + $env:CARGO_HOME = "/etc/skel/.cargo" } function Get-RustVersion { @@ -52,4 +53,4 @@ function Get-RustdocVersion { function Get-RustfmtVersion { $rustfmtVersion = $(rustfmt --version) | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "-" return "Rustfmt $rustfmtVersion" -} \ No newline at end of file +} diff --git a/images/linux/scripts/installers/rust.sh b/images/linux/scripts/installers/rust.sh index a611183c4..123c0362e 100644 --- a/images/linux/scripts/installers/rust.sh +++ b/images/linux/scripts/installers/rust.sh @@ -7,8 +7,8 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/etc-environment.sh -export RUSTUP_HOME=/usr/share/rust/.rustup -export CARGO_HOME=/usr/share/rust/.cargo +export RUSTUP_HOME=/etc/skel/.rustup +export CARGO_HOME=/etc/skel/.cargo curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable --profile=minimal @@ -19,19 +19,10 @@ source $CARGO_HOME/env rustup component add rustfmt clippy cargo install --locked bindgen cbindgen cargo-audit cargo-outdated -# Permissions -chmod -R 777 $(dirname $RUSTUP_HOME) - # Cleanup Cargo cache rm -rf ${CARGO_HOME}/registry/* # Update /etc/environemnt -prependEtcEnvironmentPath "${CARGO_HOME}/bin" +prependEtcEnvironmentPath '$HOME/.cargo/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 - -invoke_tests "Tools" "Rust" \ No newline at end of file +invoke_tests "Tools" "Rust" diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index 6cfbc01f2..56596be32 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -15,6 +15,13 @@ Describe "Bicep" { } Describe "Rust" { + BeforeAll { + $env:PATH = "/etc/skel/.cargo/bin:/etc/skel/.rustup/bin:$($env:PATH)" + $env:RUSTUP_HOME = "/etc/skel/.rustup" + $env:CARGO_HOME = "/etc/skel/.cargo" + } + + It "Rustup is installed" { "rustup --version" | Should -ReturnZeroExitCode }