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"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container"
|
"hakurei.app/container"
|
||||||
"hakurei.app/internal/pkg"
|
"hakurei.app/internal/pkg"
|
||||||
"hakurei.app/internal/rosa"
|
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -22,10 +20,15 @@ type cache struct {
|
|||||||
// Should generally not be used directly.
|
// Should generally not be used directly.
|
||||||
c *pkg.Cache
|
c *pkg.Cache
|
||||||
|
|
||||||
cures, jobs int
|
cures, jobs int
|
||||||
hostAbstract, idle bool
|
// Primarily to work around missing landlock LSM.
|
||||||
verboseInit bool
|
hostAbstract bool
|
||||||
arch string
|
// Set SCHED_IDLE.
|
||||||
|
idle bool
|
||||||
|
// Unset [pkg.CSuppressInit].
|
||||||
|
verboseInit bool
|
||||||
|
// Loaded artifact of [rosa.QEMU].
|
||||||
|
qemu pkg.Artifact
|
||||||
|
|
||||||
base string
|
base string
|
||||||
}
|
}
|
||||||
@@ -83,49 +86,32 @@ func (cache *cache) open() (err error) {
|
|||||||
}
|
}
|
||||||
done <- struct{}{}
|
done <- struct{}{}
|
||||||
|
|
||||||
if cache.arch != "" && cache.arch != runtime.GOARCH {
|
if cache.qemu != nil {
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
var pathname *check.Absolute
|
var pathname *check.Absolute
|
||||||
pathname, _, err = cache.c.Cure(rosa.Std.Load(rosa.QEMU))
|
pathname, _, err = cache.c.Cure(cache.qemu)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cache.c.Close()
|
cache.c.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg.RegisterArch(cache.arch, container.BinfmtEntry{
|
pkg.RegisterArch("riscv64", container.BinfmtEntry{
|
||||||
Offset: offset,
|
Offset: 0,
|
||||||
Magic: magic,
|
Magic: "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00",
|
||||||
Mask: mask,
|
Mask: "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff",
|
||||||
Interpreter: pathname.Append(
|
Interpreter: pathname.Append(
|
||||||
"system/bin",
|
"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
|
return
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ func main() {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
flagQuiet bool
|
flagQuiet bool
|
||||||
|
flagQEMU bool
|
||||||
|
flagArch string
|
||||||
flagCheck bool
|
flagCheck bool
|
||||||
flagLTO bool
|
flagLTO bool
|
||||||
|
|
||||||
@@ -94,6 +96,17 @@ func main() {
|
|||||||
flags |= rosa.OptLLVMNoLTO
|
flags |= rosa.OptLLVMNoLTO
|
||||||
}
|
}
|
||||||
rosa.DropCaches("", flags)
|
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
|
return nil
|
||||||
}).Flag(
|
}).Flag(
|
||||||
@@ -101,7 +114,11 @@ func main() {
|
|||||||
"q", command.BoolFlag(false),
|
"q", command.BoolFlag(false),
|
||||||
"Do not print cure messages",
|
"Do not print cure messages",
|
||||||
).Flag(
|
).Flag(
|
||||||
&cm.arch,
|
&flagQEMU,
|
||||||
|
"register", command.BoolFlag(false),
|
||||||
|
"Enable additional target architectures",
|
||||||
|
).Flag(
|
||||||
|
&flagArch,
|
||||||
"arch", command.StringFlag(runtime.GOARCH),
|
"arch", command.StringFlag(runtime.GOARCH),
|
||||||
"Target architecture",
|
"Target architecture",
|
||||||
).Flag(
|
).Flag(
|
||||||
|
|||||||
@@ -49,3 +49,12 @@ func init() {
|
|||||||
Description: "Rosa OS stage0 bootstrap seed",
|
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