Commit 443df2dffd9d6973a6d7219f1de75c66453ffbdb

Patrick Steinhardt 2019-06-24T16:27:00

azure: replace mingw setup with bash We're about to phase out our Powershell scripts as Azure Pipelines does in fact support Bash scripts on all platforms. As a preparatory step, let's replace our MinGW setup script with a Bash script.

diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 7f491e0..98e8097 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -91,7 +91,7 @@ jobs:
   displayName: 'Windows (amd64; MinGW)'
   pool: Hosted
   steps:
-  - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1'
+  - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
     displayName: Setup
     env:
       TEMP: $(Agent.TempDirectory)
@@ -106,7 +106,7 @@ jobs:
   displayName: 'Windows (x86; MinGW)'
   pool: Hosted
   steps:
-  - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1'
+  - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
     displayName: Setup
     workingDirectory: '$(Build.BinariesDirectory)'
     env:
diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml
index 78e93f6..c494037 100644
--- a/azure-pipelines/nightly.yml
+++ b/azure-pipelines/nightly.yml
@@ -94,7 +94,7 @@ jobs:
   displayName: 'Windows (amd64; MinGW)'
   pool: Hosted
   steps:
-  - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1'
+  - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
     displayName: Setup
     env:
       TEMP: $(Agent.TempDirectory)
@@ -110,7 +110,7 @@ jobs:
   displayName: 'Windows (x86; MinGW)'
   pool: Hosted
   steps:
-  - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1'
+  - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
     displayName: Setup
     workingDirectory: '$(Build.BinariesDirectory)'
     env:
diff --git a/azure-pipelines/setup-mingw.ps1 b/azure-pipelines/setup-mingw.ps1
deleted file mode 100644
index 76ecd39..0000000
--- a/azure-pipelines/setup-mingw.ps1
+++ /dev/null
@@ -1,25 +0,0 @@
-Set-StrictMode -Version Latest
-
-$ErrorActionPreference = "Stop"
-$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
-
-[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
-
-[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem");
-
-Write-Host "##############################################################################"
-Write-Host "## Downloading mingw"
-Write-Host "##############################################################################"
-
-if ($env:ARCH -eq "amd64") {
-	$mingw_uri = "https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip"
-	$platform = "x86_64"
-} else {
-	$mingw_uri = "https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip"
-	$platform = "x86"
-}
-
-$wc = New-Object net.webclient
-$wc.Downloadfile($mingw_uri, "${Env:TEMP}/mingw-${Env:ARCH}.zip")
-
-[System.IO.Compression.ZipFile]::ExtractToDirectory("${Env:TEMP}/mingw-${Env:ARCH}.zip", $Env:TEMP)
diff --git a/azure-pipelines/setup-mingw.sh b/azure-pipelines/setup-mingw.sh
new file mode 100755
index 0000000..1172c20
--- /dev/null
+++ b/azure-pipelines/setup-mingw.sh
@@ -0,0 +1,15 @@
+#!/bin/sh -e
+
+echo "##############################################################################"
+echo "## Downloading mingw"
+echo "##############################################################################"
+
+case "$ARCH" in
+	amd64)
+		MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip";;
+	x86)
+		MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";;
+esac
+
+curl -s -L "$MINGW_URI" -o "$TEMP"/mingw-"$ARCH".zip
+unzip -q "$TEMP"/mingw-"$ARCH".zip -d "$TEMP"