Add support for PostgreSQL 18 on Windows: new winget input manifest and per-machine installer/uninstaller PowerShell scripts; outputs metadata for version 18.4-1 (installer URL, sha256, and script refs) and app registration in apps.json. Also add frontend icon component and 60x60 image asset, and update icons index to include the new icon. This enables silent install/uninstall via the EnterpriseDB (BitRock) installer and exposes the app in the software listing.
73 lines
2.2 KiB
PowerShell
73 lines
2.2 KiB
PowerShell
$displayNameLike = "PostgreSQL 18*"
|
|
$publisher = "PostgreSQL Global Development Group"
|
|
|
|
$paths = @(
|
|
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
|
|
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall',
|
|
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
|
|
'HKCU:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
|
|
)
|
|
|
|
$uninstall = $null
|
|
foreach ($p in $paths) {
|
|
$items = Get-ItemProperty "$p\*" -ErrorAction SilentlyContinue | Where-Object {
|
|
$_.DisplayName -like $displayNameLike -and $_.Publisher -like "$publisher*"
|
|
}
|
|
if ($items) { $uninstall = $items | Select-Object -First 1; break }
|
|
}
|
|
|
|
if (-not $uninstall -or (-not $uninstall.UninstallString -and -not $uninstall.QuietUninstallString)) {
|
|
Write-Host "Uninstall entry not found"
|
|
Exit 0
|
|
}
|
|
|
|
$uninstallCommand = if ($uninstall.QuietUninstallString) {
|
|
$uninstall.QuietUninstallString
|
|
} else {
|
|
$uninstall.UninstallString
|
|
}
|
|
|
|
# Registry uninstall strings come in three shapes; parse defensively. The EDB
|
|
# uninstaller (uninstall-postgresql.exe) lives under a path with spaces
|
|
# ("C:\Program Files\PostgreSQL\18\...") and is typically quoted.
|
|
$exePath = ""
|
|
$existingArgs = ""
|
|
if ($uninstallCommand -match '^\s*"([^"]+)"\s*(.*)$') {
|
|
$exePath = $matches[1]
|
|
$existingArgs = $matches[2].Trim()
|
|
} elseif ($uninstallCommand -match '(?i)^\s*(.+?\.exe)\s*(.*)$') {
|
|
$exePath = $matches[1]
|
|
$existingArgs = $matches[2].Trim()
|
|
} elseif ($uninstallCommand -match '^\s*(\S+)\s*(.*)$') {
|
|
$exePath = $matches[1]
|
|
$existingArgs = $matches[2].Trim()
|
|
} else {
|
|
Throw "Could not parse uninstall string: $uninstallCommand"
|
|
}
|
|
|
|
# BitRock uninstaller silent switch.
|
|
if ($existingArgs -notmatch '(?i)--mode\s+unattended') {
|
|
$existingArgs = ("$existingArgs --mode unattended").Trim()
|
|
}
|
|
|
|
Write-Host "Uninstall command: $exePath"
|
|
Write-Host "Uninstall args: $existingArgs"
|
|
|
|
try {
|
|
$processOptions = @{
|
|
FilePath = $exePath
|
|
ArgumentList = $existingArgs
|
|
NoNewWindow = $true
|
|
PassThru = $true
|
|
Wait = $true
|
|
}
|
|
|
|
$process = Start-Process @processOptions
|
|
$exitCode = $process.ExitCode
|
|
Write-Host "Uninstall exit code: $exitCode"
|
|
Exit $exitCode
|
|
} catch {
|
|
Write-Host "Error running uninstaller: $_"
|
|
Exit 1
|
|
}
|