cask "virtualbox" do arch arm: "macOSArm64", intel: "OSX" version "7.1.4,165100" sha256 arm: "296316b49cb8c8518c8790a23960821026452b7cdf3d81184e9a2cc0ab8a7b9e", intel: "f8b2b649ac8b438843eeb4df017a8d2bdaed128232fedecc2c2c03789ad45a57" url "https://download.virtualbox.org/virtualbox/#{version.csv.first}/VirtualBox-#{version.csv.first}-#{version.csv.second}-#{arch}.dmg" name "Oracle VirtualBox" desc "Virtualiser for x86 hardware" homepage "https://www.virtualbox.org/" livecheck do url "https://www.virtualbox.org/wiki/Downloads" regex(/href=.*?VirtualBox[._-]v?(\d+(?:\.\d+)+)[._-](\d+)[._-]OSX.dmg/i) strategy :page_match do |page, regex| match = page.match(regex) next if match.blank? "#{match[1]},#{match[2]}" end end conflicts_with cask: [ "virtualbox@6", "virtualbox@beta", ] depends_on macos: ">= :catalina" pkg "VirtualBox.pkg", choices: [ { "choiceIdentifier" => "choiceVBoxKEXTs", "choiceAttribute" => "selected", "attributeSetting" => 1, }, { "choiceIdentifier" => "choiceVBox", "choiceAttribute" => "selected", "attributeSetting" => 1, }, { "choiceIdentifier" => "choiceVBoxCLI", "choiceAttribute" => "selected", "attributeSetting" => 1, }, { "choiceIdentifier" => "choiceOSXFuseCore", "choiceAttribute" => "selected", "attributeSetting" => 0, }, ] postflight do # If VirtualBox is installed before `/usr/local/lib/pkgconfig` is created by Homebrew, it creates it itself # with incorrect permissions that break other packages # See https://github.com/Homebrew/homebrew-cask/issues/68730#issuecomment-534363026 set_ownership "/usr/local/lib/pkgconfig" end uninstall script: { executable: "VirtualBox_Uninstall.tool", args: ["--unattended"], sudo: true, }, pkgutil: "org.virtualbox.pkg.*", delete: "/usr/local/bin/vboximg-mount" zap trash: [ "/Library/Application Support/VirtualBox", "~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/org.virtualbox.app.virtualbox*", "~/Library/Preferences/org.virtualbox.app.VirtualBox*", "~/Library/Saved Application State/org.virtualbox.app.VirtualBox*", "~/Library/VirtualBox", ], rmdir: "~/VirtualBox VMs" end