Skip to content

Commit 141797c

Browse files
committed
Set GOOS in generate command
Signed-off-by: Florian Lehner <dev@der-flo.net>
1 parent afe143e commit 141797c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

initramfs/init.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ func (b *Bluebox) createInit(dir string) error {
4747
cmd := exec.CommandContext(context.TODO(), "go", "build", "-o", filepath.Join(dir, "init"),
4848
f.Name())
4949

50-
cmd.Env = append(os.Environ(), fmt.Sprintf("GOARCH=%s", b.arch))
50+
cmd.Env = append(os.Environ(),
51+
fmt.Sprintf("GOARCH=%s", b.arch),
52+
"GOOS=linux",
53+
)
5154

5255
return cmd.Run()
5356
}

initramfs/initramfs.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99
"path/filepath"
1010
"runtime"
11+
"strings"
1112

1213
"github.com/cavaliergopher/cpio"
1314
)
@@ -98,7 +99,12 @@ func (b *Bluebox) Embed(file string) error {
9899
// Setarch sets the architecture for the generated initramfs archive. If the architecture is not
99100
// part of GOARCH an error will be returned. By default the architecture of the host is used.
100101
func (b *Bluebox) Setarch(arch string) error {
101-
// TODO: validate arch.
102+
arch = strings.ToLower(arch)
103+
104+
// No specific checks are done on arch at this point.
105+
// If arch is not supported, then Generate() will fail
106+
// and return an appropriate error.
107+
102108
b.arch = arch
103109
return nil
104110
}

0 commit comments

Comments
 (0)