All checks were successful
Test / Create distribution (push) Successful in 59s
Test / Sandbox (push) Successful in 2m33s
Test / Hakurei (push) Successful in 3m55s
Test / ShareFS (push) Successful in 3m56s
Test / Hpkg (push) Successful in 4m26s
Test / Sandbox (race detector) (push) Successful in 5m0s
Test / Hakurei (race detector) (push) Successful in 6m14s
Test / Flake checks (push) Successful in 1m48s
This provides a shell, as part of the effort to replace busybox. Signed-off-by: Ophestra <cat@gensokyo.uk>
138 lines
2.8 KiB
Go
138 lines
2.8 KiB
Go
package rosa
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"hakurei.app/internal/pkg"
|
|
)
|
|
|
|
// PArtifact is a lazily-initialised [pkg.Artifact] preset.
|
|
type PArtifact int
|
|
|
|
const (
|
|
ACL PArtifact = iota
|
|
Attr
|
|
Autoconf
|
|
Bash
|
|
Busybox
|
|
CMake
|
|
Coreutils
|
|
Diffutils
|
|
Fuse
|
|
Gawk
|
|
Gettext
|
|
Git
|
|
Go
|
|
Gperf
|
|
Hakurei
|
|
HakureiDist
|
|
IniConfig
|
|
KernelHeaders
|
|
LibXau
|
|
Libexpat
|
|
Libffi
|
|
Libgd
|
|
Libseccomp
|
|
Libxml2
|
|
M4
|
|
Make
|
|
Meson
|
|
Mksh
|
|
NSS
|
|
NSSCACert
|
|
Ninja
|
|
Packaging
|
|
Patch
|
|
Perl
|
|
PkgConfig
|
|
Pluggy
|
|
PyTest
|
|
Pygments
|
|
Python
|
|
Rsync
|
|
Setuptools
|
|
Wayland
|
|
WaylandProtocols
|
|
XCB
|
|
XCBProto
|
|
Xproto
|
|
Zlib
|
|
|
|
buildcatrust
|
|
|
|
// _presetEnd is the total number of presets and does not denote a preset.
|
|
_presetEnd
|
|
)
|
|
|
|
var (
|
|
// artifactsF is an array of functions for the result of [PArtifact].
|
|
artifactsF [_presetEnd]func(t Toolchain) pkg.Artifact
|
|
|
|
// artifacts stores the result of artifactsF.
|
|
artifacts [_toolchainEnd][len(artifactsF)]pkg.Artifact
|
|
// artifactsOnce is for lazy initialisation of artifacts.
|
|
artifactsOnce [_toolchainEnd][len(artifactsF)]sync.Once
|
|
)
|
|
|
|
// 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)
|
|
})
|
|
return artifacts[t][p]
|
|
}
|
|
|
|
// ResolveName returns a [PArtifact] by name.
|
|
func (t Toolchain) ResolveName(name string) (p PArtifact, ok bool) {
|
|
p, ok = map[string]PArtifact{
|
|
"acl": ACL,
|
|
"attr": Attr,
|
|
"autoconf": Autoconf,
|
|
"bash": Bash,
|
|
"busybox": Busybox,
|
|
"cmake": CMake,
|
|
"coreutils": Coreutils,
|
|
"diffutils": Diffutils,
|
|
"fuse": Fuse,
|
|
"gawk": Gawk,
|
|
"gettext": Gettext,
|
|
"git": Git,
|
|
"go": Go,
|
|
"gperf": Gperf,
|
|
"hakurei": Hakurei,
|
|
"hakurei-dist": HakureiDist,
|
|
"iniconfig": IniConfig,
|
|
"kernel-headers": KernelHeaders,
|
|
"libXau": LibXau,
|
|
"libexpat": Libexpat,
|
|
"libseccomp": Libseccomp,
|
|
"libxml2": Libxml2,
|
|
"libffi": Libffi,
|
|
"libgd": Libgd,
|
|
"m4": M4,
|
|
"make": Make,
|
|
"meson": Meson,
|
|
"mksh": Mksh,
|
|
"nss": NSS,
|
|
"nss-cacert": NSSCACert,
|
|
"ninja": Ninja,
|
|
"packaging": Packaging,
|
|
"patch": Patch,
|
|
"perl": Perl,
|
|
"pkg-config": PkgConfig,
|
|
"pluggy": Pluggy,
|
|
"pytest": PyTest,
|
|
"pygments": Pygments,
|
|
"python": Python,
|
|
"rsync": Rsync,
|
|
"setuptools": Setuptools,
|
|
"wayland": Wayland,
|
|
"wayland-protocols": WaylandProtocols,
|
|
"xcb": XCB,
|
|
"xcb-proto": XCBProto,
|
|
"xproto": Xproto,
|
|
"zlib": Zlib,
|
|
}[name]
|
|
return
|
|
}
|