internal/rosa: key metadata by string
All checks were successful
Test / Create distribution (push) Successful in 1m5s
Test / Sandbox (push) Successful in 2m55s
Test / ShareFS (push) Successful in 3m46s
Test / Hakurei (push) Successful in 3m57s
Test / Sandbox (race detector) (push) Successful in 5m25s
Test / Hakurei (race detector) (push) Successful in 6m29s
Test / Flake checks (push) Successful in 1m21s

For upcoming azalea integration. The API is quite ugly right now to ease migration.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-17 13:07:12 +09:00
parent c2ff9c9fa5
commit 30eb0d6a61
95 changed files with 1514 additions and 1567 deletions

View File

@@ -10,6 +10,7 @@ import (
"strings"
"syscall"
"testing"
"unique"
"unsafe"
"hakurei.app/internal/pkg"
@@ -20,6 +21,13 @@ import (
func TestInfo(t *testing.T) {
t.Parallel()
_, qemuVersion := rosa.Native().Load(rosa.Std, rosa.QEMU)
_, glibVersion := rosa.Native().Load(rosa.Std, rosa.GLib)
zlib, zlibVersion := rosa.Native().Load(rosa.Std, rosa.Zlib)
_, zstdVersion := rosa.Native().Load(rosa.Std, rosa.Zstd)
_, hakureiVersion := rosa.Native().Load(rosa.Std, rosa.Hakurei)
_, hakureiDistVersion := rosa.Native().Load(rosa.Std, rosa.HakureiDist)
testCases := []struct {
name string
args []string
@@ -29,24 +37,24 @@ func TestInfo(t *testing.T) {
wantErr any
}{
{"qemu", []string{"qemu"}, nil, "", `
name : qemu-` + rosa.Std.Version(rosa.QEMU) + `
name : qemu-` + qemuVersion + `
description : a generic and open source machine emulator and virtualizer
website : https://www.qemu.org
depends on : glib-` + rosa.Std.Version(rosa.GLib) + ` zstd-` + rosa.Std.Version(rosa.Zstd) + `
depends on : glib-` + glibVersion + ` zstd-` + zstdVersion + `
`, nil},
{"multi", []string{"hakurei", "hakurei-dist"}, nil, "", `
name : hakurei-` + rosa.Std.Version(rosa.Hakurei) + `
name : hakurei-` + hakureiVersion + `
description : low-level userspace tooling for Rosa OS
website : https://hakurei.app
name : hakurei-dist-` + rosa.Std.Version(rosa.HakureiDist) + `
name : hakurei-dist-` + hakureiDistVersion + `
description : low-level userspace tooling for Rosa OS (distribution tarball)
website : https://hakurei.app
`, nil},
{"nonexistent", []string{"zlib", "\x00"}, nil, "", `
name : zlib-` + rosa.Std.Version(rosa.Zlib) + `
name : zlib-` + zlibVersion + `
description : lossless data-compression library
website : https://zlib.net
@@ -56,12 +64,12 @@ website : https://zlib.net
"zstd": "internal/pkg (amd64) on satori\n",
"hakurei": "internal/pkg (amd64) on satori\n\n",
}, "", `
name : zlib-` + rosa.Std.Version(rosa.Zlib) + `
name : zlib-` + zlibVersion + `
description : lossless data-compression library
website : https://zlib.net
status : not yet cured
name : zstd-` + rosa.Std.Version(rosa.Zstd) + `
name : zstd-` + zstdVersion + `
description : a fast compression algorithm
website : https://facebook.github.io/zstd
status : internal/pkg (amd64) on satori
@@ -70,19 +78,19 @@ status : internal/pkg (amd64) on satori
{"status cache perm", []string{"zlib"}, map[string]string{
"zlib": "\x00",
}, "", `
name : zlib-` + rosa.Std.Version(rosa.Zlib) + `
name : zlib-` + zlibVersion + `
description : lossless data-compression library
website : https://zlib.net
`, func(cm *cache) error {
return &os.PathError{
Op: "open",
Path: filepath.Join(cm.base, "status", pkg.Encode(cm.c.Ident(rosa.Std.Load(rosa.Zlib)).Value())),
Path: filepath.Join(cm.base, "status", pkg.Encode(cm.c.Ident(zlib).Value())),
Err: syscall.EACCES,
}
}},
{"status report", []string{"zlib"}, nil, strings.Repeat("\x00", len(pkg.Checksum{})+8), `
name : zlib-` + rosa.Std.Version(rosa.Zlib) + `
name : zlib-` + zlibVersion + `
description : lossless data-compression library
website : https://zlib.net
status : not in report
@@ -131,8 +139,8 @@ status : not in report
if tc.status != nil {
for name, status := range tc.status {
p, ok := rosa.ResolveName(name)
if !ok {
a, _ := rosa.Native().Load(rosa.Std, rosa.ArtifactH(unique.Make(name)))
if a == nil {
t.Fatalf("invalid name %q", name)
}
perm := os.FileMode(0400)
@@ -143,7 +151,7 @@ status : not in report
return os.WriteFile(filepath.Join(
cm.base,
"status",
pkg.Encode(cache.Ident(rosa.Std.Load(p)).Value()),
pkg.Encode(cache.Ident(a).Value()),
), unsafe.Slice(unsafe.StringData(status), len(status)), perm)
}); err != nil {
t.Fatalf("Do: error = %v", err)