Skip to content

Commit 53d0847

Browse files
[Anka] Exclude upgrade to Sonoma (#8551)
1 parent c138066 commit 53d0847

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

images.CI/macos/anka/CreateCleanAnkaTemplate.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function Invoke-SoftwareUpdate {
9090

9191
Write-Host "`t[*] Fetching Software Updates ready to install on '$TemplateName' VM:"
9292
Show-StringWithFormat $newUpdates
93-
$listOfNewUpdates = $($($newUpdates.Split("*")).Split("Title") | Where-Object {$_ -match "Label:"}).Replace("Label: ", '') | Where-Object {$_ -notmatch "macOS Sonoma"}
93+
$listOfNewUpdates = $($($newUpdates.Split("*")).Split("Title") | Where-Object {$_ -match "Label:"}).Replace("Label: ", '')
9494
Write-Host "`t[*] Installing Software Updates on '$TemplateName' VM:"
9595
Install-SoftwareUpdate -HostName $ipAddress -listOfUpdates $listOfNewUpdates -Password $Password | Show-StringWithFormat
9696

@@ -99,7 +99,7 @@ function Invoke-SoftwareUpdate {
9999
$listOfNewUpdates = $newUpdates.split('*').Trim('')
100100
foreach ($newupdate in $listOfNewUpdates) {
101101
# Will be True if the value is not Venture, not empty, and contains "Action: restart" words
102-
if ($newupdate.Contains("Action: restart") -and (!$newupdate.Contains("macOS Ventura") -or !$newupdate.Contains("macOS Sonoma")) -and (-not [String]::IsNullOrEmpty($newupdate))) {
102+
if ($newupdate.Contains("Action: restart") -and !$newupdate.Contains("macOS Ventura") -and !$newupdate.Contains("macOS Sonoma") -and (-not [String]::IsNullOrEmpty($newupdate))) {
103103
Write-Host "`t[*] Sleep 60 seconds before the software updates have been installed"
104104
Start-Sleep -Seconds 60
105105

images.CI/macos/anka/Service.Helpers.psm1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,25 @@ function Install-SoftwareUpdate {
244244
[array] $listOfUpdates,
245245
[string] $Password
246246
)
247-
$osVersion = [Environment]::OSVersion
248-
# If an update is happening on macOS 12 we will use the prepared list of updates, otherwise, we will install all updates.
249-
if ($osVersion.Version.Major -eq "12") {
247+
# If an update is happening on macOS 12 or 13 we will use the prepared list of updates, otherwise, we will install all updates.
248+
$command = "sw_vers"
249+
$guestMacosVersion = Invoke-SSHPassCommand -HostName $HostName -Command $command
250+
if ($guestMacosVersion[1] -match "12") {
250251
foreach ($update in $listOfUpdates){
251252
# Filtering updates that contain "Ventura" word
252253
if ($update -notmatch "Ventura") {
253254
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
254255
Invoke-SSHPassCommand -HostName $HostName -Command $command
255256
}
256257
}
258+
} elseif ($guestMacosVersion[1] -match "13") {
259+
foreach ($update in $listOfUpdates){
260+
# Filtering updates that contain "Sonoma" word
261+
if ($update -notmatch "Sonoma") {
262+
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
263+
Invoke-SSHPassCommand -HostName $HostName -Command $command
264+
}
265+
}
257266
} else {
258267
$osArch = $(arch)
259268
if ($osArch -eq "arm64") {

0 commit comments

Comments
 (0)