mirror of
https://github.com/actions/runner-images.git
synced 2025-12-10 19:16:48 +00:00
Fix macOS 13 arm64 software update part (#8772)
Co-authored-by: Alexey Ayupov <“alexey.ayupov@akvelon.com”>
This commit is contained in:
@@ -96,13 +96,20 @@ function Invoke-SoftwareUpdate {
|
||||
Install-SoftwareUpdate -HostName $ipAddress -listOfUpdates $listOfNewUpdates -Password $Password | Show-StringWithFormat
|
||||
|
||||
# Check if Action: restart
|
||||
# Define the next macOS version
|
||||
$command = "sw_vers"
|
||||
$guestMacosVersion = Invoke-SSHPassCommand -HostName $ipAddress -Command $command
|
||||
switch -regex ($guestMacosVersion[1]) {
|
||||
'12.\d' { $nextOSVersion = 'macOS Ventura' }
|
||||
'13.\d' { $nextOSVersion = 'macOS Sonoma' }
|
||||
}
|
||||
# Make an array of updates
|
||||
$listOfNewUpdates = $newUpdates.split('*').Trim('')
|
||||
foreach ($newupdate in $listOfNewUpdates) {
|
||||
# Will be True if the value is not Venture, not empty, and contains "Action: restart" words
|
||||
if ($newupdate.Contains("Action: restart") -and !$newupdate.Contains("macOS Ventura") -and !$newupdate.Contains("macOS Sonoma") -and (-not [String]::IsNullOrEmpty($newupdate))) {
|
||||
Write-Host "`t[*] Sleep 60 seconds before the software updates have been installed"
|
||||
Start-Sleep -Seconds 60
|
||||
if ($newupdate.Contains("Action: restart") -and !$newupdate.Contains("$nextOSVersion") -and (-not [String]::IsNullOrEmpty($newupdate))) {
|
||||
Write-Host "`t[*] Sleep 120 seconds before the software updates have been installed"
|
||||
Start-Sleep -Seconds 120
|
||||
|
||||
Write-Host "`t[*] Waiting for loginwindow process"
|
||||
Wait-LoginWindow -HostName $ipAddress | Show-StringWithFormat
|
||||
@@ -112,7 +119,7 @@ function Invoke-SoftwareUpdate {
|
||||
|
||||
# Check software updates have been installed
|
||||
$updates = Get-SoftwareUpdate -HostName $ipAddress
|
||||
if ($updates.Contains("Action: restart")) {
|
||||
if ($updates.Contains("Action: restart") -and !$updates.Contains("$nextOSVersion")) {
|
||||
Write-Host "`t[x] Software updates failed to install: "
|
||||
Show-StringWithFormat $updates
|
||||
exit 1
|
||||
@@ -123,6 +130,10 @@ function Invoke-SoftwareUpdate {
|
||||
Write-Host "`t[*] Show the install history:"
|
||||
$hUpdates = Get-SoftwareUpdateHistory -HostName $ipAddress
|
||||
Show-StringWithFormat $hUpdates
|
||||
|
||||
Write-Host "`t[*] The current macOS version:"
|
||||
$command = "sw_vers"
|
||||
Invoke-SSHPassCommand -HostName $ipAddress -Command $command | Show-StringWithFormat
|
||||
}
|
||||
|
||||
function Invoke-UpdateSettings {
|
||||
|
||||
@@ -28,14 +28,31 @@ function Invoke-SoftwareUpdateArm64 {
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $Password
|
||||
[string] $Password,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[array] $ListOfUpdates
|
||||
)
|
||||
|
||||
# Define the next macOS version
|
||||
$command = "sw_vers"
|
||||
$guestMacosVersion = Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
switch -regex ($guestMacosVersion[1]) {
|
||||
'13.\d' { $nextOSVersion = 'Sonoma' }
|
||||
'14.\d' { $nextOSVersion = 'NotYetDefined' }
|
||||
}
|
||||
|
||||
$url = "https://raw.githubusercontent.com/actions/runner-images/main/images/macos/provision/configuration/auto-software-update-arm64.exp"
|
||||
$script = Invoke-RestMethod -Uri $url
|
||||
$base64 = [Convert]::ToBase64String($script.ToCharArray())
|
||||
$command = "echo $base64 | base64 --decode > ./auto-software-update-arm64.exp;chmod +x ./auto-software-update-arm64.exp; ./auto-software-update-arm64.exp ${Password};rm ./auto-software-update-arm64.exp"
|
||||
Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
foreach ($update in $listOfUpdates) {
|
||||
if ($update -notmatch "$nextOSVersion") {
|
||||
$updatedScript = $script.Replace("MACOSUPDATE", $($($update.trim()).Replace(" ","\ ")))
|
||||
$base64 = [Convert]::ToBase64String($updatedScript.ToCharArray())
|
||||
$command = "echo $base64 | base64 --decode > ./auto-software-update-arm64.exp;chmod +x ./auto-software-update-arm64.exp; ./auto-software-update-arm64.exp ${Password};rm ./auto-software-update-arm64.exp"
|
||||
Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-AvailableVersions {
|
||||
@@ -261,17 +278,22 @@ function Install-SoftwareUpdate {
|
||||
}
|
||||
}
|
||||
} elseif ($guestMacosVersion[1] -match "13") {
|
||||
foreach ($update in $listOfUpdates) {
|
||||
# Filtering updates that contain "Sonoma" word
|
||||
if ($update -notmatch "Sonoma") {
|
||||
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
|
||||
Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
$osArch = $(arch)
|
||||
if ($osArch -eq "arm64") {
|
||||
Invoke-SoftwareUpdateArm64 -HostName $HostName -Password $Password -ListOfUpdates $listOfUpdates
|
||||
} else {
|
||||
foreach ($update in $listOfUpdates) {
|
||||
# Filtering updates that contain "Sonoma" word
|
||||
if ($update -notmatch "Sonoma") {
|
||||
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
|
||||
Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$osArch = $(arch)
|
||||
if ($osArch -eq "arm64") {
|
||||
Invoke-SoftwareUpdateArm64 -HostName $HostName -Password $Password
|
||||
Invoke-SoftwareUpdateArm64 -HostName $HostName -Password $Password -ListOfUpdates $listOfUpdates
|
||||
} else {
|
||||
$command = "sudo /usr/sbin/softwareupdate --all --install --restart --verbose"
|
||||
Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#! /usr/bin/expect -f
|
||||
|
||||
set timeout -1
|
||||
spawn sudo /usr/sbin/softwareupdate --all --install --restart --verbose
|
||||
spawn sudo /usr/sbin/softwareupdate --restart --verbose --install "MACOSUPDATE"
|
||||
expect "Password*"
|
||||
send "[lindex $argv 0]\r"
|
||||
expect eof
|
||||
|
||||
Reference in New Issue
Block a user