[macos] prepare repository for ARM64 arch (#7396)

This commit is contained in:
Alexey-Ayupov
2023-05-12 13:30:13 +02:00
committed by GitHub
parent b6c7afbb26
commit 8b099099d9
35 changed files with 571 additions and 188 deletions

View File

@@ -2,9 +2,11 @@
source ~/utils/utils.sh
echo Installing PowerShell...
arch=$(get_arch)
psmetadata=$(curl "https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json" -s)
psver=$(echo $psmetadata | jq -r '.LTSReleaseTag[0]')
psDownloadUrl=$(get_github_package_download_url "PowerShell/PowerShell" "contains(\"osx-x64.pkg\")" "$psver" "$API_PAT")
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
@@ -19,15 +21,30 @@ for module in ${psModules[@]}; do
echo "Installing $module module"
moduleVersions="$(get_toolset_value ".powershellModules[] | select(.name==\"$module\") | .versions[]?")"
if [[ -z "$moduleVersions" ]];then
pwsh -command "& {Install-Module $module -Force -Scope AllUsers}"
# 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
echo " - $version"
pwsh -command "& {Install-Module $module -RequiredVersion $version -Force -Scope AllUsers}"
# 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
if [[ $arch == "arm64" ]]; then
sudo chown -R $USER ~/.local
fi
# A dummy call to initialize .IdentityService directory
pwsh -command "& {Import-Module Az}"