internal/pkg: support explicit overlay mount
All checks were successful
Test / Create distribution (push) Successful in 47s
Test / Sandbox (push) Successful in 2m48s
Test / ShareFS (push) Successful in 4m43s
Test / Sandbox (race detector) (push) Successful in 5m15s
Test / Hpkg (push) Successful in 5m25s
Test / Hakurei (push) Successful in 5m38s
Test / Hakurei (race detector) (push) Successful in 7m28s
Test / Flake checks (push) Successful in 1m44s

This removes all but the /work/ auto overlay behaviour and enables much greater flexibility. This also renames ExecContainerPath to ExecPath so it is easier to type.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-08 07:36:01 +09:00
parent b3c30bcc51
commit 7bd4d7d0e6
4 changed files with 110 additions and 215 deletions

View File

@@ -24,6 +24,7 @@ func main() {
wantArgs := []string{"testtool"}
if len(os.Args) == 2 {
hostNet = true
log.SetPrefix("testtool(net): ")
wantArgs = []string{"testtool", "net"}
}
if !slices.Equal(os.Args, wantArgs) {
@@ -34,27 +35,25 @@ func main() {
wantEnv := []string{"HAKUREI_TEST=1"}
if len(os.Environ()) == 2 {
overlayRoot = true
log.SetPrefix("testtool(overlay root): ")
wantEnv = []string{"HAKUREI_TEST=1", "HAKUREI_ROOT=1"}
}
if !slices.Equal(wantEnv, os.Environ()) {
log.Fatalf("Environ: %q, want %q", os.Environ(), wantEnv)
}
var overlayTmp, overlayWork bool
var overlayWork bool
const (
wantExec = "/opt/bin/testtool"
wantExecTmp = "/tmp/bin/testtool"
wantExecWork = "/work/bin/testtool"
)
if got, err := os.Executable(); err != nil {
log.Fatalf("Executable: error = %v", err)
} else if got != wantExec {
switch got {
case wantExecTmp:
overlayTmp = true
case wantExecWork:
overlayWork = true
log.SetPrefix("testtool(overlay work): ")
default:
log.Fatalf("Executable: %q, want %q", got, wantExec)
@@ -99,12 +98,12 @@ func main() {
}
const checksumEmptyDir = "MGWmEfjut2QE2xPJwTsmUzpff4BN_FEnQ7T0j7gvUCCiugJQNwqt9m151fm9D1yU"
ident := "oHuqV7p0v1Vd8IdAzjyYM8sfCS0P2LR5tfv5cb6Gbf2ZWUm8Ec-7hYPJ_qr183m7"
ident := "U2cbgVgEtjfRuvHfE1cQnZ3t8yoexULQyo_VLgvxAVJSsobMcNaFIsuDWtmt7kzK"
log.Println(m)
next := func() { m = m.Next; log.Println(m) }
if overlayRoot {
ident = "cIjP14zs5el6W_BQhufL_c0vWg-V6Z6pDpsbEa3sYtZ1381u1bKnH3N16RIrw-1S"
ident = "5ey2wpmMpj483YYa7ZZQciYLA2cx3_l167JCqWW4Pd-5DVp81dj9EsBtVTwYptF6"
if m.Root != "/" || m.Target != "/" ||
m.Source != "overlay" || m.FsType != "overlay" {
@@ -122,7 +121,7 @@ func main() {
}
} else {
if hostNet {
ident = "I3T53NtN6HPAyyodHtq2B0clcsoS1nPdvCEb-Zc5K-hoqFGL2od1mftHhwG7gX1S"
ident = "QdsJhGgnk5N2xdUNGcndXQxFKifxf1V_2t9X8CQ-pDcg24x6mGJC_BiLfGbs6Qml"
}
if m.Root != "/sysroot" || m.Target != "/" {
@@ -140,28 +139,11 @@ func main() {
}
}
if !overlayTmp {
next() // testtool artifact
} else {
ident = "3ELJ8l42g6XeIoLGR9LheVhMIwSIleD6VrhsliBuon5DAdBOwFSMqd7aiUI4fll7"
next()
if path.Base(m.Root) != checksumEmptyDir || m.Target != "/tmp" {
log.Fatal("unexpected artifact checksum")
}
}
if overlayTmp {
next() // testtool artifact
if m.Root != "/" || m.Target != "/tmp" ||
m.Source != "overlay" || m.FsType != "overlay" {
log.Fatal("unexpected temp mount entry")
}
}
next() // testtool artifact
next()
if overlayWork {
ident = "VMCurZKCA_MV80zb-ZBWVytfl3rhYOKJeo2u9l-OuaytQ_w_r4EsqgJ2nfO93x5_"
ident = "5ynpgDp5mcAmbFndOESXjQnOy_RG6furIxDpQz6c0bImBBLMAI8FouNbAB0uNs6f"
if m.Root != "/" || m.Target != "/work" ||
m.Source != "overlay" || m.FsType != "overlay" {
log.Fatal("unexpected work mount entry")
@@ -172,11 +154,9 @@ func main() {
}
}
if !overlayTmp {
next()
if path.Base(m.Root) != ident || m.Target != "/tmp" {
log.Fatal("unexpected temp mount entry")
}
next()
if path.Base(m.Root) != ident || m.Target != "/tmp" {
log.Fatal("unexpected temp mount entry")
}
next()