internal/rosa/go: migrate to generic helper
All checks were successful
Test / Create distribution (push) Successful in 1m9s
Test / ShareFS (push) Successful in 9m41s
Test / Sandbox (race detector) (push) Successful in 10m9s
Test / Hakurei (race detector) (push) Successful in 12m44s
Test / Sandbox (push) Successful in 1m35s
Test / Hakurei (push) Successful in 2m38s
Test / Flake checks (push) Successful in 1m20s
All checks were successful
Test / Create distribution (push) Successful in 1m9s
Test / ShareFS (push) Successful in 9m41s
Test / Sandbox (race detector) (push) Successful in 10m9s
Test / Hakurei (race detector) (push) Successful in 12m44s
Test / Sandbox (push) Successful in 1m35s
Test / Hakurei (push) Successful in 2m38s
Test / Flake checks (push) Successful in 1m20s
The go toolchain predates all abstractions currently available. This migration causes rebuilds due to internal cleanups affecting the final build script. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -8,89 +8,111 @@ import (
|
|||||||
|
|
||||||
var _go = H("go")
|
var _go = H("go")
|
||||||
|
|
||||||
// newGoBootstrap returns the Go bootstrap toolchain.
|
|
||||||
func (t Toolchain) newGoBootstrap() pkg.Artifact {
|
|
||||||
const checksum = "8o9JL_ToiQKadCTb04nvBDkp8O1xiWOolAxVEqaTGodieNe4lOFEjlOxN3bwwe23"
|
|
||||||
return t.New("go1.4-bootstrap", 0, t.Append(nil,
|
|
||||||
_bash,
|
|
||||||
), nil, []string{
|
|
||||||
"CGO_ENABLED=0",
|
|
||||||
}, `
|
|
||||||
mkdir -p /var/tmp/ /work/system/
|
|
||||||
cp -r /usr/src/go /work/system/
|
|
||||||
cd /work/system/go/src
|
|
||||||
chmod -R +w ..
|
|
||||||
|
|
||||||
./make.bash
|
|
||||||
`, pkg.Path(AbsUsrSrc.Append("go"), false, newTar(
|
|
||||||
"https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz",
|
|
||||||
checksum,
|
|
||||||
pkg.TarGzip,
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// newGo returns a specific version of the Go toolchain.
|
// newGo returns a specific version of the Go toolchain.
|
||||||
func (t Toolchain) newGo(
|
func (t Toolchain) newGo(
|
||||||
version, checksum string,
|
version, checksum string,
|
||||||
env []string,
|
env []string,
|
||||||
script string,
|
script string,
|
||||||
extra ...pkg.Artifact,
|
boot pkg.Artifact,
|
||||||
) pkg.Artifact {
|
) pkg.Artifact {
|
||||||
name := "all"
|
return t.NewPackage("go", version, newTar(
|
||||||
if t.opts&OptSkipCheck != 0 {
|
"https://go.dev/dl/go"+version+".src.tar.gz",
|
||||||
name = "make"
|
checksum,
|
||||||
}
|
pkg.TarGzip,
|
||||||
return t.New("go"+version, 0, t.Append(extra,
|
), &PackageAttr{
|
||||||
_bash,
|
EnterSource: true,
|
||||||
), nil, slices.Concat([]string{
|
Env: slices.Concat([]string{
|
||||||
"CC=cc",
|
"CC=cc",
|
||||||
"GOCACHE=/tmp/gocache",
|
"GOCACHE=/tmp/gocache",
|
||||||
"GOROOT_BOOTSTRAP=/system/go",
|
"GOROOT_BOOTSTRAP=/system/go",
|
||||||
"TMPDIR=/dev/shm/go",
|
"TMPDIR=/dev/shm/go",
|
||||||
}, env), `
|
}, env),
|
||||||
mkdir /work/system "${TMPDIR}"
|
|
||||||
cp -r /usr/src/go /work/system
|
Extra: []pkg.Artifact{boot},
|
||||||
cd /work/system/go/src
|
}, &GenericHelper{
|
||||||
|
InPlace: true,
|
||||||
|
Build: `
|
||||||
|
mkdir /work/system/ "${TMPDIR}"
|
||||||
|
cp -r . /work/system/go
|
||||||
|
cd /work/system/go/src/
|
||||||
chmod -R +w ..
|
chmod -R +w ..
|
||||||
`+script+`
|
` + script + `
|
||||||
./`+name+`.bash
|
set +u
|
||||||
|
. ./make.bash "$@" --no-banner
|
||||||
|
set -u
|
||||||
|
`,
|
||||||
|
Check: "bash run.bash --no-rebuild\n",
|
||||||
|
Install: `
|
||||||
|
../bin/go tool dist banner # print build info
|
||||||
|
|
||||||
mkdir /work/system/bin
|
mkdir /work/system/bin
|
||||||
ln -s \
|
ln -s \
|
||||||
../go/bin/go \
|
../go/bin/go \
|
||||||
../go/bin/gofmt \
|
../go/bin/gofmt \
|
||||||
/work/system/bin
|
/work/system/bin
|
||||||
`, pkg.Path(AbsUsrSrc.Append("go"), false, newTar(
|
`,
|
||||||
"https://go.dev/dl/go"+version+".src.tar.gz",
|
},
|
||||||
checksum,
|
_bash,
|
||||||
pkg.TarGzip,
|
)
|
||||||
)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Toolchain) newGoLatest() (pkg.Artifact, string) {
|
func init() {
|
||||||
var (
|
const (
|
||||||
bootstrapEnv []string
|
version = "1.26.3"
|
||||||
bootstrapExtra []pkg.Artifact
|
checksum = "lEiFocZFnN5fKvZzmwVdqc9pYUjAuhzqZGbuiOqxUP4XdcY8yECisKcqsQ_eNn1N"
|
||||||
|
|
||||||
finalEnv []string
|
|
||||||
)
|
)
|
||||||
switch t.arch {
|
meta := Metadata{
|
||||||
case "amd64":
|
Name: "go",
|
||||||
bootstrapExtra = append(bootstrapExtra, t.newGoBootstrap())
|
Description: "the Go programming language toolchain",
|
||||||
|
Website: "https://go.dev",
|
||||||
|
Version: version,
|
||||||
|
|
||||||
case "arm64", "riscv64":
|
ID: 1227,
|
||||||
bootstrapEnv = append(bootstrapEnv, "GOROOT_BOOTSTRAP=/system")
|
|
||||||
bootstrapExtra = t.Append(bootstrapExtra, H("gcc"))
|
|
||||||
finalEnv = append(finalEnv, "CGO_ENABLED=0")
|
|
||||||
|
|
||||||
default:
|
|
||||||
panic("unsupported target " + t.arch)
|
|
||||||
}
|
}
|
||||||
|
native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
|
||||||
|
var (
|
||||||
|
bootstrapEnv []string
|
||||||
|
bootstrapEarly pkg.Artifact
|
||||||
|
|
||||||
go119 := t.newGo(
|
finalEnv []string
|
||||||
"1.19",
|
)
|
||||||
"9_e0aFHsIkVxWVGsp9T2RvvjOc3p4n9o9S8tkNe9Cvgzk_zI2FhRQB7ioQkeAAro",
|
switch t.arch {
|
||||||
append(bootstrapEnv, "CGO_ENABLED=0"), `
|
case "amd64":
|
||||||
|
bootstrapEarly = t.NewPackage("go", "1.4-bootstrap", newTar(
|
||||||
|
"https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz",
|
||||||
|
"8o9JL_ToiQKadCTb04nvBDkp8O1xiWOolAxVEqaTGodieNe4lOFEjlOxN3bwwe23",
|
||||||
|
pkg.TarGzip,
|
||||||
|
), &PackageAttr{
|
||||||
|
EnterSource: true,
|
||||||
|
Env: []string{
|
||||||
|
"CGO_ENABLED=0",
|
||||||
|
},
|
||||||
|
}, &GenericHelper{
|
||||||
|
InPlace: true,
|
||||||
|
Build: `
|
||||||
|
mkdir /work/system/
|
||||||
|
cp -r . /work/system/go
|
||||||
|
cd /work/system/go/src/
|
||||||
|
mkdir -p /var/tmp/
|
||||||
|
./make.bash
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
_bash,
|
||||||
|
)
|
||||||
|
|
||||||
|
case "arm64", "riscv64":
|
||||||
|
bootstrapEnv = append(bootstrapEnv, "GOROOT_BOOTSTRAP=/system")
|
||||||
|
_, bootstrapEarly = t.MustLoad(H("gcc"))
|
||||||
|
finalEnv = append(finalEnv, "CGO_ENABLED=0")
|
||||||
|
|
||||||
|
default:
|
||||||
|
panic("unsupported target " + t.arch)
|
||||||
|
}
|
||||||
|
|
||||||
|
go119 := t.newGo(
|
||||||
|
"1.19",
|
||||||
|
"9_e0aFHsIkVxWVGsp9T2RvvjOc3p4n9o9S8tkNe9Cvgzk_zI2FhRQB7ioQkeAAro",
|
||||||
|
append(bootstrapEnv, "CGO_ENABLED=0"), `
|
||||||
rm \
|
rm \
|
||||||
crypto/tls/handshake_client_test.go \
|
crypto/tls/handshake_client_test.go \
|
||||||
cmd/pprof/pprof_test.go \
|
cmd/pprof/pprof_test.go \
|
||||||
@@ -101,12 +123,12 @@ sed -i \
|
|||||||
echo \
|
echo \
|
||||||
'type syscallDescriptor = int' >> \
|
'type syscallDescriptor = int' >> \
|
||||||
os/rawconn_test.go
|
os/rawconn_test.go
|
||||||
`, bootstrapExtra...)
|
`, bootstrapEarly)
|
||||||
|
|
||||||
go121 := t.newGo(
|
go121 := t.newGo(
|
||||||
"1.21.13",
|
"1.21.13",
|
||||||
"YtrDka402BOAEwywx03Vz4QlVwoBiguJHzG7PuythMCPHXS8CVMLvzmvgEbu4Tzu",
|
"YtrDka402BOAEwywx03Vz4QlVwoBiguJHzG7PuythMCPHXS8CVMLvzmvgEbu4Tzu",
|
||||||
[]string{"CGO_ENABLED=0"}, `
|
[]string{"CGO_ENABLED=0"}, `
|
||||||
sed -i \
|
sed -i \
|
||||||
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
|
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
|
||||||
cmd/link/internal/`+t.arch+`/obj.go
|
cmd/link/internal/`+t.arch+`/obj.go
|
||||||
@@ -119,22 +141,22 @@ echo \
|
|||||||
'type syscallDescriptor = int' >> \
|
'type syscallDescriptor = int' >> \
|
||||||
os/rawconn_test.go
|
os/rawconn_test.go
|
||||||
`, go119,
|
`, go119,
|
||||||
)
|
)
|
||||||
|
|
||||||
go123 := t.newGo(
|
go123 := t.newGo(
|
||||||
"1.23.12",
|
"1.23.12",
|
||||||
"wcI32bl1tkqbgcelGtGWPI4RtlEddd-PTd76Eb-k7nXA5LbE9yTNdIL9QSOOxMOs",
|
"wcI32bl1tkqbgcelGtGWPI4RtlEddd-PTd76Eb-k7nXA5LbE9yTNdIL9QSOOxMOs",
|
||||||
[]string{"CGO_ENABLED=0"}, `
|
[]string{"CGO_ENABLED=0"}, `
|
||||||
sed -i \
|
sed -i \
|
||||||
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
|
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
|
||||||
cmd/link/internal/`+t.arch+`/obj.go
|
cmd/link/internal/`+t.arch+`/obj.go
|
||||||
`, go121,
|
`, go121,
|
||||||
)
|
)
|
||||||
|
|
||||||
go125 := t.newGo(
|
go125 := t.newGo(
|
||||||
"1.25.10",
|
"1.25.10",
|
||||||
"TwKwatkpwal-j9U2sDSRPEdM3YesI4Gm88YgGV59wtU-L85K9gA7UPy9SCxn6PMb",
|
"TwKwatkpwal-j9U2sDSRPEdM3YesI4Gm88YgGV59wtU-L85K9gA7UPy9SCxn6PMb",
|
||||||
[]string{"CGO_ENABLED=0"}, `
|
[]string{"CGO_ENABLED=0"}, `
|
||||||
sed -i \
|
sed -i \
|
||||||
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
|
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
|
||||||
cmd/link/internal/`+t.arch+`/obj.go
|
cmd/link/internal/`+t.arch+`/obj.go
|
||||||
@@ -143,16 +165,12 @@ rm \
|
|||||||
os/root_unix_test.go \
|
os/root_unix_test.go \
|
||||||
net/smtp/smtp_test.go
|
net/smtp/smtp_test.go
|
||||||
`, go123,
|
`, go123,
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
return &meta, t.newGo(
|
||||||
version = "1.26.3"
|
version,
|
||||||
checksum = "lEiFocZFnN5fKvZzmwVdqc9pYUjAuhzqZGbuiOqxUP4XdcY8yECisKcqsQ_eNn1N"
|
checksum,
|
||||||
)
|
finalEnv, `
|
||||||
return t.newGo(
|
|
||||||
version,
|
|
||||||
checksum,
|
|
||||||
finalEnv, `
|
|
||||||
sed -i \
|
sed -i \
|
||||||
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
|
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
|
||||||
cmd/link/internal/`+t.arch+`/obj.go
|
cmd/link/internal/`+t.arch+`/obj.go
|
||||||
@@ -165,14 +183,7 @@ rm \
|
|||||||
cmd/cgo/internal/testsanitizers/tsan_test.go \
|
cmd/cgo/internal/testsanitizers/tsan_test.go \
|
||||||
cmd/cgo/internal/testsanitizers/cshared_test.go
|
cmd/cgo/internal/testsanitizers/cshared_test.go
|
||||||
`, go125,
|
`, go125,
|
||||||
), version
|
)
|
||||||
}
|
|
||||||
func init() {
|
|
||||||
native.mustRegister(Toolchain.newGoLatest, &Metadata{
|
|
||||||
Name: "go",
|
|
||||||
Description: "the Go programming language toolchain",
|
|
||||||
Website: "https://go.dev/",
|
|
||||||
|
|
||||||
ID: 1227,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ go build -o /bin/hostname /usr/src/hostname/main.go
|
|||||||
return t.NewPackage(name, hakureiVersion, t.NewPatchedSource(
|
return t.NewPackage(name, hakureiVersion, t.NewPatchedSource(
|
||||||
"hakurei-"+hakureiVersion, hakureiSource, false, hakureiPatches...,
|
"hakurei-"+hakureiVersion, hakureiSource, false, hakureiPatches...,
|
||||||
), &PackageAttr{
|
), &PackageAttr{
|
||||||
Writable: true,
|
EnterSource: true,
|
||||||
|
Writable: true,
|
||||||
Env: []string{
|
Env: []string{
|
||||||
"CGO_ENABLED=1",
|
"CGO_ENABLED=1",
|
||||||
"GOCACHE=/tmp/gocache",
|
"GOCACHE=/tmp/gocache",
|
||||||
@@ -42,6 +43,7 @@ func main() {
|
|||||||
`),
|
`),
|
||||||
))},
|
))},
|
||||||
}, &GenericHelper{
|
}, &GenericHelper{
|
||||||
|
InPlace: true,
|
||||||
Build: hostname + `
|
Build: hostname + `
|
||||||
HAKUREI_VERSION='v` + hakureiVersion + `'
|
HAKUREI_VERSION='v` + hakureiVersion + `'
|
||||||
` + build,
|
` + build,
|
||||||
|
|||||||
@@ -413,6 +413,8 @@ type PackageAttr struct {
|
|||||||
// Passed to [Toolchain.NewPatchedSource].
|
// Passed to [Toolchain.NewPatchedSource].
|
||||||
Patches []KV
|
Patches []KV
|
||||||
|
|
||||||
|
// Unregistered extras.
|
||||||
|
Extra []pkg.Artifact
|
||||||
// Passed through to [Toolchain.New], before source.
|
// Passed through to [Toolchain.New], before source.
|
||||||
Paths []pkg.ExecPath
|
Paths []pkg.ExecPath
|
||||||
// Passed through to [Toolchain.New].
|
// Passed through to [Toolchain.New].
|
||||||
@@ -481,7 +483,8 @@ func (t Toolchain) NewPackage(
|
|||||||
rn = name + "-" + version
|
rn = name + "-" + version
|
||||||
}
|
}
|
||||||
wantsChmod, wantsWrite := helper.wantsChmod(), helper.wantsWrite()
|
wantsChmod, wantsWrite := helper.wantsChmod(), helper.wantsWrite()
|
||||||
extraRes := make([]pkg.Artifact, 0, 1<<3+len(extra))
|
extraRes := make([]pkg.Artifact, 0, 1<<3+len(attr.Extra)+len(extra))
|
||||||
|
extraRes = append(extraRes, attr.Extra...)
|
||||||
{
|
{
|
||||||
pv := paGet()
|
pv := paGet()
|
||||||
for _, p := range helper.extra(attr.Flag) {
|
for _, p := range helper.extra(attr.Flag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user