aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/go.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-21 19:47:55 +0900
committerOphestra <cat@gensokyo.uk>2026-05-21 19:55:38 +0900
commit0914569e62089f2a9545243c529d238c662d4b04 (patch)
tree0808b7c88d19f56ab89b7a47fa29aeaccb3ae77a /internal/rosa/go.go
parent25d9edfc64a6e75f9384999416afd4791b6a716d (diff)
internal/rosa/go: migrate to generic helper
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>
Diffstat (limited to 'internal/rosa/go.go')
-rw-r--r--internal/rosa/go.go203
1 files changed, 107 insertions, 96 deletions
diff --git a/internal/rosa/go.go b/internal/rosa/go.go
index e1acbaff..bc11af9a 100644
--- a/internal/rosa/go.go
+++ b/internal/rosa/go.go
@@ -8,89 +8,111 @@ import (
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.
func (t Toolchain) newGo(
version, checksum string,
env []string,
script string,
- extra ...pkg.Artifact,
+ boot pkg.Artifact,
) pkg.Artifact {
- name := "all"
- if t.opts&OptSkipCheck != 0 {
- name = "make"
- }
- return t.New("go"+version, 0, t.Append(extra,
- _bash,
- ), nil, slices.Concat([]string{
- "CC=cc",
- "GOCACHE=/tmp/gocache",
- "GOROOT_BOOTSTRAP=/system/go",
- "TMPDIR=/dev/shm/go",
- }, env), `
-mkdir /work/system "${TMPDIR}"
-cp -r /usr/src/go /work/system
-cd /work/system/go/src
+ return t.NewPackage("go", version, newTar(
+ "https://go.dev/dl/go"+version+".src.tar.gz",
+ checksum,
+ pkg.TarGzip,
+ ), &PackageAttr{
+ EnterSource: true,
+ Env: slices.Concat([]string{
+ "CC=cc",
+ "GOCACHE=/tmp/gocache",
+ "GOROOT_BOOTSTRAP=/system/go",
+ "TMPDIR=/dev/shm/go",
+ }, env),
+
+ Extra: []pkg.Artifact{boot},
+ }, &GenericHelper{
+ InPlace: true,
+ Build: `
+mkdir /work/system/ "${TMPDIR}"
+cp -r . /work/system/go
+cd /work/system/go/src/
chmod -R +w ..
-`+script+`
-./`+name+`.bash
+` + script + `
+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
ln -s \
../go/bin/go \
../go/bin/gofmt \
/work/system/bin
-`, pkg.Path(AbsUsrSrc.Append("go"), false, newTar(
- "https://go.dev/dl/go"+version+".src.tar.gz",
- checksum,
- pkg.TarGzip,
- )))
+`,
+ },
+ _bash,
+ )
}
-func (t Toolchain) newGoLatest() (pkg.Artifact, string) {
- var (
- bootstrapEnv []string
- bootstrapExtra []pkg.Artifact
-
- finalEnv []string
+func init() {
+ const (
+ version = "1.26.3"
+ checksum = "lEiFocZFnN5fKvZzmwVdqc9pYUjAuhzqZGbuiOqxUP4XdcY8yECisKcqsQ_eNn1N"
)
- switch t.arch {
- case "amd64":
- bootstrapExtra = append(bootstrapExtra, t.newGoBootstrap())
-
- case "arm64", "riscv64":
- bootstrapEnv = append(bootstrapEnv, "GOROOT_BOOTSTRAP=/system")
- bootstrapExtra = t.Append(bootstrapExtra, H("gcc"))
- finalEnv = append(finalEnv, "CGO_ENABLED=0")
+ meta := Metadata{
+ Name: "go",
+ Description: "the Go programming language toolchain",
+ Website: "https://go.dev",
+ Version: version,
- default:
- panic("unsupported target " + t.arch)
+ ID: 1227,
}
+ native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
+ var (
+ bootstrapEnv []string
+ bootstrapEarly pkg.Artifact
- go119 := t.newGo(
- "1.19",
- "9_e0aFHsIkVxWVGsp9T2RvvjOc3p4n9o9S8tkNe9Cvgzk_zI2FhRQB7ioQkeAAro",
- append(bootstrapEnv, "CGO_ENABLED=0"), `
+ finalEnv []string
+ )
+ switch t.arch {
+ 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 \
crypto/tls/handshake_client_test.go \
cmd/pprof/pprof_test.go \
@@ -101,12 +123,12 @@ sed -i \
echo \
'type syscallDescriptor = int' >> \
os/rawconn_test.go
-`, bootstrapExtra...)
+`, bootstrapEarly)
- go121 := t.newGo(
- "1.21.13",
- "YtrDka402BOAEwywx03Vz4QlVwoBiguJHzG7PuythMCPHXS8CVMLvzmvgEbu4Tzu",
- []string{"CGO_ENABLED=0"}, `
+ go121 := t.newGo(
+ "1.21.13",
+ "YtrDka402BOAEwywx03Vz4QlVwoBiguJHzG7PuythMCPHXS8CVMLvzmvgEbu4Tzu",
+ []string{"CGO_ENABLED=0"}, `
sed -i \
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
cmd/link/internal/`+t.arch+`/obj.go
@@ -119,22 +141,22 @@ echo \
'type syscallDescriptor = int' >> \
os/rawconn_test.go
`, go119,
- )
+ )
- go123 := t.newGo(
- "1.23.12",
- "wcI32bl1tkqbgcelGtGWPI4RtlEddd-PTd76Eb-k7nXA5LbE9yTNdIL9QSOOxMOs",
- []string{"CGO_ENABLED=0"}, `
+ go123 := t.newGo(
+ "1.23.12",
+ "wcI32bl1tkqbgcelGtGWPI4RtlEddd-PTd76Eb-k7nXA5LbE9yTNdIL9QSOOxMOs",
+ []string{"CGO_ENABLED=0"}, `
sed -i \
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
cmd/link/internal/`+t.arch+`/obj.go
`, go121,
- )
+ )
- go125 := t.newGo(
- "1.25.10",
- "TwKwatkpwal-j9U2sDSRPEdM3YesI4Gm88YgGV59wtU-L85K9gA7UPy9SCxn6PMb",
- []string{"CGO_ENABLED=0"}, `
+ go125 := t.newGo(
+ "1.25.10",
+ "TwKwatkpwal-j9U2sDSRPEdM3YesI4Gm88YgGV59wtU-L85K9gA7UPy9SCxn6PMb",
+ []string{"CGO_ENABLED=0"}, `
sed -i \
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
cmd/link/internal/`+t.arch+`/obj.go
@@ -143,16 +165,12 @@ rm \
os/root_unix_test.go \
net/smtp/smtp_test.go
`, go123,
- )
+ )
- const (
- version = "1.26.3"
- checksum = "lEiFocZFnN5fKvZzmwVdqc9pYUjAuhzqZGbuiOqxUP4XdcY8yECisKcqsQ_eNn1N"
- )
- return t.newGo(
- version,
- checksum,
- finalEnv, `
+ return &meta, t.newGo(
+ version,
+ checksum,
+ finalEnv, `
sed -i \
's,/lib/ld-musl-`+t.linuxArch()+`.so.1,/system/bin/linker,' \
cmd/link/internal/`+t.arch+`/obj.go
@@ -165,14 +183,7 @@ rm \
cmd/cgo/internal/testsanitizers/tsan_test.go \
cmd/cgo/internal/testsanitizers/cshared_test.go
`, go125,
- ), version
-}
-func init() {
- native.mustRegister(Toolchain.newGoLatest, &Metadata{
- Name: "go",
- Description: "the Go programming language toolchain",
- Website: "https://go.dev/",
+ )
- ID: 1227,
})
}