package rosa import ( "slices" "hakurei.app/pkg" ) // newGo returns a specific version of the Go toolchain. func (t Toolchain) newGo( version, checksum string, env []string, script string, boot ...pkg.Artifact, ) pkg.Artifact { return t.New("go", version, newTar( "https://go.dev/dl/go"+version+".src.tar.gz", checksum, pkg.Gzip, ), &PackageAttr{ EnterSource: true, Env: slices.Concat([]string{ "CC=cc", "GOCACHE=/tmp/gocache", "GOROOT_BOOTSTRAP=" + Prefix + "/go", "TMPDIR=/dev/shm/go", }, env), Extra: boot, }, &GenericHelper{ InPlace: true, Build: ` mkdir /work` + Prefix + `/ "${TMPDIR}" cp -r . /work` + Prefix + `/go cd /work` + Prefix + `/go/src/ chmod -R +w .. ` + script + ` set +u . ./make.bash "$@" --no-banner set -u `, Install: ` ../bin/go tool dist banner # print build info mkdir /work` + Prefix + `/bin ln -s \ ../go/bin/go \ ../go/bin/gofmt \ /work` + Prefix + `/bin `, }, _bash, ) } func init() { const ( version = "1.25.14" checksum = "QKYjKzziCmD1eboU__Oi8VjqbPjaHrHAI9ceWyF3D9ORm7cPHN8muZuiGsoLKjCJ" ) meta := Metadata{ Name: "go-bootstrap", Description: "the Go programming language toolchain (bootstrap)", Website: "https://go.dev", Version: version, Exclude: true, } builtin.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) { if t.cross() { panic(CrossError("go-bootstrap")) } var ( bootstrapEnv []string bootstrapEarly []pkg.Artifact finalEnv []string ) arch := t.Arch() switch arch { case "amd64": bootstrapEarly = []pkg.Artifact{t.New("go", "1.4-bootstrap", newTar( "https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz", "8o9JL_ToiQKadCTb04nvBDkp8O1xiWOolAxVEqaTGodieNe4lOFEjlOxN3bwwe23", pkg.Gzip, ), &PackageAttr{ EnterSource: true, Env: []string{ "CGO_ENABLED=0", }, }, &GenericHelper{ InPlace: true, Build: ` mkdir /work` + Prefix + `/ cp -r . /work` + Prefix + `/go cd /work` + Prefix + `/go/src/ mkdir -p /var/tmp/ ./make.bash `, }, _bash, )} case "arm64", "riscv64": bootstrapEnv = append(bootstrapEnv, "GOROOT_BOOTSTRAP="+Prefix) bootstrapEarly = t.Append(bootstrapEarly, H("gcc")) finalEnv = append(finalEnv, "CGO_ENABLED=0") default: panic("unsupported target " + arch) } go119 := t.newGo( "1.19.13", "MpXfAzOlxdEW_XHmss2IpErg7rJiBsAD9WGgjNo26FXsIyc2gShcz0UJawhEj0IT", append(bootstrapEnv, "CGO_ENABLED=0"), "", bootstrapEarly...) go121 := t.newGo( "1.21.13", "YtrDka402BOAEwywx03Vz4QlVwoBiguJHzG7PuythMCPHXS8CVMLvzmvgEbu4Tzu", []string{"CGO_ENABLED=0"}, "", go119, ) go123 := t.newGo( "1.23.12", "wcI32bl1tkqbgcelGtGWPI4RtlEddd-PTd76Eb-k7nXA5LbE9yTNdIL9QSOOxMOs", []string{"CGO_ENABLED=0"}, "", go121, ) go125 := t.newGo( version, checksum, []string{"CGO_ENABLED=0"}, "", go123, ) return &meta, go125 }) }