internal/rosa: create metadata alongside artifact
All checks were successful
Test / Create distribution (push) Successful in 1m5s
Test / Sandbox (push) Successful in 2m45s
Test / ShareFS (push) Successful in 3m47s
Test / Hakurei (push) Successful in 4m0s
Test / Sandbox (race detector) (push) Successful in 5m28s
Test / Hakurei (race detector) (push) Successful in 6m32s
Test / Flake checks (push) Successful in 1m21s
All checks were successful
Test / Create distribution (push) Successful in 1m5s
Test / Sandbox (push) Successful in 2m45s
Test / ShareFS (push) Successful in 3m47s
Test / Hakurei (push) Successful in 4m0s
Test / Sandbox (race detector) (push) Successful in 5m28s
Test / Hakurei (race detector) (push) Successful in 6m32s
Test / Flake checks (push) Successful in 1m21s
This enables deferring evaluation of azalea-based packages and fixes the longstanding quirk of version being disjoint from other metadata. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -39,14 +39,13 @@ func commandInfo(
|
||||
t := rosa.Native().Std()
|
||||
for i, name := range args {
|
||||
handle := rosa.ArtifactH(unique.Make(name))
|
||||
if meta := rosa.Native().Get(handle); meta == nil {
|
||||
if meta, a := t.Load(handle); meta == nil {
|
||||
return fmt.Errorf("unknown artifact %q", name)
|
||||
} else {
|
||||
var suffix string
|
||||
|
||||
a, version := t.MustLoad(handle)
|
||||
if version != rosa.Unversioned {
|
||||
suffix += "-" + version
|
||||
if meta.Version != rosa.Unversioned {
|
||||
suffix += "-" + meta.Version
|
||||
}
|
||||
mustPrintln("name : " + name + suffix)
|
||||
|
||||
@@ -58,9 +57,10 @@ func commandInfo(
|
||||
if len(meta.Dependencies) > 0 {
|
||||
mustPrint("depends on :")
|
||||
for _, d := range meta.Dependencies {
|
||||
s := rosa.Native().MustGet(d).Name
|
||||
if _, _version := t.Load(d); _version != rosa.Unversioned {
|
||||
s += "-" + _version
|
||||
_meta, _ := rosa.Native().Std().MustLoad(d)
|
||||
s := _meta.Name
|
||||
if _meta.Version != rosa.Unversioned {
|
||||
s += "-" + _meta.Version
|
||||
}
|
||||
mustPrint(" " + s)
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ func TestInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_t := rosa.Native().Std()
|
||||
_, qemuVersion := _t.Load(rosa.QEMU)
|
||||
_, glibVersion := _t.Load(rosa.GLib)
|
||||
zlib, zlibVersion := _t.Load(rosa.Zlib)
|
||||
_, zstdVersion := _t.Load(rosa.Zstd)
|
||||
_, hakureiVersion := _t.Load(rosa.Hakurei)
|
||||
_, hakureiDistVersion := _t.Load(rosa.HakureiDist)
|
||||
qemuMeta, _ := _t.Load(rosa.QEMU)
|
||||
glibMeta, _ := _t.Load(rosa.GLib)
|
||||
zlibMeta, zlib := _t.Load(rosa.Zlib)
|
||||
zstdMeta, _ := _t.Load(rosa.Zstd)
|
||||
hakureiMeta, _ := _t.Load(rosa.Hakurei)
|
||||
hakureiDistMeta, _ := _t.Load(rosa.HakureiDist)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -38,24 +38,24 @@ func TestInfo(t *testing.T) {
|
||||
wantErr any
|
||||
}{
|
||||
{"qemu", []string{"qemu"}, nil, "", `
|
||||
name : qemu-` + qemuVersion + `
|
||||
name : qemu-` + qemuMeta.Version + `
|
||||
description : a generic and open source machine emulator and virtualizer
|
||||
website : https://www.qemu.org
|
||||
depends on : glib-` + glibVersion + ` zstd-` + zstdVersion + `
|
||||
depends on : glib-` + glibMeta.Version + ` zstd-` + zstdMeta.Version + `
|
||||
`, nil},
|
||||
|
||||
{"multi", []string{"hakurei", "hakurei-dist"}, nil, "", `
|
||||
name : hakurei-` + hakureiVersion + `
|
||||
name : hakurei-` + hakureiMeta.Version + `
|
||||
description : low-level userspace tooling for Rosa OS
|
||||
website : https://hakurei.app
|
||||
|
||||
name : hakurei-dist-` + hakureiDistVersion + `
|
||||
name : hakurei-dist-` + hakureiDistMeta.Version + `
|
||||
description : low-level userspace tooling for Rosa OS (distribution tarball)
|
||||
website : https://hakurei.app
|
||||
`, nil},
|
||||
|
||||
{"nonexistent", []string{"zlib", "\x00"}, nil, "", `
|
||||
name : zlib-` + zlibVersion + `
|
||||
name : zlib-` + zlibMeta.Version + `
|
||||
description : lossless data-compression library
|
||||
website : https://zlib.net
|
||||
|
||||
@@ -65,12 +65,12 @@ website : https://zlib.net
|
||||
"zstd": "internal/pkg (amd64) on satori\n",
|
||||
"hakurei": "internal/pkg (amd64) on satori\n\n",
|
||||
}, "", `
|
||||
name : zlib-` + zlibVersion + `
|
||||
name : zlib-` + zlibMeta.Version + `
|
||||
description : lossless data-compression library
|
||||
website : https://zlib.net
|
||||
status : not yet cured
|
||||
|
||||
name : zstd-` + zstdVersion + `
|
||||
name : zstd-` + zstdMeta.Version + `
|
||||
description : a fast compression algorithm
|
||||
website : https://facebook.github.io/zstd
|
||||
status : internal/pkg (amd64) on satori
|
||||
@@ -79,7 +79,7 @@ status : internal/pkg (amd64) on satori
|
||||
{"status cache perm", []string{"zlib"}, map[string]string{
|
||||
"zlib": "\x00",
|
||||
}, "", `
|
||||
name : zlib-` + zlibVersion + `
|
||||
name : zlib-` + zlibMeta.Version + `
|
||||
description : lossless data-compression library
|
||||
website : https://zlib.net
|
||||
`, func(cm *cache) error {
|
||||
@@ -91,7 +91,7 @@ website : https://zlib.net
|
||||
}},
|
||||
|
||||
{"status report", []string{"zlib"}, nil, strings.Repeat("\x00", len(pkg.Checksum{})+8), `
|
||||
name : zlib-` + zlibVersion + `
|
||||
name : zlib-` + zlibMeta.Version + `
|
||||
description : lossless data-compression library
|
||||
website : https://zlib.net
|
||||
status : not in report
|
||||
@@ -140,7 +140,7 @@ status : not in report
|
||||
|
||||
if tc.status != nil {
|
||||
for name, status := range tc.status {
|
||||
a, _ := _t.Load(rosa.ArtifactH(unique.Make(name)))
|
||||
_, a := _t.Load(rosa.ArtifactH(unique.Make(name)))
|
||||
if a == nil {
|
||||
t.Fatalf("invalid name %q", name)
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ type packageIndex struct {
|
||||
// metadata holds [rosa.Metadata] extended with additional information.
|
||||
type metadata struct {
|
||||
handle rosa.ArtifactH
|
||||
*rosa.Artifact
|
||||
*rosa.Metadata
|
||||
|
||||
// Populated via [rosa.Toolchain.Version], [rosa.Unversioned] is equivalent
|
||||
// to the zero value. Otherwise, the zero value is invalid.
|
||||
// Copied from [rosa.Metadata], [rosa.Unversioned] is equivalent to the zero
|
||||
// value. Otherwise, the zero value is invalid.
|
||||
Version string `json:"version,omitempty"`
|
||||
// Output data size, available if present in report.
|
||||
Size int64 `json:"size,omitempty"`
|
||||
@@ -61,12 +61,12 @@ func (index *packageIndex) populate(report *rosa.Report) (err error) {
|
||||
index.names = make(map[string]*metadata)
|
||||
ir := pkg.NewIR()
|
||||
for i, handle := range handles {
|
||||
a, version := rosa.Native().Std().MustLoad(handle)
|
||||
meta, a := rosa.Native().Std().MustLoad(handle)
|
||||
m := metadata{
|
||||
handle: handle,
|
||||
|
||||
Artifact: rosa.Native().MustGet(handle),
|
||||
Version: version,
|
||||
Metadata: meta,
|
||||
Version: meta.Version,
|
||||
}
|
||||
if m.Version == "" {
|
||||
return errors.New("invalid version from " + m.Name)
|
||||
|
||||
@@ -118,7 +118,7 @@ func main() {
|
||||
rosa.Native().DropCaches("", flags)
|
||||
cross := flagArch != "" && flagArch != runtime.GOARCH
|
||||
if flagQEMU || cross {
|
||||
cm.qemu, _ = rosa.Native().Std().Load(rosa.QEMU)
|
||||
_, cm.qemu = rosa.Native().Std().MustLoad(rosa.QEMU)
|
||||
}
|
||||
|
||||
if cross {
|
||||
@@ -358,7 +358,7 @@ func main() {
|
||||
for range max(flagJobs, 1) {
|
||||
wg.Go(func() {
|
||||
for p := range w {
|
||||
meta := rosa.Native().MustGet(p)
|
||||
meta, _ := rosa.Native().Std().MustLoad(p)
|
||||
if meta.ID == 0 {
|
||||
continue
|
||||
}
|
||||
@@ -371,13 +371,9 @@ func main() {
|
||||
continue
|
||||
}
|
||||
|
||||
_, version := rosa.Native().Std().Load(p)
|
||||
if current, latest :=
|
||||
version,
|
||||
meta.GetLatest(v); current != latest {
|
||||
|
||||
if latest := meta.GetLatest(v); meta.Version != latest {
|
||||
n.Add(1)
|
||||
log.Printf("%s %s < %s", meta.Name, current, latest)
|
||||
log.Printf("%s %s < %s", meta.Name, meta.Version, latest)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -453,7 +449,7 @@ func main() {
|
||||
)
|
||||
|
||||
if err = cm.Do(func(cache *pkg.Cache) (err error) {
|
||||
llvm, _ := rosa.Native().New(s - 2).Load(rosa.LLVM)
|
||||
_, llvm := rosa.Native().New(s - 2).Load(rosa.LLVM)
|
||||
pathname, _, err = cache.Cure(llvm)
|
||||
return
|
||||
}); err != nil {
|
||||
@@ -462,7 +458,7 @@ func main() {
|
||||
log.Println("stage1:", pathname)
|
||||
|
||||
if err = cm.Do(func(cache *pkg.Cache) (err error) {
|
||||
llvm, _ := rosa.Native().New(s - 1).Load(rosa.LLVM)
|
||||
_, llvm := rosa.Native().New(s - 1).Load(rosa.LLVM)
|
||||
pathname, checksum[0], err = cache.Cure(llvm)
|
||||
return
|
||||
}); err != nil {
|
||||
@@ -470,7 +466,7 @@ func main() {
|
||||
}
|
||||
log.Println("stage2:", pathname)
|
||||
if err = cm.Do(func(cache *pkg.Cache) (err error) {
|
||||
llvm, _ := rosa.Native().New(s).Load(rosa.LLVM)
|
||||
_, llvm := rosa.Native().New(s).Load(rosa.LLVM)
|
||||
pathname, checksum[1], err = cache.Cure(llvm)
|
||||
return
|
||||
}); err != nil {
|
||||
@@ -492,7 +488,7 @@ func main() {
|
||||
|
||||
if flagStage0 {
|
||||
if err = cm.Do(func(cache *pkg.Cache) (err error) {
|
||||
stage0, _ := rosa.Native().New(s).Load(rosa.Stage0)
|
||||
_, stage0 := rosa.Native().New(s).Load(rosa.Stage0)
|
||||
pathname, _, err = cache.Cure(stage0)
|
||||
return
|
||||
}); err != nil {
|
||||
@@ -546,7 +542,7 @@ func main() {
|
||||
t -= 1
|
||||
}
|
||||
|
||||
a, _ := rosa.Native().New(t).Load(rosa.ArtifactH(unique.Make(args[0])))
|
||||
_, a := rosa.Native().New(t).Load(rosa.ArtifactH(unique.Make(args[0])))
|
||||
if a == nil {
|
||||
return fmt.Errorf("unknown artifact %q", args[0])
|
||||
}
|
||||
@@ -762,7 +758,7 @@ func main() {
|
||||
handles := make([]rosa.ArtifactH, len(args)+3)
|
||||
for i, arg := range args {
|
||||
handles[i] = rosa.ArtifactH(unique.Make(arg))
|
||||
if rosa.Native().Get(handles[i]) == nil {
|
||||
if meta, _ := rosa.Native().Std().Load(handles[i]); meta == nil {
|
||||
return fmt.Errorf("unknown artifact %q", arg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ func TestCureAll(t *testing.T) {
|
||||
})
|
||||
|
||||
for _, handle := range rosa.Native().Collect() {
|
||||
a, _ := rosa.Native().Std().MustLoad(handle)
|
||||
t.Run(rosa.Native().MustGet(handle).Name, func(t *testing.T) {
|
||||
_, a := rosa.Native().Std().MustLoad(handle)
|
||||
t.Run(handle.String(), func(t *testing.T) {
|
||||
_, err := cureRemote(t.Context(), &addr, a, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user