Replace the sed maze with one generate-recipe call for each combination.

This commit is contained in:
Cyril Brulebois 2021-08-28 05:51:05 +02:00
parent 1410839911
commit 0f8884c39c
1 changed files with 7 additions and 95 deletions

102
Makefile
View File

@ -24,101 +24,13 @@ endif
target_platforms:
@echo $(platforms)
raspi_base_buster.yaml: raspi_master.yaml
cat raspi_master.yaml | \
sed "s/__FIRMWARE_PKG__/raspi3-firmware/" | \
sed "s/__RELEASE__/buster/" |\
sed "s/__SECURITY_SUITE__/buster\/updates/" |\
sed "s/__FIX_FIRMWARE_PKG_NAME__/sed -i s\/raspi-firmware\/raspi3-firmware\/ \$${ROOT?}\/etc\/systemd\/system\/rpi-reconfigure-raspi-firmware.service/" |\
grep -v '__EXTRA_SHELL_CMDS__' > $@
raspi_1_buster.yaml: raspi_base_buster.yaml
cat raspi_base_buster.yaml | sed "s/__ARCH__/armel/" | \
sed "s/__LINUX_IMAGE__/linux-image-rpi/" | \
sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-rpi\\/bcm*rpi-*.dtb/" |\
sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" |\
grep -v "__OTHER_APT_ENABLE__" |\
sed "s/__HOST__/rpi1/" |\
grep -v '__EXTRA_SHELL_CMDS__' > $@
raspi_2_buster.yaml: raspi_base_buster.yaml
cat raspi_base_buster.yaml | sed "s/__ARCH__/armhf/" | \
sed "s/__LINUX_IMAGE__/linux-image-armmp/" | \
grep -v "__EXTRA_PKGS__" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-armmp\\/bcm*rpi*.dtb/" |\
sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" |\
sed "s/__OTHER_APT_ENABLE__//" |\
sed "s/__HOST__/rpi2/" |\
grep -v '__EXTRA_SHELL_CMDS__' > $@
raspi_3_buster.yaml: raspi_base_buster.yaml
cat raspi_base_buster.yaml | sed "s/__ARCH__/arm64/" | \
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/" |\
sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" |\
sed "s/__OTHER_APT_ENABLE__//" |\
sed "s/__HOST__/rpi3/" |\
grep -v '__EXTRA_SHELL_CMDS__' > $@
raspi_4_buster.yaml: raspi_base_buster.yaml
cat raspi_base_buster.yaml | sed "s/__ARCH__/arm64/" | \
sed "s#raspi3-firmware#raspi-firmware/buster-backports#" | \
sed "s#apt-get update#echo 'APT::Default-Release \"buster\";' > /etc/apt/apt.conf\n apt-get update#" | \
sed "s#\(RASPIROOT.*cmdline.txt\)#\1\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\/buster-backports/" | \
sed "s/__EXTRA_PKGS__/- firmware-brcm80211\/buster-backports/" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" |\
sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" |\
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/" |\
sed "s/__HOST__/rpi4/" |\
grep -v '__EXTRA_SHELL_CMDS__' > $@
raspi_base_bullseye.yaml: raspi_master.yaml
cat raspi_master.yaml | \
sed "s/__RELEASE__/bullseye/" |\
sed "s/__FIRMWARE_PKG__/raspi-firmware/" | \
grep -v "__OTHER_APT_ENABLE__" |\
grep -v "__FIX_FIRMWARE_PKG_NAME__" |\
sed "s/__SECURITY_SUITE__/bullseye-security/" > $@
raspi_1_bullseye.yaml: raspi_base_bullseye.yaml
cat raspi_base_bullseye.yaml | sed "s/__ARCH__/armel/" | \
sed "s/__LINUX_IMAGE__/linux-image-rpi/" | \
sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-rpi\\/bcm*rpi-*.dtb/" |\
sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" |\
sed "s/__HOST__/rpi_1/" |\
grep -v '__EXTRA_SHELL_CMDS__' > $@
raspi_2_bullseye.yaml: raspi_base_bullseye.yaml
cat raspi_base_bullseye.yaml | sed "s/__ARCH__/armhf/" | \
sed "s/__LINUX_IMAGE__/linux-image-armmp/" | \
grep -v "__EXTRA_PKGS__" | \
sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-armmp\\/bcm*rpi*.dtb/" |\
sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" |\
sed "s/__HOST__/rpi_2/" |\
grep -v '__EXTRA_SHELL_CMDS__' > $@
raspi_3_bullseye.yaml: raspi_base_bullseye.yaml
cat raspi_base_bullseye.yaml | sed "s/__ARCH__/arm64/" | \
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/" |\
sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" |\
sed "s/__HOST__/rpi_3/" |\
grep -v '__EXTRA_SHELL_CMDS__' > $@
raspi_4_bullseye.yaml: raspi_base_bullseye.yaml
cat raspi_base_bullseye.yaml | sed "s/__ARCH__/arm64/" | \
sed "s#\(RASPIROOT.*cmdline.txt\)#\1\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/" |\
sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" |\
sed "s/__HOST__/rpi_4/" |\
grep -v '__EXTRA_SHELL_CMDS__' > $@
# Generate targets based on all family * release combinations:
define dynamic_yaml_target =
raspi_$(1)_$(2).yaml: raspi_master.yaml generate-recipe.py
raspi_$(1)_$(2).yaml:
./generate-recipe.py $(1) $(2)
endef
$(foreach release,$(BUILD_RELEASES),$(foreach family,$(BUILD_FAMILIES),$(eval $(call dynamic_yaml_target,$(family),$(release)))))
%.img.sha256: %.img
echo $@