internal/rosa: provide package metadata
All checks were successful
Test / Create distribution (push) Successful in 59s
Test / Sandbox (push) Successful in 2m32s
Test / Hakurei (push) Successful in 3m39s
Test / ShareFS (push) Successful in 3m44s
Test / Sandbox (race detector) (push) Successful in 5m0s
Test / Hakurei (race detector) (push) Successful in 5m56s
Test / Flake checks (push) Successful in 1m29s

This had to be done out-of-band because there was no way to efficiently represent these within Artifact.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-03-04 18:01:18 +09:00
parent 6fdd800b2b
commit 7636f39066
59 changed files with 1286 additions and 478 deletions

View File

@@ -120,7 +120,10 @@ const (
Zlib
Zstd
buildcatrust
// _presetUnexportedStart is the first unexported preset.
_presetUnexportedStart
buildcatrust = iota - 1
utilMacros
// Musl is a standalone libc that does not depend on the toolchain.
@@ -138,131 +141,59 @@ const (
_presetEnd
)
var (
// artifactsF is an array of functions for the result of [PArtifact].
artifactsF [_presetEnd]func(t Toolchain) pkg.Artifact
// Metadata is stage-agnostic information of a [PArtifact] not directly
// representable in the resulting [pkg.Artifact].
type Metadata struct {
f func(t Toolchain) (a pkg.Artifact, version string)
// artifacts stores the result of artifactsF.
artifacts [_toolchainEnd][len(artifactsF)]pkg.Artifact
// Unique package name.
Name string `json:"name"`
// Short user-facing description.
Description string `json:"description"`
// Project home page.
Website string `json:"website,omitempty"`
}
// Unversioned denotes an unversioned [PArtifact].
const Unversioned = "\x00"
var (
// artifactsM is an array of [PArtifact] metadata.
artifactsM [_presetEnd]Metadata
// artifacts stores the result of Metadata.f.
artifacts [_toolchainEnd][len(artifactsM)]pkg.Artifact
// versions stores the version of [PArtifact].
versions [_toolchainEnd][len(artifactsM)]string
// artifactsOnce is for lazy initialisation of artifacts.
artifactsOnce [_toolchainEnd][len(artifactsF)]sync.Once
artifactsOnce [_toolchainEnd][len(artifactsM)]sync.Once
)
// GetMetadata returns [Metadata] of a [PArtifact].
func GetMetadata(p PArtifact) *Metadata { return &artifactsM[p] }
// Load returns the resulting [pkg.Artifact] of [PArtifact].
func (t Toolchain) Load(p PArtifact) pkg.Artifact {
artifactsOnce[t][p].Do(func() {
artifacts[t][p] = artifactsF[p](t)
artifacts[t][p], versions[t][p] = artifactsM[p].f(t)
})
return artifacts[t][p]
}
// Version returns the version string of [PArtifact].
func (t Toolchain) Version(p PArtifact) string {
artifactsOnce[t][p].Do(func() {
artifacts[t][p], versions[t][p] = artifactsM[p].f(t)
})
return versions[t][p]
}
// ResolveName returns a [PArtifact] by name.
func ResolveName(name string) (p PArtifact, ok bool) {
p, ok = map[string]PArtifact{
"initramfs-image": ImageInitramfs,
"kernel": Kernel,
"kernel-headers": KernelHeaders,
"kernel-source": KernelSource,
"acl": ACL,
"argp-standalone": ArgpStandalone,
"attr": Attr,
"autoconf": Autoconf,
"automake": Automake,
"bc": BC,
"bash": Bash,
"binutils": Binutils,
"bison": Bison,
"bzip2": Bzip2,
"cmake": CMake,
"coreutils": Coreutils,
"curl": Curl,
"dtc": DTC,
"diffutils": Diffutils,
"elfutils": Elfutils,
"fakeroot": Fakeroot,
"findutils": Findutils,
"flex": Flex,
"fuse": Fuse,
"gmp": GMP,
"glib": GLib,
"gawk": Gawk,
"gen_init_cpio": GenInitCPIO,
"gettext": Gettext,
"git": Git,
"go": Go,
"gperf": Gperf,
"grep": Grep,
"gzip": Gzip,
"hakurei": Hakurei,
"hakurei-dist": HakureiDist,
"iniconfig": IniConfig,
"kmod": Kmod,
"libXau": LibXau,
"libcap": Libcap,
"libexpat": Libexpat,
"libiconv": Libiconv,
"libpsl": Libpsl,
"libseccomp": Libseccomp,
"libucontext": Libucontext,
"libxml2": Libxml2,
"libxslt": Libxslt,
"libffi": Libffi,
"libgd": Libgd,
"libtool": Libtool,
"m4": M4,
"mpc": MPC,
"mpfr": MPFR,
"make": Make,
"meson": Meson,
"mksh": Mksh,
"musl-fts": MuslFts,
"musl-obstack": MuslObstack,
"nss": NSS,
"nss-cacert": NSSCACert,
"ncurses": Ncurses,
"ninja": Ninja,
"openssl": OpenSSL,
"pcre2": PCRE2,
"packaging": Packaging,
"patch": Patch,
"perl": Perl,
"Locale::gettext": PerlLocaleGettext,
"MIME::Charset": PerlMIMECharset,
"Module::Build": PerlModuleBuild,
"Pod::Parser": PerlPodParser,
"SGMLS": PerlSGMLS,
"Term::ReadKey": PerlTermReadKey,
"Text::CharWidth": PerlTextCharWidth,
"Text::WrapI18N": PerlTextWrapI18N,
"Unicode::GCString": PerlUnicodeGCString,
"YAML::Tiny": PerlYAMLTiny,
"pkg-config": PkgConfig,
"pluggy": Pluggy,
"procps": Procps,
"pytest": PyTest,
"pygments": Pygments,
"python": Python,
"qemu": QEMU,
"rsync": Rsync,
"sed": Sed,
"setuptools": Setuptools,
"squashfs-tools": SquashfsTools,
"tamago": TamaGo,
"tar": Tar,
"texinfo": Texinfo,
"toybox": Toybox,
"unzip": Unzip,
"util-linux": UtilLinux,
"wayland": Wayland,
"wayland-protocols": WaylandProtocols,
"xcb": XCB,
"xcb-proto": XCBProto,
"xproto": Xproto,
"xz": XZ,
"zlib": Zlib,
"zstd": Zstd,
}[name]
return
for i := range _presetUnexportedStart {
if name == artifactsM[i].Name {
return i, true
}
}
return 0, false
}