internal/rosa: handle nil source
Test / Create distribution (push) Successful in 1m1s
Test / Sandbox (push) Successful in 3m15s
Test / Hakurei (push) Successful in 4m39s
Test / ShareFS (push) Successful in 4m52s
Test / Sandbox (race detector) (push) Successful in 6m7s
Test / Hakurei (race detector) (push) Successful in 7m23s
Test / Flake checks (push) Successful in 1m6s

Source is not always required. This improves flexibility.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-06-28 18:02:54 +09:00
parent cf7c34555c
commit d1319a497c
3 changed files with 18 additions and 15 deletions
-1
View File
@@ -25,7 +25,6 @@ package system-image {
version = unversioned;
exclude = true;
source = earlyinit;
extra = [
musl,
mksh,
+12 -10
View File
@@ -476,9 +476,6 @@ func (t Toolchain) NewPackage(
if name == "" || version == "" {
panic("name must be non-empty")
}
if source == nil {
panic("source must be non-nil")
}
rn := name
if version != Unversioned {
rn = name + "-" + version
@@ -536,6 +533,17 @@ cd '/usr/src/` + name + `/'
panic("cannot remain in root")
}
paths := attr.Paths
if source != nil {
paths = slices.Concat(attr.Paths, []pkg.ExecPath{
pkg.Path(AbsUsrSrc.Append(
name+sourceSuffix,
), attr.Writable || wantsWrite, t.NewPatchedSource(
rn, source, !attr.Chmod && !wantsChmod, attr.Patches...,
)),
})
}
return t.New(
rn,
attr.Flag,
@@ -543,13 +551,7 @@ cd '/usr/src/` + name + `/'
attr.KnownChecksum,
attr.Env,
scriptEarly+helper.script(t, name),
slices.Concat(attr.Paths, []pkg.ExecPath{
pkg.Path(AbsUsrSrc.Append(
name+sourceSuffix,
), attr.Writable || wantsWrite, t.NewPatchedSource(
rn, source, !attr.Chmod && !wantsChmod, attr.Patches...,
)),
})...,
paths...,
)
}
+6 -4
View File
@@ -1134,10 +1134,12 @@ func (ctx *evalContext) pf(
}
default:
panic(azalea.TypeError{
Concrete: reflect.TypeOf(sourceA),
Asserted: reflect.TypeFor[pkg.Artifact](),
})
if sourceA != nil {
panic(azalea.TypeError{
Concrete: reflect.TypeOf(sourceA),
Asserted: reflect.TypeFor[pkg.Artifact](),
})
}
}
v = cachedArtifact{&meta, ctx.t.NewPackage(