From 0615899e5666aa3a4c8aa9fb69622be411f33dab Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 21 May 2026 22:19:10 +0900 Subject: internal/rosa: do not register stage0 Nothing can depend on this, so remove it from the namespace. Signed-off-by: Ophestra --- internal/rosa/rosa.go | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) (limited to 'internal/rosa/rosa.go') 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...) } -- cgit v1.3.1