internal/rosa: lazy initialise all artifacts
All checks were successful
Test / Create distribution (push) Successful in 48s
Test / Sandbox (push) Successful in 2m37s
Test / Hakurei (push) Successful in 4m5s
Test / ShareFS (push) Successful in 4m2s
Test / Hpkg (push) Successful in 4m33s
Test / Sandbox (race detector) (push) Successful in 4m59s
Test / Hakurei (race detector) (push) Successful in 5m57s
Test / Flake checks (push) Successful in 1m44s

This improves performance, though not as drastically as lazy initialising llvm.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-25 01:32:21 +09:00
parent 43b8a40fc0
commit 20790af71e
17 changed files with 174 additions and 94 deletions

View File

@@ -2,8 +2,7 @@ package rosa
import "hakurei.app/internal/pkg"
// NewMake returns a [pkg.Artifact] containing an installation of GNU Make.
func (t Toolchain) NewMake() pkg.Artifact {
func (t Toolchain) newMake() pkg.Artifact {
const (
version = "4.4.1"
checksum = "YS_B07ZcAy9PbaK5_vKGj64SrxO2VMpnMKfc9I0Q9IC1rn0RwOH7802pJoj2Mq4a"
@@ -23,15 +22,15 @@ cd "$(mktemp -d)"
pkg.TarGzip,
)))
}
func init() { artifactsF[Make] = Toolchain.newMake }
// NewM4 returns a [pkg.Artifact] containing an installation of GNU M4.
func (t Toolchain) NewM4() pkg.Artifact {
func (t Toolchain) newM4() pkg.Artifact {
const (
version = "1.4.20"
checksum = "RT0_L3m4Co86bVBY3lCFAEs040yI1WdeNmRylFpah8IZovTm6O4wI7qiHJN3qsW9"
)
return t.New("m4-"+version, []pkg.Artifact{
t.NewMake(),
t.Load(Make),
}, nil, nil, `
cd /usr/src/m4
chmod +w tests/test-c32ispunct.sh && echo '#!/bin/sh' > tests/test-c32ispunct.sh
@@ -49,17 +48,17 @@ make DESTDIR=/work install
pkg.TarBzip2,
)))
}
func init() { artifactsF[M4] = Toolchain.newM4 }
// NewAutoconf returns a [pkg.Artifact] containing an installation of GNU Autoconf.
func (t Toolchain) NewAutoconf() pkg.Artifact {
func (t Toolchain) newAutoconf() pkg.Artifact {
const (
version = "2.72"
checksum = "-c5blYkC-xLDer3TWEqJTyh1RLbOd1c5dnRLKsDnIrg_wWNOLBpaqMY8FvmUFJ33"
)
return t.New("autoconf-"+version, []pkg.Artifact{
t.NewMake(),
t.NewM4(),
t.NewPerl(),
t.Load(Make),
t.Load(M4),
t.Load(Perl),
}, nil, nil, `
cd "$(mktemp -d)"
/usr/src/autoconf/configure \
@@ -74,15 +73,15 @@ make DESTDIR=/work install
pkg.TarGzip,
)))
}
func init() { artifactsF[Autoconf] = Toolchain.newAutoconf }
// NewGettext returns a [pkg.Artifact] containing an installation of GNU gettext.
func (t Toolchain) NewGettext() pkg.Artifact {
func (t Toolchain) newGettext() pkg.Artifact {
const (
version = "0.26"
checksum = "IMu7yDZX7xL5UO1ZxXc-iBMbY9LLEUlOroyuSlHMZwg9MKtxG7HIm8F2LheDua0y"
)
return t.New("gettext-"+version, []pkg.Artifact{
t.NewMake(),
t.Load(Make),
}, nil, nil, `
cd /usr/src/gettext
test_disable() { chmod +w "$2" && echo "$1" > "$2"; }
@@ -110,15 +109,15 @@ make DESTDIR=/work install
pkg.TarGzip,
)))
}
func init() { artifactsF[Gettext] = Toolchain.newGettext }
// NewDiffutils returns a [pkg.Artifact] containing an installation of GNU diffutils.
func (t Toolchain) NewDiffutils() pkg.Artifact {
func (t Toolchain) newDiffutils() pkg.Artifact {
const (
version = "3.12"
checksum = "9J5VAq5oA7eqwzS1Yvw-l3G5o-TccUrNQR3PvyB_lgdryOFAfxtvQfKfhdpquE44"
)
return t.New("diffutils-"+version, []pkg.Artifact{
t.NewMake(),
t.Load(Make),
}, nil, nil, `
cd /usr/src/diffutils
test_disable() { chmod +w "$2" && echo "$1" > "$2"; }
@@ -139,15 +138,15 @@ make DESTDIR=/work install
pkg.TarGzip,
)))
}
func init() { artifactsF[Diffutils] = Toolchain.newDiffutils }
// NewPatch returns a [pkg.Artifact] containing an installation of GNU patch.
func (t Toolchain) NewPatch() pkg.Artifact {
func (t Toolchain) newPatch() pkg.Artifact {
const (
version = "2.8"
checksum = "MA0BQc662i8QYBD-DdGgyyfTwaeALZ1K0yusV9rAmNiIsQdX-69YC4t9JEGXZkeR"
)
return t.New("patch-"+version, []pkg.Artifact{
t.NewMake(),
t.Load(Make),
}, nil, nil, `
cd /usr/src/patch
test_disable() { chmod +w "$2" && echo "$1" > "$2"; }
@@ -168,15 +167,15 @@ make DESTDIR=/work install
pkg.TarGzip,
)))
}
func init() { artifactsF[Patch] = Toolchain.newPatch }
// NewBash returns a [pkg.Artifact] containing an installation of GNU Bash.
func (t Toolchain) NewBash() pkg.Artifact {
func (t Toolchain) newBash() pkg.Artifact {
const (
version = "5.3"
checksum = "4LQ_GRoB_ko-Ih8QPf_xRKA02xAm_TOxQgcJLmFDT6udUPxTAWrsj-ZNeuTusyDq"
)
return t.New("bash-"+version, []pkg.Artifact{
t.NewMake(),
t.Load(Make),
}, nil, nil, `
cd "$(mktemp -d)"
/usr/src/bash/configure \
@@ -192,18 +191,18 @@ make DESTDIR=/work install
pkg.TarGzip,
)))
}
func init() { artifactsF[Bash] = Toolchain.newBash }
// NewCoreutils returns a [pkg.Artifact] containing an installation of GNU Coreutils.
func (t Toolchain) NewCoreutils() pkg.Artifact {
func (t Toolchain) newCoreutils() pkg.Artifact {
const (
version = "9.9"
checksum = "B1_TaXj1j5aiVIcazLWu8Ix03wDV54uo2_iBry4qHG6Y-9bjDpUPlkNLmU_3Nvw6"
)
return t.New("coreutils-"+version, []pkg.Artifact{
t.NewMake(),
t.NewPerl(),
t.Load(Make),
t.Load(Perl),
t.NewKernelHeaders(),
t.Load(KernelHeaders),
}, nil, nil, `
cd /usr/src/coreutils
test_disable() { chmod +w "$2" && echo "$1" > "$2"; }
@@ -223,3 +222,4 @@ make DESTDIR=/work install
pkg.TarGzip,
)))
}
func init() { artifactsF[Coreutils] = Toolchain.newCoreutils }