internal/rosa: optionally block packages from early stages

This helps avoid inadvertently increasing bootstrap input count.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
cat
2026-08-10 17:50:36 +09:00
parent 7f690145e3
commit f1ffb180bc
3 changed files with 21 additions and 0 deletions
+14
View File
@@ -320,6 +320,8 @@ type PackageAttr struct {
// Whether to replace /usr/bin/ with a symlink to /bin/.
PopulateUsrBin bool
// Whether this package is disallowed from bootstrap stages.
Std bool
// Hint for an early variant of toybox to be used when available.
Early bool
// Whether to omit output colour environment variables.
@@ -375,6 +377,14 @@ func (t Toolchain) Append(a []pkg.Artifact, handles ...ArtifactH) []pkg.Artifact
return a
}
// A BootstrapError describes a package disallowed from bootstrap stages.
type BootstrapError string
func (e BootstrapError) Error() string {
return "package " + strconv.Quote(string(e)) +
" must not be built by bootstrap stages"
}
// New constructs a [pkg.Artifact] via a build system helper.
func (t Toolchain) New(
name, version string,
@@ -387,6 +397,10 @@ func (t Toolchain) New(
attr = new(PackageAttr)
}
if attr.Std && !t.stage.isStd() {
panic(BootstrapError(name))
}
if name == "" || version == "" {
panic("name must be non-empty")
}