mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-17 15:28:16 +00:00
[macos] use mist-cli for downloading OS distribution when generating anka clean vm (#8141)
This commit is contained in:
@@ -180,7 +180,7 @@ Remove-AnkaVM -VMName $TemplateName
|
|||||||
|
|
||||||
Write-Host "`t[*] Creating Anka VM template with name '$TemplateName' and '$TemplateUsername' user"
|
Write-Host "`t[*] Creating Anka VM template with name '$TemplateName' and '$TemplateUsername' user"
|
||||||
Write-Host "`t[*] CPU Count: $CPUCount, RamSize: ${RamSizeGb}G, DiskSizeGb: ${DiskSizeGb}G, InstallerPath: $macOSInstaller, TemplateName: $TemplateName"
|
Write-Host "`t[*] CPU Count: $CPUCount, RamSize: ${RamSizeGb}G, DiskSizeGb: ${DiskSizeGb}G, InstallerPath: $macOSInstaller, TemplateName: $TemplateName"
|
||||||
New-AnkaVMTemplate -InstallerPath $macOSInstaller `
|
New-AnkaVMTemplate -InstallerPath "$macOSInstaller" `
|
||||||
-TemplateName $TemplateName `
|
-TemplateName $TemplateName `
|
||||||
-TemplateUsername $TemplateUsername `
|
-TemplateUsername $TemplateUsername `
|
||||||
-TemplatePassword $TemplatePassword `
|
-TemplatePassword $TemplatePassword `
|
||||||
|
|||||||
@@ -180,26 +180,19 @@ function Get-MacOSInstaller {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$installerPathPattern = "/Applications/Install macOS ${macOSName}*.app"
|
|
||||||
if (Test-Path $installerPathPattern) {
|
|
||||||
$previousInstallerPath = Get-Item -Path $installerPathPattern
|
|
||||||
Write-Host "`t[*] Removing '$previousInstallerPath' installation app before downloading the new one"
|
|
||||||
sudo rm -rf "$previousInstallerPath"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Clear LastRecommendedMajorOSBundleIdentifier to prevent error during fetching updates
|
# Clear LastRecommendedMajorOSBundleIdentifier to prevent error during fetching updates
|
||||||
# Install failed with error: Update not found
|
# Install failed with error: Update not found
|
||||||
Update-SoftwareBundle
|
Update-SoftwareBundle
|
||||||
|
|
||||||
# Download macOS installer
|
# Download macOS installer
|
||||||
Write-Host "`t[*] Requested macOS '$MacOSVersion' version installer found, fetching it from Apple Software Update"
|
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
|
Invoke-WithRetry -Command { sudo /usr/local/bin/mist download installer $MacOSVersion application --force --export installer.json --output-directory /Applications } -BreakCondition { $LASTEXITCODE -eq 0 } | Out-Null
|
||||||
if (-not $result.Contains("Install finished successfully")) {
|
if (-not(Test-Path installer.json -PathType leaf)) {
|
||||||
Write-Host "`t[x] Failed to fetch $MacOSVersion macOS `n$result"
|
Write-Host "`t[x] Failed to fetch $MacOSVersion macOS"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$installerPath = (Get-Item -Path $installerPathPattern).FullName
|
$installerPath = (Get-Content installer.json | Out-String | ConvertFrom-Json).options.applicationPath
|
||||||
if (-not $installerPath) {
|
if (-not $installerPath) {
|
||||||
Write-Host "`t[x] Path not found using '$installerPathPattern'"
|
Write-Host "`t[x] Path not found using '$installerPathPattern'"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user