space_:= ${nul_} ${nul_}
.PHONY: clean .FORCE _target
-.PHONY: _bootloader_raspi _bootloader_pc _partition_gpt _partition_raspi
+.PHONY: _bootloader_raspi _bootloader_pc _bootloader_iso _partition_gpt _partition_raspi
.PHONY: _squash_modules
-.PHONY: _qemu _bootstrap _install _copy _config _squash
-.PHONY: _format _mount _sparse _umount _partcopy _mbr
+.PHONY: _qemu _bootstrap _install _copy _config _squash _isosquash
+.PHONY: _format _mount _sparse _umount _partcopy _mbr _iso_image
ARCH := amd64
BOOTSTRAP := http://cdn.debian.net/debian
KEYRING := keys/debian-archive-stretch-stable.gpg
endif
+ifndef SOURCES
define SOURCES :=
deb http://cdn.debian.net/debian stretch main
deb http://cdn.debian.net/debian buster main
deb http://cdn.debian.net/debian ${release} main
endef
+endif
ifdef disk
VOLUME := ${disk}
else ifdef iso
ISO := iso
- SQUASH := rootfs.squash
+ ISOROOT := iso_root/
SYSROOT := sys_root_${release}/
CFGROOT := cfg_root/
PACKAGES += squashfs-tools
- _target: _isohybrid _install _config
+ _target: _iso_image _install _config
_bootstrap:
_install: _bootstrap
_copy: _install
_config: _copy _squash_modules
- _squash: _config
- _isohybrid: _squash
+ _isosquash: _config
+ _bootloader_iso: _config
+ _iso_image: _bootloader_iso _isosquash
else ifdef raspi
VOLUME := ${raspi}
PACKAGES += linux-image-686
endif
-export SOURCES SYSROOT CFGROOT VOLUME PBOOT PROOT SQUASH ARCH KEYRING BOOTSTRAP
+export SOURCES SYSROOT CFGROOT VOLUME PBOOT PROOT SQUASH ARCH KEYRING BOOTSTRAP ISOROOT ISO
sys_root_${release}/:
btrfs subvol create "$@" || mkdir "$@"
chmod 755 "$@"
+rpi_root_${release}/:
+ btrfs subvol create "$@" || mkdir "$@"
+ chmod 755 "$@"
+
cfg_root/: sys_root_${release}/ _install
-btrfs sub del "$@" || rm -r "$@"
btrfs sub snap "$<" "$@" || mkdir "$@"
chmod 755 "$@"
-rpi_root_${release}/:
+${ISOROOT}:
+ -btrfs sub del "$@" || rm -r "$@"
btrfs subvol create "$@" || mkdir "$@"
- chmod 755 "$@"
+ mkdir "$@/live"
+ chmod 755 "$@" "$@/live"
img_mount/:
mkdir -p -m 755 "$@"
_squash: ${SQUASH} _squash_modules
+_isosquash: ${ISOROOT}/live/live.squashfs
+${ISOROOT}/live/live.squashfs: ${CFGROOT} ${ISOROOT}
+ -rm "$@"
+ printf '%s\n' boot |mksquashfs "$${CFGROOT}" "$@" -comp xz -ef /dev/stdin
+
${VOLUME}: .FORCE
! printf '%s\n' "$${VOLUME}" |grep -q '^/dev/' # abort if volume should be real device
dd count=0 of="$${VOLUME}" # truncate
mkfs.fat -F 32 -n BOOT "$${PBOOT}"
mkfs.ext4 -F -L FSROOT "$${PROOT}"
+_iso_image: ${ISOROOT}
+ xorriso -as mkisofs -o "$${ISO}" -b grub.bin -c boot.cat \
+ -no-emul-boot -boot-load-size 4 -boot-info-table \
+ -eltorito-alt-boot -e efi.img -no-emul-boot \
+ "$${ISOROOT}"
+
.PHONY: _syslinux_efi32 _syslinux_efi64 _syslinux_bios
.PHONY: _grub_efi32 _grub_efi64
printf "menuentry 'Rescue' --id 'rescue' {\n linux '/%s' root=LABEL=FSROOT init=/bin/sh\n initrd '/%s'\n}\n" \
"$$k" "$$i" >>"$${CFGROOT}/boot/grub.cfg"
+_bootloader_iso: ${CFGROOT} ${ISOROOT} _grub_efi32 _grub_efi64
+ grub-mkimage -p / -O i386-pc-eltorito biosdisk iso9660 normal linux all_video >"$${ISOROOT}/grub.bin"
+ grub-glue-efi -3 "$${CFGROOT}/boot/EFI/BOOT/BOOTIA32.EFI" -6 "$${CFGROOT}/boot/EFI/BOOT/BOOTX64.EFI" >"$${ISOROOT}/efi.img"
+ cp -L "$${CFGROOT}/vmlinuz" "$${CFGROOT}/initrd.img" "$${ISOROOT}"
+ printf '%s\n' "set timeout=10" "default=buster" \
+ "menuentry 'Debian Buster' --id 'buster' {" \
+ "linux '/vmlinuz' boot=live" "initrd '/initrd.img'" "}" \
+ >"$${ISOROOT}/grub.cfg"
+
.PHONY: _syslinux_mbr _grub_mbr
_syslinux_mbr: ${VOLUME}