Update winmake.ps1 to build arm64 artifacts

Winmake could only build amd64 artifacts (podman-remote, gvproxy,
win-sshproxy, podman.msi and podman-setup.exe).

This commit makes the necessary change to winmake so that it:
1) builds arm64 artifacts when executed on arm64
2) cross-compiles to arm64/amd64 with the  `-architecture` parameter

It depends on https://github.com/containers/podman/pull/26023 that
removes the need to build `check.c` code (that is not used anyway).

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
This commit is contained in:
Mario Loriedo
2025-05-02 10:54:46 +02:00
parent b5befcd514
commit 7fddbd4d4d
5 changed files with 53 additions and 19 deletions

View File

@ -55,6 +55,7 @@ if ($args.Count -lt 1 -or $args[0].Length -lt 1) {
Write-Host 'Uses Env Vars: '
Write-Host ' $ENV:FETCH_BASE_URL - GitHub Repo Address to locate release on'
Write-Host ' $ENV:V531_SETUP_EXE_PATH - Path to v5.3.1 setup.exe used to build the patch'
Write-Host ' $ENV:PODMAN_ARCH - Installer target platform (x64 or arm64)'
Write-Host 'Env Settings for signing (optional)'
Write-Host ' $ENV:VAULT_ID'
Write-Host ' $ENV:APP_ID'
@ -103,6 +104,16 @@ if ($ENV:INSTVER -eq "") {
Exit 1
}
$installerPlatform = ""
if ($null -eq $ENV:PODMAN_ARCH -or $ENV:PODMAN_ARCH -eq "amd64") {
$installerPlatform = "x64"
} elseif ($ENV:PODMAN_ARCH -eq "arm64") {
$installerPlatform = "arm64"
} else {
Write-Host "Unknown architecture $ENV:PODMAN_ARCH. Valid options are amd64 or arm64."
Exit 1
}
SignItem @("artifacts/win-sshproxy.exe",
"artifacts/podman.exe")
$gvExists = Test-Path "artifacts/gvproxy.exe"
@ -123,10 +134,10 @@ if ($gvExists) {
if (Test-Path ./obj) {
Remove-Item ./obj -Recurse -Force -Confirm:$false
}
dotnet build podman.wixproj /property:DefineConstants="VERSION=$ENV:INSTVER" -o .; ExitOnError
dotnet build podman.wixproj /property:DefineConstants="VERSION=$ENV:INSTVER" /property:InstallerPlatform="$installerPlatform" -o .; ExitOnError
SignItem @("en-US\podman.msi")
dotnet build podman-setup.wixproj /property:DefineConstants="VERSION=$ENV:INSTVER" -o .; ExitOnError
dotnet build podman-setup.wixproj /property:DefineConstants="VERSION=$ENV:INSTVER" /property:InstallerPlatform="$installerPlatform" -o .; ExitOnError
wix burn detach podman-setup.exe -engine engine.exe; ExitOnError
SignItem @("engine.exe")

View File

@ -1,6 +1,5 @@
<Project Sdk="WixToolset.Sdk/5.0.2">
<PropertyGroup>
<InstallerPlatform>x64</InstallerPlatform>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<OutputType>Bundle</OutputType>
</PropertyGroup>

View File

@ -1,6 +1,5 @@
<Project Sdk="WixToolset.Sdk/5.0.2">
<PropertyGroup>
<InstallerPlatform>x64</InstallerPlatform>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>

View File

@ -51,7 +51,7 @@
-->
<SetProperty Id="HIDE_PROVIDER_CHOICE" After="AppSearch" Value="1" Sequence="first" Condition="(SKIP_CONFIG_FILE_CREATION = 1) OR (MACHINE_PROVIDER_CONFIG_FILE_PATH) OR (MAIN_EXECUTABLE_FILE_PATH)" />
<CustomAction Id="OpenGuide" DllEntry="WixShellExec" Impersonate="yes" BinaryRef="Wix4UtilCA_X86" />
<CustomAction Id="OpenGuide" DllEntry="WixShellExec" Impersonate="yes" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" />
<util:BroadcastEnvironmentChange />
<Feature Id="Complete" Level="1">
<ComponentRef Id="INSTALLDIR_Component" />

View File

@ -1,5 +1,22 @@
#!/usr/bin/env powershell
[CmdletBinding(PositionalBinding=$false)]
param (
[ValidateSet("amd64", "arm64")]
[Alias("arch")]
[string]$architecture = $(
$defaultArchitecture = "amd64"
$arch = try {& go env GOARCH} catch {
Write-Warning "Failed retriving the host architecture, using default ($defaultArchitecture). Is Go installed?"
return $defaultArchitecture
}
if ($arch -cnotin @("arm64", "amd64")) {
Write-Warning "Unsupported architecture $arch. Using default ($defaultArchitecture)."
return $defaultArchitecture
}
),
[parameter(ValueFromRemainingArguments)][object[]]$params = @()
)
. ./contrib/cirrus/win-lib.ps1
@ -12,6 +29,7 @@ function Podman-Remote{
$commit = Git-Commit
$commit = "-X github.com/containers/podman/v5/libpod/define.gitCommit=$commit "
$ENV:GOARCH = $architecture
Run-Command "go build --ldflags `"$commit $buildInfo `" --tags `"$remotetags`" --o ./bin/windows/podman.exe ./cmd/podman/."
}
@ -75,8 +93,14 @@ function Win-SSHProxy {
$match = Select-String -Path "$PSScriptRoot\go.mod" -Pattern "github.com/containers/gvisor-tap-vsock\s+(v[\d\.]+)"
$Version = $match.Matches.Groups[1].Value
}
curl.exe -sSL -o "./bin/windows/gvproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/gvproxy-windowsgui.exe"
curl.exe -sSL -o "./bin/windows/win-sshproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/win-sshproxy.exe"
Write-Host "Downloading gvproxy version $version"
if ($architecture -eq "amd64") {
curl.exe -sSL -o "./bin/windows/gvproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/gvproxy-windowsgui.exe"
curl.exe -sSL -o "./bin/windows/win-sshproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/win-sshproxy.exe"
} else {
curl.exe -sSL -o "./bin/windows/gvproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/gvproxy-windows-arm64.exe"
curl.exe -sSL -o "./bin/windows/win-sshproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/win-sshproxy-arm64.exe"
}
}
function Installer{
@ -115,6 +139,7 @@ function Installer{
# Run \contrib\win-installer\build.ps1
Push-Location $PSScriptRoot\contrib\win-installer
$ENV:PODMAN_ARCH = $architecture # This is used by the "build.ps1" script
Run-Command ".\build.ps1 $version $suffix `"$zipFileDest`""
Pop-Location
}
@ -298,7 +323,7 @@ function Build-Distribution-Zip-File{
);
$binariesFolder = "$PSScriptRoot\bin\windows"
$documentationFolder = "$PSScriptRoot\docs\build\remote\"
$zipFile = "$destinationPath\podman-remote-release-windows_amd64.zip"
$zipFile = "$destinationPath\podman-remote-release-windows_$architecture.zip"
# Create a temporary folder to store the distribution files
$tempFolder = New-Item -ItemType Directory -Force -Path "$env:TEMP\podman-windows"
@ -332,7 +357,7 @@ function Get-Podman-Version{
}
# Init script
$target = $args[0]
$target = $params[0]
$remotetags = "remote exclude_graphdriver_btrfs containers_image_openpgp"
@ -344,30 +369,30 @@ switch ($target) {
Local-Unit
}
'localmachine' {
if ($args.Count -gt 1) {
$files = $args[1]
if ($params.Count -gt 1) {
$files = $params[1]
}
Local-Machine -files $files
Local-Machine -files $files
}
'clean' {
Make-Clean
}
{$_ -in 'win-sshproxy', 'win-gvproxy'} {
if ($args.Count -gt 1) {
$ref = $args[1]
if ($params.Count -gt 1) {
$ref = $params[1]
}
Win-SSHProxy($ref)
}
'installer' {
if ($args.Count -gt 1) {
Installer -version $args[1]
if ($params.Count -gt 1) {
Installer -version $params[1]
} else {
Installer
}
}
'installertest' {
if ($args.Count -gt 1) {
Test-Installer -provider $args[1]
if ($params.Count -gt 1) {
Test-Installer -provider $params[1]
} else {
Test-Installer
}
@ -385,7 +410,7 @@ switch ($target) {
Lint
}
default {
Write-Host "Usage: " $MyInvocation.MyCommand.Name "<target> [options]"
Write-Host "Usage: " $MyInvocation.MyCommand.Name "<target> [options] [<-architecture|-arch>=<amd64|arm64>]"
Write-Host
Write-Host "Example: Build podman-remote "
Write-Host " .\winmake podman-remote"