[openwrt/openwrt] image: support generating per device targz rootfs

LEDE Commits lede-commits at lists.infradead.org
Mon Feb 9 07:44:06 PST 2026


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/d89cb72c23fea53883c1e6203020d9b555208452

commit d89cb72c23fea53883c1e6203020d9b555208452
Author: Robert Marko <robert.marko at sartura.hr>
AuthorDate: Mon Feb 9 12:25:56 2026 +0100

    image: support generating per device targz rootfs
    
    Currently, for targets that use the CONFIG_TARGET_ROOTFS_TARGZ a single
    rootfs tarball is generated for the subtarget based of $(TARGET_DIR).
    
    However, this means that it does not respect DEVICE_PACKAGES like other
    rootfs images.
    
    So, lets augment CONFIG_TARGET_ROOTFS_TARGZ by adding a proper targz fstype
    so that per device rootfs is generated under lock.
    
    This is required so that devices that use custom sysupgrade archives like
    Methode devices, can actually include a per device rootfs so when building
    for multiple devices and with CONFIG_TARGET_PER_DEVICE_ROOTFS set the built
    image actually includes the listed DEVICE_PACKAGES.
    
    Signed-off-by: Robert Marko <robert.marko at sartura.hr>
---
 include/image.mk | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/image.mk b/include/image.mk
index 38005b2ab2..e62468c598 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -117,6 +117,7 @@ fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2_NAND) += $(addprefix jffs2-nand-,$(NAND_BL
 fs-types-$(CONFIG_TARGET_ROOTFS_EXT4FS) += ext4
 fs-types-$(CONFIG_TARGET_ROOTFS_UBIFS) += ubifs
 fs-types-$(CONFIG_TARGET_ROOTFS_EROFS) += erofs
+fs-types-$(CONFIG_TARGET_ROOTFS_TARGZ) += targz
 fs-subtypes-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addsuffix -raw,$(addprefix jffs2-,$(JFFS2_BLOCKSIZE)))
 
 TARGET_FILESYSTEMS := $(fs-types-y)
@@ -329,6 +330,12 @@ define Image/mkfs/erofs
 		$@ $(call mkfs_target_dir,$(1))
 endef
 
+define Image/mkfs/targz
+	$(TAR) -cp --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
+		$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
+		-C $(call mkfs_target_dir,$(1)) . | gzip -9n > $@
+endef
+
 define Image/Manifest
 	$(if $(CONFIG_USE_APK), \
 		$(call apk,$(TARGET_DIR_ORIG)) list --quiet --manifest --no-network \




More information about the lede-commits mailing list