Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Unpin Postgres allowing latest v14 version #11047

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions images/windows/scripts/build/Install-PostgreSQL.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,24 @@ if ($null -ne ($toolsetVersion | Select-String -Pattern '\d+\.\d+\.\d+')) {
} while (!$response)
}

if ((Get-ToolsetContent).postgresql.installVcRedist) {
# Postgres 14 requires the vs 17 redistributable
$vs17RedistUrl = "https://aka.ms/vs/17/release/vc_redist.x64.exe"
Install-Binary `
-Url $vs17RedistUrl `
-InstallArgs @("/install", "/quiet", "/norestart") `
-ExpectedSignature (Get-ToolsetContent).postgresql.vcRedistSignature
}

# Return the previous value of ErrorAction and invoke Install-Binary function
$ErrorActionPreference = $errorActionOldValue
$installerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended")

Install-Binary `
-Url $installerUrl `
-InstallArgs $installerArgs `
-ExpectedSignature (Get-ToolsetContent).postgresql.signature
-InstallerLogPath "$env:TEMP/**/postgresql-install.log"
lawrencegripper marked this conversation as resolved.
Show resolved Hide resolved

# Get Path to pg_ctl.exe
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
Expand Down
15 changes: 14 additions & 1 deletion images/windows/scripts/helpers/InstallHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ function Install-Binary {
.PARAMETER ExpectedSHA512Sum
The expected SHA512 sum of the binary. If specified, the binary's SHA512 sum is checked before installation.

.PARAMETER InstallerLogPath
The path to the log file which is produced when the installation fails. This can be used for debugging purposes.
This is only displayed when the installation fails.

.EXAMPLE
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Type EXE -InstallArgs ("/features", "+", "/quiet") -ExpectedSignature "A5C7D5B7C838D5F89DDBEDB85B2C566B4CDA881F"
#>
Expand All @@ -46,7 +50,8 @@ function Install-Binary {
[String[]] $ExtraInstallArgs,
[String[]] $ExpectedSignature,
[String] $ExpectedSHA256Sum,
[String] $ExpectedSHA512Sum
[String] $ExpectedSHA512Sum,
[String] $InstallerLogPath
)

if ($PSCmdlet.ParameterSetName -eq "LocalPath") {
Expand Down Expand Up @@ -122,6 +127,14 @@ function Install-Binary {
} else {
Write-Host "Installation process returned unexpected exit code: $exitCode"
Write-Host "Time elapsed: $installCompleteTime seconds"

if ($InstallerLogPath -and (Test-Path -Path $InstallerLogPath)) {
lawrencegripper marked this conversation as resolved.
Show resolved Hide resolved
Write-Host "Searching for logs maching $InstallerLogPath pattern"
Get-ChildItem -Path $InstallerLogPath | ForEach-Object {
Write-Output "Found Installer Log: $InstallerLogPath"
Get-Content -Path $InstallerLogPath
}
}
exit $exitCode
}
} catch {
Expand Down
2 changes: 1 addition & 1 deletion images/windows/templates/windows-2022.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ build {
provisioner "powershell" {
environment_vars = ["IMAGE_FOLDER=${var.image_folder}", "TEMP_DIR=${var.temp_dir}"]
scripts = [
"${path.root}/../scripts/build/Install-PostgreSQL.ps1",
"${path.root}/../scripts/build/Install-ActionsCache.ps1",
"${path.root}/../scripts/build/Install-Ruby.ps1",
"${path.root}/../scripts/build/Install-PyPy.ps1",
Expand Down Expand Up @@ -380,7 +381,6 @@ build {
"${path.root}/../scripts/build/Install-Zstd.ps1",
"${path.root}/../scripts/build/Install-NSIS.ps1",
"${path.root}/../scripts/build/Install-Vcpkg.ps1",
"${path.root}/../scripts/build/Install-PostgreSQL.ps1",
"${path.root}/../scripts/build/Install-Bazel.ps1",
"${path.root}/../scripts/build/Install-AliyunCli.ps1",
"${path.root}/../scripts/build/Install-RootCA.ps1",
Expand Down
6 changes: 4 additions & 2 deletions images/windows/toolsets/toolset-2019.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,10 @@
"version": "18"
},
"postgresql": {
"version": "14.12.1",
"signature": "698BA51AA27CC31282AACA5055E4B9190BC6C0E9"
"signature": "698BA51AA27CC31282AACA5055E4B9190BC6C0E9",
"version": "14",
"vcRedistSignature": "245D262748012A4FE6CE8BA6C951A4C4AFBC3E5D",
"installVcRedist": true
},
"kotlin": {
"version": "latest"
Expand Down
6 changes: 4 additions & 2 deletions images/windows/toolsets/toolset-2022.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,10 @@
"version": "8.3"
},
"postgresql": {
"version": "14.12.1",
"signature": "698BA51AA27CC31282AACA5055E4B9190BC6C0E9"
"signature": "698BA51AA27CC31282AACA5055E4B9190BC6C0E9",
"version": "14",
"vcRedistSignature": "245D262748012A4FE6CE8BA6C951A4C4AFBC3E5D",
"installVcRedist": true
},
"kotlin": {
"version": "latest"
Expand Down