Improve Postgresql installation on Windows

Similar to the mysql change (parent commit) it's faster to rename any
older artifacts and install only what we need. This also generalizes the
zip archive extraction code for "dev" packages.

Change-Id: I3ad1f23efaed80fab3e0778a3e8c46317138f1ad
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
Simon Hausmann
2017-05-08 14:28:56 +02:00
parent 982659b081
commit ce47238ed9
3 changed files with 44 additions and 23 deletions

View File

@@ -30,6 +30,32 @@ function Extract-Zip
$destinationFolder.CopyHere($zipfile.Items(), 16)
}
function Extract-Dev-Folders-From-Zip
{
Param (
[string]$package,
[string]$zipDir,
[string]$installPath
)
$shell = new-object -com shell.application
echo "Extracting contents of $package"
foreach ($subDir in "lib", "include", "bin", "share") {
$zip = $shell.Namespace($package + "\" + $zipDir + "\" + $subDir)
if ($zip) {
Write-Host "Extracting $subDir from zip archive"
} else {
Write-Host "$subDir is missing from zip archive - skipping"
continue
}
$destDir = $installPath + "\" + $subdir
New-Item $destDir -type directory
$destinationFolder = $shell.Namespace($destDir)
$destinationFolder.CopyHere($zip.Items(), 16)
}
}
function BadParam
{
Param ([string]$Description)
@@ -44,7 +70,11 @@ function Download
[string] $Destination = $(BadParam("a download target location"))
)
try {
Invoke-WebRequest -UseBasicParsing $CachedUrl -OutFile $Destination
if ($CachedUrl.StartsWith("http")) {
Invoke-WebRequest -UseBasicParsing $CachedUrl -OutFile $Destination
} else {
Copy-Item $CachedUrl $Destination
}
} catch {
Invoke-WebRequest -UseBasicParsing $OfficialUrl -OutFile $Destination
}

View File

@@ -51,22 +51,8 @@ function DownloadAndInstall
echo "Fetching from URL ..."
Copy-Item $internalUrl $package
$shell = new-object -com shell.application
echo "Extracting contents"
foreach ($subDir in "lib", "include", "bin") {
$zipDir = $shell.Namespace($package + "\" + [io.path]::GetFileNameWithoutExtension($package) + "\" + $subDir)
if ($zipDir) {
Write-Host "Extracting $subDir from zip archive"
} else {
Write-Host "$subDir is missing from zip archive - skipping"
continue
}
$destDir = $installPath + "\" + $subdir
New-Item $destDir -type directory
$destinationFolder = $shell.Namespace($destDir)
$destinationFolder.CopyHere($zipDir.Items(), 16)
}
$zipDir = [io.path]::GetFileNameWithoutExtension($package)
Extract-Dev-Folders-From-Zip $package $zipDir $installPath
Remove-Item $package
}

View File

@@ -42,16 +42,21 @@ $packagex86 = "C:\Windows\temp\postgresql-$version-windows-binaries.zip"
# Install x64 bit versions
$architecture = "x64"
$installFolder = "C:\Utils\postgresql"
$installFolder = "C:\Utils\postgresql\pgsql"
$externalUrl = "http://get.enterprisedb.com/postgresql/postgresql-$version-windows-x64-binaries.zip"
$internalUrl = "http://ci-files01-hki.ci.local/input/windows/postgresql-$version-windows-x64-binaries.zip"
$internalUrl = "\\ci-files01-hki.ci.local\provisioning\windows\postgresql-$version-windows-x64-binaries.zip"
$sha1 = "4da0453cdfda335e064d4437cf5bb9d356054cfd"
# Delete any leftovers
try {
Rename-Item -ErrorAction 'Stop' c:\utils\postgresql c:\utils\postgresql-deleted
} catch {}
echo "Fetching from URL ..."
Download $externalUrl $internalUrl $packagex64
Verify-Checksum $packagex64 $sha1
echo "Installing $packagex64 ..."
Extract-Zip $packagex64 $installFolder
Extract-Dev-Folders-From-Zip $packagex64 "pgsql" $installFolder
echo "Remove downloaded $packagex64 ..."
Remove-Item $packagex64
@@ -62,16 +67,16 @@ echo "Set $architecture environment variables ..."
# Install x86 bit version
$architecture = "x86"
$installFolder = "C:\Utils\postgresql$architecture"
$installFolder = "C:\Utils\postgresql$architecture\pgsql"
$externalUrl = "http://get.enterprisedb.com/postgresql/postgresql-$version-windows-binaries.zip"
$internalUrl = "http://ci-files01-hki.ci.local/input/windows/postgresql-$version-windows-binaries.zip"
$internalUrl = "\\ci-files01-hki.ci.local\provisioning\windows\postgresql-$version-windows-binaries.zip"
$sha1 = "eb4f01845e1592800edbb74f60944b6c0aca51a9"
echo "Fetching from URL..."
Download $externalUrl $internalUrl $packagex86
Verify-Checksum $packagex86 $sha1
echo "Installing $packagex86 ..."
Extract-Zip $packagex86 $installFolder
Extract-Dev-Folders-From-Zip $packagex86 "pgsql" $installFolder
echo "Remove downloaded $packagex86 ..."
Remove-Item $packagex86