aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/all.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/rosa/all.go')
-rw-r--r--internal/rosa/all.go159
1 files changed, 45 insertions, 114 deletions
diff --git a/internal/rosa/all.go b/internal/rosa/all.go
index 22ba015f..28a0ac96 100644
--- a/internal/rosa/all.go
+++ b/internal/rosa/all.go
@@ -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
)
+// 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)
+
+ // 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 (
- // artifactsF is an array of functions for the result of [PArtifact].
- artifactsF [_presetEnd]func(t Toolchain) pkg.Artifact
+ // artifactsM is an array of [PArtifact] metadata.
+ artifactsM [_presetEnd]Metadata
- // artifacts stores the result of artifactsF.
- artifacts [_toolchainEnd][len(artifactsF)]pkg.Artifact
+ // 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
}