diff --git a/images/macos/provision/core/commonutils.sh b/images/macos/provision/core/commonutils.sh index 550e1abe0832..bb4c2873520a 100644 --- a/images/macos/provision/core/commonutils.sh +++ b/images/macos/provision/core/commonutils.sh @@ -13,6 +13,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_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" diff --git a/images/macos/provision/utils/confirm-identified-developers.scpt b/images/macos/provision/utils/confirm-identified-developers.scpt new file mode 100644 index 000000000000..9c293cae3dba --- /dev/null +++ b/images/macos/provision/utils/confirm-identified-developers.scpt @@ -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 \ No newline at end of file diff --git a/images/macos/software-report/SoftwareReport.Common.psm1 b/images/macos/software-report/SoftwareReport.Common.psm1 index 240efc0cf9aa..bc6493ec4dc2 100644 --- a/images/macos/software-report/SoftwareReport.Common.psm1 +++ b/images/macos/software-report/SoftwareReport.Common.psm1 @@ -394,7 +394,7 @@ function Get-NewmanVersion { function Get-VirtualBoxVersion { $virtualBox = Run-Command "vboxmanage -v" - return "virtualbox $virtualBox" + return "VirtualBox $virtualBox" } function Get-VagrantVersion { diff --git a/images/macos/software-report/SoftwareReport.Generator.ps1 b/images/macos/software-report/SoftwareReport.Generator.ps1 index c4b82d9f70db..534bf0c5ca02 100644 --- a/images/macos/software-report/SoftwareReport.Generator.ps1 +++ b/images/macos/software-report/SoftwareReport.Generator.ps1 @@ -129,7 +129,8 @@ $utilitiesList = @( (Get-MongodVersion), (Get-7zipVersion), (Get-BsdtarVersion), - (Get-GnuTarVersion) + (Get-GnuTarVersion), + (Get-VirtualBoxVersion) ) if ($os.IsHigherThanMojave) { @@ -140,7 +141,6 @@ if ($os.IsHigherThanMojave) { if ($os.IsLessThanBigSur) { $utilitiesList += @( - (Get-VirtualBoxVersion), (Get-VagrantVersion), (Get-ParallelVersion) ) diff --git a/images/macos/templates/macOS-11.json b/images/macos/templates/macOS-11.json index cf8bcbc9812d..6e3480c435f7 100644 --- a/images/macos/templates/macOS-11.json +++ b/images/macos/templates/macOS-11.json @@ -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`}}" ] }, { @@ -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", diff --git a/images/macos/tests/BasicTools.Tests.ps1 b/images/macos/tests/BasicTools.Tests.ps1 index e5248800c938..a57c723b3056 100644 --- a/images/macos/tests/BasicTools.Tests.ps1 +++ b/images/macos/tests/BasicTools.Tests.ps1 @@ -144,8 +144,8 @@ Describe "vagrant" -Skip:($os.IsBigSur) { } } -Describe "virtualbox" -Skip:($os.IsBigSur) { - It "virtualbox" { +Describe "VirtualBox" { + It "vboxmanage" { "vboxmanage -v" | Should -ReturnZeroExitCode } } diff --git a/images/macos/tests/Common.Tests.ps1 b/images/macos/tests/Common.Tests.ps1 index 0c2366a1b7f9..7b9a3b7608ca 100644 --- a/images/macos/tests/Common.Tests.ps1 +++ b/images/macos/tests/Common.Tests.ps1 @@ -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" + } } \ No newline at end of file diff --git a/images/macos/toolsets/toolset-11.json b/images/macos/toolsets/toolset-11.json index 0b45dd16c818..9790588697b5 100644 --- a/images/macos/toolsets/toolset-11.json +++ b/images/macos/toolsets/toolset-11.json @@ -155,7 +155,8 @@ "zstd" ], "cask_packages": [ - "julia" + "julia", + "virtualbox" ] }, "gcc": {