[openwrt/openwrt] image: add gzip-filename build recipe

LEDE Commits lede-commits at lists.infradead.org
Fri Jan 6 06:35:14 PST 2023


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/ee87dbb3fef2c0771b20967ec4a8638fdab9c9bf

commit ee87dbb3fef2c0771b20967ec4a8638fdab9c9bf
Author: Michael Pratt <mcpratt at pm.me>
AuthorDate: Wed Dec 21 21:33:04 2022 -0500

    image: add gzip-filename build recipe
    
    Some vendors use basic gzip metadata (original filename and timestamp)
    to verify valid images, along with the size of it's contents.
    
    Also, add a new device profile variable FACTORY_IMG_NAME
    which would be ideal to use with this new recipe.
    
    Signed-off-by: Michael Pratt <mcpratt at pm.me>
---
 include/image-commands.mk | 9 +++++++++
 include/image.mk          | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/include/image-commands.mk b/include/image-commands.mk
index 15084093d2..ff8acf96c4 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -316,6 +316,15 @@ define Build/gzip
 	@mv $@.new $@
 endef
 
+define Build/gzip-filename
+	@mkdir -p $@.tmp
+	@cp $@ $@.tmp/$(word 1,$(1))
+	$(if $(SOURCE_DATE_EPOCH),touch -hcd "@$(SOURCE_DATE_EPOCH)" $@.tmp/$(word 1,$(1)) $(word 2,$(1)))
+	$(STAGING_DIR_HOST)/bin/gzip -f -9 -N -c $@.tmp/$(word 1,$(1)) $(word 2,$(1)) > $@.new
+	@mv $@.new $@
+	@rm -rf $@.tmp
+endef
+
 define Build/install-dtb
 	$(call locked, \
 		$(foreach dts,$(DEVICE_DTS), \
diff --git a/include/image.mk b/include/image.mk
index 5d9d4acb41..01bc3bda86 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -359,6 +359,7 @@ define Device/Init
   ARTIFACTS :=
   DEVICE_IMG_PREFIX := $(IMG_PREFIX)-$(1)
   DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(1)-$$(2)
+  FACTORY_IMG_NAME :=
   IMAGE_SIZE :=
   KERNEL_PREFIX = $$(DEVICE_IMG_PREFIX)
   KERNEL_SUFFIX := -kernel.bin
@@ -418,6 +419,7 @@ DEFAULT_DEVICE_VARS := \
   DEVICE_FDT_NUM DEVICE_IMG_PREFIX SOC BOARD_NAME UIMAGE_MAGIC UIMAGE_NAME \
   SUPPORTED_DEVICES IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR \
   UBOOT_PATH IMAGE_SIZE \
+  FACTORY_IMG_NAME \
   DEVICE_PACKAGES DEVICE_COMPAT_VERSION DEVICE_COMPAT_MESSAGE \
   DEVICE_VENDOR DEVICE_MODEL DEVICE_VARIANT \
   DEVICE_ALT0_VENDOR DEVICE_ALT0_MODEL DEVICE_ALT0_VARIANT \




More information about the lede-commits mailing list