[Ubuntu] get rid of post-gen rust script (#4575)

This commit is contained in:
Mikhail Koliada
2021-11-26 12:39:13 +03:00
committed by GitHub
parent 8922c7b5bf
commit af645a7b5e
4 changed files with 15 additions and 30 deletions

View File

@@ -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

View File

@@ -1,6 +1,7 @@
function Initialize-RustEnvironment { function Initialize-RustEnvironment {
ln -sf "/usr/share/rust/.rustup" $HOME/.rustup $env:PATH = "/etc/skel/.cargo/bin:/etc/skel/.rustup/bin:$($env:PATH)"
ln -sf "/usr/share/rust/.cargo" $HOME/.cargo $env:RUSTUP_HOME = "/etc/skel/.rustup"
$env:CARGO_HOME = "/etc/skel/.cargo"
} }
function Get-RustVersion { function Get-RustVersion {

View File

@@ -7,8 +7,8 @@
# Source the helpers for use with the script # Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh source $HELPER_SCRIPTS/etc-environment.sh
export RUSTUP_HOME=/usr/share/rust/.rustup export RUSTUP_HOME=/etc/skel/.rustup
export CARGO_HOME=/usr/share/rust/.cargo export CARGO_HOME=/etc/skel/.cargo
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable --profile=minimal 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 rustup component add rustfmt clippy
cargo install --locked bindgen cbindgen cargo-audit cargo-outdated cargo install --locked bindgen cbindgen cargo-audit cargo-outdated
# Permissions
chmod -R 777 $(dirname $RUSTUP_HOME)
# Cleanup Cargo cache # Cleanup Cargo cache
rm -rf ${CARGO_HOME}/registry/* rm -rf ${CARGO_HOME}/registry/*
# Update /etc/environemnt # 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" invoke_tests "Tools" "Rust"

View File

@@ -15,6 +15,13 @@ Describe "Bicep" {
} }
Describe "Rust" { 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" { It "Rustup is installed" {
"rustup --version" | Should -ReturnZeroExitCode "rustup --version" | Should -ReturnZeroExitCode
} }