comma_:= ,
space_:= ${nul_} ${nul_}
-.PHONY: clean .FORCE
-.PHONY: _config_raspi _partition_raspi
-.PHONY: _qemu _bootstrap _install _copy _config_raspi _config _bootloader _squash
-.PHONY: _target _partition _format _mount _sparse _umount _partcopy _mbr
+.PHONY: clean .FORCE _target
+.PHONY: _bootloader_raspi _bootloader_pc _partition_gpt _partition_raspi
+.PHONY: _squash_modules
+.PHONY: _qemu _bootstrap _install _copy _config _bootloader _squash
+.PHONY: _partition _format _mount _sparse _umount _partcopy _mbr
ARCH := amd64
KEYRING := keys/debian-archive-stretch-stable.gpg
PACKAGES := ${PACKAGES} apt busybox-static debian-archive-keyring init systemd
+include config.mk
config.mk:
cp "config.example" "$@"
-include config.mk
-
ifdef disk
-VOLUME := ${disk}
-PBOOT := ${disk}1
-PROOT := ${disk}2
-SYSROOT := hdd_mount/
-CFGROOT := hdd_mount/
-
-_target: _mbr _umount _config _install _partition
-
-_partition:
-_format: _partition
-_mount: _format
-_bootstrap: _mount
-_install: _bootstrap _mount
-_config: _install _mount
-_bootloader: _mount
-_umount: _mount _config _bootloader
-_mbr: _umount _bootloader
+ VOLUME := ${disk}
+ PBOOT := ${disk}1
+ PROOT := ${disk}2
+ SYSROOT := hdd_mount/
+ CFGROOT := hdd_mount/
+
+ _target: _mbr _umount _config _install _partition
+
+ _partition: _partition_gpt
+ _format: _partition
+ _mount: _format
+ _bootstrap: _mount
+ _install: _bootstrap _mount
+ _config: _install _mount
+ _bootloader: _mount _bootloader_pc
+ _umount: _mount _config _bootloader
+ _mbr: _umount _bootloader
else ifdef image
-VOLUME := ${image}
-PBOOT := part_boot.img
-PROOT := part_root.img
-SYSROOT := sys_root/
-CFGROOT := img_mount/
-
-_target: _mbr _umount _partcopy _config _install
-
-_bootstrap:
-_install: _bootstrap
-_sparse:
-_format: _sparse
-_mount: _format
-_copy: _install _mount
-_config: _copy _mount
-_bootloader: _mount
-_umount: _mount _config _bootloader
-_partition:
-_partcopy: _partition _umount
-_mbr: _partcopy _bootloader
+ VOLUME := ${image}
+ PBOOT := part_boot.img
+ PROOT := part_root.img
+ SYSROOT := sys_root/
+ CFGROOT := img_mount/
+
+ _target: _mbr _umount _partcopy _config _install
+
+ _bootstrap:
+ _install: _bootstrap
+ _sparse:
+ _format: _sparse
+ _mount: _format
+ _copy: _install _mount
+ _config: _copy _mount
+ _bootloader: _mount _bootloader_pc
+ _umount: _mount _config _bootloader
+ _partition: _partition_gpt
+ _partcopy: _partition _umount
+ _mbr: _partcopy _bootloader
else ifdef squash
-SQUASH := ${squash}
-SYSROOT := sys_root/
-CFGROOT := cfg_root/
-
-_target: _squash _install _config
-
-_bootstrap:
-_install: _bootstrap
-_copy: _install
-_config: _copy
-_squash: _config
+ SQUASH := ${squash}
+ SYSROOT := sys_root/
+ CFGROOT := cfg_root/
+
+ _target: _squash _install _config
+
+ _bootstrap:
+ _install: _bootstrap
+ _copy: _install
+ _config: _copy
+ _squash: _config _squash_modules
else ifdef raspi
-VOLUME := ${raspi}
-PBOOT := rpi_boot.img
-PROOT := rpi_root.img
-SYSROOT := rpi_root/
-CFGROOT := img_mount/
-
-ARCH := armhf
-KEYRING := keys/raspbian-archive-keyring.gpg
-BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian
-
-define SOURCES =
-deb http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi
-deb http://archive.raspberrypi.org/debian stretch main
-endef
+ VOLUME := ${raspi}
+ PBOOT := rpi_boot.img
+ PROOT := rpi_root.img
+ SYSROOT := rpi_root/
+ CFGROOT := img_mount/
+
+ ARCH := armhf
+ KEYRING := keys/raspbian-archive-keyring.gpg
+ BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian
+
+ define SOURCES =
+ deb http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi
+ deb http://archive.raspberrypi.org/debian stretch main
+ endef
PACKAGES := ${PACKAGES} firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel
-_target: _umount _partcopy _config _install
-
-_qemu:
-_bootstrap: _qemu
-_install: _bootstrap
-_sparse:
-_format: _sparse
-_mount: _format
-_copy: _install _mount
-_config_raspi: _copy _mount
-_config: _copy _mount _config_raspi
-_umount: _mount _config
-_partition_raspi:
-_partcopy: _partition_raspi _umount
+ _target: _umount _partcopy _config _install
+
+ _qemu:
+ _bootstrap: _qemu
+ _install: _bootstrap
+ _sparse:
+ _format: _sparse
+ _mount: _format
+ _copy: _install _mount
+ _config: _copy _mount
+ _bootloader: _mount _bootloader_raspi
+ _umount: _mount _config _bootloader
+ _partition: _partition_raspi
+ _partcopy: _partition _umount
else
-_target:
+ _target:
false
endif
include modules/default.mk
ifdef modules
-include $(addsuffix .mk, $(addprefix modules/, $(subst ${comma_},${space_},${modules})))
+ include $(addsuffix .mk, $(addprefix modules/, $(subst ${comma_},${space_},${modules})))
endif
ifeq "${ARCH}" "amd64"
-PACKAGES := ${PACKAGES} linux-image-amd64
+ PACKAGES += linux-image-amd64
else ifeq "${ARCH}" "i386"
-PACKAGES := ${PACKAGES} linux-image-686
+ PACKAGES += linux-image-686
endif
export SOURCES SYSROOT CFGROOT VOLUME PBOOT PROOT SQUASH ARCH KEYRING BOOTSTRAP
_copy: ${SYSROOT} ${CFGROOT}
cp -au "$${SYSROOT}/." "$${CFGROOT}/"
-_config_raspi: ${CFGROOT}/boot/cmdline.txt
-${CFGROOT}/boot/cmdline.txt: ${CFGROOT}
- printf 'dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet' >"$@"
-
.PHONY: _common_config
_config: _common_config
_common_config: ${CFGROOT}
-rm "$${SQUASH}"
mksquashfs "$${CFGROOT}" "$${SQUASH}" -comp xz
-_squash: ${SQUASH}
+_squash_modules: ${CFGROOT}
+ printf '%s\n' squashfs nbd >>"${CFGROOT}/etc/initramfs-tools/modules"
+
+_squash: ${SQUASH} _squash_modules
${VOLUME}: .FORCE
! printf '%s\n' "$${VOLUME}" |grep -q '^/dev/' # abort if volume should be real device
printf 'label: dos\n\n: start=2MiB, size=%iMiB, type=c\n: start=%iMiB, size=%iMiB, type=83\n' \
${BOOT_MB} "$$((${BOOT_MB} + 2))" ${ROOT_MB} | sfdisk "$${VOLUME}"
-_partition: ${VOLUME}
+_partition_gpt: ${VOLUME}
printf 'label: gpt\n\n: start=2MiB, size=%iMiB, type=1, attrs="LegacyBIOSBootable"\n: size=%iMiB, type=20\n' \
${BOOT_MB} ${ROOT_MB} | sfdisk "$${VOLUME}"
mkdir -p "$${CFGROOT}/boot/EFI/BOOT"
grub-mkimage -p / -O x86_64-efi fat part_gpt normal linux all_video >"$${CFGROOT}/boot/EFI/BOOT/BOOTX64.EFI"
-_bootloader: ${CFGROOT} _grub_efi32 _grub_efi64 _syslinux_bios #_syslinux_efi32 _syslinux_efi64
+${CFGROOT}/boot/cmdline.txt: ${CFGROOT}
+ printf 'root=/dev/mmcblk0p2 rootfstype=ext4 fsck.repair=yes rootwait' >"$@"
+
+_bootloader_raspi: ${CFGROOT} ${CFGROOT}/boot/cmdline.txt
+
+_bootloader_pc: ${CFGROOT} _grub_efi32 _grub_efi64 _syslinux_bios #_syslinux_efi32 _syslinux_efi64
printf 'UI menu.c32\nDEFAULT stretch\nTIMEOUT 30\n' >"$${CFGROOT}/boot/bootmenu.cfg"
printf 'set timeout=3\ndefault=stretch\n\n' >"$${CFGROOT}/boot/grub.cfg"
k="$$(printf ' %s' "$${CFGROOT}/boot/"vmlinuz-*)"; k="$${k##*/}"; \