From 8f0481f19a4b2f6847bf86a0003cd41ba7e7e67e Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Wed, 27 Jan 2021 07:16:23 +0200 Subject: docker/windows: make the powershell scripts more robust Check the exit codes of various commands and fail appropriatly upon error. Part-of: --- docker/windows/build_image.ps1 | 20 +++++++++++++-- docker/windows/install_choco.ps1 | 18 ++++++++++++-- docker/windows/install_toolchain.ps1 | 47 ++++++++++++++++++++++++++++++++---- docker/windows/prepare_gst_env.ps1 | 8 ++++++ 4 files changed, 84 insertions(+), 9 deletions(-) diff --git a/docker/windows/build_image.ps1 b/docker/windows/build_image.ps1 index 8494dfd..95a60d8 100644 --- a/docker/windows/build_image.ps1 +++ b/docker/windows/build_image.ps1 @@ -1,6 +1,22 @@ $env:DEFAULT_BRANCH='master' -$env:VERSION='v17' +$env:VERSION='v18' $env:tag ="registry.freedesktop.org/gstreamer/gst-ci/amd64/windows:$env:VERSION-$env:DEFAULT_BRANCH" -echo "Building $env:tag" + +Get-Date +Write-Output "Building $env:tag" docker build --build-arg DEFAULT_BRANCH=$env:DEFAULT_BRANCH -f Dockerfile -t $env:tag . +if (!$?) { + Write-Host "Failed to build docker image $env:tag" + Exit 1 +} + +# Get-Date +# Write-Output "Pushing $env:tag" # docker push $env:tag +# if (!$?) { +# Write-Host "Failed to push docker image $env:tag" +# Exit 1 +# } + +Get-Date +Write-Output "Build Finished" \ No newline at end of file diff --git a/docker/windows/install_choco.ps1 b/docker/windows/install_choco.ps1 index 9fb9d13..dd435ed 100644 --- a/docker/windows/install_choco.ps1 +++ b/docker/windows/install_choco.ps1 @@ -1,6 +1,20 @@ -Write-Host "Installing Choco" +Get-Date +Write-Host "Installing Chocolatey" Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) -Write-Host "Installing Choco packages" +Import-Module "$env:ProgramData\chocolatey\helpers\chocolateyProfile.psm1" +Update-SessionEnvironment + +Write-Host "Installing Chocolatey packages" choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' +$cmake_install = $? + choco install -y git --params "/NoAutoCrlf /NoCredentialManager /NoShellHereIntegration /NoGuiHereIntegration /NoShellIntegration" +$git_install = $? + choco install -y python3 git-lfs 7zip +$rest_installs = $? + +if (!($cmake_install -and $git_install -and $rest_installs)) { + Write-Host "Failed to install some dependencies from choco" + Exit 1 +} diff --git a/docker/windows/install_toolchain.ps1 b/docker/windows/install_toolchain.ps1 index a29330b..fd61b42 100644 --- a/docker/windows/install_toolchain.ps1 +++ b/docker/windows/install_toolchain.ps1 @@ -4,29 +4,66 @@ $msvc_2017_url = 'https://aka.ms/vs/15/release/vs_buildtools.exe' $msys2_url = 'https://github.com/msys2/msys2-installer/releases/download/2021-02-15/msys2-base-x86_64-20210215.tar.xz' $msys_mingw_get_url = 'https://dotsrc.dl.osdn.net/osdn/mingw/68260/mingw-get-0.6.3-mingw32-pre-20170905-1-bin.tar.xz' -Write-Host "Installing VisualStudio" +Get-Date +Write-Host "Downloading Visual Studio 2017 build tools" Invoke-WebRequest -Uri $msvc_2017_url -OutFile C:\vs_buildtools.exe -Start-Process C:\vs_buildtools.exe -ArgumentList '--quiet --wait --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended' -Wait + +Get-Date +Write-Host "Installing Visual Studio 2017" +Start-Process -NoNewWindow -Wait C:\vs_buildtools.exe -ArgumentList '--wait --quiet --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended' +if (!$?) { + Write-Host "Failed to install Visual Studio tools" + Exit 1 +} Remove-Item C:\vs_buildtools.exe -Force +Get-Date Write-Host "Downloading and extracting mingw-get for MSYS" Invoke-WebRequest -Uri $msys_mingw_get_url -OutFile C:\mingw-get.tar.xz 7z e C:\mingw-get.tar.xz -o"C:\\" +$res1 = $? 7z x C:\mingw-get.tar -o"C:\\MinGW" +$res2 = $? + +if (!($res1 -and $res2)) { + Write-Host "Failed to extract mingw-get" + Exit 1 +} + Remove-Item C:\mingw-get.tar.xz -Force Remove-Item C:\mingw-get.tar -Force +Get-Date Write-Host "Installing MSYS for Cerbero into C:/MinGW using mingw-get" -Start-Process C:\MinGW\bin\mingw-get.exe -ArgumentList 'install msys-base mingw32-base mingw-developer-toolkit' -Wait +Start-Process -Wait C:\MinGW\bin\mingw-get.exe -ArgumentList 'install msys-base mingw32-base mingw-developer-toolkit' +if (!$?) { + Write-Host "Failed to install Msys for cerbero using MinGW" + Exit 1 +} +Get-Date Write-Host "Installing MSYS2 into C:/msys64" Invoke-WebRequest -Uri $msys2_url -OutFile C:\msys2-x86_64.tar.xz + 7z e C:\msys2-x86_64.tar.xz -o"C:\\" +$res1 = $? 7z x C:\msys2-x86_64.tar -o"C:\\" +$res2 = $? + +if (!($res1 -and $res2)) { + Write-Host "Failed to extract msys2" + Exit 1 +} + Remove-Item C:\msys2-x86_64.tar.xz -Force Remove-Item C:\msys2-x86_64.tar -Force +Get-Date Write-Host "Installing Meson" -pip install meson +pip3 install meson +if (!$?) { + Write-Host "Failed to install meson from pip" + Exit 1 +} -Write-Host "Complete" +Write-Host "Toolchain Install Complete" diff --git a/docker/windows/prepare_gst_env.ps1 b/docker/windows/prepare_gst_env.ps1 index f5316e9..601e799 100644 --- a/docker/windows/prepare_gst_env.ps1 +++ b/docker/windows/prepare_gst_env.ps1 @@ -7,9 +7,17 @@ # Download gst-build and all its subprojects git clone -b $env:DEFAULT_BRANCH https://gitlab.freedesktop.org/gstreamer/gst-build.git C:\gst-build +if (!$?) { + Write-Host "Failed to clone gst-build" + Exit 1 +} # download the subprojects to try and cache them meson subprojects download --sourcedir C:\gst-build +if (!$?) { + Write-Host "Failed to download the subprojects" + Exit 1 +} # Remove files that will conflict with a fresh clone on the runner side Remove-Item -Force 'C:/gst-build/subprojects/*.wrap' -- cgit v1.2.3