[macOS] Add virtualbox to macOS-12 (#5594)

* Add virtualbox to macOS-12

* Fix Get_OSVersion function as isBigSur didn't work

* Use proper comparison
This commit is contained in:
Mikhail Timofeev
2022-05-24 23:48:57 +04:00
committed by GitHub
parent 12cbf387ca
commit 7a7fafda99
9 changed files with 83 additions and 14 deletions

View File

@@ -28,17 +28,14 @@ function Get-EnvironmentVariable($variable) {
function Get-OSVersion {
$osVersion = [Environment]::OSVersion
$osVersionMajorMinor = $osVersion.Version.ToString(2)
# Monterey needs future review:
# [Environment]::OSVersion returns 11.0 for Monterey preview.
[SemVer]$osMontereyVersion = sw_vers -productVersion
return [PSCustomObject]@{
Version = $osVersion.Version
Platform = $osVersion.Platform
IsCatalina = $osVersionMajorMinor -eq "10.15"
IsBigSur = $osVersionMajorMinor -eq "11.0"
IsMonterey = $osMontereyVersion.Major -eq "12"
IsLessThanMonterey = $osMontereyVersion -lt "12.0"
IsHigherThanCatalina = [SemVer]$osVersion.Version -ge "11.0"
IsBigSur = $osVersion.Version.Major -eq "11"
IsMonterey = $osVersion.Version.Major -eq "12"
IsLessThanMonterey = $osVersion.Version.Major -lt "12"
IsHigherThanCatalina = $osVersion.Version.Major -ge "11"
}
}

View File

@@ -16,6 +16,12 @@ for package in $cask_packages; do
brew install --cask $package
done
# Execute AppleScript to change security preferences for virtualbox
# System Preferences -> Security & Privacy -> General -> Unlock -> Allow -> Not now
if is_Monterey; then
osascript $HOME/utils/confirm-identified-developers.scpt $USER_PASSWORD
fi
# Invoke bazel to download bazel version via bazelisk
bazel

View File

@@ -0,0 +1,53 @@
# This AppleScript confirms developers in security preferences via macOS UI.
# It uses after VirtualBox installation to add 'Oracle Inc' as identified developer.
# Steps:
# - Close security preferences pop-up (it can be open after VirtualBox installation)
# - Open System Preferences -> Security & Privacy -> General
# - Unlock security preferences with user password (button 'Click the lock to make changes')
# - Click 'Allow' or 'Details…' button to confirm developers
# - Click 'Not now' button on restarting pop-up
# - Close System Preferences
on run argv
set userpassword to item 1 of argv
set secpane to "Security & Privacy"
tell application "System Events"
tell security preferences
keystroke return
delay 5
end tell
end tell
activate application "System Preferences"
delay 5
tell application "System Events"
tell process "System Preferences"
click menu item secpane of menu "View" of menu bar 1
delay 5
click button 1 of window 1
delay 5
keystroke userpassword
delay 5
keystroke return
delay 5
click radio button "General" of tab group 1 of window 1
delay 5
if exists of UI element "Details…" of tab group 1 of window 1 then
click button "Details…" of tab group 1 of window 1
delay 5
keystroke return
delay 5
keystroke return
delay 5
end if
if exists of UI element "Allow" of tab group 1 of window 1 then
click button "Allow" of tab group 1 of window 1
delay 5
keystroke return
delay 5
end if
click button 5 of window 1
end tell
end tell
end run

View File

@@ -389,7 +389,7 @@ function Get-NewmanVersion {
function Get-VirtualBoxVersion {
$virtualBox = Run-Command "vboxmanage -v"
return "virtualbox $virtualBox"
return "VirtualBox $virtualBox"
}
function Get-VagrantVersion {

View File

@@ -141,12 +141,17 @@ if ($os.IsLessThanMonterey) {
if ($os.IsCatalina) {
$utilitiesList += @(
(Get-VirtualBoxVersion),
(Get-VagrantVersion),
(Get-ParallelVersion)
)
}
if (-not $os.IsBigSur) {
$utilitiesList += @(
(Get-VirtualBoxVersion)
)
}
$markdown += New-MDList -Style Unordered -Lines ($utilitiesList | Sort-Object)
# Tools

View File

@@ -152,10 +152,12 @@
"./provision/core/ruby.sh",
"./provision/core/rubygem.sh",
"./provision/core/git.sh",
"./provision/core/node.sh"
"./provision/core/node.sh",
"./provision/core/commonutils.sh"
],
"environment_vars": [
"API_PAT={{user `github_api_pat`}}"
"API_PAT={{user `github_api_pat`}}",
"USER_PASSWORD={{user `vm_password`}}"
]
},
{
@@ -177,7 +179,6 @@
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}",
"scripts": [
"./provision/core/commonutils.sh",
"./provision/core/llvm.sh",
"./provision/core/golang.sh",
"./provision/core/swiftlint.sh",

View File

@@ -144,7 +144,7 @@ Describe "vagrant" -Skip:($os.IsHigherThanCatalina) {
}
}
Describe "virtualbox" -Skip:($os.IsHigherThanCatalina) {
Describe "virtualbox" -Skip:($os.IsBigSur) {
It "virtualbox" {
"vboxmanage -v" | Should -ReturnZeroExitCode
}

View File

@@ -121,3 +121,9 @@ Describe "GraalVM" {
'$GRAALVM_11_ROOT/native-image --version' | Should -ReturnZeroExitCode
}
}
Describe "VirtualBox" -Skip:($os.IsBigSur) {
It "Check kext kernel modules" {
kextstat | Out-String | Should -Match "org.virtualbox.kext"
}
}

View File

@@ -149,7 +149,8 @@
"imagemagick"
],
"cask_packages": [
"julia"
"julia",
"virtualbox"
]
},
"gcc": {