internal/rosa/package: migrate kernel

This introduces bindings for extra paths and KnownChecksum, and exposes a passthrough special case.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-19 20:47:34 +09:00
parent 6fd6d971ed
commit 962b02cf25
16 changed files with 1349 additions and 1370 deletions

View File

@@ -53,6 +53,9 @@ func (handle *ArtifactH) UnmarshalJSON(data []byte) error {
type HandleError ArtifactH
func (e HandleError) Error() string {
if e == (HandleError{}) {
return "invalid handle error"
}
return "package " + strconv.Quote(ArtifactH(e).String()) + " not available"
}
@@ -763,10 +766,13 @@ func (ctx *evalContext) pf(
var (
attr PackageAttr
patches []string
files []string
excl bool
early bool
anitya int64
kc any
output pkg.Artifact
sourceA any
helper Helper
@@ -787,13 +793,16 @@ func (ctx *evalContext) pf(
k("env"): &attr.Env,
k("early"): &attr.ScriptEarly,
k("patches"): &patches,
k("files"): &files,
k("exclusive"): &excl,
k("toyboxEarly"): &early,
k("source"): &sourceA,
k("exec"): &helper,
k("inputs"): &inputs,
k("runtime"): &runtimes,
k("checksum"): &kc,
k("output"): &output,
k("source"): &sourceA,
k("exec"): &helper,
k("inputs"): &inputs,
k("runtime"): &runtimes,
k("anityaFallback"): &anityaFallback,
k("anityaLegacyCPAN"): &anityaLegacyCPAN,
@@ -807,24 +816,6 @@ func (ctx *evalContext) pf(
return
}
for _, pathname := range patches {
var p []byte
p, err = fs.ReadFile(ctx.b, pathname)
if err != nil {
return
}
attr.Patches = append(attr.Patches, KV{
strings.TrimSuffix(filepath.Base(pathname), ".patch"),
unsafe.String(unsafe.SliceData(p), len(p)),
})
}
if excl {
attr.Flag |= TExclusive
}
if early {
attr.Flag |= TEarly
}
meta.ID = int(anitya)
if anityaFallback {
meta.latest = (*Versions).getStable
@@ -843,6 +834,63 @@ func (ctx *evalContext) pf(
return v.Latest
}
}
if output != nil {
v = cachedArtifact{&meta, output}
set = true
return
}
for _, pathname := range patches {
var p []byte
p, err = fs.ReadFile(ctx.b, pathname)
if err != nil {
return
}
attr.Patches = append(attr.Patches, KV{
strings.TrimSuffix(filepath.Base(pathname), ".patch"),
unsafe.String(unsafe.SliceData(p), len(p)),
})
}
for _, pair := range files {
base, pathname, ok := strings.Cut(pair, ":")
if !ok {
pathname, base = base, filepath.Base(base)
}
var p []byte
p, err = fs.ReadFile(ctx.b, pathname)
if err != nil {
return
}
attr.Paths = append(attr.Paths, pkg.Path(
AbsUsrSrc.Append(base),
false,
pkg.NewFile(base, p),
))
}
if excl {
attr.Flag |= TExclusive
}
if early {
attr.Flag |= TEarly
}
if kc != nil {
checksum, ok := kc.(string)
if !ok {
err = azalea.TypeError{
Concrete: reflect.TypeOf(checksum),
Asserted: reflect.TypeFor[string](),
}
return
}
attr.KnownChecksum = new(mustDecode(checksum))
}
var source pkg.Artifact
switch p := sourceA.(type) {
case pkg.Artifact: