forked from rosa/hakurei
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:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user