diff --git a/cmd/mkuimage/main.go b/cmd/mkuimage/main.go index cdc7f07..7bfed17 100644 --- a/cmd/mkuimage/main.go +++ b/cmd/mkuimage/main.go @@ -12,14 +12,11 @@ import ( "log" "log/slog" "os" - "runtime" - "strings" "github.com/dustin/go-humanize" "github.com/u-root/gobusybox/src/pkg/golang" "github.com/u-root/mkuimage/uimage" - "github.com/u-root/mkuimage/uimage/builder" - "github.com/u-root/mkuimage/uimage/uflags" + "github.com/u-root/mkuimage/uimage/mkuimage" "github.com/u-root/uio/llog" ) @@ -68,8 +65,8 @@ func main() { } env := golang.Default(golang.DisableCGO()) - f := &uflags.Flags{ - Commands: uflags.CommandFlags{ + f := &mkuimage.Flags{ + Commands: mkuimage.CommandFlags{ Builder: "bb", BuildOpts: &golang.BuildOpts{}, }, @@ -84,15 +81,14 @@ func main() { l.RegisterVerboseFlag(flag.CommandLine, "v", slog.LevelDebug) flag.Parse() - l.Infof("Build environment: %s", env) - if env.GOOS != "linux" { - l.Warnf("GOOS is not linux. Did you mean to set GOOS=linux?") + m := []uimage.Modifier{ + uimage.WithReplaceEnv(env), + uimage.WithBaseArchive(uimage.DefaultRamfs()), + uimage.WithCPIOOutput(defaultFile(env)), } - - // Main is in a separate functions so defers run on return. - if err := Main(l, env, f); err != nil { - l.Errorf("Build error: %v", err) - return + if err := mkuimage.CreateUimage(l, m, f, flag.Args()); err != nil { + l.Errorf("mkuimage error: %v", err) + os.Exit(1) } if stat, err := os.Stat(f.OutputFile); err == nil && f.ArchiveFormat == "cpio" { @@ -100,79 +96,9 @@ func main() { } } -var recommendedVersions = []string{ - "go1.20", - "go1.21", - "go1.22", -} - -func isRecommendedVersion(v string) bool { - for _, r := range recommendedVersions { - if strings.HasPrefix(v, r) { - return true - } - } - return false -} - func defaultFile(env *golang.Environ) string { if len(env.GOOS) == 0 || len(env.GOARCH) == 0 { return "/tmp/initramfs.cpio" } return fmt.Sprintf("/tmp/initramfs.%s_%s.cpio", env.GOOS, env.GOARCH) } - -// Main is a separate function so defers are run on return, which they wouldn't -// on exit. -func Main(l *llog.Logger, env *golang.Environ, f *uflags.Flags) error { - v, err := env.Version() - if err != nil { - l.Infof("Could not get environment's Go version, using runtime's version: %v", err) - v = runtime.Version() - } - if !isRecommendedVersion(v) { - l.Warnf(`You are not using one of the recommended Go versions (have = %s, recommended = %v). - Some packages may not compile. - Go to https://golang.org/doc/install to find out how to install a newer version of Go, - or use https://godoc.org/golang.org/dl/%s to install an additional version of Go.`, - v, recommendedVersions, recommendedVersions[0]) - } - - keepTempDir := f.KeepTempDir - if f.TempDir == "" { - var err error - f.TempDir, err = os.MkdirTemp("", "u-root") - if err != nil { - return err - } - defer func() { - if keepTempDir { - l.Infof("Keeping temp dir %s", f.TempDir) - } else { - os.RemoveAll(f.TempDir) - } - }() - } else if _, err := os.Stat(f.TempDir); os.IsNotExist(err) { - if err := os.MkdirAll(f.TempDir, 0o755); err != nil { - return fmt.Errorf("temporary directory %q did not exist; tried to mkdir but failed: %v", f.TempDir, err) - } - } - - // Set defaults. - m := []uimage.Modifier{ - uimage.WithReplaceEnv(env), - uimage.WithBaseArchive(uimage.DefaultRamfs()), - uimage.WithCPIOOutput(defaultFile(env)), - } - more, err := f.Modifiers(flag.Args()...) - if err != nil { - return err - } - - err = uimage.Create(l, append(m, more...)...) - if errors.Is(err, builder.ErrBusyboxFailed) { - l.Errorf("Preserving temp dir due to busybox build error") - keepTempDir = true - } - return err -} diff --git a/cmd/mkuimage/main_test.go b/cmd/mkuimage/main_test.go index efd5b65..f53a47d 100644 --- a/cmd/mkuimage/main_test.go +++ b/cmd/mkuimage/main_test.go @@ -13,7 +13,9 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "strings" + "syscall" "testing" "github.com/u-root/gobusybox/src/pkg/golang" @@ -22,9 +24,29 @@ import ( "golang.org/x/sync/errgroup" ) -var twocmds = []string{ - "github.com/u-root/u-root/cmds/core/ls", - "github.com/u-root/u-root/cmds/core/init", +func hasTempDir(t *testing.T, output string) { + t.Helper() + tempDir := regexp.MustCompile(`Keeping temp dir (.+)`).FindStringSubmatch(output) + if tempDir == nil { + t.Errorf("Keeping temp dir not found in output") + return + } + if fi, err := os.Stat(tempDir[1]); err != nil { + t.Error(err) + } else if !fi.IsDir() { + t.Errorf("Stat(%s) = %v, want directory", tempDir[1], fi) + } +} + +func dirExists(name string) func(t *testing.T, output string) { + return func(t *testing.T, output string) { + t.Helper() + if fi, err := os.Stat(name); err != nil { + t.Error(err) + } else if !fi.IsDir() { + t.Errorf("Stat(%s) = %v, want directory", name, fi) + } + } } func TestUrootCmdline(t *testing.T) { @@ -60,13 +82,15 @@ func TestUrootCmdline(t *testing.T) { if err = os.WriteFile(filepath.Join(sampledir, "bar"), nil, 0o644); err != nil { t.Fatal(err) } + tempDir := filepath.Join(t.TempDir(), "tempdir") type testCase struct { name string env []string args []string - err error + exitCode int validators []itest.ArchiveValidator + wantOutput func(*testing.T, string) } noCmdTests := []testCase{ @@ -74,7 +98,6 @@ func TestUrootCmdline(t *testing.T) { name: "include one extra file", args: []string{"-nocmd", "-files=/bin/bash"}, env: []string{"GO111MODULE=off"}, - err: nil, validators: []itest.ArchiveValidator{ itest.HasFile{Path: "bin/bash"}, }, @@ -83,7 +106,6 @@ func TestUrootCmdline(t *testing.T) { name: "fix usage of an absolute path", args: []string{"-nocmd", fmt.Sprintf("-files=%s:/bin", sampledir)}, env: []string{"GO111MODULE=off"}, - err: nil, validators: []itest.ArchiveValidator{ itest.HasFile{Path: "/bin/foo"}, itest.HasFile{Path: "/bin/bar"}, @@ -122,7 +144,6 @@ func TestUrootCmdline(t *testing.T) { { name: "uinitcmd", args: []string{"-uinitcmd=echo foobar fuzz", "-defaultsh=", "github.com/u-root/u-root/cmds/core/init", "github.com/u-root/u-root/cmds/core/echo"}, - err: nil, validators: []itest.ArchiveValidator{ itest.HasRecord{R: cpio.Symlink("bin/uinit", "../bbin/echo")}, itest.HasContent{ @@ -133,8 +154,12 @@ func TestUrootCmdline(t *testing.T) { }, { name: "binary build", - args: []string{"-build=binary", "-defaultsh=", "github.com/u-root/u-root/cmds/core/init", "github.com/u-root/u-root/cmds/core/echo"}, - err: nil, + args: []string{ + "-build=binary", + "-defaultsh=", + "github.com/u-root/u-root/cmds/core/init", + "github.com/u-root/u-root/cmds/core/echo", + }, validators: []itest.ArchiveValidator{ itest.HasFile{Path: "bin/init"}, itest.HasFile{Path: "bin/echo"}, @@ -143,23 +168,41 @@ func TestUrootCmdline(t *testing.T) { }, { name: "hosted mode", - args: append([]string{"-base=/dev/null", "-defaultsh=", "-initcmd="}, twocmds...), + args: []string{ + "-base=/dev/null", + "-defaultsh=", + "-initcmd=", + "github.com/u-root/u-root/cmds/core/ls", + "github.com/u-root/u-root/cmds/core/init", + }, }, { name: "AMD64 build", env: []string{"GOARCH=amd64"}, args: []string{ + "-defaultsh=echo", + "github.com/u-root/u-root/cmds/core/echo", "github.com/u-root/u-root/cmds/core/init", - "github.com/u-root/u-root/cmds/core/elvish", + }, + }, + { + name: "AMD64 build with temp dir", + env: []string{"GOARCH=amd64"}, + args: []string{ + "--keep-tmp-dir", + "--defaultsh=echo", "github.com/u-root/u-root/cmds/core/echo", + "github.com/u-root/u-root/cmds/core/init", }, + exitCode: 1, + wantOutput: hasTempDir, }, { name: "ARM7 build", env: []string{"GOARCH=arm", "GOARM=7"}, args: []string{ + "-defaultsh=", "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", }, }, @@ -167,8 +210,8 @@ func TestUrootCmdline(t *testing.T) { name: "ARM64 build", env: []string{"GOARCH=arm64"}, args: []string{ + "-defaultsh=", "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", }, }, @@ -176,11 +219,50 @@ func TestUrootCmdline(t *testing.T) { name: "RISCV 64bit build", env: []string{"GOARCH=riscv64"}, args: []string{ + "-defaultsh=", "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: "build invalid", + args: []string{ + "-build=source", + "github.com/u-root/u-root/cmds/core/init", + "github.com/u-root/u-root/cmds/core/echo", + }, + exitCode: 1, + }, + { + name: "build invalid", + args: []string{ + "-build=source", + "github.com/u-root/u-root/cmds/core/init", + "github.com/u-root/u-root/cmds/core/echo", + }, + exitCode: 1, + }, + { + name: "arch invalid preserves temp dir", + env: []string{"GOARCH=doesnotexist"}, + args: []string{ + "--defaultsh=echo", + "github.com/u-root/u-root/cmds/core/echo", + "github.com/u-root/u-root/cmds/core/init", + }, + exitCode: 1, + wantOutput: hasTempDir, + }, + { + name: "specify temp dir", + args: []string{ + "--tmp-dir=" + tempDir, + "github.com/u-root/u-root/cmds/core/echo", + "github.com/u-root/u-root/cmds/core/init", + }, + exitCode: 1, + wantOutput: dirExists(tempDir), + }, } for _, tt := range append(noCmdTests, bareTests...) { @@ -188,22 +270,35 @@ func TestUrootCmdline(t *testing.T) { t.Run(tt.name, func(t *testing.T) { var g errgroup.Group var f1, f2 *os.File + var out string var sum1, sum2 []byte g.Go(func() error { var err error - f1, sum1, err = buildIt(t, execPath, tt.args, tt.env, tt.err, gocoverdir) + f1, out, sum1, err = buildIt(t, execPath, tt.args, tt.env, gocoverdir) return err }) g.Go(func() error { var err error - f2, sum2, err = buildIt(t, execPath, tt.args, tt.env, tt.err, gocoverdir) + f2, _, sum2, err = buildIt(t, execPath, tt.args, tt.env, gocoverdir) return err }) - if err := g.Wait(); err != nil { - t.Fatal(err) + err := g.Wait() + if tt.wantOutput != nil { + tt.wantOutput(t, out) + } + + var exitErr *exec.ExitError + if errors.As(err, &exitErr) { + if ec := exitErr.Sys().(syscall.WaitStatus).ExitStatus(); ec != tt.exitCode { + t.Errorf("mkuimage exit code = %d, want %d", ec, tt.exitCode) + } + return + } else if err != nil { + t.Errorf("mkuimage failed: %v", err) + return } a, err := itest.ReadArchive(f1.Name()) @@ -225,11 +320,11 @@ func TestUrootCmdline(t *testing.T) { } } -func buildIt(t *testing.T, execPath string, args, env []string, want error, gocoverdir string) (*os.File, []byte, error) { +func buildIt(t *testing.T, execPath string, args, env []string, gocoverdir string) (*os.File, string, []byte, error) { t.Helper() initramfs, err := os.CreateTemp(t.TempDir(), "u-root-") if err != nil { - return nil, nil, err + return nil, "", nil, err } // Use the u-root command outside of the $GOPATH tree to make sure it @@ -239,19 +334,18 @@ func buildIt(t *testing.T, execPath string, args, env []string, want error, goco c := exec.Command(execPath, args...) c.Env = append(os.Environ(), env...) - c.Env = append(c.Env, golang.Default().Env()...) c.Env = append(c.Env, "GOCOVERDIR="+gocoverdir) - if out, err := c.CombinedOutput(); err != want { - return nil, nil, fmt.Errorf("Error: %v\nOutput:\n%s", err, out) - } else if err != nil { - return initramfs, nil, err + out, err := c.CombinedOutput() + t.Logf("Output:\n%s", out) + if err != nil { + return nil, string(out), nil, err } h1 := sha256.New() if _, err := io.Copy(h1, initramfs); err != nil { - return nil, nil, err + return nil, string(out), nil, err } - return initramfs, h1.Sum(nil), nil + return initramfs, string(out), h1.Sum(nil), nil } func TestCheckArgs(t *testing.T) { diff --git a/dependencies.go b/dependencies.go index 5afec72..cadf10b 100644 --- a/dependencies.go +++ b/dependencies.go @@ -9,7 +9,6 @@ package mkuimage import ( _ "github.com/u-root/u-root/cmds/core/dhclient" _ "github.com/u-root/u-root/cmds/core/echo" - _ "github.com/u-root/u-root/cmds/core/elvish" _ "github.com/u-root/u-root/cmds/core/init" _ "github.com/u-root/u-root/cmds/core/ip" _ "github.com/u-root/u-root/cmds/core/ls" diff --git a/go.mod b/go.mod index 2f12558..bb1c1b2 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/josharian/native v1.1.0 // indirect github.com/klauspost/compress v1.17.4 // indirect github.com/klauspost/pgzip v1.2.6 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect github.com/mdlayher/packet v1.1.2 // indirect github.com/mdlayher/socket v0.5.0 // indirect github.com/pierrec/lz4/v4 v4.1.14 // indirect @@ -27,8 +26,6 @@ require ( github.com/ulikunitz/xz v0.5.11 // indirect github.com/vishvananda/netlink v1.2.1-beta.2 // indirect github.com/vishvananda/netns v0.0.4 // indirect - golang.org/dl v0.0.0-20240206215513-68cc34b6ca6f // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.20.0 // indirect - src.elv.sh v0.16.0-rc1.0.20220116211855-fda62502ad7f // indirect ) diff --git a/go.sum b/go.sum index 2ef9d30..bfcee98 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,5 @@ github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= -github.com/creack/pty v1.1.15/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0= github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -25,7 +24,6 @@ github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mdlayher/packet v1.1.2 h1:3Up1NG6LZrsgDVn6X4L9Ge/iyRyxFEFD9o6Pr3Q1nQY= @@ -55,10 +53,6 @@ github.com/vishvananda/netlink v1.2.1-beta.2/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhg github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= -go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -golang.org/dl v0.0.0-20240206215513-68cc34b6ca6f h1:IWM5GianvyTx750h5TRfWms43pREUt1gQ0ZdVQdoiOM= -golang.org/dl v0.0.0-20240206215513-68cc34b6ca6f/go.mod h1:fwQ+hlTD8I6TIzOGkQqxQNfE2xqR+y7SzGaDkksVFkw= golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE= golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= @@ -69,10 +63,6 @@ golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= diff --git a/uimage/builder/binary_test.go b/uimage/builder/binary_test.go index 8b881c7..2697684 100644 --- a/uimage/builder/binary_test.go +++ b/uimage/builder/binary_test.go @@ -18,7 +18,6 @@ func TestBinaryBuild(t *testing.T) { Env: golang.Default(golang.DisableCGO()), Packages: []string{ "../../cmd/mkuimage", - "github.com/u-root/u-root/cmds/core/elvish", "github.com/u-root/u-root/cmds/core/init", "cmd/test2json", }, @@ -31,7 +30,6 @@ func TestBinaryBuild(t *testing.T) { } mustContain := []string{ - "bin/elvish", "bin/mkuimage", "bin/test2json", "bin/init", diff --git a/uimage/mkuimage/cmd.go b/uimage/mkuimage/cmd.go new file mode 100644 index 0000000..d91efe3 --- /dev/null +++ b/uimage/mkuimage/cmd.go @@ -0,0 +1,92 @@ +// Copyright 2024 the u-root Authors. All rights reserved +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mkuimage + +import ( + "errors" + "fmt" + "os" + "runtime" + "strings" + + "github.com/u-root/mkuimage/uimage" + "github.com/u-root/mkuimage/uimage/builder" + "github.com/u-root/uio/llog" +) + +var recommendedVersions = []string{ + "go1.20", + "go1.21", + "go1.22", +} + +func isRecommendedVersion(v string) bool { + for _, r := range recommendedVersions { + if strings.HasPrefix(v, r) { + return true + } + } + return false +} + +// CreateUimage creates a uimage from the given base modifiers and flags. +func CreateUimage(l *llog.Logger, base []uimage.Modifier, f *Flags, args []string) error { + keepTempDir := f.KeepTempDir + if f.TempDir == "" { + var err error + f.TempDir, err = os.MkdirTemp("", "u-root") + if err != nil { + return err + } + defer func() { + if keepTempDir { + l.Infof("Keeping temp dir %s", f.TempDir) + } else { + os.RemoveAll(f.TempDir) + } + }() + } else if _, err := os.Stat(f.TempDir); os.IsNotExist(err) { + if err := os.MkdirAll(f.TempDir, 0o755); err != nil { + return fmt.Errorf("temporary directory %q did not exist; tried to mkdir but failed: %v", f.TempDir, err) + } + } + + // Set defaults. + more, err := f.Modifiers(args...) + if err != nil { + return err + } + + opts, err := uimage.OptionsFor(append(base, more...)...) + if err != nil { + return err + } + + env := opts.Env + + l.Infof("Build environment: %s", env) + if env.GOOS != "linux" { + l.Warnf("GOOS is not linux. Did you mean to set GOOS=linux?") + } + v, err := env.Version() + if err != nil { + l.Infof("Could not get environment's Go version, using runtime's version: %v", err) + v = runtime.Version() + } + if !isRecommendedVersion(v) { + l.Warnf(`You are not using one of the recommended Go versions (have = %s, recommended = %v). + Some packages may not compile. + Go to https://golang.org/doc/install to find out how to install a newer version of Go, + or use https://godoc.org/golang.org/dl/%s to install an additional version of Go.`, + v, recommendedVersions, recommendedVersions[0]) + } + + err = opts.Create(l) + if errors.Is(err, builder.ErrBusyboxFailed) { + l.Errorf("Preserving temp dir due to busybox build error") + keepTempDir = true + } + return err +} diff --git a/uimage/uflags/uflags.go b/uimage/mkuimage/uflags.go similarity index 98% rename from uimage/uflags/uflags.go rename to uimage/mkuimage/uflags.go index 8121dab..317c96d 100644 --- a/uimage/uflags/uflags.go +++ b/uimage/mkuimage/uflags.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package uflags defines mkuimage flags. -package uflags +// Package mkuimage defines mkuimage flags and creation function. +package mkuimage import ( "flag" diff --git a/uimage/uflags/uflags_test.go b/uimage/mkuimage/uflags_test.go similarity index 97% rename from uimage/uflags/uflags_test.go rename to uimage/mkuimage/uflags_test.go index 153355d..2abc344 100644 --- a/uimage/uflags/uflags_test.go +++ b/uimage/mkuimage/uflags_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package uflags +package mkuimage import ( "errors"