diff --git a/cmd/mbf/internal/pkgserver/api.go b/cmd/mbf/internal/pkgserver/api.go index e73b8bbe..125be829 100644 --- a/cmd/mbf/internal/pkgserver/api.go +++ b/cmd/mbf/internal/pkgserver/api.go @@ -30,7 +30,7 @@ var ( // handleInfo writes constant system information. func handleInfo(w http.ResponseWriter, _ *http.Request) { infoPayloadOnce.Do(func() { - infoPayload.Count = int(rosa.Native().Count()) + infoPayload.Count = len(rosa.Native().Collect()) infoPayload.HakureiVersion = info.Version() }) // TODO(mae): cache entire response if no additional fields are planned diff --git a/cmd/mbf/internal/pkgserver/api_test.go b/cmd/mbf/internal/pkgserver/api_test.go index 4c178fb9..3a9945da 100644 --- a/cmd/mbf/internal/pkgserver/api_test.go +++ b/cmd/mbf/internal/pkgserver/api_test.go @@ -31,7 +31,7 @@ func TestAPIInfo(t *testing.T) { checkPayload(t, resp, struct { Count int `json:"count"` HakureiVersion string `json:"hakurei_version"` - }{rosa.Native().Count(), info.Version()}) + }{len(rosa.Native().Collect()), info.Version()}) } func TestAPIGet(t *testing.T) { @@ -92,11 +92,12 @@ func TestAPIGet(t *testing.T) { ) }) + count := len(rosa.Native().Collect()) t.Run("index", func(t *testing.T) { t.Parallel() checkValidate( - t, "limit=1&sort=0&index", 0, rosa.Native().Count()-1, - "index must be an integer between 0 and "+strconv.Itoa(rosa.Native().Count()-1), + t, "limit=1&sort=0&index", 0, count-1, + "index must be an integer between 0 and "+strconv.Itoa(count-1), ) }) diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go index f87d388f..bf057115 100644 --- a/cmd/mbf/main.go +++ b/cmd/mbf/main.go @@ -387,7 +387,7 @@ func main() { } done: - for _, p := range rosa.Native().Collect() { + for _, p := range rosa.Native().CollectAll() { select { case w <- p: break diff --git a/internal/rosa/package/kernel/package.az b/internal/rosa/package/kernel/package.az index 70dbe28d..d768ebac 100644 --- a/internal/rosa/package/kernel/package.az +++ b/internal/rosa/package/kernel/package.az @@ -1,6 +1,7 @@ package kernel-source { description = "unpatched Linux kernel source tree"; website = "https://kernel.org"; + exclude = true; version* = "6.12.87"; output = remoteTar { diff --git a/internal/rosa/package/musl/package.az b/internal/rosa/package/musl/package.az index 893567e8..11ffd0c0 100644 --- a/internal/rosa/package/musl/package.az +++ b/internal/rosa/package/musl/package.az @@ -1,5 +1,6 @@ package musl-source { description = "an implementation of the C standard library - source code"; + exclude = true; version* = "1.2.6"; output = remoteTar { diff --git a/internal/rosa/package/stage0.az b/internal/rosa/package/stage0.az index 02930657..d1276b82 100644 --- a/internal/rosa/package/stage0.az +++ b/internal/rosa/package/stage0.az @@ -1,5 +1,6 @@ package stage0-dist { description = "Rosa OS stage0 bootstrap seed"; + exclude = true; version* = "20260504"; output = remoteTar { diff --git a/internal/rosa/state.go b/internal/rosa/state.go index 6ff6f1cf..7cdf7cb5 100644 --- a/internal/rosa/state.go +++ b/internal/rosa/state.go @@ -384,14 +384,14 @@ func (s *S) mustRegister( }) } -// Count returns the number of [Artifact] registered to s. -func (s *S) Count() int { +// count returns the number of [Artifact] registered to s. +func (s *S) count() int { return int(s.artifactCount.Load()) } -// Collect returns all [ArtifactH] registered to s. -func (s *S) Collect() (handles P) { - handles = make(P, 0, s.Count()) +// CollectAll returns all [ArtifactH] registered to s. +func (s *S) CollectAll() (handles P) { + handles = make(P, 0, s.count()) s.artifacts.Range(func(key, _ any) bool { handles = append(handles, key.(ArtifactH)) return true @@ -402,6 +402,23 @@ func (s *S) Collect() (handles P) { return } +// Collect returns all non-excluded [ArtifactH] registered to s. +func (s *S) Collect() (handles P) { + handles = make(P, 0, s.count()) + s.artifacts.Range(func(key, _ any) bool { + h := key.(ArtifactH) + meta, _ := s.Std().MustLoad(h) + if !meta.Exclude { + handles = append(handles, h) + } + return true + }) + slices.SortFunc(handles, func(a, b ArtifactH) int { + return strings.Compare(a.String(), b.String()) + }) + return +} + // deferredGit is a call to Toolchain.newTagRemote from azalea. type deferredGit struct { url string @@ -915,6 +932,7 @@ func (ctx *evalContext) pf( k("description"): &meta.Description, k("website"): &meta.Website, k("version"): &meta.Version, + k("exclude"): &meta.Exclude, k("anitya"): &anitya, k("latest"): &meta.latest,