Improve mysql installation
authorSimon Hausmann <simon.hausmann@qt.io>
Mon, 8 May 2017 10:15:40 +0000 (12:15 +0200)
committerSimon Hausmann <simon.hausmann@qt.io>
Tue, 6 Jun 2017 20:15:09 +0000 (20:15 +0000)
* Instead of deleting the files from a previous installation, which will
  not actually release any disk space but just make the qcow2 file
  larger, let's just rename the directory the old files are in.
  That is a significantly faster operation.
* When extracting the zip archive, only extract what we need for Qt:
  Libraries, binaries and headers. We can skip the installation of
  several thousand documentation files for example, which takes a long
  time.
* Instead of downloading the zip archive via PowerShell's
  Invoke-WebRequest we can get the data much faster using CopyItem off
  the CIFS share. As a bonus this is also more robust against download
  failures.

Change-Id: I9128bd70e5f4a4ebcdbf046765e76b63bad033a5
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
coin/provisioning/qtci-windows-10-x86_64/mysql.ps1

index 5e75f66..6f2c86a 100644 (file)
 # Both x86 and x64 versions needed when x86 integrations are done on x64 machine
 
 $version = "5.6.11"
-$packagex64 = "C:\Windows\temp\mysql-$version-win64.zip"
+$packagex64 = "C:\Windows\temp\mysql-$version-winx64.zip"
 $packagex86 = "C:\Windows\temp\mysql-$version-win32.zip"
 
-function CheckAndRemovePreviousInstallation
-{
-    Param (
-        [string]$InstallFolder
-    )
-    echo "Check for previous installation..."
-    $FolderExists = Test-Path $ExistingInstallation
-    If ($FolderExists -eq $True) {
-        echo "Removing previous installation ($ExistingInstallation)"
-        Remove-Item $ExistingInstallation -recurse
-    }
-}
-
 function DownloadAndInstall
 {
     Param (
-        [string]$arch,
-        [string]$externalUrl,
         [string]$internalUrl,
         [string]$package,
-        [string]$sha1,
         [string]$installPath
     )
 
-   echo "Fetching from URL ..."
-   Download $externalUrl $internalUrl $package
-   Verify-Checksum $package $sha1
-   Extract-Zip $package $installPath
+    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)
+    }
+
+    Remove-Item $package
 }
 
+# Remove any leftovers
+try {
+    Rename-Item -ErrorAction 'Stop' c:\utils\my_sql c:\utils\mysql_deleted
+} catch {}
+
 # Install x64 bit version
 $architecture = "x64"
-$installFolder = "C:\Utils\my_sql"
-$existingInstallation = "$installFolder\my_sql"
-$internalUrl = "http://ci-files01-hki.ci.local/input/windows/mysql-$version-winx64"
-$sha1 = "f4811512b5f3c8ad877ee4feba2062312a0acc38"
-
-echo "Check and remove previous installation ..."
-CheckAndRemovePreviousInstallation $existingInstallation
-DownloadAndInstall $architecture $internalUrl $internalUrl $packagex64 $sha1 $installFolder
-Rename-Item -path $installFolder\mysql-$version-winx64 -newName $installFolder\my_sql
+$installFolder = "C:\Utils\my_sql\my_sql"
+$internalUrl = "\\ci-files01-hki.ci.local\provisioning\windows\mysql-$version-winx64.zip"
 
-echo "Remove downloaded package ..."
-Remove-Item $packagex64
+DownloadAndInstall $internalUrl $packagex64 $installFolder
 
 echo "Set environment variables ..."
 [Environment]::SetEnvironmentVariable("MYSQL_INCLUDE_x64", "$installFolder\my_sql\include", "Machine")
@@ -91,18 +89,10 @@ echo "Set environment variables ..."
 
 # Install x86 bit version
 $architecture = "x86"
-$installFolder = "C:\Utils\my_sql$architecture"
-$existingInstallation = "$installFolder\my_sql"
-$internalUrl = "http://ci-files01-hki.ci.local/input/windows/mysql-$version-win32"
-$sha1 = "e0aa62d5c5d6c6ec28906a831752d04336562679"
-
-echo "Check and remove previous installation ..."
-CheckAndRemovePreviousInstallation $existingInstallation
-DownloadAndInstall $architecture $internalUrl $internalUrl $packagex86 $sha1 $installFolder
-Rename-Item -path $installFolder\mysql-$version-win32 -newName $installFolder\my_sql
-
-echo "Remove downloaded package ..."
-Remove-Item $packagex86
+$installFolder = "C:\Utils\my_sql\my_sql$architecture"
+$internalUrl = "\\ci-files01-hki.ci.local\provisioning\windows\mysql-$version-win32.zip"
+
+DownloadAndInstall $internalUrl $packagex86 $installFolder
 
 echo "Set environment variables ..."
 [Environment]::SetEnvironmentVariable("MYSQL_INCLUDE_x86", "$installFolder\my_sql\include", "Machine")