From c562f252be28507df1d2f45e1912734e1ef0a8e4 Mon Sep 17 00:00:00 2001 From: Gordon GECOS Date: Wed, 22 Nov 2023 14:30:53 -0500 Subject: build system cleanups --- .gitignore | 1 + Makefile | 32 ++++++++++++++++++-------------- fsmgr | 2 +- rootfs/Makefile | 29 +++++++++-------------------- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index b4bc1ce..4820162 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,4 @@ apt-get-update-stamp *.img *.tmp samizdat-ficlonerange +/rootfs/_filesystem/ diff --git a/Makefile b/Makefile index 1290a94..9f7a5f5 100644 --- a/Makefile +++ b/Makefile @@ -118,9 +118,10 @@ update-submodules: install-submodules: cmd=install install-submodules: update-submodules $(INSTALL_SUBMODULES) -rootfs = rootfs/_filesystem/samizdat.seed.btrfs -patchfs = $(patsubst %.seed.btrfs,%.patch.btrfs,$(rootfs)) -rootfs_verity = $(addsuffix .verity,$(rootfs) $(patchfs)) +rootfsdir = rootfs/_filesystem +rootfs = $(rootfsdir)/samizdat.seed.btrfs +patchfs = $(rootfsdir)/samizdat.patch.btrfs +rootfs_verity = $(addprefix _build/,$(addsuffix .verity,$(notdir $(rootfs) $(patchfs)))) .PHONY: rootfs rootfs-deps rootfs-deps: @@ -129,7 +130,7 @@ rootfs-deps: btrfs_images = $(rootfs) $(patchfs) rootfs-clean: - make -C rootfs clean all + make -C rootfs clean rootfs: rootfs-deps $(btrfs_images) $(rootfs_verity) sudo mkdir -p /srv/nbd @@ -138,9 +139,8 @@ ifneq (,$(patchfs)) sudo ln -sf "$$PWD"/$(patchfs) /srv/nbd/samizdat.patch.btrfs endif -FORCE: -$(btrfs_images): FORCE - $(MAKE) -C rootfs $(notdir $@) +rootfs/%.btrfs: + $(MAKE) -C rootfs $(@:rootfs/%=%) boot: rootfs sudo update-initramfs -u @@ -154,8 +154,10 @@ get_min_size="$$(btrfs inspect-internal min-dev-size --id 1 $@.mnt | (read b _; verity_root_hash = $(shell sed -ne 's/^Root hash:[ \t]*//p' $<) -%.verity.log: %.verity -%.verity: % +_build: + mkdir $@ + +_build/%.verity: rootfs/_filesystem/% | _build rm -f $@~tmp sudo veritysetup format $^ $@~tmp > $@.log~tmp sudo chmod 644 $@~tmp @@ -164,16 +166,13 @@ verity_root_hash = $(shell sed -ne 's/^Root hash:[ \t]*//p' $<) root_hash = $(shell sed -ne 's/^Root hash: *//p' < $<.log) -veritymount: $(rootfs).verity.log +veritymount: _build/$(notdir $(rootfs)).verity.log @sudo veritysetup remove samizverity >/dev/null 2>&1 || true sudo veritysetup create samizverity $(basename $(basename $<)) \ $(basename $<) \ $(verity_root_hash) sudo veritysetup remove samizverity -rootfs/%.btrfs: - $(SUDO_MAKE) -C rootfs $(notdir $@) - debian_dist := $(shell . /etc/os-release && printf %s $$VERSION_CODENAME) stale = [ ! -e $@ ] || [ $$(( $$(date +%s) - $$(date -r $@ +%s) )) -gt 36000 ] @@ -182,7 +181,12 @@ apt = $(shell which apt || which apt-get) .PHONY: apt-get-update-stamp apt-get-update-stamp: - @if $(stale); then set -x; sudo $(apt) update && touch $@; fi + @if $(stale) \ + then \ + set -x; \ + sudo dpkg --add-architecture i386; \ + sudo $(apt) update && touch $@; \ + fi rootfs/seed.iso: $(rootfs) $(if $(VERITY),$(addprefix $(rootfs),.verity .verity.log)) rm -f $@~tmp diff --git a/fsmgr b/fsmgr index 7eda6b8..486fb62 160000 --- a/fsmgr +++ b/fsmgr @@ -1 +1 @@ -Subproject commit 7eda6b846463c19411efd2747d3c6c3b3b9d3566 +Subproject commit 486fb62abd0ac5a87a85ca18beb939d21323fad1 diff --git a/rootfs/Makefile b/rootfs/Makefile index ef2921e..c85132f 100644 --- a/rootfs/Makefile +++ b/rootfs/Makefile @@ -6,38 +6,27 @@ endif sudo := $(shell [ "$$(id -u)" = 0 ] || echo sudo) -rootfs ?= samizdat.seed.btrfs -patchfs ?= samizdat.patch.btrfs - .DEFAULT_GOAL = all -.PHONY: all rootfs patchfs clean cleaner -all: $(rootfs) $(patchfs) +.PHONY: all clean cleaner +all: $(addprefix _filesystem/samizdat., seed.btrfs patch.btrfs) + +_build/%: _build +_filesystem/%: _filesystem _build _filesystem: $(sudo) btrfs subvolume create $@ -clean = $(patchfs) $(rootfs) $(rootfs:%.seed.btrfs=%.btrfs) -clean := $(clean) $(clean:%=%.tmp) - clean: - rm -f $(clean) + btrfs subvolume delete _build cleaner: clean -$(sudo) btrfs subvolume delete _filesystem -rootfs: $(rootfs) -patchfs: $(patchfs) +_build/%.patch.btrfs: %.seed.btrfs -%.patch.btrfs: %.seed.btrfs - $(sudo) $(fsmgr) build $@ +_build/%.seed.btrfs: %.btrfs -%.seed.btrfs: %.btrfs - $(sudo) $(fsmgr) build $@ +_filesystem/%.btrfs: _build/%.btrfs %.btrfs: $(sudo) $(fsmgr) build $@ - -$(patchfs): $(rootfs) - -$(patchfs) $(rootfs): - $(sudo) REWRITE_SOURCES_LIST=y $(fsmgr) build $@ -- cgit v1.2.3