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; version = unversioned;
exclude = true; exclude = true;
source = earlyinit;
extra = [ extra = [
musl, musl,
mksh, mksh,
+12 -10
View File
@@ -476,9 +476,6 @@ func (t Toolchain) NewPackage(
if name == "" || version == "" { if name == "" || version == "" {
panic("name must be non-empty") panic("name must be non-empty")
} }
if source == nil {
panic("source must be non-nil")
}
rn := name rn := name
if version != Unversioned { if version != Unversioned {
rn = name + "-" + version rn = name + "-" + version
@@ -536,6 +533,17 @@ cd '/usr/src/` + name + `/'
panic("cannot remain in root") 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( return t.New(
rn, rn,
attr.Flag, attr.Flag,
@@ -543,13 +551,7 @@ cd '/usr/src/` + name + `/'
attr.KnownChecksum, attr.KnownChecksum,
attr.Env, attr.Env,
scriptEarly+helper.script(t, name), scriptEarly+helper.script(t, name),
slices.Concat(attr.Paths, []pkg.ExecPath{ paths...,
pkg.Path(AbsUsrSrc.Append(
name+sourceSuffix,
), attr.Writable || wantsWrite, t.NewPatchedSource(
rn, source, !attr.Chmod && !wantsChmod, attr.Patches...,
)),
})...,
) )
} }
+2
View File
@@ -1134,11 +1134,13 @@ func (ctx *evalContext) pf(
} }
default: default:
if sourceA != nil {
panic(azalea.TypeError{ panic(azalea.TypeError{
Concrete: reflect.TypeOf(sourceA), Concrete: reflect.TypeOf(sourceA),
Asserted: reflect.TypeFor[pkg.Artifact](), Asserted: reflect.TypeFor[pkg.Artifact](),
}) })
} }
}
v = cachedArtifact{&meta, ctx.t.NewPackage( v = cachedArtifact{&meta, ctx.t.NewPackage(
meta.Name, meta.Name,