aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-02-10 19:40:45 +0900
committerOphestra <cat@gensokyo.uk>2026-02-10 21:22:46 +0900
commitfb101a02f21d048515561659b06bfc2a35568c56 (patch)
tree463d221e3408de18728ba85cf3412cde8b5a3e48
parent3dbd67d1138e46d15df408d1404c946163e15ef1 (diff)
internal/rosa: self-host stage0 tarball
This replaces gentoo stage3 tarballs. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--cmd/mbf/main.go92
-rw-r--r--internal/rosa/all.go4
-rw-r--r--internal/rosa/stage0.go39
-rw-r--r--internal/rosa/toybox.go4
4 files changed, 102 insertions, 37 deletions
diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go
index db5e80af..83bb6714 100644
--- a/cmd/mbf/main.go
+++ b/cmd/mbf/main.go
@@ -109,46 +109,66 @@ func main() {
)
}
- c.NewCommand(
- "stage3",
- "Check for toolchain 3-stage non-determinism",
- func(args []string) (err error) {
- _, _, _, stage1 := (rosa.Std - 2).NewLLVM()
- _, _, _, stage2 := (rosa.Std - 1).NewLLVM()
- _, _, _, stage3 := rosa.Std.NewLLVM()
- var (
- pathname *check.Absolute
- checksum [2]unique.Handle[pkg.Checksum]
- )
+ {
+ var (
+ flagStage0 bool
+ )
+ c.NewCommand(
+ "stage3",
+ "Check for toolchain 3-stage non-determinism",
+ func(args []string) (err error) {
+ _, _, _, stage1 := (rosa.Std - 2).NewLLVM()
+ _, _, _, stage2 := (rosa.Std - 1).NewLLVM()
+ _, _, _, stage3 := rosa.Std.NewLLVM()
+ var (
+ pathname *check.Absolute
+ checksum [2]unique.Handle[pkg.Checksum]
+ )
- if pathname, _, err = cache.Cure(stage1); err != nil {
- return err
- }
- log.Println("stage1:", pathname)
+ if pathname, _, err = cache.Cure(stage1); err != nil {
+ return err
+ }
+ log.Println("stage1:", pathname)
- if pathname, checksum[0], err = cache.Cure(stage2); err != nil {
- return err
- }
- log.Println("stage2:", pathname)
- if pathname, checksum[1], err = cache.Cure(stage3); err != nil {
- return err
- }
- log.Println("stage3:", pathname)
+ if pathname, checksum[0], err = cache.Cure(stage2); err != nil {
+ return err
+ }
+ log.Println("stage2:", pathname)
+ if pathname, checksum[1], err = cache.Cure(stage3); err != nil {
+ return err
+ }
+ log.Println("stage3:", pathname)
- if checksum[0] != checksum[1] {
- err = &pkg.ChecksumMismatchError{
- Got: checksum[0].Value(),
- Want: checksum[1].Value(),
+ if checksum[0] != checksum[1] {
+ err = &pkg.ChecksumMismatchError{
+ Got: checksum[0].Value(),
+ Want: checksum[1].Value(),
+ }
+ } else {
+ log.Println(
+ "stage2 is identical to stage3",
+ "("+pkg.Encode(checksum[0].Value())+")",
+ )
}
- } else {
- log.Println(
- "stage2 is identical to stage3",
- "("+pkg.Encode(checksum[0].Value())+")",
- )
- }
- return
- },
- )
+
+ if flagStage0 {
+ if pathname, _, err = cache.Cure(
+ rosa.Std.Load(rosa.Stage0),
+ ); err != nil {
+ return err
+ }
+ log.Println(pathname)
+ }
+
+ return
+ },
+ ).
+ Flag(
+ &flagStage0,
+ "stage0", command.BoolFlag(false),
+ "Create bootstrap stage0 tarball",
+ )
+ }
{
var (
diff --git a/internal/rosa/all.go b/internal/rosa/all.go
index 0fdfdc8a..6c1a8ab7 100644
--- a/internal/rosa/all.go
+++ b/internal/rosa/all.go
@@ -83,6 +83,10 @@ const (
// 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
)
diff --git a/internal/rosa/stage0.go b/internal/rosa/stage0.go
new file mode 100644
index 00000000..7b347255
--- /dev/null
+++ b/internal/rosa/stage0.go
@@ -0,0 +1,39 @@
+package rosa
+
+import "hakurei.app/internal/pkg"
+
+func (t Toolchain) newStage0() pkg.Artifact {
+ musl, compilerRT, runtimes, clang := t.NewLLVM()
+ return t.New("rosa-stage0", 0, []pkg.Artifact{
+ musl,
+ compilerRT,
+ runtimes,
+ clang,
+
+ t.Load(Bzip2),
+
+ t.Load(Patch),
+ t.Load(Make),
+ t.Load(CMake),
+ t.Load(Ninja),
+
+ t.Load(Libffi),
+ t.Load(Python),
+ t.Load(Perl),
+ t.Load(Diffutils),
+ t.Load(Bash),
+ t.Load(Gawk),
+ t.Load(Coreutils),
+ t.Load(Findutils),
+
+ t.Load(KernelHeaders),
+ }, nil, nil, `
+umask 377
+tar \
+ -vjc \
+ -C / \
+ -f /work/stage0-`+triplet()+`.tar.bz2 \
+ system bin usr/bin/env
+`)
+}
+func init() { artifactsF[Stage0] = Toolchain.newStage0 }
diff --git a/internal/rosa/toybox.go b/internal/rosa/toybox.go
index 2e4d470e..a35215b7 100644
--- a/internal/rosa/toybox.go
+++ b/internal/rosa/toybox.go
@@ -16,7 +16,9 @@ func (t Toolchain) newToybox(suffix, script string) pkg.Artifact {
), nil, stage0Concat(t, []string{},
"ROSA_CHECK=make USER=cure tests",
), `
-ln -s ../system/bin/bash /bin/ || true
+chmod +w /bin/
+ln -sf ../system/bin/bash /bin/
+
cd /usr/src/toybox
chmod +w kconfig tests
rm \