From 3f33b62dfdc9402eec55566204434efd6e842826 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 23 May 2026 17:44:38 +0900 Subject: [PATCH] internal/rosa/package: migrate system image The overlay argument also enables migration of stage0. Signed-off-by: Ophestra --- internal/rosa/images.go | 29 ------------------------- internal/rosa/package/images/package.az | 24 ++++++++++++++++++++ internal/rosa/state.go | 29 +++++++++++++++++++------ 3 files changed, 46 insertions(+), 36 deletions(-) delete mode 100644 internal/rosa/images.go diff --git a/internal/rosa/images.go b/internal/rosa/images.go deleted file mode 100644 index 3c9b2fbf..00000000 --- a/internal/rosa/images.go +++ /dev/null @@ -1,29 +0,0 @@ -package rosa - -import ( - "hakurei.app/fhs" - "hakurei.app/internal/pkg" -) - -func init() { - meta := Metadata{ - Name: "system-image", - Description: "Rosa OS system image", - Version: Unversioned, - } - native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) { - return &meta, t.New("system.img", TNoToolchain, t.Append(nil, - H("squashfs-tools"), - ), nil, nil, ` -mksquashfs /mnt/system /work/system.img -`, pkg.Path(fhs.AbsRoot.Append("mnt"), false, t.Append(nil, - _musl, - _mksh, - _toybox, - - H("kmod"), - H("kernel"), - H("firmware"), - )...)) - }) -} diff --git a/internal/rosa/package/images/package.az b/internal/rosa/package/images/package.az index 901d1491..786068c0 100644 --- a/internal/rosa/package/images/package.az +++ b/internal/rosa/package/images/package.az @@ -19,3 +19,27 @@ package initramfs-image { gen_init_cpio, ]; } + +package system-image { + description = "Rosa OS system image"; + version = unversioned; + exclude = true; + + source = earlyinit; + extra = [ + musl, + mksh, + toybox, + + kmod, + kernel, + firmware, + ]; + overlay = "/mnt"; + + exec = generic { + build = "mksquashfs /mnt/system /work/system.img"; + }; + + inputs = [ squashfs-tools ]; +} diff --git a/internal/rosa/state.go b/internal/rosa/state.go index 5c822426..888378d8 100644 --- a/internal/rosa/state.go +++ b/internal/rosa/state.go @@ -932,6 +932,7 @@ func (ctx *evalContext) pf( output pkg.Artifact sourceA any helper Helper + overlay string inputs, runtimes, extra azalea.Array ) @@ -960,6 +961,7 @@ func (ctx *evalContext) pf( k("inputs"): &inputs, k("runtime"): &runtimes, k("extra"): &extra, + k("overlay"): &overlay, }); err != nil { return } @@ -991,13 +993,26 @@ func (ctx *evalContext) pf( }) } - for _, h := range extraH { - _, a := ctx.t.MustLoad(h) - attr.Paths = append(attr.Paths, pkg.Path( - AbsUsrSrc.Append("extra", h.String()), - attr.Writable, - a, - )) + if overlay == "" { + for _, h := range extraH { + _, a := ctx.t.MustLoad(h) + attr.Paths = append(attr.Paths, pkg.Path( + AbsUsrSrc.Append("extra", h.String()), + attr.Writable, + a, + )) + } + } else { + var o pkg.ExecPath + if o.P, err = check.NewAbs(overlay); err != nil { + o.P = AbsUsrSrc.Append("extra", overlay) + } + o.A = make([]pkg.Artifact, len(extraH)) + for i, h := range extraH { + _, a := ctx.t.MustLoad(h) + o.A[i] = a + } + attr.Paths = append(attr.Paths, o) } for _, pair := range files {