Make installed banger self-contained
Fix the misleading make install path where banger and bangerd still depended on a repo checkout for Firecracker, guest artifacts, image builds, and the SSH key. Replace repo-root inference with an explicit runtime bundle model: resolve a runtime_dir from env/config/install layout, derive concrete artifact paths from it, and update the daemon, CLI, and image-build flow to use those paths. Keep repo_root only as an explicit compatibility alias instead of auto-detecting it. Teach customize.sh to run from a read-only bundled runtime tree while writing transient state under XDG/BANGER_STATE_DIR, and make make install copy the runtime assets into PREFIX/lib/banger so installed binaries stay usable outside the repo. Validate with go test ./..., make build, bash -n customize.sh, and make install DESTDIR=/tmp/banger-install PREFIX=/usr. An out-of-repo installed-binary smoke test was attempted, but this sandbox blocked bangerd from binding its Unix socket (setsockopt: operation not permitted).
This commit is contained in:
parent
375900cf65
commit
ce1be52047
13 changed files with 437 additions and 107 deletions
54
internal/daemon/daemon_test.go
Normal file
54
internal/daemon/daemon_test.go
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
package daemon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"banger/internal/model"
|
||||
"banger/internal/store"
|
||||
)
|
||||
|
||||
func TestEnsureDefaultImageUsesConfiguredDefaultRootfs(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
rootfs := filepath.Join(dir, "rootfs-docker.ext4")
|
||||
kernel := filepath.Join(dir, "vmlinux")
|
||||
for _, path := range []string{rootfs, kernel} {
|
||||
if err := os.WriteFile(path, []byte("test"), 0o644); err != nil {
|
||||
t.Fatalf("write %s: %v", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
db, err := store.Open(filepath.Join(dir, "state.db"))
|
||||
if err != nil {
|
||||
t.Fatalf("open store: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
_ = db.Close()
|
||||
})
|
||||
|
||||
d := &Daemon{
|
||||
config: model.DaemonConfig{
|
||||
DefaultImageName: "default",
|
||||
DefaultRootfs: rootfs,
|
||||
DefaultKernel: kernel,
|
||||
},
|
||||
store: db,
|
||||
}
|
||||
|
||||
if err := d.ensureDefaultImage(context.Background()); err != nil {
|
||||
t.Fatalf("ensureDefaultImage: %v", err)
|
||||
}
|
||||
|
||||
image, err := db.GetImageByName(context.Background(), "default")
|
||||
if err != nil {
|
||||
t.Fatalf("GetImageByName: %v", err)
|
||||
}
|
||||
if image.RootfsPath != rootfs {
|
||||
t.Fatalf("RootfsPath = %q, want %q", image.RootfsPath, rootfs)
|
||||
}
|
||||
if image.KernelPath != kernel {
|
||||
t.Fatalf("KernelPath = %q, want %q", image.KernelPath, kernel)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue