All checks were successful
Test / Create distribution (push) Successful in 58s
Test / Sandbox (push) Successful in 2m36s
Test / Hakurei (push) Successful in 3m42s
Test / ShareFS (push) Successful in 3m48s
Test / Sandbox (race detector) (push) Successful in 4m55s
Test / Hakurei (race detector) (push) Successful in 5m53s
Test / Flake checks (push) Successful in 1m35s
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>
200 lines
3.5 KiB
Go
200 lines
3.5 KiB
Go
package rosa
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"hakurei.app/internal/pkg"
|
|
)
|
|
|
|
// PArtifact is a lazily-initialised [pkg.Artifact] preset.
|
|
type PArtifact int
|
|
|
|
const (
|
|
// ImageInitramfs is the Rosa OS initramfs archive.
|
|
ImageInitramfs PArtifact = iota
|
|
|
|
// Kernel is the generic Rosa OS Linux kernel.
|
|
Kernel
|
|
// KernelHeaders is an installation of kernel headers for [Kernel].
|
|
KernelHeaders
|
|
// KernelSource is a writable kernel source tree installed to [AbsUsrSrc].
|
|
KernelSource
|
|
|
|
ACL
|
|
ArgpStandalone
|
|
Attr
|
|
Autoconf
|
|
Automake
|
|
BC
|
|
Bash
|
|
Binutils
|
|
Bison
|
|
Bzip2
|
|
CMake
|
|
Coreutils
|
|
Curl
|
|
DTC
|
|
Diffutils
|
|
Elfutils
|
|
Fakeroot
|
|
Findutils
|
|
Flex
|
|
Fuse
|
|
GMP
|
|
GLib
|
|
Gawk
|
|
GenInitCPIO
|
|
Gettext
|
|
Git
|
|
Go
|
|
Gperf
|
|
Grep
|
|
Gzip
|
|
Hakurei
|
|
HakureiDist
|
|
IniConfig
|
|
Kmod
|
|
LibXau
|
|
Libcap
|
|
Libexpat
|
|
Libiconv
|
|
Libpsl
|
|
Libffi
|
|
Libgd
|
|
Libtool
|
|
Libseccomp
|
|
Libucontext
|
|
Libxml2
|
|
Libxslt
|
|
M4
|
|
MPC
|
|
MPFR
|
|
Make
|
|
Meson
|
|
Mksh
|
|
MuslFts
|
|
MuslObstack
|
|
NSS
|
|
NSSCACert
|
|
Ncurses
|
|
Ninja
|
|
OpenSSL
|
|
PCRE2
|
|
Packaging
|
|
Patch
|
|
Perl
|
|
PerlLocaleGettext
|
|
PerlMIMECharset
|
|
PerlModuleBuild
|
|
PerlPodParser
|
|
PerlSGMLS
|
|
PerlTermReadKey
|
|
PerlTextCharWidth
|
|
PerlTextWrapI18N
|
|
PerlUnicodeGCString
|
|
PerlYAMLTiny
|
|
PkgConfig
|
|
Pluggy
|
|
Procps
|
|
PyTest
|
|
Pygments
|
|
Python
|
|
QEMU
|
|
Rsync
|
|
Sed
|
|
Setuptools
|
|
SquashfsTools
|
|
TamaGo
|
|
Tar
|
|
Texinfo
|
|
Toybox
|
|
toyboxEarly
|
|
Unzip
|
|
UtilLinux
|
|
Wayland
|
|
WaylandProtocols
|
|
XCB
|
|
XCBProto
|
|
Xproto
|
|
XZ
|
|
Zlib
|
|
Zstd
|
|
|
|
// _presetUnexportedStart is the first unexported preset.
|
|
_presetUnexportedStart
|
|
|
|
buildcatrust = iota - 1
|
|
utilMacros
|
|
|
|
// Musl is a standalone libc that does not depend on the toolchain.
|
|
Musl
|
|
|
|
// gcc is a hacked-to-pieces GCC toolchain meant for use in intermediate
|
|
// stages only. This preset and its direct output must never be exposed.
|
|
gcc
|
|
|
|
// Stage0 is a tarball containing all compile-time dependencies of artifacts
|
|
// part of the [Std] toolchain.
|
|
Stage0
|
|
|
|
// _presetEnd is the total number of presets and does not denote a preset.
|
|
_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 (
|
|
// 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(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], 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) {
|
|
for i := range _presetUnexportedStart {
|
|
if name == artifactsM[i].Name {
|
|
return i, true
|
|
}
|
|
}
|
|
return 0, false
|
|
}
|