aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/state.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/rosa/state.go')
-rw-r--r--internal/rosa/state.go85
1 files changed, 68 insertions, 17 deletions
diff --git a/internal/rosa/state.go b/internal/rosa/state.go
index fca1aa48..01abf736 100644
--- a/internal/rosa/state.go
+++ b/internal/rosa/state.go
@@ -91,7 +91,9 @@ type Metadata struct {
Website string `json:"website,omitempty"`
// Runtime dependencies.
- Dependencies P `json:"dependencies"`
+ Runtimes P `json:"runtime"`
+ // Whether this package is unlike to be a runtime dependency.
+ Unlikely bool `json:"unlikely,omitempty"`
// Package version.
Version string `json:"version"`
@@ -1028,6 +1030,12 @@ func (t Toolchain) evalArtifact(v any, meta *Metadata) pkg.Artifact {
}
}
+// isUnlikely returns whether p is unlikely to be a runtime dependency.
+func (t Toolchain) isUnlikely(handle ArtifactH) bool {
+ meta, _ := t.MustLoad(handle)
+ return meta.Unlikely
+}
+
// pf implements [azalea.PF].
func (ctx *evalContext) pf(
name azalea.Ident,
@@ -1049,9 +1057,11 @@ func (ctx *evalContext) pf(
source any
helper Helper
overlay string
+ join bool
- inputs, runtimes, extra azalea.Array
+ tools, inputs, extra azalea.Array
+ runtimes = azalea.Array{}
bootstrap = true
)
if err = args.Apply(map[unique.Handle[azalea.Ident]]any{
@@ -1082,7 +1092,10 @@ func (ctx *evalContext) pf(
k("source"): &source,
k("exec"): &helper,
k("inputs"): &inputs,
+ k("tools"): &tools,
k("runtime"): &runtimes,
+ k("join"): &join,
+ k("unlikely"): &meta.Unlikely,
k("extra"): &extra,
k("overlay"): &overlay,
}); err != nil {
@@ -1092,12 +1105,39 @@ func (ctx *evalContext) pf(
var inputsH, extraH P
if inputsH, err = toHandles(inputs); err != nil {
return
- } else if meta.Dependencies, err = toHandles(runtimes); err != nil {
+ } else if attr.Tools, err = toHandles(tools); err != nil {
return
} else if extraH, err = toHandles(extra); err != nil {
return
}
+ if join || (runtimes != nil && len(runtimes) == 0 && helper != nil) {
+ hi := helper.inputs()
+ meta.Runtimes = make(P, 0, len(hi)+len(inputsH)+len(runtimes))
+ for _, h := range hi {
+ if ctx.t.isUnlikely(h) {
+ continue
+ }
+ meta.Runtimes = append(meta.Runtimes, h)
+ }
+ for _, h := range inputsH {
+ if ctx.t.isUnlikely(h) {
+ continue
+ }
+ meta.Runtimes = append(meta.Runtimes, h)
+ }
+
+ if join {
+ var extraRuntimes P
+ if extraRuntimes, err = toHandles(runtimes); err != nil {
+ return
+ }
+ meta.Runtimes = append(meta.Runtimes, extraRuntimes...)
+ }
+ } else if meta.Runtimes, err = toHandles(runtimes); err != nil {
+ return
+ }
+
meta.ID = int(anitya)
for _, pathname := range patches {
var p []byte
@@ -1299,6 +1339,30 @@ func (s *S) RegisterFS(fsys fs.FS) error {
return nil
}
+// setSource overrides the hakurei-source package with the specified tarball and
+// version string. The resulting IR is curable on the daemon. Must not be used
+// concurrently with any other method.
+func (s *S) setSource(p []byte, version string) {
+ const name = "hakurei-source"
+ s.p.Store(
+ H(name),
+ Artifact(func(t Toolchain) (*Metadata, pkg.Artifact) {
+ return &Metadata{
+ Name: name,
+ Description: "hakurei source tree (current)",
+ Version: version,
+ Exclude: true,
+ }, pkg.NewTar(
+ pkg.NewDecompress(
+ pkg.NewFile("hakurei-src-current.tar.gz", p),
+ pkg.Gzip,
+ ),
+ )
+ }),
+ )
+ s.DropCaches(s.Arch(), s.Flags())
+}
+
// SetSource overrides the hakurei-source package with a cached tarball of fsys.
// The resulting IR is curable on the daemon. Must not be used concurrently with
// any other method.
@@ -1376,20 +1440,7 @@ func (s *S) SetSource(fsys fs.FS) error {
return err
}
- const name = "hakurei-source"
- a := pkg.NewFile("hakurei-src-current.tar.gz", buf.Bytes())
- s.p.Store(
- H(name),
- Artifact(func(t Toolchain) (*Metadata, pkg.Artifact) {
- return &Metadata{
- Name: name,
- Description: "hakurei source tree (current)",
- Version: version,
- Exclude: true,
- }, pkg.NewTar(pkg.NewDecompress(a, pkg.Gzip))
- }),
- )
- s.DropCaches(s.Arch(), s.Flags())
+ s.setSource(buf.Bytes(), version)
return nil
}