mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-08-03 16:00:36 +00:00
linuxkit: fix pkg build on Windows
Previously when we set `cmd.Stderr = os.Stderr`, the stderr from buildx would be mixed with the image tar, corrupting it. Work around this (Windows-specific) problem by adding an explicit indirection via a io.Pipe() Signed-off-by: David Scott <dave@recoil.org>
This commit is contained in:
parent
f5a1541e00
commit
f5f5dce318
@ -14,6 +14,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
versioncompare "github.com/hashicorp/go-version"
|
versioncompare "github.com/hashicorp/go-version"
|
||||||
@ -80,7 +81,17 @@ func (dr *dockerRunnerImpl) command(stdin io.Reader, stdout, stderr io.Writer, a
|
|||||||
stdout = os.Stdout
|
stdout = os.Stdout
|
||||||
}
|
}
|
||||||
if stderr == nil {
|
if stderr == nil {
|
||||||
stderr = os.Stderr
|
if runtime.GOOS != "windows" {
|
||||||
|
stderr = os.Stderr
|
||||||
|
} else {
|
||||||
|
// On Windows directly setting stderr to os.Stderr results in the output being written to stdout,
|
||||||
|
// corrupting the image tar. Adding an explicit indirection via a pipe works around the issue.
|
||||||
|
r, w := io.Pipe()
|
||||||
|
stderr = w
|
||||||
|
go func() {
|
||||||
|
_, _ = io.Copy(os.Stderr, r)
|
||||||
|
}()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cmd.Stdout = stdout
|
cmd.Stdout = stdout
|
||||||
cmd.Stderr = stderr
|
cmd.Stderr = stderr
|
||||||
|
Loading…
Reference in New Issue
Block a user