--- /dev/null
+ISOLABEL := Blast
+
+ISO = ${iso}
+ISOROOT = iso_root
+SQUASH = ${ISOROOT}/live/live.squashfs
+
+PACKAGES += squashfs-tools
+
+.PHONY: _squash_modules _bootloader_iso _iso_clean
+
+_squash_modules: _copy
+_bootloader_iso: _config
+${SQUASH}: _config _squash_modules
+${ISO}: _bootloader_iso ${SQUASH}
+_target: ${ISO}
+clean: _iso_clean
+
+define GRUBCFG
+insmod all_video
+set gfxmode=auto
+load_video
+insmod gfxterm
+set timeout=10
+default=${release}
+
+menuentry 'Debian ${release}' --id '${release}' {
+ linux /vmlinuz boot=live
+ initrd /initrd.img
+}
+endef
+
+export SQUASH ISOROOT ISO ISOLABEL GRUBCFG
+
+${ISOROOT}:
+ -btrfs sub del "$@" || rm -r "$@"
+ btrfs subvol create "$@" || mkdir "$@"
+ mkdir "$@/live"
+ chmod 755 "$@" "$@/live"
+
+_squash_modules:
+ printf '%s\n' squashfs >>"${CFGROOT}/etc/initramfs-tools/modules"
+
+${SQUASH}: ${CFGROOT} ${ISOROOT} .FORCE
+ -rm -- "$@"
+ { cd "$${CFGROOT}"; printf '%s\n' boot/*; } \
+ | mksquashfs "$${CFGROOT}" "$@" -comp xz -ef /dev/stdin
+
+${ISO}: ${ISOROOT} ${SQUASH}
+ grub-mkrescue --compress=xz -volid "$${ISOLABEL}" \
+ -o "$@" "$${ISOROOT}"
+
+${ISOROOT}/boot/grub/grub.cfg: ${ISOROOT} .FORCE
+ mkdir -p "$${ISOROOT}/boot/grub/"
+ printf '%s\n' "$${GRUBCFG}" >"$@"
+
+${ISOROOT}/%: ${CFGROOT}/%
+ cp -L -- "$<" "$@"
+
+_bootloader_iso: ${ISOROOT}/vmlinuz ${ISOROOT}/initrd.img
+_bootloader_iso: ${ISOROOT}/boot/grub/grub.cfg
+
+_iso_clean:
+ [ "$${ISOROOT#/}" ] || false # (abort receipe)
+ if [ -d "$${ISOROOT}" ]; then \
+ btrfs sub del "$${ISOROOT}" || rm -r -- "$${ISOROOT}"; \
+ fi
+ -[ -f "$${ISO}" ] && rm -- "$${ISO}"
--- /dev/null
+SQUASH := ${squash}
+CFGROOT := cfg_root/
+
+PACKAGES += squashfs-tools nbd-client
+
+.PHONY: _squash _squash_modules _squash_clean
+
+_squash_modules: _copy
+${SQUASH}: _config _squash_modules
+_target: ${SQUASH}
+clean: _squash_clean
+
+export SQUASH
+
+${SQUASH}: .FORCE
+ -[ -f "$${SQUASH}" ] && rm -- "$${SQUASH}"
+ mksquashfs "$${CFGROOT}" "$@" -comp xz
+
+_squash_modules:
+ printf '%s\n' squashfs nbd >>"$${CFGROOT}/etc/initramfs-tools/modules"
+
+_squash_clean:
+ -[ -f "$${SQUASH}" ] && rm -- "$${SQUASH}"