podman
/
winmake.ps1
110 строк · 3.2 Кб
1
2. ./contrib/cirrus/win-lib.ps1
3
4# Targets
5function Podman-Remote{
6New-Item -ItemType Directory -Force -Path "./bin/windows"
7
8$buildInfo = Get-Date -UFormat %s -Millisecond 0
9$buildInfo = "-X github.com/containers/podman/v5/libpod/define.buildInfo=$buildInfo "
10$commit = Git-Commit
11$commit = "-X github.com/containers/podman/v5/libpod/define.gitCommit=$commit "
12
13Run-Command "go build --ldflags `"$commit $buildInfo `" --tags `"$remotetags`" --o ./bin/windows/podman.exe ./cmd/podman/."
14}
15
16function Make-Clean{
17Remove-Item ./bin -Recurse -Force -Confirm:$false
18}
19
20function Local-Machine {
21param (
22[string]$files
23);
24Build-Ginkgo
25if ($files) {
26$files = " --focus-file $files "
27}
28
29Run-Command "./test/tools/build/ginkgo.exe -vv --tags `"$remotetags`" -timeout=90m --trace --no-color $files pkg/machine/e2e/."
30}
31
32# Expect starting directory to be /podman
33function Win-SSHProxy {
34param (
35[string]$Version
36);
37
38New-Item -ItemType Directory -Force -Path "./bin/windows"
39if (-Not $Version) {
40$Version = "v0.7.2"
41}
42curl.exe -sSL -o "./bin/windows/gvproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/gvproxy-windowsgui.exe"
43curl.exe -sSL -o "./bin/windows/win-sshproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/win-sshproxy.exe"
44}
45
46# Helpers
47function Build-Ginkgo{
48if (Test-Path -Path ./test/tools/build/ginkgo.exe -PathType Leaf) {
49return
50}
51Write-Host "Building Ginkgo"
52Push-Location ./test/tools
53Run-Command "go build -o build/ginkgo.exe ./vendor/github.com/onsi/ginkgo/v2/ginkgo"
54Pop-Location
55}
56
57function Git-Commit{
58# git is not installed by default on windows,
59# so if we can't get the commit, we don't include this info
60Get-Command git -ErrorAction SilentlyContinue | out-null
61if(!$?){
62return
63}
64$commit = git rev-parse HEAD
65$dirty = git status --porcelain --untracked-files=no
66if ($dirty){
67$commit = "$commit-dirty"
68}
69return $commit
70}
71
72# Init script
73$target = $args[0]
74
75$remotetags = "remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp"
76
77switch ($target) {
78{$_ -in '', 'podman-remote', 'podman'} {
79Podman-Remote
80}
81'localmachine' {
82if ($args.Count -gt 1) {
83$files = $args[1]
84}
85Local-Machine -files $files
86}
87'clean' {
88Make-Clean
89}
90{$_ -in 'win-sshproxy', 'win-gvproxy'} {
91if ($args.Count -gt 1) {
92$ref = $args[1]
93}
94Win-SSHProxy -Ref $ref
95}
96default {
97Write-Host "Usage: " $MyInvocation.MyCommand.Name "<target> [options]"
98Write-Host
99Write-Host "Example: Build podman-remote "
100Write-Host " .\winmake podman-remote"
101Write-Host
102Write-Host "Example: Run all machine tests "
103Write-Host " .\winmake localmachine"
104Write-Host
105Write-Host "Example: Run specfic machine tests "
106Write-Host " .\winmake localmachine "basic_test.go""
107Write-Host
108Write-Host "Example: Download win-gvproxy and win-sshproxy helpers"
109Write-Host " .\winmake win-gvproxy"
110}
111}
112