diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-05-21 22:19:10 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-05-21 22:20:01 +0900 |
| commit | 0615899e5666aa3a4c8aa9fb69622be411f33dab (patch) | |
| tree | 6275a071f50f34e528f043fe3716ad6310d43522 /internal/rosa | |
| parent | 0914569e62089f2a9545243c529d238c662d4b04 (diff) | |
internal/rosa: do not register stage0
Nothing can depend on this, so remove it from the namespace.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa')
| -rw-r--r-- | internal/rosa/images.go | 4 | ||||
| -rw-r--r-- | internal/rosa/rosa.go | 47 | ||||
| -rw-r--r-- | internal/rosa/rosa_test.go | 5 | ||||
| -rw-r--r-- | internal/rosa/stage0.go | 43 |
4 files changed, 39 insertions, 60 deletions
diff --git a/internal/rosa/images.go b/internal/rosa/images.go index 8a65f82f..617b5b9d 100644 --- a/internal/rosa/images.go +++ b/internal/rosa/images.go @@ -42,8 +42,8 @@ func init() { mksquashfs /mnt/system /work/system.img `, pkg.Path(fhs.AbsRoot.Append("mnt"), false, t.Append(nil, _musl, - Mksh, - Toybox, + _mksh, + _toybox, H("kmod"), H("kernel"), diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go index 5d75735a..94d827bc 100644 --- a/internal/rosa/rosa.go +++ b/internal/rosa/rosa.go @@ -213,15 +213,12 @@ const ( ) var ( - // The Mksh shell is added by [Toolchain.New] and used by almost all packages. - 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") - _stage0Dist = H("stage0-dist") + _mksh = H("mksh") + _toybox = H("toybox") _toyboxEarly = H("toybox-early") + _llvm = H("llvm") + _patch = H("patch") ) // New returns a [pkg.Artifact] based on a [Toolchain] via s. @@ -282,12 +279,12 @@ mkdir -vp /work/system/bin name += "-std" } - toybox := Toybox + toybox := _toybox if flag&TEarly != 0 { toybox = _toyboxEarly } - base := LLVM + base := _llvm if flag&TNoToolchain != 0 { base = _musl } @@ -296,7 +293,7 @@ mkdir -vp /work/system/bin cureEtc{newIANAEtc()}, }, base, - Mksh, + _mksh, toybox, )) env = fixupEnviron(env, []string{ @@ -326,8 +323,32 @@ mkdir -vp /work/system/bin ) } -// patch is used by [Toolchain.NewPatchedSource]. -var patch = H("patch") +// NewStage0 returns a [pkg.Artifact] curing to a stage0 distribution. +func (t Toolchain) NewStage0() pkg.Artifact { + return t.New("stage0", 0, t.Append(nil, + H("bzip2"), + ), nil, nil, ` +umask 377 +tar \ + -vjc \ + -C /stage0 \ + -f /work/stage0-`+t.triple()+`.tar.bz2 \ + . +`, pkg.Path(fhs.AbsRoot.Append("stage0"), false, t.Append(nil, + _llvm, + _mksh, + _toyboxEarly, + )...)) +} + +// HasStageEarly returns whether a stage0 distribution is available. +func (s *S) HasStageEarly() (ok bool) { + func() { + defer func() { ok = recover() == nil }() + s.New(stageEarly).MustLoad(_stage0Dist) + }() + return +} // NewPatchedSource returns [pkg.Artifact] of source with patches applied. If // passthrough is true, source is returned as is for zero length patches. @@ -365,7 +386,7 @@ cat /usr/src/` + name + `-patches/* | \ aname += "-patched" } return t.New(aname, 0, t.Append(nil, - patch, + _patch, ), nil, nil, script, paths...) } diff --git a/internal/rosa/rosa_test.go b/internal/rosa/rosa_test.go index 958cd506..e612c11d 100644 --- a/internal/rosa/rosa_test.go +++ b/internal/rosa/rosa_test.go @@ -77,7 +77,7 @@ func TestCureAll(t *testing.T) { cache := getCache(t) t.Parallel() - for _, p := range rosa.Native().Collect() { + for _, p := range rosa.Native().CollectAll() { _, a := rosa.Native().Std().MustLoad(p) t.Run(p.String(), func(t *testing.T) { t.Parallel() @@ -94,8 +94,9 @@ func TestCureAll(t *testing.T) { func BenchmarkStage3(b *testing.B) { t := rosa.Native().Clone().Std() + llvm := rosa.H("llvm") for b.Loop() { - t.MustLoad(rosa.LLVM) + t.MustLoad(llvm) b.StopTimer() t.DropCaches("", 0) diff --git a/internal/rosa/stage0.go b/internal/rosa/stage0.go deleted file mode 100644 index a3bd8984..00000000 --- a/internal/rosa/stage0.go +++ /dev/null @@ -1,43 +0,0 @@ -package rosa - -import ( - "hakurei.app/fhs" - "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() { - meta := Metadata{ - Name: "rosa-stage0", - Description: "Rosa OS stage0 toolchain tarball for bootstrap", - Version: Unversioned, - } - native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) { - return &meta, t.New("rosa-stage0", 0, t.Append(nil, - H("bzip2"), - ), nil, nil, ` -umask 377 -tar \ - -vjc \ - -C /stage0 \ - -f /work/stage0-`+t.triple()+`.tar.bz2 \ - . -`, pkg.Path(fhs.AbsRoot.Append("stage0"), false, t.Append(nil, - LLVM, - Mksh, - _toyboxEarly, - )...)) - }) -} - -// HasStage0 returns whether a stage0 distribution is available. -func (s *S) HasStage0() (ok bool) { - func() { - defer func() { ok = recover() == nil }() - s.New(stageEarly).MustLoad(_stage0Dist) - }() - return -} |
