Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Install virtualbox on macOS-11 #4010

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions images/macos/provision/core/commonutils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ for package in $cask_packages; do
brew install --cask $package
done

# Execute AppleScript to change security preferences for virtualbox
vsafonkin marked this conversation as resolved.
Show resolved Hide resolved
# System Preferences -> Security & Privacy -> General -> Unlock -> Allow -> Not now
if is_BigSur; then
osascript $HOME/utils/confirm-identified-developers.scpt $USER_PASSWORD
fi

# Specify Bazel version 3.7.1 to install due to the bug with 4.0.0: https://github.com/bazelbuild/bazel/pull/12882
if is_Less_Catalina; then
export USE_BAZEL_VERSION="3.7.1"
Expand Down
53 changes: 53 additions & 0 deletions images/macos/provision/utils/confirm-identified-developers.scpt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion images/macos/software-report/SoftwareReport.Common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ function Get-NewmanVersion {

function Get-VirtualBoxVersion {
$virtualBox = Run-Command "vboxmanage -v"
return "virtualbox $virtualBox"
return "VirtualBox $virtualBox"
}

function Get-VagrantVersion {
Expand Down
4 changes: 2 additions & 2 deletions images/macos/software-report/SoftwareReport.Generator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ $utilitiesList = @(
(Get-MongodVersion),
(Get-7zipVersion),
(Get-BsdtarVersion),
(Get-GnuTarVersion)
(Get-GnuTarVersion),
(Get-VirtualBoxVersion)
)

if ($os.IsHigherThanMojave) {
Expand All @@ -140,7 +141,6 @@ if ($os.IsHigherThanMojave) {

if ($os.IsLessThanBigSur) {
$utilitiesList += @(
(Get-VirtualBoxVersion),
(Get-VagrantVersion),
(Get-ParallelVersion)
)
Expand Down
7 changes: 5 additions & 2 deletions images/macos/templates/macOS-11.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@
"./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": [
"USER_PASSWORD={{user `vm_password`}}"
]
},
{
Expand All @@ -164,7 +168,6 @@
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}",
"scripts": [
"./provision/core/commonutils.sh",
"./provision/core/swiftlint.sh",
"./provision/core/openjdk.sh",
"./provision/core/php.sh",
Expand Down
4 changes: 2 additions & 2 deletions images/macos/tests/BasicTools.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ Describe "vagrant" -Skip:($os.IsBigSur) {
}
}

Describe "virtualbox" -Skip:($os.IsBigSur) {
It "virtualbox" {
Describe "VirtualBox" {
It "vboxmanage" {
"vboxmanage -v" | Should -ReturnZeroExitCode
}
}
Expand Down
6 changes: 6 additions & 0 deletions images/macos/tests/Common.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@ Describe "Bicep" {
It "Bicep" {
"bicep --version" | Should -ReturnZeroExitCode
}
}

Describe "VirtualBox" {
It "Check kext kernel modules" {
kextstat | Out-String | Should -Match "org.virtualbox.kext"
}
}
3 changes: 2 additions & 1 deletion images/macos/toolsets/toolset-11.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@
"zstd"
],
"cask_packages": [
"julia"
"julia",
"virtualbox"
]
},
"gcc": {
Expand Down