internal/pkg: automatic overlay mount on work

This directly submits the upperdir to cache. It is primarily used in bootstrapping where tools are limited and should not be used unless there is a very good reason to.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-07 03:14:33 +09:00
parent 54da6ce03d
commit 8e08e8f518
4 changed files with 140 additions and 25 deletions

View File

@@ -40,18 +40,25 @@ func main() {
log.Fatalf("Environ: %q, want %q", os.Environ(), wantEnv)
}
var overlayTmp bool
var overlayTmp, overlayWork bool
const (
wantExec = "/opt/bin/testtool"
wantExecOverlay = "/tmp/bin/testtool"
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 {
if got != wantExecOverlay {
switch got {
case wantExecTmp:
overlayTmp = true
case wantExecWork:
overlayWork = true
default:
log.Fatalf("Executable: %q, want %q", got, wantExec)
}
overlayTmp = true
}
wantHostname := "cure"
@@ -153,8 +160,16 @@ func main() {
}
next()
if path.Base(m.Root) != ident || m.Target != "/work" {
log.Fatal("unexpected work mount entry")
if overlayWork {
ident = "VMCurZKCA_MV80zb-ZBWVytfl3rhYOKJeo2u9l-OuaytQ_w_r4EsqgJ2nfO93x5_"
if m.Root != "/" || m.Target != "/work" ||
m.Source != "overlay" || m.FsType != "overlay" {
log.Fatal("unexpected work mount entry")
}
} else {
if path.Base(m.Root) != ident || m.Target != "/work" {
log.Fatal("unexpected work mount entry")
}
}
if !overlayTmp {