Stop treating Firecracker, kernels, modules, and guest images as tracked source files. Source checkouts now resolve runtime assets from ./runtime, while installed binaries keep using ../lib/banger. Add a small runtimebundle helper plus runtime-bundle.toml so make can bootstrap, package, and install a runtime bundle with checksum validation. Update the shell helpers and daemon path hints to fail clearly when the bundle is missing instead of assuming repo-root artifacts. This removes the tracked runtime blobs from HEAD in favor of an ignored local runtime/ tree. Verified with go test ./..., make build, bash -n on the shell helpers, make -n install, and a temporary package/fetch smoke test. The manifest URL/SHA still need a published bundle before fresh clones can bootstrap, and history rewrite remains a separate rollout step.
93 lines
3.5 KiB
Makefile
93 lines
3.5 KiB
Makefile
SHELL := /usr/bin/env bash
|
|
|
|
GO ?= go
|
|
GOFMT ?= gofmt
|
|
INSTALL ?= install
|
|
PREFIX ?= $(HOME)/.local
|
|
BINDIR ?= $(PREFIX)/bin
|
|
LIBDIR ?= $(PREFIX)/lib
|
|
RUNTIMEDIR ?= $(LIBDIR)/banger
|
|
DESTDIR ?=
|
|
RUNTIME_MANIFEST ?= runtime-bundle.toml
|
|
RUNTIME_SOURCE_DIR ?= runtime
|
|
RUNTIME_ARCHIVE ?= dist/banger-runtime.tar.gz
|
|
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 id_ed25519 rootfs-docker.ext4
|
|
RUNTIME_OPTIONAL_DATA_FILES := rootfs.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
|
|
|
|
.PHONY: help build banger bangerd test fmt tidy clean rootfs install runtime-bundle runtime-package check-runtime
|
|
|
|
help:
|
|
@printf '%s\n' \
|
|
'Targets:' \
|
|
' make build Build ./banger and ./bangerd' \
|
|
' make runtime-bundle Download and unpack ./runtime from runtime-bundle.toml' \
|
|
' make runtime-package Package $(RUNTIME_SOURCE_DIR) into $(RUNTIME_ARCHIVE) and print its SHA256' \
|
|
' 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 Rebuild the source-checkout default rootfs image in ./runtime'
|
|
|
|
build: $(BINARIES)
|
|
|
|
banger: $(GO_SOURCES) go.mod go.sum
|
|
$(GO) build -o ./banger ./cmd/banger
|
|
|
|
bangerd: $(GO_SOURCES) go.mod go.sum
|
|
$(GO) build -o ./bangerd ./cmd/bangerd
|
|
|
|
test:
|
|
$(GO) test ./...
|
|
|
|
fmt:
|
|
$(GOFMT) -w $(GO_SOURCES)
|
|
|
|
tidy:
|
|
$(GO) mod tidy
|
|
|
|
clean:
|
|
rm -f ./banger ./bangerd
|
|
|
|
runtime-bundle:
|
|
$(GO) run ./cmd/runtimebundle fetch --manifest "$(RUNTIME_MANIFEST)" --out "$(RUNTIME_SOURCE_DIR)"
|
|
|
|
runtime-package:
|
|
$(GO) run ./cmd/runtimebundle package --manifest "$(RUNTIME_MANIFEST)" --runtime-dir "$(RUNTIME_SOURCE_DIR)" --out "$(RUNTIME_ARCHIVE)"
|
|
|
|
check-runtime:
|
|
@test -d "$(RUNTIME_SOURCE_DIR)" || { echo "missing runtime bundle directory: $(RUNTIME_SOURCE_DIR); run 'make runtime-bundle'" >&2; exit 1; }
|
|
@for path in $(RUNTIME_EXECUTABLES) $(RUNTIME_DATA_FILES) $(RUNTIME_BOOT_FILES) $(RUNTIME_MODULES_DIR); do \
|
|
test -e "$(RUNTIME_SOURCE_DIR)/$$path" || { echo "missing runtime artifact: $(RUNTIME_SOURCE_DIR)/$$path; run 'make runtime-bundle'" >&2; exit 1; }; \
|
|
done
|
|
|
|
install: build check-runtime
|
|
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 "$(RUNTIME_SOURCE_DIR)/$$path" "$(DESTDIR)$(RUNTIMEDIR)/$$path"; \
|
|
done
|
|
@for path in $(RUNTIME_DATA_FILES) $(RUNTIME_BOOT_FILES); do \
|
|
$(INSTALL) -m 0644 "$(RUNTIME_SOURCE_DIR)/$$path" "$(DESTDIR)$(RUNTIMEDIR)/$$path"; \
|
|
done
|
|
@for path in $(RUNTIME_OPTIONAL_DATA_FILES); do \
|
|
if test -e "$(RUNTIME_SOURCE_DIR)/$$path"; then \
|
|
$(INSTALL) -m 0644 "$(RUNTIME_SOURCE_DIR)/$$path" "$(DESTDIR)$(RUNTIMEDIR)/$$path"; \
|
|
fi; \
|
|
done
|
|
chmod 0600 "$(DESTDIR)$(RUNTIMEDIR)/id_ed25519"
|
|
cp -a "$(RUNTIME_SOURCE_DIR)/$(RUNTIME_MODULES_DIR)" "$(DESTDIR)$(RUNTIMEDIR)/wtf/root/lib/modules/"
|
|
|
|
rootfs:
|
|
BANGER_RUNTIME_DIR="$(abspath $(RUNTIME_SOURCE_DIR))" ./make-rootfs.sh
|