From 57cf70f7916880d77efea1f14345165c81a47844 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Tue, 7 Dec 2021 14:30:22 +0300 Subject: [PATCH] [Anka] Clear LastRecommendedMajorOSBundleIdentifier property (#4675) * clear LastRecommendedMajorOSBundleIdentifier property * remove property --- images.CI/macos/anka/Service.Helpers.psm1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/images.CI/macos/anka/Service.Helpers.psm1 b/images.CI/macos/anka/Service.Helpers.psm1 index 2c5ba9bdd..855b754fa 100644 --- a/images.CI/macos/anka/Service.Helpers.psm1 +++ b/images.CI/macos/anka/Service.Helpers.psm1 @@ -93,6 +93,10 @@ function Get-MacOSInstaller { sudo rm -rf "$previousInstallerPath" } + # Clear LastRecommendedMajorOSBundleIdentifier to prevent error during fetching updates + # Install failed with error: Update not found + Update-SoftwareBundle + # Download macOS installer Write-Host "`t[*] Requested macOS '$MacOSVersion' version installer found, fetching it from Apple Software Update" $result = Invoke-WithRetry { /usr/sbin/softwareupdate --fetch-full-installer --full-installer-version $MacOSVersion } {$LASTEXITCODE -eq 0} | Out-String @@ -324,3 +328,12 @@ function Wait-LoginWindow { } Invoke-WithRetry -RetryCount $RetryCount -Seconds $Seconds -BreakCondition $condition } + +function Update-SoftwareBundle { + $productVersion = sw_vers -productVersion + + if ( $productVersion.StartsWith('11.') ) { + sudo rm -rf /Library/Preferences/com.apple.commerce.plist + sudo /usr/bin/defaults delete /Library/Preferences/com.apple.SoftwareUpdate.plist LastRecommendedMajorOSBundleIdentifier | Out-Null + } +}