/
chocolateyInstall.ps1
55 lines (49 loc) · 2.23 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
$ErrorActionPreference = 'Stop'
$toolsPath = Split-Path -parent $MyInvocation.MyCommand.Definition
$packageArgs = @{
packageName = $env:ChocolateyPackageName
fileType = 'msi'
url = 'https://inkscape.org/gallery/item/37365/inkscape-1.2.2_2022-12-09_732a01da63-x86.msi'
checksum = '5CD4A9C448246BA56DD7EB846FB9484D5188D13A8DB913D07DC1844A8C2C1436'
checksumType = 'sha256'
file64 = "$toolsPath\inkscape-1.2.2_2022-12-09_732a01da63-x64.msi"
softwareName = 'InkScape*'
silentArgs = "/qn /norestart /l*v `"$($env:TEMP)\$($env:chocolateyPackageName).$($env:chocolateyPackageVersion).MsiInstall.log`""
validExitCodes = @(0)
}
[array]$key = Get-UninstallRegistrykey $packageArgs['softwareName']
if ($key.Count -eq 1) {
if ($key[0].DisplayVersion -eq '1.2.2') {
Write-Host "Software already installed"
return
}
else {
# We need to do it this way, as PSChildName isn't available in POSHv2
$msiId = $key[0].UninstallString -replace '^.*MsiExec\.exe\s*\/I', ''
Uninstall-ChocolateyPackage -packageName $packageArgs['packageName'] `
-fileType $packageArgs['fileType'] `
-silentArgs "$msiId $($packageArgs['silentArgs'] -replace 'MsiInstall','MsiUninstall')" `
-validExitCodes $packageArgs['validExitCodes'] `
-file ''
}
}
elseif ($key.Count -gt 1) {
Write-Warning "$($key.Count) matches found!"
Write-Warning "To prevent accidental data loss, no programs will be uninstalled."
Write-Warning "This will most likely cause a 1603/1638 failure when installing InkScape."
Write-Warning "Please uninstall InkScape before installing this package."
}
if ((Get-OSArchitectureWidth 32) -or ($env:chocolateyForceX86 -eq $true)) {
Install-ChocolateyPackage @packageArgs
}
else {
Install-ChocolateyInstallPackage @packageArgs
}
Get-ChildItem $toolsPath\*.msi | ForEach-Object { Remove-Item $_ -ea 0; if (Test-Path $_) { Set-Content "$_.ignore" } }
$packageName = $packageArgs.packageName
$installLocation = Get-AppInstallLocation $packageArgs['softwareName']
if ($installLocation) {
Install-BinFile 'inkscape' $installLocation\bin\inkscape.exe
Write-Host "$packageName installed to '$installLocation'"
}
else { Write-Warning "Can't find $PackageName install location" }