Skip to content

Commit

Permalink
bb: always build with GO111MODULE=off
Browse files Browse the repository at this point in the history
Now that findpkg has dropped support for finding packages that are not
also found by `go list`, we can simplify busybox module resolution as
well.

To support workspaces, modules, and no-module compilation, we query `go
list` for all dependencies, write them to the temporary directory, and
build with `GO111MODULE=off`. This means we will always support offline
compilation (E.g. a vendored workspace or a vendored module will remain
offline.)

Signed-off-by: Chris Koch <chrisko@google.com>
  • Loading branch information
hugelgupf committed Feb 24, 2024
1 parent 6734996 commit 1102213
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 521 deletions.
3 changes: 0 additions & 3 deletions gobuilds.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash
set -eux

# This one hasn't been migrated to the go test yet.
(cd ./test/requestconflict && ./test.sh)

(cd ./src/cmd/makebb && GO111MODULE=on go build .)
(cd ./test && go test --makebb=../src/cmd/makebb/makebb -v)
11 changes: 1 addition & 10 deletions src/cmd/makebb/makebb.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,7 @@ func main() {
GenerateOnly: *genOnly,
}
if err := bb.BuildBusybox(l, opts); err != nil {
l.Print(err)
var errGopath *bb.ErrGopathBuild
var errGomod *bb.ErrModuleBuild
if errors.As(err, &errGopath) {
l.Fatalf("Preserving bb generated source directory at %s due to error. To reproduce build, `cd %s` and `GO111MODULE=off GOPATH=%s go build`.", tmpDir, errGopath.CmdDir, errGopath.GOPATH)
} else if errors.As(err, &errGomod) {
l.Fatalf("Preserving bb generated source directory at %s due to error. To debug build, `cd %s` and use `go build` to build, or `go mod [why|tidy|graph]` to debug dependencies, or `go list -m all` to list all dependency versions.", tmpDir, errGomod.CmdDir)
} else {
l.Fatalf("Preserving bb generated source directory at %s due to error.", tmpDir)
}
l.Fatalf("Preserving bb generated source directory at %s due to error: %v", tmpDir, err)
} else if opts.GenerateOnly {
l.Printf("Generated source can be found in %s. `cd %s && go build` to build.", tmpDir, filepath.Join(tmpDir, "src/bb.u-root.com/bb"))
}
Expand Down
4 changes: 2 additions & 2 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/u-root/gobusybox/src
go 1.20

require (
github.com/google/goterm v0.0.0-20200907032337-555d40f16ae2
github.com/u-root/uio v0.0.0-20210528151154-e40b768296a7
golang.org/x/mod v0.14.0
golang.org/x/tools v0.16.1
)

require golang.org/x/mod v0.14.0 // indirect
2 changes: 0 additions & 2 deletions src/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
github.com/google/goterm v0.0.0-20200907032337-555d40f16ae2 h1:CVuJwN34x4xM2aT4sIKhmeib40NeBPhRihNjQmpJsA4=
github.com/google/goterm v0.0.0-20200907032337-555d40f16ae2/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4=
github.com/u-root/uio v0.0.0-20210528151154-e40b768296a7 h1:XMAtQHwKjWHIRwg+8Nj/rzUomQY1q6cM3ncA0wP8GU4=
github.com/u-root/uio v0.0.0-20210528151154-e40b768296a7/go.mod h1:LpEX5FO/cB+WF4TYGY1V5qktpaZLkKkSegbr0V4eYXA=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
Expand Down
Loading

0 comments on commit 1102213

Please sign in to comment.