mirror of
https://github.com/actions/runner-images.git
synced 2025-12-18 15:57:17 +00:00
Handle looking for installer log before exit
This commit is contained in:
@@ -70,46 +70,12 @@ if ((Get-ToolsetContent).postgresql.installVcRedist) {
|
|||||||
# Return the previous value of ErrorAction and invoke Install-Binary function
|
# Return the previous value of ErrorAction and invoke Install-Binary function
|
||||||
$ErrorActionPreference = $errorActionOldValue
|
$ErrorActionPreference = $errorActionOldValue
|
||||||
$installerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended")
|
$installerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended")
|
||||||
try {
|
|
||||||
Install-Binary `
|
|
||||||
-Url $installerUrl `
|
|
||||||
-InstallArgs $installerArgs `
|
|
||||||
-ExpectedSignature (Get-ToolsetContent).postgresql.signature
|
|
||||||
} catch {
|
|
||||||
# Recursively search for install-postgres.log
|
|
||||||
$installPostgresLog = Get-ChildItem -Path $env:TEMP -Recurse -Filter "install-postgresql.log" -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
||||||
|
|
||||||
if ($installPostgresLog) {
|
Install-Binary `
|
||||||
Write-Output "install-postgres.log found at: $($installPostgresLog.FullName)"
|
-Url $installerUrl `
|
||||||
Write-Output "Content of install-postgres.log:"
|
-InstallArgs $installerArgs `
|
||||||
Get-Content -Path $installPostgresLog.FullName | ForEach-Object { Write-Output $_ }
|
-ExpectedSignature (Get-ToolsetContent).postgresql.signature
|
||||||
} else {
|
-InstallerLogPath "$env:TEMP/**/postgresql-install.log"
|
||||||
Write-Output "install-postgres.log not found."
|
|
||||||
|
|
||||||
# Recursively search for bitrock_installer.log or bitrock_installer_*.log
|
|
||||||
$bitrockInstallerLogs = @(
|
|
||||||
Get-ChildItem -Path $tempPath -Recurse -Filter "bitrock_installer.log" -ErrorAction SilentlyContinue,
|
|
||||||
Get-ChildItem -Path $tempPath -Recurse -Filter "bitrock_installer_*.log" -ErrorAction SilentlyContinue
|
|
||||||
)
|
|
||||||
|
|
||||||
# Flatten the array to remove nested arrays
|
|
||||||
$bitrockInstallerLogs = $bitrockInstallerLogs | Where-Object { $_ }
|
|
||||||
|
|
||||||
foreach ($log in $bitrockInstallerLogs) {
|
|
||||||
if ($log) {
|
|
||||||
Write-Output "Found log file: $($log.FullName)"
|
|
||||||
Write-Output "Content of bitrock_install*.log:"
|
|
||||||
Get-Content -Path $log.FullName | ForEach-Object { Write-Output $_ }
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# If no log files were found
|
|
||||||
if (-not $log) {
|
|
||||||
Write-Warning "No relevant log files found in the temporary directory."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get Path to pg_ctl.exe
|
# Get Path to pg_ctl.exe
|
||||||
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
|
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ function Install-Binary {
|
|||||||
.PARAMETER ExpectedSHA512Sum
|
.PARAMETER ExpectedSHA512Sum
|
||||||
The expected SHA512 sum of the binary. If specified, the binary's SHA512 sum is checked before installation.
|
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
|
.EXAMPLE
|
||||||
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Type EXE -InstallArgs ("/features", "+", "/quiet") -ExpectedSignature "A5C7D5B7C838D5F89DDBEDB85B2C566B4CDA881F"
|
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Type EXE -InstallArgs ("/features", "+", "/quiet") -ExpectedSignature "A5C7D5B7C838D5F89DDBEDB85B2C566B4CDA881F"
|
||||||
#>
|
#>
|
||||||
@@ -46,7 +50,8 @@ function Install-Binary {
|
|||||||
[String[]] $ExtraInstallArgs,
|
[String[]] $ExtraInstallArgs,
|
||||||
[String[]] $ExpectedSignature,
|
[String[]] $ExpectedSignature,
|
||||||
[String] $ExpectedSHA256Sum,
|
[String] $ExpectedSHA256Sum,
|
||||||
[String] $ExpectedSHA512Sum
|
[String] $ExpectedSHA512Sum,
|
||||||
|
[String] $InstallerLogPath
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($PSCmdlet.ParameterSetName -eq "LocalPath") {
|
if ($PSCmdlet.ParameterSetName -eq "LocalPath") {
|
||||||
@@ -122,6 +127,14 @@ function Install-Binary {
|
|||||||
} else {
|
} else {
|
||||||
Write-Host "Installation process returned unexpected exit code: $exitCode"
|
Write-Host "Installation process returned unexpected exit code: $exitCode"
|
||||||
Write-Host "Time elapsed: $installCompleteTime seconds"
|
Write-Host "Time elapsed: $installCompleteTime seconds"
|
||||||
|
|
||||||
|
if ($InstallerLogPath -and (Test-Path -Path $InstallerLogPath)) {
|
||||||
|
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
|
exit $exitCode
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user