From aa8fefb67be3363617ab5be11d1a3471fb58f5e0 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Tue, 21 May 2024 02:18:46 +0900 Subject: [PATCH] Updated build process for Zabbix agent (windows) --- .../build-base/windows/Dockerfile.agent2 | 130 ++---------------- 1 file changed, 10 insertions(+), 120 deletions(-) diff --git a/Dockerfiles/build-base/windows/Dockerfile.agent2 b/Dockerfiles/build-base/windows/Dockerfile.agent2 index 2fe0dfbf9..46734fa0c 100644 --- a/Dockerfiles/build-base/windows/Dockerfile.agent2 +++ b/Dockerfiles/build-base/windows/Dockerfile.agent2 @@ -43,123 +43,13 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" ` SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -RUN Set-Location -Path $env:SystemDrive\.; ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - ` - $env:PATH = [string]::Format('{0}\mingw64\bin;{0}\go\bin;{0}\git\cmd;{0}\git\mingw64\bin;{0}\git\usr\bin;{1}\7-Zip;', $env:SystemDrive, ${env:ProgramFiles}) + $env:PATH; ` - $env:PATH = $env:PATH + [string]::Format(';{0}\msys64\usr\bin;{0}\msys64\ucrt64\bin;{0}\msys64\mingw64\bin', $env:SystemDrive); ` - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); ` - ` - $env:BUILD_OUTPUT = [string]::Format('{0}\build_output', $env:SystemDrive); ` - [Environment]::SetEnvironmentVariable('BUILD_OUTPUT', $env:BUILD_OUTPUT, [EnvironmentVariableTarget]::Machine); ` - $env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); ` - [Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); ` - ` - Write-Host ('Downloading {0} ...' -f $env:GIT_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\git.zip -Uri $env:GIT_URL; ` - ` - $sha256 = '273f55e881094d00877d64f56570b0c997c4da5dedcb26738d56481033c1eba1'; ` - $d_sha256 = (Get-FileHash $env:TEMP\git.zip -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum GIT for Windows ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:SEVEN_ZIP_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\7z.msi -Uri $env:SEVEN_ZIP_URL; ` - ` - $sha256 = '0F6AA6596D418B1694F62C8583DE05D24589B8D7FFACCE5A7DAB52AE71F832B6'; ` - $d_sha256 = (Get-FileHash $env:TEMP\7z.msi -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum 7-zip ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; ` - ` - $sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; ` - $d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum Go Lang ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\mingw.7z -Uri $env:MINGW_URL; ` - ` - $sha256 = '74ca64c55220edd3196681782fbff653c2b9cb4f427f9e532ab6e9a0823dc997'; ` - $d_sha256 = (Get-FileHash $env:TEMP\mingw.7z -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum Mingw-w64 ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:MSYS2_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $env:MSYS2_URL; ` - ` - $sha256 = 'D96C53ECBFA4B9D81F6C58077965BB2E31472A8BDA4D4446EF8F45F9C601B11D'; ` - $d_sha256 = (Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum MSYS2 ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; ` - ` - Write-Host 'Installing GIT...'; ` - Expand-Archive ` - -Path $env:TEMP\git.zip ` - -DestinationPath $env:SystemDrive\git\.; ` - Write-Host 'Removing downloaded...'; ` - ` - Write-Host 'Verifying install ("git version") ...'; ` - git version; ` - ` - Write-Host 'Installing 7z...'; ` - Start-Process ` - -FilePath $env:TEMP\7z.msi ` - -Wait ` - -ArgumentList '/qn /norestart'; ` - ` - Write-Host 'Verifying install ("7z -h") ...'; ` - 7z -h | Select -first 2; ` - ` - Write-Host 'Installing Go Lang...'; ` - Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; ` - ` - Write-Host 'Verifying install ("go version") ...'; ` - go version; ` - ` - Write-Host 'Installing Mingw-w64...'; ` - 7z x $env:TEMP\mingw.7z; ` - ` - Write-Host 'Verifying install ("gcc -v") ...'; ` - gcc -v; ` - tasklist; ` - ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -UseBasicParsing -uri "https://github.com/msys2/msys2-installer/releases/download/nightly-x86_64/msys2-base-x86_64-latest.sfx.exe" -OutFile $env:SystemDrive\msys2.exe; ` - & $env:SystemDrive\msys2.exe -y -o"""$env:SystemDrive\""" | Out-Null; ` - Remove-Item $env:SystemDrive\msys2.exe ; ` - function msys() { C:\msys64\usr\bin\bash.exe @('-lc') + @Args; }; ` - msys ' '; ` - msys 'pacman --noconfirm -Syuu'; ` - msys 'pacman --noconfirm -Syuu'; ` - bash -lc 'pacman --sync --quiet --noconfirm mingw-w64-ucrt-x86_64-cmake'; ` - msys 'pacman --noconfirm -Scc'; ` - ` - Write-Host 'Verifying install ("bash --version") ...'; ` - bash --version; ` - ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Recurse $env:TEMP\*; ` - tasklist; ` - get-process; ` - taskkill /F /FI """MODULES eq msys-2.0.dll"""; +RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` + Invoke-WebRequest -UseBasicParsing -uri "https://github.com/msys2/msys2-installer/releases/download/nightly-x86_64/msys2-base-x86_64-latest.sfx.exe" -OutFile msys2.exe; ` + & msys2.exe -y -oC:\; ` + Remove-Item msys2.exe ; ` + function msys() { C:\msys64\usr\bin\bash.exe @('-lc') + @Args; } ` + msys ' '; ` + msys 'pacman --noconfirm -Syuu'; ` + msys 'pacman --noconfirm -Syuu'; ` + msys 'pacman --sync --quiet --noconfirm mingw-w64-ucrt-x86_64-cmake'; ` + msys 'pacman --noconfirm -Scc';