-
Notifications
You must be signed in to change notification settings - Fork 374
/
chocolateyInstall.ps1
66 lines (57 loc) · 3.4 KB
/
chocolateyInstall.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#https://www.virtualbox.org/manual/ch02.html#idm819
$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
. $toolsPath\helpers.ps1
$cert = Get-ChildItem Cert:\CurrentUser\TrustedPublisher -Recurse | Where-Object { $_.Thumbprint -eq 'a88fd9bdaa06bc0f3c491ba51e231be35f8d1ad5' }
if (!$cert) {
$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
Start-ChocolateyProcessAsAdmin "certutil -addstore 'TrustedPublisher' '$toolsPath\oracle.cer'"
}
$pp = Get-PackageParameters
$silentArgs = @('-s -l -msiparams REBOOT=ReallySuppress')
$silentArgs += if (!$pp.CurrentUser) { 'ALLUSERS=1' } else { 'ALLUSERS=2'; Write-Host 'Param: Installing for current user' }
$silentArgs += if ($pp.NoDesktopShortcut) { 'VBOX_INSTALLDESKTOPSHORTCUT=0'; Write-Host 'Param: No desktop shortcut' }
$silentArgs += if ($pp.NoQuickLaunch) { 'VBOX_INSTALLQUICKLAUNCHSHORTCUT=0'; Write-Host 'Param: No quick launch shortcut' }
$silentArgs += if ($pp.NoRegister) { 'VBOX_REGISTERFILEEXTENSIONS=0'; Write-Host 'Param: No registration for virtualbox file extensions' }
$packageArgs = @{
packageName = 'virtualbox'
fileType = 'EXE'
url = 'https://download.virtualbox.org/virtualbox/7.0.0/VirtualBox-7.0.0-153978-Win.exe'
url64bit = 'https://download.virtualbox.org/virtualbox/7.0.0/VirtualBox-7.0.0-153978-Win.exe'
checksum = 'cc686543c9c386ff964ef84a5d23135e9bde2fe7efecd116d72e53f9749e0068'
checksum64 = 'cc686543c9c386ff964ef84a5d23135e9bde2fe7efecd116d72e53f9749e0068'
checksumType = 'sha256'
checksumType64 = 'sha256'
silentArgs = $silentArgs
validExitCodes = @(0)
softwareName = 'Oracle VM VirtualBox *'
}
Install-ChocolateyPackage @packageArgs
$packageName = $packageArgs.packageName
$installLocation = Get-VirtualBoxIntallLocation
if (!$installLocation) { Write-Warning "Can't find $packageName install location, can't install extension pack"; return }
if ($pp.ExtensionPack) {
Write-Host "Installing extension pack"
Write-Warning "*** THIS IS A COMMERCIAL EXTENSION AND CAN INCURE SIGNIFICANT FINANCIAL COSTS ***"
$url_ep = 'https://download.virtualbox.org/virtualbox/7.0.0/Oracle_VM_VirtualBox_Extension_Pack-7.0.0.vbox-extpack'
$checksum_ep = 'e32555a2d2482c1e1126747f967742364ddfdfd49fce3107a9627780f373ffd7'
$file_path_ep = (Get-PackageCacheLocation) + '\' + ($url_ep -split '/' | Select-Object -Last 1)
Get-ChocolateyWebFile `
-PackageName 'virtualbox-extensionpack' `
-FileFullPath $file_path_ep `
-Url $url_ep `
-Url64bit $url_ep `
-Checksum $checksum_ep `
-Checksum64 $checksum_ep `
-ChecksumType 'sha256' `
-ChecksumType64 'sha256'
if (!(Test-Path $file_path_ep)) { Write-Warning "Can't download latest extension pack" }
else {
Set-Alias vboxmanage $installLocation\VBoxManage.exe
"y" | vboxmanage extpack install --replace $file_path_ep 2>&1
if ($LastExitCode -ne 0) { Write-Warning "Extension pack installation failed with exit code $LastExitCode" }
}
}
if (!$pp.NoPath) { Write-Host "Adding to PATH if needed"; Install-ChocolateyPath $installLocation }
Write-Host "$packageName installed to '$installLocation'"
Register-Application "$installLocation\$packageName.exe" vbox
Write-Host "$packageName registered as vbox"