From f6e0f57be0afd1baae8376c8c58535f9a9fe6e4d Mon Sep 17 00:00:00 2001 From: Eric Fahlgren Date: Wed, 8 Oct 2025 09:42:21 -0700 Subject: [PATCH] targetwide: imagebuilder: add explicit guards around initramfs rules The imagebuilder is not intended to build initramfs images. Some profiles attempt to do this and succeed, due to buildroot leaking the initramfs-kernel into staging_dir; others attempt it, but fail due to not having initramfs binaries present in the imagebuilder. Fix this by adding an explict guard around the unsupported generation of the initramfs images. This saves space and time during imagebuilder runs, fixes those that are currently broken and protects against future breakage for profiles that inadvertently work now. Fixes: https://github.com/openwrt/openwrt/issues/20151 Signed-off-by: Eric Fahlgren Link: https://github.com/openwrt/openwrt/pull/20347 Signed-off-by: Robert Marko --- target/linux/ath79/image/common-nec.mk | 2 ++ target/linux/ath79/image/generic.mk | 4 ++++ target/linux/mediatek/image/filogic.mk | 22 ++++++++++++++++++++++ target/linux/qualcommax/image/ipq807x.mk | 4 ++++ target/linux/ramips/image/mt7620.mk | 4 ++++ target/linux/ramips/image/mt7621.mk | 10 ++++++++++ 6 files changed, 46 insertions(+) diff --git a/target/linux/ath79/image/common-nec.mk b/target/linux/ath79/image/common-nec.mk index 23671e215d..d18ec25f69 100644 --- a/target/linux/ath79/image/common-nec.mk +++ b/target/linux/ath79/image/common-nec.mk @@ -12,6 +12,7 @@ define Device/nec-netbsd-aterm KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | uImage none KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | uImage none ARTIFACTS := uboot.bin +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) COMPILE := loader-$(1).bin COMPILE/loader-$(1).bin := loader-okli-compile @@ -19,6 +20,7 @@ ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \ pad-to 4 skip=16 | \ nec-usbaterm-fw -f 0x0003 -d $$(KDIR)/loader-$(1).bin -d $$$$@ | check-size +endif endif UBOOT_PATH := $$(STAGING_DIR_IMAGE)/$$(SOC)_nec_aterm-u-boot.bin ARTIFACT/uboot.bin := append-uboot | check-size 128k diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index aa068f5a1e..794d199187 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -1354,11 +1354,13 @@ define Device/elecom_wrc-1750ghbk2-i DEVICE_VENDOR := ELECOM DEVICE_MODEL := WRC-1750GHBK2-I/C IMAGE_SIZE := 15808k +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.bin ARTIFACT/initramfs-factory.bin := append-image initramfs-kernel.bin | \ pad-to 2 | edimax-header -b -s CSYS -m RN68 -f 0x70000 -S 0x01100000 | \ elecom-product-header WRC-1750GHBK2 | check-size +endif endif DEVICE_PACKAGES := kmod-ath10k-ct ath10k-firmware-qca988x-ct endef @@ -1369,12 +1371,14 @@ define Device/elecom_wrc-300ghbk2-i DEVICE_VENDOR := ELECOM DEVICE_MODEL := WRC-300GHBK2-I IMAGE_SIZE := 7616k +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.bin ARTIFACT/initramfs-factory.bin := append-image initramfs-kernel.bin | \ pad-to 2 | edimax-header -b -s CSYS -m RN51 -f 0x70000 -S 0x01100000 | \ elecom-product-header WRC-300GHBK2-I | check-size endif +endif endef TARGET_DEVICES += elecom_wrc-300ghbk2-i diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 908c63ef66..b9ed99055f 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -342,9 +342,11 @@ define Device/asus_rt-ax52 KERNEL_INITRAMFS := kernel-bin | lzma | \ fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +ifeq ($(IB),) ARTIFACTS := initramfs.trx ARTIFACT/initramfs.trx := append-image-stage initramfs-kernel.bin | \ uImage none | asus-trx -v 3 -n $$(DEVICE_MODEL) +endif endef TARGET_DEVICES += asus_rt-ax52 @@ -403,10 +405,12 @@ define Device/asus_zenwifi-bt8 KERNEL_LOADADDR := 0x48080000 IMAGES := sysupgrade.bin IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := factory.bin ARTIFACT/factory.bin := append-image initramfs-kernel.bin | uImage lzma endif +endif endef TARGET_DEVICES += asus_zenwifi-bt8 @@ -1039,10 +1043,12 @@ define Device/dlink_aquila-pro-ai-m30-a1 IMAGES += recovery.bin IMAGE_SIZE := 51200k IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) IMAGE/recovery.bin := append-image-stage initramfs-kernel.bin | sysupgrade-tar kernel=$$$$@ |\ pad-to $$(IMAGE_SIZE) | dlink-ai-recovery-header DLK6E6110001 \x6A\x28\xEE\x0B \x00\x00\x2C\x00 \x00\x00\x20\x03 \x61\x6E endif +endif endef TARGET_DEVICES += dlink_aquila-pro-ai-m30-a1 @@ -1056,10 +1062,12 @@ define Device/dlink_aquila-pro-ai-m60-a1 IMAGES += recovery.bin IMAGE_SIZE := 51200k IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) IMAGE/recovery.bin := append-image-stage initramfs-kernel.bin | sysupgrade-tar kernel=$$$$@ |\ pad-to $$(IMAGE_SIZE) | dlink-ai-recovery-header DLK6E8202001 \x30\x6C\x19\x0C \x00\x00\x2C\x00 \x00\x00\x20\x03 \x82\x6E endif +endif endef TARGET_DEVICES += dlink_aquila-pro-ai-m60-a1 @@ -2248,9 +2256,11 @@ define Device/xiaomi_mi-router-ax3000t BLOCKSIZE := 128k PAGESIZE := 2048 DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.ubi ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-kernel.bin | ubinize-kernel +endif endif IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata endef @@ -2277,10 +2287,12 @@ define Device/xiaomi_mi-router-ax3000t-ubootmod ARTIFACTS := preloader.bin bl31-uboot.fip ARTIFACT/preloader.bin := mt7981-bl2 spim-nand-ddr3 ARTIFACT/bl31-uboot.fip := mt7981-bl31-uboot xiaomi_mi-router-ax3000t +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS += initramfs-factory.ubi ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-recovery.itb | ubinize-kernel endif +endif endef TARGET_DEVICES += xiaomi_mi-router-ax3000t-ubootmod @@ -2293,9 +2305,11 @@ define Device/xiaomi_mi-router-wr30u-stock BLOCKSIZE := 128k PAGESIZE := 2048 DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.ubi ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-kernel.bin | ubinize-kernel +endif endif IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata endef @@ -2322,10 +2336,12 @@ define Device/xiaomi_mi-router-wr30u-ubootmod ARTIFACTS := preloader.bin bl31-uboot.fip ARTIFACT/preloader.bin := mt7981-bl2 spim-nand-ddr3 ARTIFACT/bl31-uboot.fip := mt7981-bl31-uboot xiaomi_mi-router-wr30u +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS += initramfs-factory.ubi ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-recovery.itb | ubinize-kernel endif +endif endef TARGET_DEVICES += xiaomi_mi-router-wr30u-ubootmod @@ -2338,9 +2354,11 @@ define Device/xiaomi_redmi-router-ax6000-stock UBINIZE_OPTS := -E 5 BLOCKSIZE := 128k PAGESIZE := 2048 +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.ubi ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-kernel.bin | ubinize-kernel +endif endif IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata endef @@ -2367,10 +2385,12 @@ define Device/xiaomi_redmi-router-ax6000-ubootmod ARTIFACTS := preloader.bin bl31-uboot.fip ARTIFACT/preloader.bin := mt7986-bl2 spim-nand-ddr4 ARTIFACT/bl31-uboot.fip := mt7986-bl31-uboot xiaomi_redmi-router-ax6000 +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS += initramfs-factory.ubi ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-recovery.itb | ubinize-kernel endif +endif endef TARGET_DEVICES += xiaomi_redmi-router-ax6000-ubootmod @@ -2495,10 +2515,12 @@ define Device/zyxel_ex5601-t0-ubootmod ARTIFACTS := preloader.bin bl31-uboot.fip ARTIFACT/preloader.bin := mt7986-bl2 spim-nand-4k-ddr4 ARTIFACT/bl31-uboot.fip := mt7986-bl31-uboot zyxel_ex5601-t0 +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS += initramfs-factory.ubi ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-recovery.itb | ubinize-kernel endif +endif endef TARGET_DEVICES += zyxel_ex5601-t0-ubootmod diff --git a/target/linux/qualcommax/image/ipq807x.mk b/target/linux/qualcommax/image/ipq807x.mk index bd1529807e..4074f86c6d 100644 --- a/target/linux/qualcommax/image/ipq807x.mk +++ b/target/linux/qualcommax/image/ipq807x.mk @@ -75,6 +75,7 @@ define Device/asus_rt-ax89x append-kernel | asus-fake-ramdisk |\ multiImage gzip $$(KDIR)/tmp/fakerd $$(KDIR)/image-$$(DEVICE_DTS).dtb |\ sysupgrade-tar kernel=$$$$@ | append-metadata +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.trx initramfs-uImage.itb ARTIFACT/initramfs-uImage.itb := \ @@ -85,6 +86,7 @@ ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) multiImage gzip $$(KDIR)/tmp/fakehsqs $$(KDIR)/image-$$(DEVICE_DTS).dtb |\ asus-trx -v 2 -n RT-AX89U -b 388 -e 49000 endif +endif endef TARGET_DEVICES += asus_rt-ax89x @@ -259,11 +261,13 @@ define Device/netgear_rax120v2 NETGEAR_HW_ID := 29765589+0+512+1024+4x4+8x8 DEVICE_PACKAGES := ipq-wifi-netgear_rax120v2 kmod-spi-gpio \ kmod-spi-bitbang kmod-gpio-nxp-74hc164 kmod-hwmon-g762 +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) IMAGES += web-ui-factory.img IMAGE/web-ui-factory.img := append-image initramfs-uImage.itb | \ pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | \ netgear-dni +endif endif IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | \ diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index 79d73cde59..d5c5ef4140 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -1138,10 +1138,12 @@ define Device/rostelecom_rt-fl-1 $(Device/sercomm_cpj) DEVICE_MODEL := RT-FL-1 DEVICE_ALT0_MODEL := RT-FL-1 +ifeq ($(IB),) ARTIFACT/initramfs-factory.img := \ append-image-stage initramfs-kernel.bin | check-size | \ sercomm-factory-cpj | gzip | sercomm-payload | \ sercomm-pid-setbit 0x11 | sercomm-crypto +endif endef TARGET_DEVICES += rostelecom_rt-fl-1 @@ -1149,9 +1151,11 @@ define Device/rostelecom_s1010 $(Device/sercomm_cpj) DEVICE_MODEL := S1010 DEVICE_ALT0_MODEL := S1010.RT +ifeq ($(IB),) ARTIFACT/initramfs-factory.img := \ append-image-stage initramfs-kernel.bin | check-size | \ sercomm-factory-cpj | gzip | sercomm-payload | sercomm-crypto +endif endef TARGET_DEVICES += rostelecom_s1010 diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index ac7ca0bd58..ffe59bdab2 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1223,11 +1223,13 @@ define Device/elecom_wmc-x1800gst KERNEL_LOADADDR := 0x82000000 KERNEL := kernel-bin | relocate-kernel $(loadaddr-y) | lzma | \ fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.bin ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \ check-size $$$$(KERNEL_SIZE) | elecom-wrc-gs-factory WMC-2LX 0.00 -N | \ append-string MT7621_ELECOM_WMC-2LX +endif endif DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools endef @@ -1357,11 +1359,13 @@ define Device/elecom_wrc-x1800gs fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb KERNEL_SIZE := 8192k IMAGE_SIZE := 51456k +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.bin ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \ znet-header 4.04(XVF.1)b90 COMC 0x68 | elecom-product-header WRC-X1800GS | \ check-size +endif endif DEVICE_PACKAGES := kmod-mt7915-firmware endef @@ -1375,11 +1379,13 @@ define Device/elecom_wsc-x1800gs KERNEL_LOADADDR := 0x82000000 KERNEL := kernel-bin | relocate-kernel $(loadaddr-y) | lzma | \ fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.bin ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \ check-size $$$$(KERNEL_SIZE) | elecom-wrc-gs-factory WMC-2LX 0.00 -N | \ append-string MT7621_ELECOM_WMC-2LX +endif endif DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools endef @@ -1452,10 +1458,12 @@ define Device/genexis_pulse-ex400/common --log-lebs=2 --space-fixup --squash-uids KERNEL := kernel-bin | lzma | uImage lzma KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) IMAGES += factory.bin IMAGE/factory.bin := append-image-stage initramfs-kernel.bin | \ inteno-bootfs | inteno-y3-header EX400 | append-md5sum-ascii-salted +endif endif IMAGE/sysupgrade.bin := append-kernel | inteno-bootfs | pad-to 10M | \ sysupgrade-tar kernel=$$$$@ | check-size | append-metadata @@ -1549,10 +1557,12 @@ define Device/haier-sim_wr1800k KERNEL_LOADADDR := 0x82000000 KERNEL := kernel-bin | relocate-kernel $(loadaddr-y) | lzma | \ fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb +ifeq ($(IB),) ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) ARTIFACTS := initramfs-factory.bin ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \ haier-sim_wr1800k-factory +endif endif DEVICE_PACKAGES := kmod-mt7915-firmware endef -- 2.30.2