From b5cd55c888b95061f598492955e280b384fd7f70 Mon Sep 17 00:00:00 2001 From: Chris Koch Date: Sun, 28 Jan 2024 21:27:13 +0000 Subject: [PATCH 1/3] Remove some architecture tests Not necessary to test that many in this module. Signed-off-by: Chris Koch --- cmd/mkuimage/main_test.go | 54 --------------------------------------- 1 file changed, 54 deletions(-) diff --git a/cmd/mkuimage/main_test.go b/cmd/mkuimage/main_test.go index 9e75e32..a262876 100644 --- a/cmd/mkuimage/main_test.go +++ b/cmd/mkuimage/main_test.go @@ -144,42 +144,6 @@ func TestUrootCmdline(t *testing.T) { "github.com/u-root/u-root/cmds/core/echo", }, }, - { - name: "MIPS build", - env: []string{"GOARCH=mips"}, - args: []string{ - "github.com/u-root/u-root/cmds/core/init", - "github.com/u-root/u-root/cmds/core/elvish", - "github.com/u-root/u-root/cmds/core/echo", - }, - }, - { - name: "MIPSLE build", - env: []string{"GOARCH=mipsle"}, - args: []string{ - "github.com/u-root/u-root/cmds/core/init", - "github.com/u-root/u-root/cmds/core/elvish", - "github.com/u-root/u-root/cmds/core/echo", - }, - }, - { - name: "MIPS64 build", - env: []string{"GOARCH=mips64"}, - args: []string{ - "github.com/u-root/u-root/cmds/core/init", - "github.com/u-root/u-root/cmds/core/elvish", - "github.com/u-root/u-root/cmds/core/echo", - }, - }, - { - name: "MIPS64LE build", - env: []string{"GOARCH=mips64le"}, - args: []string{ - "github.com/u-root/u-root/cmds/core/init", - "github.com/u-root/u-root/cmds/core/elvish", - "github.com/u-root/u-root/cmds/core/echo", - }, - }, { name: "ARM7 build", env: []string{"GOARCH=arm", "GOARM=7"}, @@ -198,24 +162,6 @@ func TestUrootCmdline(t *testing.T) { "github.com/u-root/u-root/cmds/core/echo", }, }, - { - name: "386 (32 bit) build", - env: []string{"GOARCH=386"}, - args: []string{ - "github.com/u-root/u-root/cmds/core/init", - "github.com/u-root/u-root/cmds/core/elvish", - "github.com/u-root/u-root/cmds/core/echo", - }, - }, - { - name: "Power 64bit build", - env: []string{"GOARCH=ppc64le"}, - args: []string{ - "github.com/u-root/u-root/cmds/core/init", - "github.com/u-root/u-root/cmds/core/elvish", - "github.com/u-root/u-root/cmds/core/echo", - }, - }, { name: "RISCV 64bit build", env: []string{"GOARCH=riscv64"}, From 1342cde4652533af448352223775c89f548e5c26 Mon Sep 17 00:00:00 2001 From: Chris Koch Date: Sun, 28 Jan 2024 21:28:38 +0000 Subject: [PATCH 2/3] Move BuildOpts -- allow specifying different BuildOpts for different commands Signed-off-by: Chris Koch --- cmd/mkuimage/main.go | 6 +++--- uroot/uroot.go | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/mkuimage/main.go b/cmd/mkuimage/main.go index 31b91e4..cdab1f8 100644 --- a/cmd/mkuimage/main.go +++ b/cmd/mkuimage/main.go @@ -350,8 +350,9 @@ func Main(l ulog.Logger, env *golang.Environ, buildOpts *golang.BuildOpts) error // The command-line tool only allows specifying one build mode // right now. c = append(c, uroot.Commands{ - Builder: b, - Packages: pkgs, + Builder: b, + Packages: pkgs, + BuildOpts: buildOpts, }) } @@ -366,7 +367,6 @@ func Main(l ulog.Logger, env *golang.Environ, buildOpts *golang.BuildOpts) error UseExistingInit: *useExistingInit, InitCmd: initCommand, DefaultShell: *defaultShell, - BuildOpts: buildOpts, } uinitArgs := shlex.Split(*uinitCmd) if len(uinitArgs) > 0 { diff --git a/uroot/uroot.go b/uroot/uroot.go index 5e528c7..6f0768c 100644 --- a/uroot/uroot.go +++ b/uroot/uroot.go @@ -103,6 +103,10 @@ type Commands struct { // BinaryDir may be empty, in which case Builder.DefaultBinaryDir() // will be used. BinaryDir string + + // Build options for building go binaries. Ultimate this holds all the + // args that end up being passed to `go build`. + BuildOpts *golang.BuildOpts } // TargetDir returns the initramfs binary directory for these Commands. @@ -224,10 +228,6 @@ type Opts struct { // // This must be specified to have a default shell. DefaultShell string - - // Build options for building go binaries. Ultimate this holds all the - // args that end up being passed to `go build`. - BuildOpts *golang.BuildOpts } // CreateInitramfs creates an initramfs built to opts' specifications. @@ -243,10 +243,6 @@ func CreateInitramfs(logger ulog.Logger, opts Opts) error { if opts.Env != nil { env = opts.Env } - if opts.BuildOpts == nil { - opts.BuildOpts = &golang.BuildOpts{} - } - files := initramfs.NewFiles() lookupEnv := findpkg.DefaultEnv() @@ -269,11 +265,15 @@ func CreateInitramfs(logger ulog.Logger, opts Opts) error { if err != nil { return err } + buildOpts := cmds.BuildOpts + if buildOpts == nil { + buildOpts = &golang.BuildOpts{} + } // Build packages. bOpts := builder.Opts{ Env: env, - BuildOpts: opts.BuildOpts, + BuildOpts: buildOpts, Packages: cmds.Packages, TempDir: builderTmpDir, BinaryDir: cmds.TargetDir(), From fbf6265998e29854763a2f611a775791ae603c45 Mon Sep 17 00:00:00 2001 From: Chris Koch Date: Sun, 28 Jan 2024 21:29:35 +0000 Subject: [PATCH 3/3] Remove old busybox warning Signed-off-by: Chris Koch --- cmd/mkuimage/main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/mkuimage/main.go b/cmd/mkuimage/main.go index cdab1f8..156eaa8 100644 --- a/cmd/mkuimage/main.go +++ b/cmd/mkuimage/main.go @@ -319,7 +319,6 @@ func Main(l ulog.Logger, env *golang.Environ, buildOpts *golang.BuildOpts) error var b builder.Builder switch *build { case "bb", "gbb": - l.Printf("NOTE: building with the new gobusybox; to get the old behavior check out commit 8b790de") b = builder.GBBBuilder{ShellBang: *shellbang} case "binary": b = builder.BinaryBuilder{}