aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/rosa/state.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/internal/rosa/state.go b/internal/rosa/state.go
index 7b755cd2..e55202c4 100644
--- a/internal/rosa/state.go
+++ b/internal/rosa/state.go
@@ -203,6 +203,9 @@ type S struct {
// For initialising arch.
archOnce sync.Once
+ // Poisoned packages.
+ poison []string
+
// Native state for tool acquisition.
native *S
@@ -261,7 +264,7 @@ func (t Toolchain) native() Toolchain {
// Clone returns a copy of s.
func (s *S) Clone() *S {
- v := S{arch: s.arch, opts: s.opts, native: s.native}
+ v := S{arch: s.arch, opts: s.opts, native: s.native, poison: s.poison}
s.p.Range(func(key, value any) bool {
v.p.Store(key, value)
v.len.Add(1)
@@ -328,6 +331,13 @@ func Arches(qemu *check.Absolute) iter.Seq2[string, container.BinfmtEntry] {
// Flags returns the current preset flags.
func (s *S) Flags() int { return s.opts }
+// WithPoison returns a copy of s with the named packages poisoned.
+func (s *S) WithPoison(poison ...string) *S {
+ p := s.Clone()
+ p.poison = slices.Concat(p.poison, poison)
+ return p
+}
+
// DropCaches arranges for all cached [pkg.Artifact] to be freed some time after
// it returns. Must not be used concurrently with any other method.
func (s *S) DropCaches(targetArch string, flags int) {
@@ -1117,11 +1127,24 @@ func (t Toolchain) isUnlikely(handle ArtifactH) bool {
return meta.Unlikely
}
+// PoisonError describes an attempt to evaluate a poisoned package.
+type PoisonError string
+
+func (e PoisonError) Error() string {
+ return "package " + strconv.Quote(string(e)) + " poisoned"
+}
+
// pf implements [azalea.PF].
func (ctx *evalContext) pf(
name azalea.Ident,
args azalea.FArgs,
) (v any, set bool, err error) {
+ for _, poisoned := range ctx.t.poison {
+ if string(name) == poisoned {
+ panic(PoisonError(name))
+ }
+ }
+
k := func(name string) unique.Handle[azalea.Ident] {
return unique.Make(azalea.Ident(name))
}