cmd/mbf: optionally register all targets
All checks were successful
Test / Create distribution (push) Successful in 2m53s
Test / Sandbox (push) Successful in 7m1s
Test / Hakurei (push) Successful in 8m58s
Test / ShareFS (push) Successful in 9m25s
Test / Sandbox (race detector) (push) Successful in 9m30s
Test / Hakurei (race detector) (push) Successful in 12m26s
Test / Flake checks (push) Successful in 2m36s
All checks were successful
Test / Create distribution (push) Successful in 2m53s
Test / Sandbox (push) Successful in 7m1s
Test / Hakurei (push) Successful in 8m58s
Test / ShareFS (push) Successful in 9m25s
Test / Sandbox (race detector) (push) Successful in 9m30s
Test / Hakurei (race detector) (push) Successful in 12m26s
Test / Flake checks (push) Successful in 2m36s
This enables non-native cures from the daemon. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -4,13 +4,11 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"hakurei.app/check"
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/internal/pkg"
|
||||
"hakurei.app/internal/rosa"
|
||||
"hakurei.app/message"
|
||||
)
|
||||
|
||||
@@ -22,10 +20,15 @@ type cache struct {
|
||||
// Should generally not be used directly.
|
||||
c *pkg.Cache
|
||||
|
||||
cures, jobs int
|
||||
hostAbstract, idle bool
|
||||
verboseInit bool
|
||||
arch string
|
||||
cures, jobs int
|
||||
// Primarily to work around missing landlock LSM.
|
||||
hostAbstract bool
|
||||
// Set SCHED_IDLE.
|
||||
idle bool
|
||||
// Unset [pkg.CSuppressInit].
|
||||
verboseInit bool
|
||||
// Loaded artifact of [rosa.QEMU].
|
||||
qemu pkg.Artifact
|
||||
|
||||
base string
|
||||
}
|
||||
@@ -83,49 +86,32 @@ func (cache *cache) open() (err error) {
|
||||
}
|
||||
done <- struct{}{}
|
||||
|
||||
if cache.arch != "" && cache.arch != runtime.GOARCH {
|
||||
var (
|
||||
name string
|
||||
offset byte
|
||||
magic string
|
||||
mask string
|
||||
)
|
||||
switch cache.arch {
|
||||
case "riscv64":
|
||||
name = "riscv64"
|
||||
offset = 0
|
||||
magic = "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00"
|
||||
mask = "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
|
||||
|
||||
case "arm64":
|
||||
name = "aarch64"
|
||||
offset = 0
|
||||
magic = "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00"
|
||||
mask = "\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
|
||||
|
||||
default:
|
||||
cache.c.Close()
|
||||
err = pkg.UnsupportedArchError(cache.arch)
|
||||
return
|
||||
}
|
||||
|
||||
if cache.qemu != nil {
|
||||
var pathname *check.Absolute
|
||||
pathname, _, err = cache.c.Cure(rosa.Std.Load(rosa.QEMU))
|
||||
pathname, _, err = cache.c.Cure(cache.qemu)
|
||||
if err != nil {
|
||||
cache.c.Close()
|
||||
return
|
||||
}
|
||||
|
||||
pkg.RegisterArch(cache.arch, container.BinfmtEntry{
|
||||
Offset: offset,
|
||||
Magic: magic,
|
||||
Mask: mask,
|
||||
pkg.RegisterArch("riscv64", container.BinfmtEntry{
|
||||
Offset: 0,
|
||||
Magic: "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00",
|
||||
Mask: "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff",
|
||||
Interpreter: pathname.Append(
|
||||
"system/bin",
|
||||
"qemu-"+name,
|
||||
"qemu-riscv64",
|
||||
),
|
||||
})
|
||||
pkg.RegisterArch("arm64", container.BinfmtEntry{
|
||||
Offset: 0,
|
||||
Magic: "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00",
|
||||
Mask: "\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff",
|
||||
Interpreter: pathname.Append(
|
||||
"system/bin",
|
||||
"qemu-aarch64",
|
||||
),
|
||||
})
|
||||
rosa.DropCaches(cache.arch, rosa.Flags())
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -67,6 +67,8 @@ func main() {
|
||||
|
||||
var (
|
||||
flagQuiet bool
|
||||
flagQEMU bool
|
||||
flagArch string
|
||||
flagCheck bool
|
||||
flagLTO bool
|
||||
|
||||
@@ -94,6 +96,17 @@ func main() {
|
||||
flags |= rosa.OptLLVMNoLTO
|
||||
}
|
||||
rosa.DropCaches("", flags)
|
||||
cross := flagArch != "" && flagArch != runtime.GOARCH
|
||||
if flagQEMU || cross {
|
||||
cm.qemu = rosa.Std.Load(rosa.QEMU)
|
||||
}
|
||||
|
||||
if cross {
|
||||
rosa.DropCaches(flagArch, rosa.Flags())
|
||||
if !rosa.HasStage0() {
|
||||
return pkg.UnsupportedArchError(flagArch)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}).Flag(
|
||||
@@ -101,7 +114,11 @@ func main() {
|
||||
"q", command.BoolFlag(false),
|
||||
"Do not print cure messages",
|
||||
).Flag(
|
||||
&cm.arch,
|
||||
&flagQEMU,
|
||||
"register", command.BoolFlag(false),
|
||||
"Enable additional target architectures",
|
||||
).Flag(
|
||||
&flagArch,
|
||||
"arch", command.StringFlag(runtime.GOARCH),
|
||||
"Target architecture",
|
||||
).Flag(
|
||||
|
||||
@@ -49,3 +49,12 @@ func init() {
|
||||
Description: "Rosa OS stage0 bootstrap seed",
|
||||
}
|
||||
}
|
||||
|
||||
// HasStage0 returns whether a stage0 distribution is available.
|
||||
func HasStage0() (ok bool) {
|
||||
func() {
|
||||
defer func() { ok = recover() == nil }()
|
||||
toolchainStage0.Load(stage0Dist)
|
||||
}()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user