diff options
-rw-r--r-- | partitions/Makefile | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/partitions/Makefile b/partitions/Makefile index f8ef259..1e40c07 100644 --- a/partitions/Makefile +++ b/partitions/Makefile | |||
@@ -9,22 +9,34 @@ whole.img: | |||
9 | key.img: | 9 | key.img: |
10 | partvi key | 10 | partvi key |
11 | 11 | ||
12 | persist.img: | ||
13 | [ ! -e $@ ] | ||
14 | fallocate -l 20G $@ | ||
15 | truncate -s 0 $@ | ||
16 | truncate -s 20G $@ | ||
17 | |||
18 | persist := $(shell [ -e persist.img ] && printf %s '-drive file=persist.img,media=disk,driver=raw' || true) | ||
19 | |||
12 | .PHONY: usb emu key emu-key keymu | 20 | .PHONY: usb emu key emu-key keymu |
13 | usb: whole.img | 21 | usb: whole.img |
14 | usb=$$(usb) && sudo dd status=progress if="$<" of="$$usb" | 22 | usb=$$(usb) && sudo dd status=progress if="$<" of="$$usb" |
15 | 23 | ||
16 | emu = qemu-system-x86_64 -m 800 -enable-kvm -boot c | 24 | define emu |
25 | qemu-system-x86_64 -m 800 -enable-kvm -boot c \ | ||
26 | -drive file=$(1),media=disk,driver=raw \ | ||
27 | $(persist) | ||
28 | endef | ||
17 | 29 | ||
18 | emu: whole.img | 30 | emu: whole.img |
19 | $(emu) $< | 31 | $(call emu,$<) |
20 | 32 | ||
21 | emu-key keymu: key.img | 33 | emu-key keymu: key.img |
22 | $(emu) $< | 34 | $(call emu,$<) |
23 | 35 | ||
24 | key: key.img | 36 | key: key.img |
25 | usb=$$(usb) && \ | 37 | usb=$$(usb) && \ |
26 | sudo dd status=progress bs=1048576 if="$<" of="$$usb" && \ | 38 | sudo dd status=progress bs=1048576 if="$<" of="$$usb" && \ |
27 | sudo $(emu) "$$usb" | 39 | sudo "$(call emu,"$$usb")" |
28 | 40 | ||
29 | clean: | 41 | clean: |
30 | rm -rf _build whole.img key.img | 42 | rm -rf _build whole.img key.img |