]> git.plutz.net Git - blast/commitdiff
squash and iso targets
authorPaul Hänsch <paul@plutz.net>
Sun, 12 Apr 2026 02:05:03 +0000 (04:05 +0200)
committerPaul Hänsch <paul@plutz.net>
Sun, 12 Apr 2026 02:05:03 +0000 (04:05 +0200)
targets/isoimage.mk [new file with mode: 0644]
targets/squashfs.mk [new file with mode: 0644]

diff --git a/targets/isoimage.mk b/targets/isoimage.mk
new file mode 100644 (file)
index 0000000..e83b3d4
--- /dev/null
@@ -0,0 +1,67 @@
+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}"
diff --git a/targets/squashfs.mk b/targets/squashfs.mk
new file mode 100644 (file)
index 0000000..925a58d
--- /dev/null
@@ -0,0 +1,23 @@
+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}"