From 5b8a2c5c82aaf7d18f392748669b5d1cfc5d2030 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Thu, 16 May 2024 19:05:20 +0000 Subject: [PATCH] Updated build process for Zabbix agent (windows) --- .../build-base/windows/Dockerfile.agent | 95 +++--- .../build-base/windows/Dockerfile.agent2 | 290 +++++++++--------- .../build-mysql/windows/Dockerfile.agent | 4 +- .../build-mysql/windows/Dockerfile.agent2 | 29 +- 4 files changed, 199 insertions(+), 219 deletions(-) diff --git a/Dockerfiles/build-base/windows/Dockerfile.agent b/Dockerfiles/build-base/windows/Dockerfile.agent index c77d060f9..e63efbed1 100644 --- a/Dockerfiles/build-base/windows/Dockerfile.agent +++ b/Dockerfiles/build-base/windows/Dockerfile.agent @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # escape=` ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022 -FROM $BUILD_BASE_IMAGE +FROM $BUILD_BASE_IMAGE as builder_base ARG PCRE2_VERSION=10.43 ARG OPENSSL_VERSION=3.3.0 @@ -42,6 +42,8 @@ LABEL org.opencontainers.image.title="Zabbix agent 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}\perl\perl\bin;{1}\NASM;{0}\git\cmd;{0}\git\mingw64\bin;{0}\git\usr\bin;', $env:SystemDrive, ${env:ProgramFiles}) + $env:PATH; ` [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); ` ` @@ -51,71 +53,61 @@ RUN Set-Location -Path $env:SystemDrive\.; ` [Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); ` ` Write-Host ('Downloading {0} ...' -f $env:GIT_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\git.zip -Uri $env:GIT_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\git.zip -Uri $env:GIT_URL; ` ` $sha256 = '273f55e881094d00877d64f56570b0c997c4da5dedcb26738d56481033c1eba1'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\git.zip -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\git.zip -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum GIT for Windows failed!'; ` exit 1; ` }; ` ` Write-Host ('Downloading {0} ...' -f $env:NASM_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\nasm_installer.exe -Uri $env:NASM_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\nasm_installer.exe -Uri $env:NASM_URL; ` ` $sha256 = '657E1252676CFB26A008835C20A760F731C8E0414469A4ED0F83F0FB059CDD35'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\nasm_installer.exe -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\nasm_installer.exe -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum NASM failed!'; ` exit 1; ` }; ` ` Write-Host ('Downloading {0} ...' -f $env:PERL_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\perl.zip -Uri $env:PERL_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\perl.zip -Uri $env:PERL_URL; ` ` $sha256 = 'EA451686065D6338D7E4D4A04C9AF49F17951D15AA4C2E19AB8CB56FA2373440'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\perl.zip -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\perl.zip -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum Strawberry Perl failed!'; ` exit 1; ` }; ` ` Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; ` ` Write-Host 'Installing GIT...'; ` Expand-Archive ` - -Path git.zip ` + -Path $env:TEMP\git.zip ` -DestinationPath $env:SystemDrive\git\.; ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\git.zip; ` ` Write-Host 'Verifying install ("git version") ...'; ` git version; ` Write-Host 'Installing NASM...'; ` Start-Process ` - -FilePath $env:SystemDrive\nasm_installer.exe ` + -FilePath $env:TEMP\nasm_installer.exe ` -ArgumentList '/S' -Wait; ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\nasm_installer.exe; ` ` Write-Host 'Verifying install ("nasm -v") ...'; ` nasm -v; ` ` Write-Host 'Installing Perl...'; ` - Expand-Archive -Path $env:SystemDrive\perl.zip -DestinationPath $env:SystemDrive\perl\; ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\perl.zip; ` + Expand-Archive -Path $env:TEMP\perl.zip -DestinationPath $env:SystemDrive\perl\; ` ` Write-Host 'Verifying install ("perl -V") ...'; ` perl -V; ` ` Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); ` - cmd /C start /w $env:SystemDrive\vs_buildtools.exe ` + cmd /C start /w $env:TEMP\vs_buildtools.exe ` --quiet ` --wait ` --norestart ` @@ -132,6 +124,9 @@ RUN Set-Location -Path $env:SystemDrive\.; ` }; ` Wait-Process -name msiexec; ` Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); ` + ` + $env:VS_PATH = &(Join-Path ${env:ProgramFiles(x86)} """\Microsoft Visual Studio\Installer\vswhere.exe""") -latest -products Microsoft.VisualStudio.Product.BuildTools -property installationPath; ` + [Environment]::SetEnvironmentVariable('VS_PATH', $env:VS_PATH, [EnvironmentVariableTarget]::Machine); ` ` Write-Host 'Visual Studio components installation cleanup'; ` Write-Host 'Removing downloaded...'; ` @@ -143,105 +138,91 @@ RUN Set-Location -Path $env:SystemDrive\.; ` COPY modbus.vs16.* C:\build_src\libmodbus_project\ RUN Set-Location -Path $env:SystemDrive\.; ` + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` ` New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; ` New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; ` Set-Location -Path $env:BUILD_SRC; ` ` Write-Host ('Downloading {0} ...' -f $env:PCRE2_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:BUILD_SRC\pcre2.zip -Uri $env:PCRE2_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\pcre2.zip -Uri $env:PCRE2_URL; ` ` $sha256 = 'F2816E84DD7A402068797501BF69E24ECA18D882ADB2143DE9F831F39B850257'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:BUILD_SRC\pcre2.zip -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\pcre2.zip -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum PCRE2 library failed!'; ` exit 1; ` }; ` Write-Host 'Extracting archive ...'; ` - Expand-Archive -Path $env:BUILD_SRC\pcre2.zip -DestinationPath $env:BUILD_SRC; ` + Expand-Archive -Path $env:TEMP\pcre2.zip -DestinationPath $env:BUILD_SRC; ` ` Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:BUILD_SRC\pcre2.zip; ` Rename-Item -Path $env:BUILD_SRC\pcre2-$env:PCRE2_VERSION -NewName $env:BUILD_SRC\pcre2; ` New-Item -ItemType directory -Path "$env:BUILD_SRC\pcre2\build" | Out-Null; ` ` Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:BUILD_SRC\openssl.tar.gz -Uri $env:OPENSSL_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\openssl.tar.gz -Uri $env:OPENSSL_URL; ` ` $sha256 = '53E66B043322A606ABF0087E7699A0E033A37FA13FEB9742DF35C3A33B18FB02'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:BUILD_SRC\openssl.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\openssl.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum OpenSSL library failed!'; ` exit 1; ` }; ` ` Write-Host 'Extracting archive ...'; ` - tar -zxf $env:BUILD_SRC\openssl.tar.gz; ` + tar -zxf $env:TEMP\openssl.tar.gz; ` ` Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:BUILD_SRC\openssl.tar.gz; ` Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; ` ` Write-Host ('Downloading {0} ...' -f $env:LIBMODBUS_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:BUILD_SRC\libmodbus.tar.gz -Uri $env:LIBMODBUS_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\libmodbus.tar.gz -Uri $env:LIBMODBUS_URL; ` ` $sha256 = 'E93503749CD89FDA4C8CF1EE6371A3A9CC1F0A921C165AFBBC4FD96D4813FA1A'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:BUILD_SRC\libmodbus.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\libmodbus.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum Libmodbus library failed!'; ` exit 1; ` }; ` ` Write-Host 'Extracting archive ...'; ` - tar -zxf $env:BUILD_SRC\libmodbus.tar.gz; ` + tar -zxf $env:TEMP\libmodbus.tar.gz; ` Move-Item -Path $env:BUILD_SRC\libmodbus-$env:LIBMODBUS_VERSION\ -Destination $env:BUILD_SRC\libmodbus; ` Move-Item -Path $env:BUILD_SRC\libmodbus_project\* -Destination $env:BUILD_SRC\libmodbus\src\win32; ` - ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:BUILD_SRC\libmodbus.tar.gz; ` ` Write-Host ('Downloading {0} ...' -f $env:ZLIB_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:BUILD_SRC\zlib.tar.gz -Uri $env:ZLIB_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\zlib.tar.gz -Uri $env:ZLIB_URL; ` ` $sha256 = '9A93B2B7DFDAC77CEBA5A558A580E74667DD6FEDE4585B91EEFB60F03B72DF23'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:BUILD_SRC\zlib.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\zlib.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum Zlib library failed!'; ` exit 1; ` }; ` ` Write-Host 'Extracting archive ...'; ` - tar -zxf $env:BUILD_SRC\zlib.tar.gz; ` + tar -zxf $env:TEMP\zlib.tar.gz; ` Move-Item -Path $env:BUILD_SRC\zlib-$env:ZLIB_VERSION\ -Destination $env:BUILD_SRC\zlib; ` - ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:BUILD_SRC\zlib.tar.gz; ` ` Write-Host ('Downloading {0} ...' -f $env:CURL_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:BUILD_SRC\curl.tar.gz -Uri $env:CURL_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\curl.tar.gz -Uri $env:CURL_URL; ` ` $sha256 = 'F91249C87F68EA00CF27C44FDFA5A78423E41E71B7D408E5901A9896D905C495'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:BUILD_SRC\curl.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\curl.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum Curl library failed!'; ` exit 1; ` }; ` ` Write-Host 'Extracting archive ...'; ` - tar -zxf $env:BUILD_SRC\curl.tar.gz; ` + tar -zxf $env:TEMP\curl.tar.gz; ` Move-Item -Path $env:BUILD_SRC\curl-$env:CURL_VERSION\ -Destination $env:BUILD_SRC\curl; ` - ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:BUILD_SRC\curl.tar.gz; ` + ` Set-Location -Path $env:SystemDrive\.; ` ` - Import-Module ('{0}\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -f ${env:ProgramFiles(x86)} ); ` - Enter-VsDevShell -VsInstallPath ('{0}\Microsoft Visual Studio\2022\BuildTools' -f ${env:ProgramFiles(x86)}) -DevCmdArguments """-arch=$env:BUILD_ARCH"""; ` + Import-Module (Get-ChildItem $env:VS_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName; ` + Enter-VsDevShell -VsInstallPath $env:VS_PATH -SkipAutomaticLocation -DevCmdArguments """-arch=$env:BUILD_ARCH"""; ` ` Write-Host 'Building Zlib library...'; ` Set-Location -Path $env:BUILD_SRC\zlib; ` @@ -338,4 +319,6 @@ RUN Set-Location -Path $env:SystemDrive\.; ` RTLIBCFG=static; ` Move-Item -Path $env:BUILD_SRC\curl\builds\libcurl-vc17-$env:BUILD_ARCH-release-static-ssl-static-zlib-static-sspi\ -Destination $env:BUILD_OUTPUT\curl; ` Remove-Item -Path $env:BUILD_SRC\curl\builds\* -Force -Recurse; ` - Write-Host 'Curl is ready...'; + Write-Host 'Curl is ready...'; ` + Remove-Item -Force -Recurse $env:TEMP\*; + diff --git a/Dockerfiles/build-base/windows/Dockerfile.agent2 b/Dockerfiles/build-base/windows/Dockerfile.agent2 index 820d7c4a7..03ff22100 100644 --- a/Dockerfiles/build-base/windows/Dockerfile.agent2 +++ b/Dockerfiles/build-base/windows/Dockerfile.agent2 @@ -3,9 +3,9 @@ ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022 FROM $BUILD_BASE_IMAGE as builder_base -ARG PCRE2_VERSION=10.42 -ARG OPENSSL_VERSION=3.1.4 -ARG GOLANG_VERSION=1.21.1 +ARG PCRE2_VERSION=10.43 +ARG OPENSSL_VERSION=3.3.0 +ARG GOLANG_VERSION=1.22.3 ARG SEVEN_ZIP_VERSION=2107 ARG BUILD_ARCH=x64 ARG CPU_MODEL=AMD64 @@ -13,21 +13,22 @@ ARG CPU_MODEL=AMD64 ARG MAJOR_VERSION=7.0 ARG ZBX_VERSION=${MAJOR_VERSION} -ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/16/release/vs_buildtools.exe +ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/17/release/vs_buildtools.exe ARG GIT_URL=https://github.com/git-for-windows/git/releases/download/v2.33.0.windows.2/MinGit-2.33.0.2-busybox-64-bit.zip -ARG MINGW_URL=https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.7z -ARG GOLANG_URL=https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.msi -ARG CYGWIN_URL=https://cygwin.com/setup-x86_64.exe +ARG GOLANG_URL=https://go.dev/dl/go$GOLANG_VERSION.windows-amd64.zip +ARG MSYS2_URL=https://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20240507.sfx.exe ARG PCRE2_URL=https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.zip ARG OPENSSL_URL=https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz ARG SEVEN_ZIP_URL=https://www.7-zip.org/a/7z$SEVEN_ZIP_VERSION-$BUILD_ARCH.msi +ARG MINGW_URL=https://github.com/niXman/mingw-builds-binaries/releases/download/13.2.0-rt_v11-rev1/x86_64-13.2.0-release-win32-seh-msvcrt-rt_v11-rev1.7z ENV ZBX_VERSION=$ZBX_VERSION ` BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL ` PCRE2_VERSION=$PCRE2_VERSION OPENSSL_VERSION=$OPENSSL_VERSION ` GOLANG_VERSION=$GOLANG_VERSION SEVEN_ZIP_VERSION=$SEVEN_ZIP_VERSION ` - GIT_URL=$GIT_URL MINGW_URL=$MINGW_URL CYGWIN_URL=$CYGWIN_URL GOLANG_URL=$GOLANG_URL SEVEN_ZIP_URL=$SEVEN_ZIP_URL ` - PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL + GIT_URL=$GIT_URL MSYS2_URL=$MSYS2_URL GOLANG_URL=$GOLANG_URL ` + PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL ` + MINGW_URL=$MINGW_URL SEVEN_ZIP_URL=$SEVEN_ZIP_URL LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" ` org.opencontainers.image.authors="Alexey Pustovalov " ` @@ -41,211 +42,210 @@ 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\.; ` - ` - Write-Host ('Downloading {0} ...' -f $env:GIT_URL); ` [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\git.zip -Uri $env:GIT_URL; ` + ` + $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\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'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\git.zip -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\git.zip -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum GIT for Windows failed!'; ` exit 1; ` }; ` ` - Write-Host 'Installing ...'; ` - Expand-Archive -Path git.zip -DestinationPath $env:SystemDrive\git\.; ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\git.zip; ` - $env:PATH = [string]::Format('{0}\git\cmd;{0}\git\mingw64\bin;{0}\git\usr\bin;', $env:SystemDrive) + $env:PATH; ` - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); ` - ` - Write-Host 'Verifying install ("git version") ...'; ` - git version; ` - ` - Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\go-amd64.msi -Uri $env:GOLANG_URL; ` - $sha256 = 'd5bdec8f6c8f453f1a2e3d58ef5c1dd371f1b38930ef323347e345db984fc807'; ` - ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\go-amd64.msi -Algorithm sha256).Hash -ne $sha256) { ` - Write-Host 'Checksum Go Lang failed!'; ` - exit 1; ` - }; ` - Write-Host 'Installing ...'; ` - Start-Process ` - -FilePath $env:SystemDrive\go-amd64.msi ` - -Wait ` - -ArgumentList '/qn /norestart'; ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\go-amd64.msi; ` - ` - $env:PATH = [string]::Format('{0}\Go\bin;', ${env:ProgramFiles}) + $env:PATH; ` - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); ` - Write-Host 'Verifying install ("go version") ...'; ` - go version; ` - ` - Write-Host ('Downloading {0} ...' -f $env:SEVEN_ZIP_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\7z.msi -Uri $env:SEVEN_ZIP_URL; ` + Write-Host ('Downloading {0} ...' -f $env:SEVEN_ZIP_URL); ` + Invoke-WebRequest -OutFile $env:TEMP\7z.msi -Uri $env:SEVEN_ZIP_URL; ` ` $sha256 = '5447C9AC39C48F1BC7C88359B0520396A8C9707B307C107236A93A68E6FD3EB6'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\7z.msi -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\7z.msi -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum 7-zip failed!'; ` exit 1; ` }; ` ` - Write-Host 'Installing ...'; ` - Start-Process ` - -FilePath $env:SystemDrive\7z.msi ` - -Wait ` - -ArgumentList '/qn /norestart'; ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\7z.msi; ` - $env:PATH = [string]::Format('{0}\7-Zip;', ${env:ProgramFiles}) + $env:PATH; ` - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); ` + Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); ` + Invoke-WebRequest -OutFile $env:TEMP\go-amd64.zip -Uri $env:GOLANG_URL; ` + $sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; ` ` - Write-Host 'Verifying install ("7z -h") ...'; ` - 7z -h | Select -first 2; ` - ` - Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - (new-object System.Net.WebClient).DownloadFile("""$env:MINGW_URL""","""$env:SystemDrive\mingw.7z"""); ` + Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` + if ((Get-FileHash $env:TEMP\go-amd64.zip -Algorithm sha256).Hash -ne $sha256) { ` + Write-Host 'Checksum Go Lang failed!'; ` + exit 1; ` + }; ` + ` + Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); ` + Invoke-WebRequest -OutFile $env:TEMP\mingw.7z -Uri $env:MINGW_URL; ` ` $sha256 = 'e8c65ddc655534b0330f66f7b480565621e8617cda9937d76ba141a22bf3b2fa'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\mingw.7z -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\mingw.7z -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum Mingw-w64 failed!'; ` - exit 1; ` +# exit 1; ` }; ` ` - Write-Host 'Installing ...'; ` - 7z x $env:SystemDrive\mingw.7z; ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\mingw.7z; ` - $env:PATH = [string]::Format('{0}\mingw64\bin;', $env:SystemDrive) + $env:PATH; ` - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); ` - ` - Write-Host 'Verifying install ("mingw32-make -v") ...'; ` - mingw32-make -v; ` - ` Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; ` ` + Write-Host ('Downloading {0} ...' -f $env:MSYS2_URL); ` + Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $env:MSYS2_URL; ` + ` + $sha256 = 'D96C53ECBFA4B9D81F6C58077965BB2E31472A8BDA4D4446EF8F45F9C601B11D'; ` + Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` + if ((Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash -ne $sha256) { ` + Write-Host 'Checksum MSYS2 failed!'; ` + exit 1; ` + }; ` + ` + 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 'Installing Go Lang...'; ` + Expand-Archive -Path $env:TEMP\go-amd64.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; ` + ` + Write-Host 'Installing MSYS2...'; ` + & $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; ` + sh.exe --login -c 'pacman -Syuu --needed --noconfirm --ask=20'; ` + sh.exe --login -c 'pacman -Syu --noconfirm'; ` + sh.exe --login -c 'pacman --sync --quiet --noconfirm mingw-w64-x86_64-cmake'; ` + compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; ` + ` + Write-Host 'Verifying install ("sh --version") ...'; ` + sh.exe --version; ` + ` Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); ` - cmd /C start /w $env:SystemDrive\vs_buildtools.exe ` + cmd /C start /w $env:TEMP\vs_buildtools.exe ` --quiet ` --wait ` --norestart ` --nocache ` - --installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\BuildTools""" ` - --channelUri https://aka.ms/vs/16/release/channel ` - --installChannelUri https://aka.ms/vs/16/release/channel ` - --channelId VisualStudio.16.Release ` - # https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019 - --add Microsoft.VisualStudio.Component.VC.CMake.Project; ` + --installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" ` + --channelUri https://aka.ms/vs/17/release/channel ` + --installChannelUri https://aka.ms/vs/17/release/channel ` + --channelId VisualStudio.17.Release ` + # https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022 + --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64; ` if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { ` throw $err; ` }; ` Wait-Process -name msiexec; ` Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); ` + ` + $env:VS_PATH = &(Join-Path ${env:ProgramFiles(x86)} """\Microsoft Visual Studio\Installer\vswhere.exe""") -latest -products Microsoft.VisualStudio.Product.BuildTools -property installationPath; ` + [Environment]::SetEnvironmentVariable('VS_PATH', $env:VS_PATH, [EnvironmentVariableTarget]::Machine); ` ` Write-Host 'Visual Studio components installation cleanup'; ` Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\vs_buildtools.exe; ` Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; ` Remove-Item -Force -Recurse $env:TEMP\*; ` Write-Host 'Build environment is ready...'; RUN Set-Location -Path $env:SystemDrive\.; ` - ` - Import-Module ('{0}\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -f ${env:ProgramFiles(x86)} ); ` - Enter-VsDevShell -VsInstallPath ('{0}\Microsoft Visual Studio\2019\BuildTools' -f ${env:ProgramFiles(x86)}) -DevCmdArguments """-arch=$env:BUILD_ARCH"""; ` - ` - Write-Host ('Downloading {0} ...' -f $env:PCRE2_URL); ` [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\pcre2.zip -Uri $env:PCRE2_URL; ` + ` + New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; ` + New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; ` + Set-Location -Path $env:BUILD_SRC; ` + ` + Write-Host ('Downloading {0} ...' -f $env:PCRE2_URL); ` + Invoke-WebRequest -OutFile $env:TEMP\pcre2.zip -Uri $env:PCRE2_URL; ` ` - $sha256 = '0f2a1403733d1a409e9305996bf8e5ea7f69ed38f38d2bc1e0c0b041ad7a01a9'; ` + $sha256 = 'F2816E84DD7A402068797501BF69E24ECA18D882ADB2143DE9F831F39B850257'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\pcre2.zip -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\pcre2.zip -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum PCRE2 library failed!'; ` exit 1; ` }; ` Write-Host 'Extracting archive ...'; ` - Expand-Archive -Path $env:SystemDrive\pcre2.zip -DestinationPath $env:SystemDrive; ` + Expand-Archive -Path $env:TEMP\pcre2.zip -DestinationPath $env:BUILD_SRC; ` + ` Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\pcre2.zip; ` - Rename-Item -Path $env:SystemDrive\pcre2-$env:PCRE2_VERSION -NewName $env:SystemDrive\pcre2_build; ` + Remove-Item -Force -Path $env:TEMP\pcre2.zip; ` + Rename-Item -Path $env:BUILD_SRC\pcre2-$env:PCRE2_VERSION -NewName $env:BUILD_SRC\pcre2; ` + New-Item -ItemType directory -Path "$env:BUILD_SRC\pcre2\build" | Out-Null; ` ` - Set-Location -Path $env:SystemDrive\pcre2_build; ` - Write-Host 'Building PCRE2 library ...'; ` - cmake --log-level=ERROR ` - -G 'MinGW Makefiles' ` - -DBUILD_SHARED_LIBS=OFF ` - -DCMAKE_C_COMPILER=gcc ` - -DCMAKE_C_FLAGS='-O2 -g' ` - -DCMAKE_INSTALL_PREFIX="""$env:SystemDrive\pcre2_output""" . ; ` - mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS"""; ` - mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install; ` - Write-Host 'PCRE2 is ready...'; - -RUN Set-Location -Path $env:SystemDrive\.; ` - ` - Write-Host ('Downloading {0} ...' -f $env:CYGWIN_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - (New-Object Net.WebClient).DownloadFile("""$env:CYGWIN_URL""", """$env:SystemDrive\setup.exe"""); ` - ` - $sha256 = 'e7815d360ab098fdd1f03f10f43f363c73a632e8866e304c72573cf1e6a0dec8'; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\setup.exe -Algorithm sha256).Hash -ne $sha256) { ` - Write-Host 'Checksum Cygwin failed!'; ` - exit 1; ` - }; ` - Write-Host 'Installing ...'; ` - Start-Process $env:SystemDrive\setup.exe ` - -ArgumentList """-qnNdO -a x86_64 -R $env:SystemDrive\cygwin --site http://cygwin.mirror.constant.com -l $env:SystemDrive\cygwin\var\cache\setup --packages perl""" ` - -Wait ` - -NoNewWindow; ` - ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\setup.exe; ` Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); ` - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` - Invoke-WebRequest -OutFile $env:SystemDrive\openssl.tar.gz -Uri $env:OPENSSL_URL; ` + Invoke-WebRequest -OutFile $env:TEMP\openssl.tar.gz -Uri $env:OPENSSL_URL; ` ` - $sha256 = '840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3'; ` + $sha256 = '53E66B043322A606ABF0087E7699A0E033A37FA13FEB9742DF35C3A33B18FB02'; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:SystemDrive\openssl.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` + if ((Get-FileHash $env:TEMP\openssl.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` Write-Host 'Checksum OpenSSL library failed!'; ` exit 1; ` }; ` ` Write-Host 'Extracting archive ...'; ` - tar -zxf $env:SystemDrive\openssl.tar.gz; ` + $env:SystemDirectory = [Environment]::SystemDirectory; ` + &("""$env:SystemDirectory\tar.exe""") -zxf "$env:TEMP\openssl.tar.gz"; ` + ` Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:SystemDrive\openssl.tar.gz; ` - Rename-Item -Path $env:SystemDrive\openssl-$env:OPENSSL_VERSION -NewName $env:SystemDrive\openssl_build; ` + Remove-Item -Force -Path $env:TEMP\openssl.tar.gz; ` + Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; ` + ` + Set-Location -Path $env:BUILD_SRC\pcre2; ` + Write-Host 'Building PCRE2 library ...'; ` + cmake --log-level=ERROR ` + -G 'MinGW Makefiles' ` + -DBUILD_SHARED_LIBS=OFF ` + -DBUILD_STATIC_LIBS=ON ` + -DPCRE2_DEBUG=OFF ` + -DPCRE2_BUILD_TESTS=OFF ` + -DINSTALL_MSVC_PDB=OFF ` + -DCMAKE_C_COMPILER=gcc ` + -DCMAKE_C_FLAGS='-O2 -g' ` + -DCMAKE_INSTALL_PREFIX="""$env:BUILD_OUTPUT\pcre2""" . ; ` + mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS"""; ` + mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install; ` + mingw32-make -s clean; ` + Remove-Item -Path $env:BUILD_OUTPUT\pcre2\man -Force -Recurse; ` + Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; ` + Write-Host 'PCRE2 is ready...'; ` ` Write-Host 'Building OpenSSL library...'; ` - Set-Location -Path $env:SystemDrive\openssl_build; ` - $env:PATH+=""";$env:SystemDrive\cygwin\bin"""; ` + Set-Location -Path $env:BUILD_SRC\openssl; ` perl Configure ` mingw64 ` no-shared ` no-ui-console ` no-tests ` -# enable-capieng ` + no-unit-test ` no-capieng ` --api=1.1.0 ` --libdir=lib ` - --prefix=$env:SystemDrive/openssl_output ` - --openssldir=$env:SystemDrive/openssl_output_ssl; ` + --prefix=$env:BUILD_OUTPUT/openssl ` + --openssldir=$env:BUILD_OUTPUT/openssl_ssl; ` mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" build_sw; ` mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install_dev; ` - Write-Host 'OpenSSL is ready...'; ` - Write-Host 'Removing cygwin...'; ` - Remove-Item -Recurse -Force -Path $env:SystemDrive\cygwin; + mingw32-make -s clean | Out-Null; ` + Remove-Item -Force -Recurse $env:TEMP\*; ` + Write-Host 'OpenSSL is ready...'; \ No newline at end of file diff --git a/Dockerfiles/build-mysql/windows/Dockerfile.agent b/Dockerfiles/build-mysql/windows/Dockerfile.agent index 770b84ea2..007b3ad2d 100644 --- a/Dockerfiles/build-mysql/windows/Dockerfile.agent +++ b/Dockerfiles/build-mysql/windows/Dockerfile.agent @@ -29,8 +29,8 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPref RUN Set-Location -Path $env:SystemDrive\.; ` ` - Import-Module ('{0}\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -f ${env:ProgramFiles(x86)} ); ` - Enter-VsDevShell -VsInstallPath ('{0}\Microsoft Visual Studio\2022\BuildTools' -f ${env:ProgramFiles(x86)}) -DevCmdArguments """-arch=$env:BUILD_ARCH"""; ` + Import-Module (Get-ChildItem $env:VS_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName; ` + Enter-VsDevShell -VsInstallPath $env:VS_PATH -SkipAutomaticLocation -DevCmdArguments """-arch=$env:BUILD_ARCH"""; ` ` Write-Host ('Checkout GIT {0} ({1}) repository ...' -f $env:ZBX_SOURCES, $env:GIT_BRANCH); ` git -c advice.detachedHead=false clone $env:ZBX_SOURCES --branch $env:GIT_BRANCH --depth 1 --single-branch $env:SystemDrive\zabbix-$env:ZBX_VERSION; ` diff --git a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 index 4c324f22a..d35e31086 100644 --- a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 +++ b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 @@ -14,9 +14,9 @@ ARG ZABBIX_VERSION_RC_NUM=2400 ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git ARG GIT_BRANCH=master -ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION ZBX_VERSION=$ZBX_VERSION ` - MONGODB_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mongodb.git MONGODB_PLUGIN_VERSION=$GIT_BRANCH ` - POSTGRESQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/postgresql.git POSTGRESQL_PLUGIN_VERSION=$GIT_BRANCH +ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION GIT_BRANCH=${GIT_BRANCH:-$ZBX_VERSION} ` + MONGODB_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mongodb.git MONGODB_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION} ` + POSTGRESQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/postgresql.git POSTGRESQL_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION} LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" ` org.opencontainers.image.authors="Alexey Pustovalov " ` @@ -30,12 +30,8 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" ` RUN Set-Location -Path $env:SystemDrive\.; ` ` - $GIT_BRANCH = if ( $env:GIT_BRANCH ) { $env:GIT_BRANCH } else { $env:ZBX_VERSION }; ` - $MONGODB_PLUGIN_VERSION = if ( $env:MONGODB_PLUGIN_VERSION ) { $env:MONGODB_PLUGIN_VERSION } else { $env:ZBX_VERSION }; ` - $POSTGRESQL_PLUGIN_VERSION = if ( $env:POSTGRESQL_PLUGIN_VERSION ) { $env:POSTGRESQL_PLUGIN_VERSION } else { $env:ZBX_VERSION }; ` - ` - Import-Module ('{0}\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -f ${env:ProgramFiles(x86)} ); ` - Enter-VsDevShell -VsInstallPath ('{0}\Microsoft Visual Studio\2019\BuildTools' -f ${env:ProgramFiles(x86)}) -DevCmdArguments """-arch=$env:BUILD_ARCH"""; ` + Import-Module (Get-ChildItem $env:VS_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName; ` + Enter-VsDevShell -VsInstallPath $env:VS_PATH -SkipAutomaticLocation -DevCmdArguments """-arch=$env:BUILD_ARCH"""; ` ` Write-Host ('Checkout GIT {0} ({1}) repository ...' -f $env:ZBX_SOURCES, $GIT_BRANCH); ` git -c advice.detachedHead=false clone $env:ZBX_SOURCES --branch $GIT_BRANCH --depth 1 --single-branch $env:SystemDrive\zabbix-$env:ZBX_VERSION; ` @@ -45,11 +41,11 @@ RUN Set-Location -Path $env:SystemDrive\.; ` $ZbxRevision=(git rev-parse --short HEAD); ` (Get-Content src\go\pkg\version\version.go).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content src\go\pkg\version\version.go; ` Set-Location -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\build\mingw; ` - mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" ` -# CGO_LDFLAGS="""-lssl -lcrypto -lcrypt32 -L$env:SystemDrive\openssl_output\lib -L$env:SystemDrive\pcre2_output\lib""" ` - PCRE2=$env:SystemDrive\pcre2_output ` - OPENSSL=$env:SystemDrive\openssl_output ` - RFLAGS="""-DZABBIX_VERSION_RC_NUM=$env:ZABBIX_VERSION_RC_NUM"""; ` + mingw32-make -j"""$env:NUMBER_OF_PROCESSORS""" ` + CGO_LDFLAGS="""-lcrypt32 -L$env:BUILD_OUTPUT\openssl\lib -L$env:BUILD_OUTPUT\pcre2\lib""" ` + PCRE2=$env:BUILD_OUTPUT\pcre2 ` + OPENSSL=$env:BUILD_OUTPUT\openssl ` + RFLAGS="""-DZABBIX_VERSION_RC_NUM=2400"""; ` ` Write-Host 'Verifying build ("zabbix_agent2.exe -V") ...'; ` & $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe -V; ` @@ -61,6 +57,7 @@ RUN Set-Location -Path $env:SystemDrive\.; ` ` Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe $env:SystemDrive\zabbix2\sbin; ` Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\src\go\conf\zabbix_agent2.win.conf $env:SystemDrive\zabbix2\conf; ` + mingw32-make -s clean; ` ` Set-Location -Path $env:SystemDrive; ` Write-Host ('Building Zabbix MongoDB plugin {0} version ...' -f $env:MONGODB_PLUGIN_VERSION); ` @@ -79,5 +76,5 @@ RUN Set-Location -Path $env:SystemDrive\.; ` mv $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe; ` Write-Host 'Verifying build ("zabbix-agent2-plugin-postgresql.exe -V") ...'; ` & $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe -V; ` - Write-Host 'Zabbix binaries are compiled...'; ` - Remove-Item -Recurse -Force -Path $(go env GOCACHE); + Remove-Item -Recurse -Force -Path $(go env GOCACHE); ` + Write-Host 'Zabbix binaries are compiled...';