2020-04-14 19:38:14 +01:00
all : shasums
2020-05-04 23:07:01 +01:00
# List all the supported and built Pi platforms here. They get expanded
2021-01-25 20:06:46 +00:00
# to names like 'raspi_2_buster.yaml' and 'raspi_3_bullseye.img.xz'.
BUILD_FAMILIES := 1 2 3 4
BUILD_RELEASES := buster bullseye
platforms := $( foreach plat, $( BUILD_FAMILIES) ,$( foreach rel, $( BUILD_RELEASES) , raspi_$( plat) _$( rel) ) )
2020-05-04 23:07:01 +01:00
shasums : $( addsuffix .sha 256,$ ( platforms ) ) $( addsuffix .xz .sha 256,$ ( platforms ) )
xzimages : $( addsuffix .img .xz ,$ ( platforms ) )
images : $( addsuffix .img ,$ ( platforms ) )
yaml : $( addsuffix .yaml ,$ ( platforms ) )
2019-12-17 20:41:16 +00:00
2021-04-24 23:07:01 +01:00
i f e q ( $( shell id -u ) , 0 )
as_root =
2021-06-24 19:22:55 +01:00
e l s e i f n e q ( , $( wildcard /usr /bin /fakemachine ) )
$( warning "This should normally be run as root , but found 'fakemachine ', so using that .")
2021-04-24 23:07:01 +01:00
as_root = fakemachine -v $( CURDIR) -- env --chdir $( CURDIR)
2021-06-24 19:22:55 +01:00
e l s e
$( error "This must be run as root ")
2021-04-24 23:07:01 +01:00
e n d i f
2021-01-26 06:55:23 +00:00
target_platforms :
@echo $( platforms)
2021-01-25 20:06:46 +00:00
raspi_base_buster.yaml : raspi_master .yaml
cat raspi_master.yaml | \
2021-01-26 06:55:23 +00:00
sed "s/__FIRMWARE_PKG__/raspi3-firmware/" | \
2021-04-13 22:58:25 +01:00
sed "s/__RELEASE__/buster/" | \
2021-05-07 18:58:56 +01:00
sed "s/__SECURITY_SUITE__/buster\/updates/" | \
2021-07-02 19:01:17 +01:00
sed "s/__FIX_FIRMWARE_PKG_NAME__/sed -i s\/raspi-firmware\/raspi3-firmware\/ \/etc\/systemd\/system\/rpi-reconfigure-raspi-firmware.service/" | \
2021-04-13 22:58:25 +01:00
grep -v '__EXTRA_SHELL_CMDS__' > $@
2021-01-25 20:06:46 +00:00
raspi_1_buster.yaml : raspi_base_buster .yaml
cat raspi_base_buster.yaml | sed "s/__ARCH__/armel/" | \
2019-12-17 20:41:16 +00:00
sed "s/__LINUX_IMAGE__/linux-image-rpi/" | \
sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-rpi\\/bcm*rpi-*.dtb/" | \
2021-02-21 10:30:55 +00:00
sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" | \
2020-07-06 06:21:19 +01:00
grep -v "__OTHER_APT_ENABLE__" | \
2021-04-13 22:58:25 +01:00
sed "s/__HOST__/rpi1/" | \
grep -v '__EXTRA_SHELL_CMDS__' > $@
2019-12-17 20:41:16 +00:00
2021-01-25 20:06:46 +00:00
raspi_2_buster.yaml : raspi_base_buster .yaml
cat raspi_base_buster.yaml | sed "s/__ARCH__/armhf/" | \
2019-12-17 20:41:16 +00:00
sed "s/__LINUX_IMAGE__/linux-image-armmp/" | \
grep -v "__EXTRA_PKGS__" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-armmp\\/bcm*rpi*.dtb/" | \
2021-02-21 10:30:55 +00:00
sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" | \
2020-04-24 17:00:10 +01:00
sed "s/__OTHER_APT_ENABLE__//" | \
2021-04-13 22:58:25 +01:00
sed "s/__HOST__/rpi2/" | \
grep -v '__EXTRA_SHELL_CMDS__' > $@
2019-12-17 20:41:16 +00:00
2021-01-25 20:06:46 +00:00
raspi_3_buster.yaml : raspi_base_buster .yaml
cat raspi_base_buster.yaml | sed "s/__ARCH__/arm64/" | \
2019-12-17 20:41:16 +00:00
sed "s/__LINUX_IMAGE__/linux-image-arm64/" | \
sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" | \
2021-02-18 17:31:23 +00:00
sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" | \
2020-04-24 17:00:10 +01:00
sed "s/__OTHER_APT_ENABLE__//" | \
2021-04-13 22:58:25 +01:00
sed "s/__HOST__/rpi3/" | \
grep -v '__EXTRA_SHELL_CMDS__' > $@
2019-12-17 20:41:16 +00:00
2021-01-25 20:06:46 +00:00
raspi_4_buster.yaml : raspi_base_buster .yaml
cat raspi_base_buster.yaml | sed "s/__ARCH__/arm64/" | \
2020-11-05 17:35:58 +00:00
sed "s#raspi3-firmware#raspi-firmware/buster-backports#" | \
2020-10-16 16:49:18 +01:00
sed "s#apt-get update#echo 'APT::Default-Release \"buster\";' > /etc/apt/apt.conf\n apt-get update#" | \
2020-05-11 00:53:22 +01:00
sed " s#cmdline.txt#cmdline.txt\n sed -i 's/cma=64M //' /boot/firmware/cmdline.txt\n sed -i 's/cma=\\\$ $CMA //' /etc/kernel/postinst.d/z50-raspi-firmware# " | \
2020-11-05 17:35:58 +00:00
sed "s/__LINUX_IMAGE__/linux-image-arm64\/buster-backports/" | \
sed "s/__EXTRA_PKGS__/- firmware-brcm80211\/buster-backports/" | \
2020-05-11 00:53:22 +01:00
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" | \
2021-02-18 17:31:23 +00:00
sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" | \
2020-11-05 17:35:58 +00:00
sed "s/__OTHER_APT_ENABLE__/deb http:\/\/deb.debian.org\/debian\/ buster-backports main contrib non-free # raspi 4 needs a kernel and raspi-firmware newer than buster's/" | \
2021-04-13 22:58:25 +01:00
sed "s/__HOST__/rpi4/" | \
grep -v '__EXTRA_SHELL_CMDS__' > $@
2020-05-11 00:53:22 +01:00
2021-01-25 20:06:46 +00:00
raspi_base_bullseye.yaml : raspi_master .yaml
cat raspi_master.yaml | \
sed "s/__RELEASE__/bullseye/" | \
2021-01-25 20:27:26 +00:00
sed "s/__FIRMWARE_PKG__/raspi-firmware/" | \
2021-01-25 20:06:46 +00:00
grep -v "__OTHER_APT_ENABLE__" | \
2021-07-02 19:01:17 +01:00
grep -v "__FIX_FIRMWARE_PKG_NAME__" | \
2021-05-07 18:58:56 +01:00
sed "s/__SECURITY_SUITE__/bullseye-security/" > $@
2021-01-25 20:06:46 +00:00
raspi_1_bullseye.yaml : raspi_base_bullseye .yaml
cat raspi_base_bullseye.yaml | sed "s/__ARCH__/armel/" | \
2021-01-14 06:55:55 +00:00
sed "s/__LINUX_IMAGE__/linux-image-rpi/" | \
sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-rpi\\/bcm*rpi-*.dtb/" | \
2021-02-21 10:30:55 +00:00
sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" | \
2021-04-13 22:58:25 +01:00
sed "s/__HOST__/rpi_1/" | \
grep -v '__EXTRA_SHELL_CMDS__' > $@
2021-01-14 06:55:55 +00:00
2021-01-25 20:06:46 +00:00
raspi_2_bullseye.yaml : raspi_base_bullseye .yaml
cat raspi_base_bullseye.yaml | sed "s/__ARCH__/armhf/" | \
2021-01-14 06:55:55 +00:00
sed "s/__LINUX_IMAGE__/linux-image-armmp/" | \
grep -v "__EXTRA_PKGS__" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-armmp\\/bcm*rpi*.dtb/" | \
2021-02-21 10:30:55 +00:00
sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" | \
2021-04-13 22:58:25 +01:00
sed "s/__HOST__/rpi_2/" | \
grep -v '__EXTRA_SHELL_CMDS__' > $@
2021-01-14 06:55:55 +00:00
2021-01-25 20:06:46 +00:00
raspi_3_bullseye.yaml : raspi_base_bullseye .yaml
cat raspi_base_bullseye.yaml | sed "s/__ARCH__/arm64/" | \
2021-01-14 06:55:55 +00:00
sed "s/__LINUX_IMAGE__/linux-image-arm64/" | \
sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" | \
2021-02-18 17:31:23 +00:00
sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" | \
2021-04-13 22:58:25 +01:00
sed "s/__HOST__/rpi_3/" | \
grep -v '__EXTRA_SHELL_CMDS__' > $@
2021-01-25 20:06:46 +00:00
raspi_4_bullseye.yaml : raspi_base_bullseye .yaml
cat raspi_base_bullseye.yaml | sed "s/__ARCH__/arm64/" | \
sed " s#cmdline.txt#cmdline.txt\n sed -i 's/cma=64M //' /boot/firmware/cmdline.txt\n sed -i 's/cma=\\\$ $CMA //' /etc/kernel/postinst.d/z50-raspi-firmware# " | \
sed "s/__LINUX_IMAGE__/linux-image-arm64/" | \
sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" | \
2021-02-18 17:31:23 +00:00
sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" | \
2021-04-13 22:58:25 +01:00
sed "s/__HOST__/rpi_4/" | \
2021-04-14 04:55:07 +01:00
grep -v '__EXTRA_SHELL_CMDS__' > $@
2021-01-14 06:55:55 +00:00
2021-02-19 11:53:22 +00:00
%.sha256 : %.img
2020-04-27 17:59:56 +01:00
echo $@
sha256sum $( @:sha256= img) > $@
%.xz.sha256 : %.img .xz
echo $@
sha256sum $( @:xz.sha256= img.xz) > $@
2020-04-15 04:27:20 +01:00
%.img.xz : %.img
2020-04-24 16:37:52 +01:00
xz -f -k -z -9 $( @:.xz= )
2019-12-17 20:41:16 +00:00
2020-04-14 19:38:14 +01:00
%.img : %.yaml
touch $( @:.img= .log)
2021-04-24 23:07:01 +01:00
time nice $( as_root) vmdb2 --verbose --rootfs-tarball= $( subst .img,.tar.gz,$@ ) --output= $@ $( subst .img,.yaml,$@ ) --log $( subst .img,.log,$@ )
2020-04-14 19:38:14 +01:00
chmod 0644 $@ $( @,.img= .log)
2019-12-17 20:41:16 +00:00
_ck_root :
[ ` whoami` = 'root' ] # Only root can summon vmdb2 ☹
_clean_yaml :
2021-01-25 20:06:46 +00:00
rm -f $( addsuffix .yaml,$( platforms) ) raspi_base_buster.yaml raspi_base_bullseye.yaml
2019-12-17 20:41:16 +00:00
_clean_images :
2020-05-04 23:07:01 +01:00
rm -f $( addsuffix .img,$( platforms) )
2020-04-24 16:37:52 +01:00
_clean_xzimages :
2020-05-04 23:07:01 +01:00
rm -f $( addsuffix .img.xz,$( platforms) )
2020-04-14 19:38:14 +01:00
_clean_shasums :
2020-05-04 23:07:01 +01:00
rm -f $( addsuffix .sha256,$( platforms) ) $( addsuffix .xz.sha256,$( platforms) )
2019-12-17 20:41:16 +00:00
_clean_logs :
2020-05-04 23:07:01 +01:00
rm -f $( addsuffix .log,$( platforms) )
2019-12-17 20:41:16 +00:00
_clean_tarballs :
2020-05-04 23:07:01 +01:00
rm -f $( addsuffix .tar.gz,$( platforms) )
2020-04-24 16:37:52 +01:00
clean : _clean_xzimages _clean_images _clean_shasums _clean_yaml _clean_tarballs _clean_logs
2019-12-17 20:41:16 +00:00
.PHONY : _ck_root _build_img clean _clean_images _clean_yaml _clean_tarballs _clean_logs