From aa4a15fc2cba6df0277d8a08bbe57c68d2289859 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 25 Jul 2026 14:17:03 +0900 Subject: [PATCH] cmd/mbf: move gentoo bootstrap path This is a lot more flexible for troubleshooting when used with the cure command. Signed-off-by: Ophestra --- cmd/mbf/main.go | 56 ++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go index 686779d8..6df5d741 100644 --- a/cmd/mbf/main.go +++ b/cmd/mbf/main.go @@ -615,27 +615,10 @@ func main() { ) { - var ( - flagGentoo string - flagChecksum string - ) c.NewCommand( "stage3", "Check for toolchain 3-stage non-determinism", func(args []string) (err error) { - s := rosa.Std - if flagGentoo != "" { - s -= 3 // magic number to discourage misuse - - var checksum pkg.Checksum - if len(flagChecksum) != 0 { - if err = pkg.Decode(&checksum, flagChecksum); err != nil { - return - } - } - rosa.Native().SetGentooStage3(flagGentoo, checksum) - } - var ( pathname *check.Absolute checksum [2]unique.Handle[pkg.Checksum] @@ -643,7 +626,7 @@ func main() { _llvm := rosa.H("llvm") if err = cm.Do(func(cache *pkg.Cache) (err error) { - _, llvm := rosa.Native().New(s - 2).Load(_llvm) + _, llvm := rosa.Native().New(rosa.Std - 2).Load(_llvm) pathname, _, err = cache.Cure(llvm) return }); err != nil { @@ -652,7 +635,7 @@ func main() { log.Println("stage1:", pathname) if err = cm.Do(func(cache *pkg.Cache) (err error) { - _, llvm := rosa.Native().New(s - 1).Load(_llvm) + _, llvm := rosa.Native().New(rosa.Std - 1).Load(_llvm) pathname, checksum[0], err = cache.Cure(llvm) return }); err != nil { @@ -660,7 +643,7 @@ func main() { } log.Println("stage2:", pathname) if err = cm.Do(func(cache *pkg.Cache) (err error) { - _, llvm := rosa.Native().New(s).Load(_llvm) + _, llvm := rosa.Native().New(rosa.Std).Load(_llvm) pathname, checksum[1], err = cache.Cure(llvm) return }); err != nil { @@ -681,14 +664,6 @@ func main() { } return }, - ).Flag( - &flagGentoo, - "gentoo", command.StringFlag(""), - "Bootstrap from a Gentoo stage3 tarball", - ).Flag( - &flagChecksum, - "checksum", command.StringFlag(""), - "Checksum of Gentoo stage3 tarball", ) } @@ -705,6 +680,9 @@ func main() { flagBoot bool flagStd bool + + flagGentoo string + flagChecksum string ) c.NewCommand( "cure", @@ -721,6 +699,18 @@ func main() { t -= 1 } + if flagGentoo != "" { + var checksum pkg.Checksum + if len(flagChecksum) != 0 { + if err := pkg.Decode(&checksum, flagChecksum); err != nil { + return err + } + } + rosa.Native().SetGentooStage3(flagGentoo, checksum) + + t -= 3 // magic number to discourage misuse + } + _, a := rosa.Native().New(t).Load(rosa.ArtifactH(unique.Make(args[0]))) if a == nil { return fmt.Errorf("unknown artifact %q", args[0]) @@ -789,7 +779,7 @@ func main() { ctx, a, "", true, os.Stdin, os.Stdout, os.Stderr, - rosa.AbsSystem.Append("bin", "mksh"), + rosa.AbsSystem.Append("bin", "sh"), "sh", ) }) @@ -899,6 +889,14 @@ func main() { &flagRebuild, "rebuild", command.BoolFlag(false), "Always enter the artifact implementation", + ).Flag( + &flagGentoo, + "gentoo", command.StringFlag(""), + "Bootstrap from a Gentoo stage3 tarball", + ).Flag( + &flagChecksum, + "checksum", command.StringFlag(""), + "Checksum of Gentoo stage3 tarball", ) }