internal/rosa: remove global handles
All checks were successful
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 4m18s
Test / Hakurei (push) Successful in 6m13s
Test / ShareFS (push) Successful in 6m11s
Test / Sandbox (race detector) (push) Successful in 6m55s
Test / Hakurei (race detector) (push) Successful in 8m5s
Test / Flake checks (push) Successful in 1m21s

These no longer serve any purpose.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-20 08:07:43 +09:00
parent 2e502ede6c
commit b482fd4abf
17 changed files with 120 additions and 125 deletions

View File

@@ -22,12 +22,12 @@ func TestInfo(t *testing.T) {
t.Parallel() t.Parallel()
_t := rosa.Native().Std() _t := rosa.Native().Std()
qemuMeta, _ := _t.Load(rosa.QEMU) qemuMeta, _ := _t.Load(rosa.H("qemu"))
glibMeta, _ := _t.Load(rosa.GLib) glibMeta, _ := _t.Load(rosa.H("glib"))
zlibMeta, zlib := _t.Load(rosa.Zlib) zlibMeta, zlib := _t.Load(rosa.H("zlib"))
zstdMeta, _ := _t.Load(rosa.Zstd) zstdMeta, _ := _t.Load(rosa.H("zstd"))
hakureiMeta, _ := _t.Load(rosa.Hakurei) hakureiMeta, _ := _t.Load(rosa.H("hakurei"))
hakureiDistMeta, _ := _t.Load(rosa.HakureiDist) hakureiDistMeta, _ := _t.Load(rosa.H("hakurei-dist"))
testCases := []struct { testCases := []struct {
name string name string

View File

@@ -122,7 +122,7 @@ func main() {
rosa.Native().DropCaches("", flags) rosa.Native().DropCaches("", flags)
cross := flagArch != "" && flagArch != runtime.GOARCH cross := flagArch != "" && flagArch != runtime.GOARCH
if flagQEMU || cross { if flagQEMU || cross {
_, cm.qemu = rosa.Native().Std().MustLoad(rosa.QEMU) _, cm.qemu = rosa.Native().Std().MustLoad(rosa.H("qemu"))
} }
if cross { if cross {
@@ -769,7 +769,7 @@ func main() {
base := rosa.LLVM base := rosa.LLVM
if !flagWithToolchain { if !flagWithToolchain {
base = rosa.Musl base = rosa.H("musl")
} }
handles = append(handles, handles = append(handles,
base, base,

View File

@@ -60,9 +60,9 @@ func (t Toolchain) newBison() (pkg.Artifact, string) {
"check", "check",
}, },
}, },
M4, H("m4"),
Diffutils, diffutils,
Sed, H("sed"),
), version ), version
} }
func init() { func init() {

View File

@@ -19,7 +19,7 @@ func (t Toolchain) NewViaGit(
path.Base(url), path.Base(url),
".git", ".git",
)+"-src-"+path.Base(rev), THostNet, t.Append(nil, )+"-src-"+path.Base(rev), THostNet, t.Append(nil,
NSSCACert, nssCACert,
Git, Git,
), &checksum, nil, ` ), &checksum, nil, `
git \ git \

View File

@@ -6,11 +6,13 @@ import (
"hakurei.app/internal/pkg" "hakurei.app/internal/pkg"
) )
var _go = H("go")
// newGoBootstrap returns the Go bootstrap toolchain. // newGoBootstrap returns the Go bootstrap toolchain.
func (t Toolchain) newGoBootstrap() pkg.Artifact { func (t Toolchain) newGoBootstrap() pkg.Artifact {
const checksum = "8o9JL_ToiQKadCTb04nvBDkp8O1xiWOolAxVEqaTGodieNe4lOFEjlOxN3bwwe23" const checksum = "8o9JL_ToiQKadCTb04nvBDkp8O1xiWOolAxVEqaTGodieNe4lOFEjlOxN3bwwe23"
return t.New("go1.4-bootstrap", 0, t.Append(nil, return t.New("go1.4-bootstrap", 0, t.Append(nil,
Bash, bash,
), nil, []string{ ), nil, []string{
"CGO_ENABLED=0", "CGO_ENABLED=0",
}, ` }, `
@@ -39,7 +41,7 @@ func (t Toolchain) newGo(
name = "make" name = "make"
} }
return t.New("go"+version, 0, t.Append(extra, return t.New("go"+version, 0, t.Append(extra,
Bash, bash,
), nil, slices.Concat([]string{ ), nil, slices.Concat([]string{
"CC=cc", "CC=cc",
"GOCACHE=/tmp/gocache", "GOCACHE=/tmp/gocache",
@@ -78,7 +80,7 @@ func (t Toolchain) newGoLatest() (pkg.Artifact, string) {
case "arm64", "riscv64": case "arm64", "riscv64":
bootstrapEnv = append(bootstrapEnv, "GOROOT_BOOTSTRAP=/system") bootstrapEnv = append(bootstrapEnv, "GOROOT_BOOTSTRAP=/system")
bootstrapExtra = t.Append(bootstrapExtra, gcc) bootstrapExtra = t.Append(bootstrapExtra, H("gcc"))
finalEnv = append(finalEnv, "CGO_ENABLED=0") finalEnv = append(finalEnv, "CGO_ENABLED=0")
default: default:

View File

@@ -48,21 +48,17 @@ HAKUREI_VERSION='v` + hakureiVersion + `'
Check: check, Check: check,
Install: install, Install: install,
}, },
Go, _go,
PkgConfig, H("pkg-config"),
// dist tarball H("libseccomp"),
Gzip, H("acl"),
H("fuse"),
H("xcb"),
H("wayland"),
H("wayland-protocols"),
// statically linked kernelHeaders,
Libseccomp,
ACL,
Fuse,
XCB,
Wayland,
WaylandProtocols,
KernelHeaders,
) )
} }
func init() { func init() {

View File

@@ -5,6 +5,8 @@ import (
"hakurei.app/internal/pkg" "hakurei.app/internal/pkg"
) )
var earlyInit = H("earlyinit")
func init() { func init() {
meta := Metadata{ meta := Metadata{
Name: "earlyinit", Name: "earlyinit",
@@ -35,17 +37,17 @@ func init() {
} }
native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) { native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
return &meta, t.New("system.img", TNoToolchain, t.Append(nil, return &meta, t.New("system.img", TNoToolchain, t.Append(nil,
SquashfsTools, H("squashfs-tools"),
), nil, nil, ` ), nil, nil, `
mksquashfs /mnt/system /work/system.img mksquashfs /mnt/system /work/system.img
`, pkg.Path(fhs.AbsRoot.Append("mnt"), false, t.Append(nil, `, pkg.Path(fhs.AbsRoot.Append("mnt"), false, t.Append(nil,
Musl, musl,
Mksh, Mksh,
Toybox, Toybox,
Kmod, H("kmod"),
Kernel, H("kernel"),
Firmware, H("firmware"),
)...)) )...))
}) })
} }
@@ -58,9 +60,9 @@ func init() {
} }
native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) { native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
return &meta, t.New("initramfs", TNoToolchain, t.Append(nil, return &meta, t.New("initramfs", TNoToolchain, t.Append(nil,
Zstd, zstd,
EarlyInit, earlyInit,
GenInitCPIO, H("gen_init_cpio"),
), nil, nil, ` ), nil, nil, `
gen_init_cpio -t 4294967295 -c /usr/src/initramfs | zstd > /work/initramfs.zst gen_init_cpio -t 4294967295 -c /usr/src/initramfs | zstd > /work/initramfs.zst
`, pkg.Path(AbsUsrSrc.Append("initramfs"), false, pkg.NewFile("initramfs", []byte(` `, pkg.Path(AbsUsrSrc.Append("initramfs"), false, pkg.NewFile("initramfs", []byte(`

View File

@@ -8,7 +8,25 @@ import (
"hakurei.app/internal/pkg" "hakurei.app/internal/pkg"
) )
// litArgs returns [LIT] arguments for optional verbosity and check skipping. var (
llvmSource = H("llvm-project")
muslHeaders = H("musl-headers")
earlyCompilerRT = H("early-compiler-rt")
earlyRuntimes = H("early-runtimes")
musl = H("musl")
bash = H("bash")
gawk = H("gawk")
coreutils = H("coreutils")
diffutils = H("diffutils")
findutils = H("findutils")
zlib = H("zlib")
zstd = H("zstd")
kernelHeaders = H("kernel-headers")
)
// litArgs returns LIT arguments for optional verbosity and check skipping.
func litArgs(verbose bool, skipChecks ...string) string { func litArgs(verbose bool, skipChecks ...string) string {
args := []string{"-sv"} args := []string{"-sv"}
if verbose { if verbose {
@@ -36,7 +54,7 @@ func init() {
Description: "early LLVM runtime: compiler-rt", Description: "early LLVM runtime: compiler-rt",
Dependencies: P{ Dependencies: P{
Musl, musl,
}, },
} }
_meta, source := t.MustLoad(llvmSource) _meta, source := t.MustLoad(llvmSource)
@@ -91,7 +109,7 @@ ln -s \
Python, Python,
muslHeaders, muslHeaders,
KernelHeaders, kernelHeaders,
) )
}) })
@@ -146,10 +164,10 @@ ln -s \
}, },
Python, Python,
Zlib, zlib,
Zstd, zstd,
earlyCompilerRT, earlyCompilerRT,
KernelHeaders, kernelHeaders,
) )
}) })
@@ -180,9 +198,9 @@ ln -s \
Website: "https://llvm.org", Website: "https://llvm.org",
Dependencies: P{ Dependencies: P{
Zlib, zlib,
Zstd, zstd,
Musl, musl,
}, },
} }
_meta, source := t.MustLoad(llvmSource) _meta, source := t.MustLoad(llvmSource)
@@ -335,16 +353,16 @@ ninja ` + jobsFlagE + ` check-all
}, },
Python, Python,
Perl, Perl,
Diffutils, diffutils,
Bash, bash,
Gawk, gawk,
Coreutils, coreutils,
Findutils, findutils,
Zlib, zlib,
Zstd, zstd,
early, early,
KernelHeaders, kernelHeaders,
) )
}) })

View File

@@ -55,8 +55,8 @@ func (attr *MakeHelper) extra(flag int) P {
extra := P{Make} extra := P{Make}
if (attr == nil || !attr.OmitDefaults) && flag&TEarly == 0 { if (attr == nil || !attr.OmitDefaults) && flag&TEarly == 0 {
extra = append(extra, extra = append(extra,
Gawk, gawk,
Coreutils, coreutils,
) )
} }
return extra return extra

View File

@@ -19,11 +19,11 @@ func init() {
ID: 2089, ID: 2089,
} }
native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) { native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
_, python := t.Load(Python) _, _python := t.Load(Python)
_, bash := t.Load(Bash) _, _bash := t.Load(bash)
return &meta, t.New(meta.Name+"-"+version, 0, []pkg.Artifact{ return &meta, t.New(meta.Name+"-"+version, 0, []pkg.Artifact{
python, _python,
bash, _bash,
}, nil, nil, ` }, nil, nil, `
cd "$(mktemp -d)" cd "$(mktemp -d)"
python3 /usr/src/ninja/configure.py \ python3 /usr/src/ninja/configure.py \

View File

@@ -6,6 +6,12 @@ import (
"hakurei.app/internal/pkg" "hakurei.app/internal/pkg"
) )
var (
unzip = H("unzip")
nss = H("nss")
nssCACert = H("nss-cacert")
)
func (t Toolchain) newNSS() (pkg.Artifact, string) { func (t Toolchain) newNSS() (pkg.Artifact, string) {
const ( const (
version = "3.123.1" version = "3.123.1"
@@ -58,12 +64,12 @@ cp -r \
}, },
Perl, Perl,
Python, Python,
Unzip, unzip,
Gawk, gawk,
Coreutils, coreutils,
Zlib, zlib,
KernelHeaders, kernelHeaders,
), version ), version
} }
func init() { func init() {
@@ -73,7 +79,7 @@ func init() {
Website: "https://firefox-source-docs.mozilla.org/security/nss/index.html", Website: "https://firefox-source-docs.mozilla.org/security/nss/index.html",
Dependencies: P{ Dependencies: P{
Zlib, zlib,
}, },
ID: 2503, ID: 2503,
@@ -82,9 +88,9 @@ func init() {
func (t Toolchain) newNSSCACert() (pkg.Artifact, string) { func (t Toolchain) newNSSCACert() (pkg.Artifact, string) {
return t.New("nss-cacert", 0, t.Append(nil, return t.New("nss-cacert", 0, t.Append(nil,
Bash, bash,
NSS, nss,
H("buildcatrust"), H("buildcatrust"),
), nil, nil, ` ), nil, nil, `
mkdir -p /work/system/etc/ssl/{certs/unbundled,certs/hashed,trust-source} mkdir -p /work/system/etc/ssl/{certs/unbundled,certs/hashed,trust-source}

View File

@@ -29,10 +29,13 @@ type PipHelper struct {
var _ Helper = new(PipHelper) var _ Helper = new(PipHelper)
// pythonPyTest is used by [PipHelper] for automated testing.
var pythonPyTest = H("python-pytest")
// extra returns python, or pytest if defaults are assumed. // extra returns python, or pytest if defaults are assumed.
func (attr *PipHelper) extra(int) P { func (attr *PipHelper) extra(int) P {
if attr == nil || (!attr.SkipCheck && attr.Check == "") { if attr == nil || (!attr.SkipCheck && attr.Check == "") {
return P{PythonPyTest} return P{pythonPyTest}
} }
return P{Python} return P{Python}
} }

View File

@@ -231,6 +231,10 @@ var (
// The Mksh shell is added by [Toolchain.New] and used by almost all packages. // The Mksh shell is added by [Toolchain.New] and used by almost all packages.
Mksh = H("mksh") Mksh = H("mksh")
// Toybox is standard utilities added by [Toolchain.New].
Toybox = H("toybox")
// LLVM is the standard toolchain added by [Toolchain.New].
LLVM = H("llvm")
) )
// New returns a [pkg.Artifact] based on a [Toolchain] via s. // New returns a [pkg.Artifact] based on a [Toolchain] via s.
@@ -298,7 +302,7 @@ mkdir -vp /work/system/bin
base := LLVM base := LLVM
if flag&TNoToolchain != 0 { if flag&TNoToolchain != 0 {
base = Musl base = musl
} }
support = slices.Concat(extra, t.S.New(t.stage-1).Append([]pkg.Artifact{ support = slices.Concat(extra, t.S.New(t.stage-1).Append([]pkg.Artifact{
@@ -335,6 +339,9 @@ mkdir -vp /work/system/bin
) )
} }
// patch is used by [Toolchain.NewPatchedSource].
var patch = H("patch")
// NewPatchedSource returns [pkg.Artifact] of source with patches applied. If // NewPatchedSource returns [pkg.Artifact] of source with patches applied. If
// passthrough is true, source is returned as is for zero length patches. // passthrough is true, source is returned as is for zero length patches.
func (t Toolchain) NewPatchedSource( func (t Toolchain) NewPatchedSource(
@@ -371,7 +378,7 @@ cat /usr/src/` + name + `-patches/* | \
aname += "-patched" aname += "-patched"
} }
return t.New(aname, 0, t.Append(nil, return t.New(aname, 0, t.Append(nil,
Patch, patch,
), nil, nil, script, paths...) ), nil, nil, script, paths...)
} }

View File

@@ -5,6 +5,10 @@ import (
"hakurei.app/internal/pkg" "hakurei.app/internal/pkg"
) )
// Stage0 is the handle of the stage0 distribution tarball built on the
// toolchain of stage [Std].
var Stage0 = H("rosa-stage0")
func init() { func init() {
meta := Metadata{ meta := Metadata{
Name: "rosa-stage0", Name: "rosa-stage0",
@@ -13,7 +17,7 @@ func init() {
} }
native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) { native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
return &meta, t.New("rosa-stage0", 0, t.Append(nil, return &meta, t.New("rosa-stage0", 0, t.Append(nil,
Bzip2, H("bzip2"),
), nil, nil, ` ), nil, nil, `
umask 377 umask 377
tar \ tar \

View File

@@ -1,49 +0,0 @@
package rosa
var (
LLVM = H("llvm")
EarlyInit = H("earlyinit")
Kernel = H("kernel")
KernelHeaders = H("kernel-headers")
Firmware = H("firmware")
ACL = H("acl")
Bash = H("bash")
Bzip2 = H("bzip2")
Coreutils = H("coreutils")
Diffutils = H("diffutils")
Findutils = H("findutils")
Fuse = H("fuse")
GLib = H("glib")
Gawk = H("gawk")
GenInitCPIO = H("gen_init_cpio")
Go = H("go")
Gzip = H("gzip")
Hakurei = H("hakurei")
HakureiDist = H("hakurei-dist")
Kmod = H("kmod")
Libseccomp = H("libseccomp")
M4 = H("m4")
NSS = H("nss")
NSSCACert = H("nss-cacert")
Patch = H("patch")
PkgConfig = H("pkg-config")
PythonPyTest = H("python-pytest")
QEMU = H("qemu")
Sed = H("sed")
SquashfsTools = H("squashfs-tools")
Toybox = H("toybox")
toyboxEarly = H("toybox-early")
Unzip = H("unzip")
Wayland = H("wayland")
WaylandProtocols = H("wayland-protocols")
XCB = H("xcb")
Zlib = H("zlib")
Zstd = H("zstd")
llvmSource = H("llvm-project")
earlyCompilerRT = H("early-compiler-rt")
earlyRuntimes = H("early-runtimes")
Musl = H("musl")
muslHeaders = H("musl-headers")
gcc = H("gcc")
Stage0 = H("rosa-stage0")
)

View File

@@ -8,8 +8,8 @@ func (t Toolchain) newTamaGo() (pkg.Artifact, string) {
checksum = "-nH3MjAzDDLTeJ2hRKYJcJwo5-Ikci4zOHfB8j1vKn7zrF9TS6zYaoLi8qohGwAE" checksum = "-nH3MjAzDDLTeJ2hRKYJcJwo5-Ikci4zOHfB8j1vKn7zrF9TS6zYaoLi8qohGwAE"
) )
return t.New("tamago-go"+version, 0, t.Append(nil, return t.New("tamago-go"+version, 0, t.Append(nil,
Bash, bash,
Go, _go,
), nil, []string{ ), nil, []string{
"CC=cc", "CC=cc",
"GOCACHE=/tmp/gocache", "GOCACHE=/tmp/gocache",

View File

@@ -2,6 +2,12 @@ package rosa
import "hakurei.app/internal/pkg" import "hakurei.app/internal/pkg"
var (
gzip = H("gzip")
toyboxEarly = H("toybox-early")
)
func (t Toolchain) newToybox(suffix, script string) (pkg.Artifact, string) { func (t Toolchain) newToybox(suffix, script string) (pkg.Artifact, string) {
const ( const (
version = "0.8.13" version = "0.8.13"
@@ -52,10 +58,10 @@ mkdir -p /work/usr/bin
ln -s ../../system/bin/env /work/usr/bin ln -s ../../system/bin/env /work/usr/bin
`, `,
}, },
Bash, bash,
Gzip, gzip,
KernelHeaders, kernelHeaders,
), version ), version
} }
func init() { func init() {