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
25
Makefile
25
Makefile
|
|
@ -5,9 +5,15 @@ GOFMT ?= gofmt
|
|||
INSTALL ?= install
|
||||
PREFIX ?= $(HOME)/.local
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
LIBDIR ?= $(PREFIX)/lib
|
||||
RUNTIMEDIR ?= $(LIBDIR)/banger
|
||||
DESTDIR ?=
|
||||
BINARIES := banger bangerd
|
||||
GO_SOURCES := $(shell find cmd internal -type f -name '*.go' | sort)
|
||||
RUNTIME_EXECUTABLES := firecracker customize.sh dns.sh packages.sh nat.sh namegen
|
||||
RUNTIME_DATA_FILES := packages.apt $(wildcard rootfs.ext4) $(wildcard rootfs-docker.ext4)
|
||||
RUNTIME_BOOT_FILES := wtf/root/boot/vmlinux-6.8.0-94-generic wtf/root/boot/initrd.img-6.8.0-94-generic
|
||||
RUNTIME_MODULES_DIR := wtf/root/lib/modules/6.8.0-94-generic
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
|
|
@ -17,12 +23,12 @@ help:
|
|||
@printf '%s\n' \
|
||||
'Targets:' \
|
||||
' make build Build ./banger and ./bangerd' \
|
||||
' make install Build and install binaries into $(DESTDIR)$(BINDIR)' \
|
||||
' make install Build and install binaries plus the runtime bundle into $(DESTDIR)$(BINDIR) and $(DESTDIR)$(RUNTIMEDIR)' \
|
||||
' make test Run go test ./...' \
|
||||
' make fmt Format Go sources under cmd/ and internal/' \
|
||||
' make tidy Run go mod tidy' \
|
||||
' make clean Remove built Go binaries' \
|
||||
' make rootfs Run ./make-rootfs.sh'
|
||||
' make rootfs Rebuild the repo-local default rootfs image'
|
||||
|
||||
build: $(BINARIES)
|
||||
|
||||
|
|
@ -45,9 +51,24 @@ clean:
|
|||
rm -f ./banger ./bangerd
|
||||
|
||||
install: build
|
||||
@for path in $(RUNTIME_EXECUTABLES) $(RUNTIME_BOOT_FILES) $(RUNTIME_MODULES_DIR) packages.apt id_ed25519; do \
|
||||
test -e "$$path" || { echo "missing runtime artifact: $$path" >&2; exit 1; }; \
|
||||
done
|
||||
@test -e rootfs-docker.ext4 || test -e rootfs.ext4 || { echo "missing runtime artifact: rootfs-docker.ext4 or rootfs.ext4" >&2; exit 1; }
|
||||
mkdir -p "$(DESTDIR)$(BINDIR)"
|
||||
mkdir -p "$(DESTDIR)$(RUNTIMEDIR)"
|
||||
mkdir -p "$(DESTDIR)$(RUNTIMEDIR)/wtf/root/boot"
|
||||
mkdir -p "$(DESTDIR)$(RUNTIMEDIR)/wtf/root/lib/modules"
|
||||
$(INSTALL) -m 0755 ./banger "$(DESTDIR)$(BINDIR)/banger"
|
||||
$(INSTALL) -m 0755 ./bangerd "$(DESTDIR)$(BINDIR)/bangerd"
|
||||
@for path in $(RUNTIME_EXECUTABLES); do \
|
||||
$(INSTALL) -m 0755 "$$path" "$(DESTDIR)$(RUNTIMEDIR)/$$path"; \
|
||||
done
|
||||
@for path in $(RUNTIME_DATA_FILES) $(RUNTIME_BOOT_FILES); do \
|
||||
$(INSTALL) -m 0644 "$$path" "$(DESTDIR)$(RUNTIMEDIR)/$$path"; \
|
||||
done
|
||||
$(INSTALL) -m 0600 id_ed25519 "$(DESTDIR)$(RUNTIMEDIR)/id_ed25519"
|
||||
cp -a "$(RUNTIME_MODULES_DIR)" "$(DESTDIR)$(RUNTIMEDIR)/wtf/root/lib/modules/"
|
||||
|
||||
rootfs:
|
||||
./make-rootfs.sh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue