diff options
-rw-r--r-- | Makefile | 67 |
1 files changed, 23 insertions, 44 deletions
@@ -140,16 +140,26 @@ update-submodules: | |||
140 | install-submodules: cmd=install | 140 | install-submodules: cmd=install |
141 | install-submodules: update-submodules $(INSTALL_SUBMODULES) | 141 | install-submodules: update-submodules $(INSTALL_SUBMODULES) |
142 | 142 | ||
143 | rootfs = samizdat | 143 | rootfs = samizdat.btrfs |
144 | export rootfs | 144 | patchfs = $(patsubst %.btrfs,%.patch.btrfs,$(rootfs)) |
145 | rootfs_verity = rootfs/$(rootfs).verity | ||
145 | 146 | ||
146 | .PHONY: rootfs | 147 | .PHONY: rootfs rootfs-deps |
147 | rootfs: | 148 | rootfs-deps: |
148 | [ -e install-submodules-stamp ] || make install-submodules-stamp | 149 | [ -e install-submodules-stamp ] || make install-submodules-stamp |
149 | [ -e install-stamp ] || $(SUDO_MAKE) install-stamp | 150 | [ -e install-stamp ] || $(SUDO_MAKE) install-stamp |
150 | $(MAKE) -C rootfs | 151 | |
152 | btrfs_images = $(addprefix rootfs/, $(rootfs) $(patchfs)) | ||
153 | rootfs: rootfs-deps $(btrfs_images) $(rootfs_verity) | ||
151 | sudo mkdir -p /srv/nbd | 154 | sudo mkdir -p /srv/nbd |
152 | sudo ln -sf "$$PWD"/rootfs/$(rootfs).btrfs /srv/nbd/samizdat.btrfs | 155 | sudo ln -sf "$$PWD"/rootfs/$(rootfs) /srv/nbd/samizdat.btrfs |
156 | ifneq (,$(patchfs)) | ||
157 | sudo ln -sf "$$PWD"/rootfs/$(patchfs) /srv/nbd/samizdat.patch.btrfs | ||
158 | endif | ||
159 | |||
160 | FORCE: | ||
161 | $(btrfs_images): FORCE | ||
162 | $(MAKE) -C rootfs $(notdir $@) | ||
153 | 163 | ||
154 | boot: rootfs | 164 | boot: rootfs |
155 | sudo SLOW_BOOT=y qemu.sh | 165 | sudo SLOW_BOOT=y qemu.sh |
@@ -193,12 +203,14 @@ get_loop_dev="$$(sudo losetup -n -O name -j $@~tmp)" | |||
193 | get_backing_file="$$(sudo losetup -n -O back-file -j $@~tmp)" | 203 | get_backing_file="$$(sudo losetup -n -O back-file -j $@~tmp)" |
194 | get_min_size="$$(btrfs inspect-internal min-dev-size --id 1 $@.mnt | (read b _; echo $$b))" | 204 | get_min_size="$$(btrfs inspect-internal min-dev-size --id 1 $@.mnt | (read b _; echo $$b))" |
195 | 205 | ||
196 | %.btrfs.verity: %.btrfs | 206 | %.verity: % |
197 | sudo veritysetup format $< $@ > $@.log | 207 | sudo veritysetup format $< $@~tmp > $@.log~tmp |
208 | mv $@.log~tmp $@.log | ||
209 | mv $@~tmp $@ | ||
198 | sudo chmod 644 $@ | 210 | sudo chmod 644 $@ |
199 | h=$$(sed -ne 's/^Root hash:[ \t]*//p' $@.log) && [ "$$h" ] | 211 | h=$$(sed -ne 's/^Root hash:[ \t]*//p' $@.log) && [ "$$h" ] |
200 | 212 | ||
201 | %.btrfs.verity.log.asc: %.btrfs.verity.log | 213 | %.verity.log.asc: %.verity.log |
202 | sudo gpg --armor --detach-sign $^ | 214 | sudo gpg --armor --detach-sign $^ |
203 | 215 | ||
204 | rootfs/samizdat.seed.btrfs: rootfs/samizdat.btrfs | 216 | rootfs/samizdat.seed.btrfs: rootfs/samizdat.btrfs |
@@ -218,8 +230,6 @@ else | |||
218 | mv $@~tmp $@ | 230 | mv $@~tmp $@ |
219 | endif | 231 | endif |
220 | 232 | ||
221 | FORCE: | ||
222 | |||
223 | debian_dist := $(shell lsb_release -cs) | 233 | debian_dist := $(shell lsb_release -cs) |
224 | 234 | ||
225 | apt_list_files = $(addprefix /./var/lib/apt/lists/, \ | 235 | apt_list_files = $(addprefix /./var/lib/apt/lists/, \ |
@@ -231,37 +241,10 @@ apt_list_files = $(addprefix /./var/lib/apt/lists/, \ | |||
231 | 241 | ||
232 | stale = [ ! -e $@ ] || [ $$(( $$(date +%s) - $$(date -r $@ +%s) )) -gt 36000 ] | 242 | stale = [ ! -e $@ ] || [ $$(( $$(date +%s) - $$(date -r $@ +%s) )) -gt 36000 ] |
233 | 243 | ||
234 | apt-get-update-stamp: FORCE | 244 | .PHONY: apt-get-update-stamp |
245 | apt-get-update-stamp: | ||
235 | @if $(stale); then set -x; sudo apt-get update && touch $@; fi | 246 | @if $(stale); then set -x; sudo apt-get update && touch $@; fi |
236 | 247 | ||
237 | rootfs/samizdat.patch.btrfs: rootfs/samizdat.seed.btrfs \ | ||
238 | $(if $(INTERACTIVE_CHROOT),FORCE,rootfs/patchroot.sh) | ||
239 | ifneq ($(shell id -u),0) | ||
240 | $(SUDO_MAKE) $@ | ||
241 | else | ||
242 | rm -f $@~tmp | ||
243 | touch $@~tmp | ||
244 | fallocate -l $(samizdat_btrfs_patch_size) $@~tmp | ||
245 | test -d $@.mnt || mkdir $@.mnt | ||
246 | ! mountpoint -q $@.mnt || umount $@.mnt | ||
247 | mount -o compress,ro -t btrfs $< $@.mnt | ||
248 | a=$(get_loop_dev); [ -z "$$a" ] || losetup -d $$a | ||
249 | losetup -f $@~tmp | ||
250 | btrfs device add $(get_loop_dev) $@.mnt | ||
251 | mount -o compress,rw,remount $@.mnt | ||
252 | $(SUDO_MAKE) apt-get-update-stamp | ||
253 | rsync -Ra $(apt_list_files) $@.mnt/ | ||
254 | ifdef INTERACTIVE_CHROOT | ||
255 | chroot $@.mnt bash -i | ||
256 | else | ||
257 | chroot $@.mnt sh < rootfs/patchroot.sh | ||
258 | endif | ||
259 | umount $@.mnt | ||
260 | losetup -f $< | ||
261 | btrfstune -S1 $@~tmp | ||
262 | mv $@~tmp $@ | ||
263 | endif | ||
264 | |||
265 | samizdat.iso: patched.iso | 248 | samizdat.iso: patched.iso |
266 | cp --reflink $< $@ | 249 | cp --reflink $< $@ |
267 | 250 | ||
@@ -326,10 +309,6 @@ rootfs/seed.iso: $(addprefix rootfs/samizdat.seed.btrf, s \ | |||
326 | -follow default | 309 | -follow default |
327 | mv $@~tmp $@ | 310 | mv $@~tmp $@ |
328 | 311 | ||
329 | rootfs/samizdat.btrfs: | ||
330 | make -C rootfs | ||
331 | |||
332 | |||
333 | .PHONY: install | 312 | .PHONY: install |
334 | install: | 313 | install: |
335 | [ -e install-submodules-stamp ] || make install-submodules-stamp | 314 | [ -e install-submodules-stamp ] || make install-submodules-stamp |