build: image: add variable for gzip-ext4-padded-squashfs
[openwrt/openwrt.git] / include / image.mk
index 5b022195589d37e806798e729c2babfa056123de..f5da4853dfcbed52d193796d9211d80aa9ede3cf 100644 (file)
@@ -178,6 +178,15 @@ ifeq ($(strip $(call kernel_patchver_ge,4.18.0)),1)
        -Wno-unique_unit_address
 endif
 
+define Image/pad-to
+       dd if=$(1) of=$(1).new bs=$(2) conv=sync
+       mv $(1).new $(1)
+endef
+
+define Image/pad-root-squashfs
+       $(call Image/pad-to,$(KDIR)/root.squashfs,$(if $(1),$(1),$(CONFIG_TARGET_ROOTFS_PARTSIZE)M))
+endef
+
 # $(1) source dts file
 # $(2) target dtb file
 # $(3) extra CPP flags
@@ -289,6 +298,23 @@ define Image/Manifest
                $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED)).manifest
 endef
 
+define Image/gzip-ext4-padded-squashfs
+
+  define Image/Build/squashfs
+    $(call Image/pad-root-squashfs)
+  endef
+
+  ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
+    define Image/Build/gzip/ext4
+      $(call Image/Build/gzip,ext4)
+    endef
+    define Image/Build/gzip/squashfs
+      $(call Image/Build/gzip,squashfs)
+    endef
+  endif
+
+endef
+
 ifdef CONFIG_TARGET_ROOTFS_TARGZ
   define Image/Build/targz
        $(TAR) -cp --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
@@ -383,6 +409,8 @@ define Device/Init
   IMAGE_METADATA :=
 
   FILESYSTEMS := $(TARGET_FILESYSTEMS)
+
+  UBOOT_PATH :=  $(STAGING_DIR_IMAGE)/uboot-$(1)
 endef
 
 DEFAULT_DEVICE_VARS := \
@@ -390,7 +418,7 @@ DEFAULT_DEVICE_VARS := \
   CMDLINE UBOOTENV_IN_UBI KERNEL_IN_UBI BLOCKSIZE PAGESIZE SUBPAGESIZE \
   VID_HDR_OFFSET UBINIZE_OPTS UBINIZE_PARTS MKUBIFS_OPTS DEVICE_DTS \
   DEVICE_DTS_CONFIG DEVICE_DTS_DIR BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \
-  IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR
+  IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR UBOOT_PATH
 
 define Device/ExportVar
   $(1) : $(2):=$$($(2))