mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 12:06:59 +00:00
[macOS] Implement new directories hierarchy (#8741)
This commit is contained in:
committed by
GitHub
parent
5d40b1e213
commit
8d6a01b370
55
images/macos/scripts/build/powershell.sh
Normal file
55
images/macos/scripts/build/powershell.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing PowerShell...
|
||||
arch=$(get_arch)
|
||||
|
||||
download_with_retries "https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json" "/tmp" "powershell-metadata.json"
|
||||
psver=$(cat /tmp/powershell-metadata.json | jq -r '.LTSReleaseTag[0]')
|
||||
psDownloadUrl=$(get_github_package_download_url "PowerShell/PowerShell" "contains(\"osx-$arch.pkg\")" "$psver" "$API_PAT")
|
||||
download_with_retries $psDownloadUrl "/tmp" "powershell.pkg"
|
||||
|
||||
# Work around the issue on macOS Big Sur 11.5 or higher for possible error message ("can't be opened because Apple cannot check it for malicious software") when installing the package
|
||||
sudo xattr -rd com.apple.quarantine /tmp/powershell.pkg
|
||||
|
||||
|
||||
sudo installer -pkg /tmp/powershell.pkg -target /
|
||||
|
||||
# Install PowerShell modules
|
||||
psModules=$(get_toolset_value '.powershellModules[].name')
|
||||
for module in ${psModules[@]}; do
|
||||
echo "Installing $module module"
|
||||
moduleVersions="$(get_toolset_value ".powershellModules[] | select(.name==\"$module\") | .versions[]?")"
|
||||
if [[ -z "$moduleVersions" ]];then
|
||||
# Check MacOS architecture and sudo on Arm64
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
sudo pwsh -command "& {Install-Module $module -Force -Scope AllUsers}"
|
||||
else
|
||||
pwsh -command "& {Install-Module $module -Force -Scope AllUsers}"
|
||||
fi
|
||||
else
|
||||
for version in ${moduleVersions[@]}; do
|
||||
# Check MacOS architecture and sudo on Arm64
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
echo " - $version"
|
||||
sudo pwsh -command "& {Install-Module $module -RequiredVersion $version -Force -Scope AllUsers}"
|
||||
else
|
||||
echo " - $version"
|
||||
pwsh -command "& {Install-Module $module -RequiredVersion $version -Force -Scope AllUsers}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
# Fix permission root => runner after installing powershell for arm64 arch
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
sudo chown -R $USER ~/.local ~/.cache ~/.config
|
||||
fi
|
||||
|
||||
# A dummy call to initialize .IdentityService directory
|
||||
pwsh -command "& {Import-Module Az}"
|
||||
|
||||
# powershell link was removed in powershell-6.0.0-beta9
|
||||
sudo ln -s /usr/local/bin/pwsh /usr/local/bin/powershell
|
||||
|
||||
invoke_tests "Powershell"
|
||||
Reference in New Issue
Block a user