From 4f4c945b3de79650cb76286967b182c79b1d1294 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 16 Sep 2019 11:21:45 +0200 Subject: [PATCH] produce BIOS bootable iso images --- Makefile | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d3df894..887422c 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,10 @@ comma_:= , 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 @@ -34,11 +34,13 @@ else 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} @@ -98,20 +100,21 @@ else ifdef squash 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} @@ -163,20 +166,26 @@ else ifeq "${ARCH}" "i386" 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 "$@" @@ -245,6 +254,11 @@ _squash_modules: ${CFGROOT} _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 @@ -276,6 +290,12 @@ _format: ${PBOOT} ${PROOT} 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 @@ -327,6 +347,15 @@ _bootloader_pc: ${CFGROOT} _grub_efi32 _grub_efi64 _syslinux_bios #_syslinux_efi 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} -- 2.39.2