Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile equiv Powershell script #20028

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions pkg/machine/qemu/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/containers/storage/pkg/lockfile"
"github.com/digitalocean/go-qemu/qmp"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)

var (
Expand Down Expand Up @@ -589,11 +588,7 @@ func (v *MachineVM) qemuPid() (int, error) {
logrus.Warnf("Reading QEMU pidfile: %v", err)
return -1, nil
}

if err := unix.Kill(pid, 0); err != nil {
if err == unix.ESRCH {
return -1, nil
}
if err := killIfFound(pid); err != nil {
ashley-cui marked this conversation as resolved.
Show resolved Hide resolved
return -1, fmt.Errorf("pinging QEMU process: %w", err)
}

Expand Down Expand Up @@ -970,7 +965,7 @@ func (v *MachineVM) Stop(_ string, _ machine.StopOptions) error {
return stopErr
}

if err := unix.Kill(qemuPid, unix.SIGKILL); err != nil {
if err := sigKill(qemuPid); err != nil {
if stopErr == nil {
return err
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/machine/qemu/machine_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ func extractTargetPath(paths []string) string {
}
return paths[0]
}

func sigKill(pid int) error {
return unix.Kill(pid, unix.SIGKILL)
}

func killIfFound(pid int) error {
if err := unix.Kill(pid, 0); err != nil {
if err == unix.ESRCH {
return nil
}
return err
}
return nil
}
8 changes: 8 additions & 0 deletions pkg/machine/qemu/machine_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ func extractTargetPath(paths []string) string {
dedup := regexp.MustCompile(`//+`)
return dedup.ReplaceAllLiteralString("/"+target, "/")
}

func sigKill(pid int) error {
return nil
}

func killIfFound(pid int) error {
return nil
}
86 changes: 86 additions & 0 deletions winmake.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Targets
function Podman-Remote{
New-Item ./bin/windows -ItemType Directory -ea 0

$buildInfo = Get-Date -UFormat %s -Millisecond 0
$buildInfo = "-X github.com/containers/podman/v4/libpod/define.buildInfo=$buildInfo "
$commit = Git-Commit
$commit = "-X github.com/containers/podman/v4/libpod/define.gitCommit=$commit "

Write-Host go build --ldflags "$commit $buildInfo " --tags "$remotetags" --o .\bin\windows\podman.exe ./cmd/podman/.
go build --ldflags "$commit $buildInfo " --tags "$remotetags" --o .\bin\windows\podman.exe ./cmd/podman/.
}

function Make-Clean{
Remove-Item ./bin -Recurse -Force -Confirm:$false
}

function Local-Machine {
param (
[string]$files
);
Build-Ginkgo
if ($files) {
$files = " --focus-file $files "
}

./test/tools/build/ginkgo.exe -vv --tags "$remotetags" -timeout=90m --trace --no-color $files pkg/machine/e2e/.
}

# Helpers
function Build-Ginkgo{
if (Test-Path -Path ./test/tools/build/ginkgo.exe -PathType Leaf) {
return
}
Push-Location ./test/tools
go build -o build/ginkgo.exe ./vendor/github.com/onsi/ginkgo/v2/ginkgo
Pop-Location
}

function Git-Commit{
# git is not installed by default on windows,
# so if we can't get the commit, we don't include this info
Get-Command git -ErrorAction SilentlyContinue | out-null
if(!$?){
return
}
$commit = git rev-parse HEAD
$dirty = git status --porcelain --untracked-files=no
if ($dirty){
$commit = "$commit-dirty"
}
return $commit
}

# Init script
$target = $args[0]

$remotetags = "remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp"
$Env:GOOS = "windows"; $Env:GOARCH = "amd64"

switch ($target) {
{$_ -in '', 'podman-remote', 'podman'} {
Podman-Remote
}
'localmachine' {
if ($args.Count -gt 1) {
$files = $args[1]
}
Local-Machine -files $files
}
'clean' {
Make-Clean
}
default {
Write-Host "Usage: " $MyInvocation.MyCommand.Name "<target> [options]"
Write-Host
Write-Host "Example: Build podman-remote "
Write-Host " .\winmake podman-remote"
Write-Host
Write-Host "Example: Run all machine tests "
Write-Host " .\winmake localmachine"
Write-Host
Write-Host "Example: Run specfic machine tests "
Write-Host " .\winmake localmachine "basic_test.go""
}
}