summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon GECOS <u@adam>2023-11-22 14:30:53 -0500
committerGordon GECOS <u@adam>2023-11-22 14:30:53 -0500
commitc562f252be28507df1d2f45e1912734e1ef0a8e4 (patch)
tree7a7c307b5533bbaacbff5f6edb3548314e7f7626
parenta215a248f499dd2f63d800629203b54030352d97 (diff)
build system cleanups
-rw-r--r--.gitignore1
-rw-r--r--Makefile32
m---------fsmgr0
-rw-r--r--rootfs/Makefile29
4 files changed, 28 insertions, 34 deletions
diff --git a/.gitignore b/.gitignore
index b4bc1ce..4820162 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,3 +58,4 @@ apt-get-update-stamp
58*.img 58*.img
59*.tmp 59*.tmp
60samizdat-ficlonerange 60samizdat-ficlonerange
61/rootfs/_filesystem/
diff --git a/Makefile b/Makefile
index 1290a94..9f7a5f5 100644
--- a/Makefile
+++ b/Makefile
@@ -118,9 +118,10 @@ update-submodules:
118install-submodules: cmd=install 118install-submodules: cmd=install
119install-submodules: update-submodules $(INSTALL_SUBMODULES) 119install-submodules: update-submodules $(INSTALL_SUBMODULES)
120 120
121rootfs = rootfs/_filesystem/samizdat.seed.btrfs 121rootfsdir = rootfs/_filesystem
122patchfs = $(patsubst %.seed.btrfs,%.patch.btrfs,$(rootfs)) 122rootfs = $(rootfsdir)/samizdat.seed.btrfs
123rootfs_verity = $(addsuffix .verity,$(rootfs) $(patchfs)) 123patchfs = $(rootfsdir)/samizdat.patch.btrfs
124rootfs_verity = $(addprefix _build/,$(addsuffix .verity,$(notdir $(rootfs) $(patchfs))))
124 125
125.PHONY: rootfs rootfs-deps 126.PHONY: rootfs rootfs-deps
126rootfs-deps: 127rootfs-deps:
@@ -129,7 +130,7 @@ rootfs-deps:
129 130
130btrfs_images = $(rootfs) $(patchfs) 131btrfs_images = $(rootfs) $(patchfs)
131rootfs-clean: 132rootfs-clean:
132 make -C rootfs clean all 133 make -C rootfs clean
133 134
134rootfs: rootfs-deps $(btrfs_images) $(rootfs_verity) 135rootfs: rootfs-deps $(btrfs_images) $(rootfs_verity)
135 sudo mkdir -p /srv/nbd 136 sudo mkdir -p /srv/nbd
@@ -138,9 +139,8 @@ ifneq (,$(patchfs))
138 sudo ln -sf "$$PWD"/$(patchfs) /srv/nbd/samizdat.patch.btrfs 139 sudo ln -sf "$$PWD"/$(patchfs) /srv/nbd/samizdat.patch.btrfs
139endif 140endif
140 141
141FORCE: 142rootfs/%.btrfs:
142$(btrfs_images): FORCE 143 $(MAKE) -C rootfs $(@:rootfs/%=%)
143 $(MAKE) -C rootfs $(notdir $@)
144 144
145boot: rootfs 145boot: rootfs
146 sudo update-initramfs -u 146 sudo update-initramfs -u
@@ -154,8 +154,10 @@ get_min_size="$$(btrfs inspect-internal min-dev-size --id 1 $@.mnt | (read b _;
154 154
155verity_root_hash = $(shell sed -ne 's/^Root hash:[ \t]*//p' $<) 155verity_root_hash = $(shell sed -ne 's/^Root hash:[ \t]*//p' $<)
156 156
157%.verity.log: %.verity 157_build:
158%.verity: % 158 mkdir $@
159
160_build/%.verity: rootfs/_filesystem/% | _build
159 rm -f $@~tmp 161 rm -f $@~tmp
160 sudo veritysetup format $^ $@~tmp > $@.log~tmp 162 sudo veritysetup format $^ $@~tmp > $@.log~tmp
161 sudo chmod 644 $@~tmp 163 sudo chmod 644 $@~tmp
@@ -164,16 +166,13 @@ verity_root_hash = $(shell sed -ne 's/^Root hash:[ \t]*//p' $<)
164 166
165root_hash = $(shell sed -ne 's/^Root hash: *//p' < $<.log) 167root_hash = $(shell sed -ne 's/^Root hash: *//p' < $<.log)
166 168
167veritymount: $(rootfs).verity.log 169veritymount: _build/$(notdir $(rootfs)).verity.log
168 @sudo veritysetup remove samizverity >/dev/null 2>&1 || true 170 @sudo veritysetup remove samizverity >/dev/null 2>&1 || true
169 sudo veritysetup create samizverity $(basename $(basename $<)) \ 171 sudo veritysetup create samizverity $(basename $(basename $<)) \
170 $(basename $<) \ 172 $(basename $<) \
171 $(verity_root_hash) 173 $(verity_root_hash)
172 sudo veritysetup remove samizverity 174 sudo veritysetup remove samizverity
173 175
174rootfs/%.btrfs:
175 $(SUDO_MAKE) -C rootfs $(notdir $@)
176
177debian_dist := $(shell . /etc/os-release && printf %s $$VERSION_CODENAME) 176debian_dist := $(shell . /etc/os-release && printf %s $$VERSION_CODENAME)
178 177
179stale = [ ! -e $@ ] || [ $$(( $$(date +%s) - $$(date -r $@ +%s) )) -gt 36000 ] 178stale = [ ! -e $@ ] || [ $$(( $$(date +%s) - $$(date -r $@ +%s) )) -gt 36000 ]
@@ -182,7 +181,12 @@ apt = $(shell which apt || which apt-get)
182 181
183.PHONY: apt-get-update-stamp 182.PHONY: apt-get-update-stamp
184apt-get-update-stamp: 183apt-get-update-stamp:
185 @if $(stale); then set -x; sudo $(apt) update && touch $@; fi 184 @if $(stale) \
185 then \
186 set -x; \
187 sudo dpkg --add-architecture i386; \
188 sudo $(apt) update && touch $@; \
189 fi
186 190
187rootfs/seed.iso: $(rootfs) $(if $(VERITY),$(addprefix $(rootfs),.verity .verity.log)) 191rootfs/seed.iso: $(rootfs) $(if $(VERITY),$(addprefix $(rootfs),.verity .verity.log))
188 rm -f $@~tmp 192 rm -f $@~tmp
diff --git a/fsmgr b/fsmgr
Subproject 7eda6b846463c19411efd2747d3c6c3b3b9d356 Subproject 486fb62abd0ac5a87a85ca18beb939d21323fad
diff --git a/rootfs/Makefile b/rootfs/Makefile
index ef2921e..c85132f 100644
--- a/rootfs/Makefile
+++ b/rootfs/Makefile
@@ -6,38 +6,27 @@ endif
6 6
7sudo := $(shell [ "$$(id -u)" = 0 ] || echo sudo) 7sudo := $(shell [ "$$(id -u)" = 0 ] || echo sudo)
8 8
9rootfs ?= samizdat.seed.btrfs
10patchfs ?= samizdat.patch.btrfs
11
12.DEFAULT_GOAL = all 9.DEFAULT_GOAL = all
13 10
14.PHONY: all rootfs patchfs clean cleaner 11.PHONY: all clean cleaner
15all: $(rootfs) $(patchfs) 12all: $(addprefix _filesystem/samizdat., seed.btrfs patch.btrfs)
13
14_build/%: _build
15_filesystem/%: _filesystem
16 16
17_build _filesystem: 17_build _filesystem:
18 $(sudo) btrfs subvolume create $@ 18 $(sudo) btrfs subvolume create $@
19 19
20clean = $(patchfs) $(rootfs) $(rootfs:%.seed.btrfs=%.btrfs)
21clean := $(clean) $(clean:%=%.tmp)
22
23clean: 20clean:
24 rm -f $(clean) 21 btrfs subvolume delete _build
25cleaner: clean 22cleaner: clean
26 -$(sudo) btrfs subvolume delete _filesystem 23 -$(sudo) btrfs subvolume delete _filesystem
27 24
28rootfs: $(rootfs) 25_build/%.patch.btrfs: %.seed.btrfs
29patchfs: $(patchfs)
30 26
31%.patch.btrfs: %.seed.btrfs 27_build/%.seed.btrfs: %.btrfs
32 $(sudo) $(fsmgr) build $@
33 28
34%.seed.btrfs: %.btrfs 29_filesystem/%.btrfs: _build/%.btrfs
35 $(sudo) $(fsmgr) build $@
36 30
37%.btrfs: 31%.btrfs:
38 $(sudo) $(fsmgr) build $@ 32 $(sudo) $(fsmgr) build $@
39
40$(patchfs): $(rootfs)
41
42$(patchfs) $(rootfs):
43 $(sudo) REWRITE_SOURCES_LIST=y $(fsmgr) build $@