0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-14 17:48:37 +00:00
netdata_netdata/packaging/windows/install-dependencies.ps1
Austin S. Hemmelgarn 9e575dbec8
Add Widnows CI jobs. ()
* Initial Windows CI support.

This also adds a proper set of production-focused packaging scripts
for working with building Netdata on Windows.

* Pivot to using existing tooling and fixing that up as required.

* General script cleanup.

* Auto-detect location of repository based on script location.

This makes the scripts properly independent of the current working
directory, allowing them to be more resilient to possible changes in the
build environment.

* Make dependency handling entirely separate from build.

* Remove development-only packages from dependency list.

They only waste time in CI, and it’s reasonable to assume that anybody
who needs them can install them themselves, just like we do with all
other platforms.

* Use absolute path for makensis.

This way it actually works without needing manual modification of the
environment.

* Add PowerShell scripts to invoke the build and package scripts.

* Clean up build directory handling.

* Fix fetching of msys2 installer.

* Further cleanup.

* Tidy up build output

* Provide proper output grouping in GitHub Actions.

* Use correct command name for makensis.

* Fix installer script path.

* Do not try to install MSYS2 using Chocolatey.

* Fix CPU architecture check.

* Add more detailed messages for MSYS2 install.

* Fix release fetching logic.

* Further release check logic fixes.

* Complete Windows CI support.

* Move second update pass into dependency handling script.

* Fix handling of icon for Windows installer.

* Default to using a working configuration for release builds.

And provide a way to pass extra options to CMake without needing to
modify the script.

* Fix expansion of optionally defined variable.
2024-07-18 13:28:45 -04:00

84 lines
2.6 KiB
PowerShell

# Set up Windows build dependencies.
#
# This script first sees if msys is installed. If so, it just uses it. If not, it tries to bootstrap it with chocolatey or winget.
#Requires -Version 4.0
$ErrorActionPreference = "Stop"
. "$PSScriptRoot\functions.ps1"
$msysprefix = Get-MSYS2Prefix
function Check-FileHash {
$file_path = $args[0]
Write-Host "Checking SHA256 hash of $file_path"
$actual_hash = (Get-FileHash -Algorithm SHA256 -Path $file_path).Hash.toLower()
$expected_hash = (Get-Content "$file_path.sha256").split()[0]
if ($actual_hash -ne $expected_hash) {
Write-Host "SHA256 hash mismatch!"
Write-Host "Expected: $expected_hash"
Write-Host "Actual: $actual_hash"
exit 1
}
}
function Install-MSYS2 {
$repo = 'msys2/msys2-installer'
$uri = "https://api.github.com/repos/$repo/releases"
$headers = @{
'Accept' = 'application/vnd.github+json'
'X-GitHub-API-Version' = '2022-11-28'
}
$installer_path = "$env:TEMP\msys2-base.exe"
if ($env:PROCESSOR_ARCHITECTURE -ne "AMD64") {
Write-Host "We can only install MSYS2 for 64-bit x86 systems, but you appear to have a different processor architecture ($env:PROCESSOR_ARCHITECTURE)."
Write-Host "You will need to install MSYS2 yourself instead."
exit 1
}
Write-Host "Determining latest release"
$release_list = Invoke-RestMethod -Uri $uri -Headers $headers -TimeoutSec 30
$release = $release_list[0]
$release_name = $release.name
$version = $release.tag_name.Replace('-', '')
$installer_url = "https://github.com/$repo/releases/download/$release_name/msys2-x86_64-$version.exe"
Write-Host "Fetching $installer_url"
Invoke-WebRequest $installer_url -OutFile $installer_path
Write-Host "Fetching $installer_url.sha256"
Invoke-WebRequest "$installer_url.sha256" -OutFile "$installer_path.sha256"
Write-Host "Checking file hash"
Check-FileHash $installer_path
Write-Host "Installing"
& $installer_path in --confirm-command --accept-messages --root C:/msys64
return "C:\msys64"
}
if (-Not ($msysprefix)) {
Write-Host "Could not find MSYS2, attempting to install it"
$msysprefix = Install-MSYS2
}
$msysbash = Get-MSYS2Bash "$msysprefix"
$env:CHERE_INVOKING = 'yes'
& $msysbash -l "$PSScriptRoot\msys2-dependencies.sh"
if ($LastExitcode -ne 0) {
Write-Host "First update attempt failed. This is expected if the msys-runtime package needed updated, trying again."
& $msysbash -l "$PSScriptRoot\msys2-dependencies.sh"
if ($LastExitcode -ne 0) {
exit 1
}
}