.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
+.PHONY: _qemu _bootstrap _install _copy _config _squash
+.PHONY: _format _mount _sparse _umount _partcopy _mbr
ARCH := amd64
KEYRING := keys/debian-archive-stretch-stable.gpg
BOOTSTRAP := http://cdn.debian.net/debian
+PACKAGES := ${PACKAGES} apt busybox-static debian-archive-keyring init systemd
# Partition Table (2M) + Boot Partition (126M)+ Root Partition + Slack Space (1M) = 2048M
BOOT_MB := 62
ROOT_MB := 959
-define SOURCES =
-deb http://cdn.debian.net/debian stretch main
-endef
-
-PACKAGES := ${PACKAGES} apt busybox-static debian-archive-keyring init systemd
-
-include config.mk
config.mk:
cp "config.example" "$@"
+ifndef config
+ include config.mk
+else
+ include ${config}
+endif
+
+ifndef release
+ release := stretch
+endif
+
+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
+
ifdef disk
VOLUME := ${disk}
PBOOT := ${disk}1
SYSROOT := hdd_mount/
CFGROOT := hdd_mount/
- _target: _mbr _umount _config _install _partition
+ _target: _mbr _umount _config _install _partition_gpt
- _partition: _partition_gpt
- _format: _partition
+ _partition_gpt:
+ _format: _partition_gpt
_mount: _format
_bootstrap: _mount
_install: _bootstrap _mount
_config: _install _mount
- _bootloader: _mount _bootloader_pc
- _umount: _mount _config _bootloader
- _mbr: _umount _bootloader
+ _bootloader_pc: _mount
+ _umount: _mount _config _bootloader_pc
+ _mbr: _umount _bootloader_pc
else ifdef image
VOLUME := ${image}
PBOOT := part_boot.img
PROOT := part_root.img
- SYSROOT := sys_root/
+ SYSROOT := sys_root_${release}/
CFGROOT := img_mount/
- _target: _mbr _umount _partcopy _config _install
+ _target: _mbr _umount _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
+ _partition_gpt: _sparse
+ _partcopy: _partition_gpt _format
+ _img_mount: _partcopy
+ _copy: _install _img_mount
+ _config: _copy _img_mount
+ _bootloader_pc: _img_mount
+ _umount: _img_mount _config _bootloader_pc
+ _mbr: _partcopy _bootloader_pc
else ifdef squash
SQUASH := ${squash}
- SYSROOT := sys_root/
+ SYSROOT := sys_root_${release}/
CFGROOT := cfg_root/
PACKAGES += squashfs-tools nbd-client
VOLUME := ${raspi}
PBOOT := rpi_boot.img
PROOT := rpi_root.img
- SYSROOT := rpi_root/
+ SYSROOT := rpi_root_${release}/
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
+ define SOURCES :=
+ deb http://raspbian.raspberrypi.org/raspbian ${release} main non-free firmware rpi
+ deb http://archive.raspberrypi.org/debian ${release} main
endef
PACKAGES += firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel
- _target: _umount _partcopy _config _install
+ _target: _umount _config
_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
+ _partition_raspi: _sparse
+ _partcopy: _partition_raspi _format
+ _img_mount: _partcopy
+ _copy: _install _img_mount
+ _config: _copy _img_mount
+ _bootloader_raspi: _img_mount
+ _umount: _img_mount _config _bootloader_raspi
else
_target:
export SOURCES SYSROOT CFGROOT VOLUME PBOOT PROOT SQUASH ARCH KEYRING BOOTSTRAP
-sys_root/:
+sys_root_${release}/:
btrfs subvol create "$@" || mkdir "$@"
chmod 755 "$@"
-cfg_root/: sys_root/ _install
+cfg_root/: sys_root_${release}/ _install
-btrfs sub del "$@" || rm -r "$@"
btrfs sub snap "$<" "$@" || mkdir "$@"
chmod 755 "$@"
-rpi_root/:
+rpi_root_${release}/:
btrfs subvol create "$@" || mkdir "$@"
chmod 755 "$@"
${SYSROOT}/bin/sh: | ${SYSROOT}
debootstrap --variant=minbase --arch="$${ARCH}" \
--keyring="$${KEYRING}" \
- stretch "$${SYSROOT}" "$${BOOTSTRAP}"
+ "${release}" "$${SYSROOT}" "$${BOOTSTRAP}"
+ printf 'APT::Default-Release "%s";' "${release}" >"$${SYSROOT}/etc/apt/apt.conf.d/10release"
+
.PHONY: _aptkeys _norecommends
_aptkeys: ${SYSROOT}/etc/apt/trusted.gpg.d/
mkdir -p -m 755 "$${CFGROOT}/boot"
mount -t vfat "$${PBOOT}" "$${CFGROOT}/boot"
+_img_mount:
+ mount -o loop,offset="$$((${BOOT_MB} + 2))"M,sizelimit=${ROOT_MB}M \
+ -t ext4 "$${VOLUME}" "$${CFGROOT}"
+ chmod 755 "$${CFGROOT}"
+ mkdir -p -m 755 "$${CFGROOT}/boot"
+ mount -o loop,offset=2M,sizelimit=${BOOT_MB}M \
+ -t vfat "$${VOLUME}" "$${CFGROOT}/boot"
+
_umount: ${CFGROOT}
-umount "$${CFGROOT}/boot"
umount "$${CFGROOT}" && rmdir "$${CFGROOT}"
-umount hdd_mount/boot
-umount hdd_mount
-rmdir hdd_mount
- if [ -d "sys_root/" ]; then btrfs sub del "sys_root/" || echo rm -r "sys_root/"; fi
+ if [ -d "sys_root_${release}/" ]; then btrfs sub del "sys_root_${release}/" || echo rm -r "sys_root_${release}/"; fi
if [ -d "cfg_root/" ]; then btrfs sub del "cfg_root/" || echo rm -r "cfg_root/"; fi
- if [ -d "rpi_root/" ]; then btrfs sub del "rpi_root/" || echo rm -r "rpi_root/"; fi
+ if [ -d "rpi_root_${release}/" ]; then btrfs sub del "rpi_root_${release}/" || echo rm -r "rpi_root_${release}/"; fi
-rm part_boot.img
-rm part_root.img
-rm rpi_boot.img