kernel: bump 5.4 to 5.4.174
[openwrt/staging/mkresin.git] / include / image-commands.mk
index 1c9e8c12bb5fa8d9c073230c775e440524dc1f81..158af853a584d51b947252dd0fc66289329555bb 100644 (file)
@@ -27,6 +27,15 @@ define Build/append-kernel
        dd if=$(IMAGE_KERNEL) >> $@
 endef
 
+define Build/package-kernel-ubifs
+       mkdir $@.kernelubifs
+       cp $@ $@.kernelubifs/kernel
+       $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
+               $(KERNEL_UBIFS_OPTS) \
+               -r $@.kernelubifs $@
+       rm -r $@.kernelubifs
+endef
+
 define Build/append-image
        dd if=$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1) >> $@
 endef
@@ -103,7 +112,7 @@ define Build/append-ubi
                $(if $(UBOOTENV_IN_UBI),--uboot-env) \
                $(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \
                $(foreach part,$(UBINIZE_PARTS),--part $(part)) \
-               $(IMAGE_ROOTFS) \
+               --rootfs $(IMAGE_ROOTFS) \
                $@.tmp \
                -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
                $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
@@ -113,6 +122,18 @@ define Build/append-ubi
        rm $@.tmp
 endef
 
+define Build/ubinize-kernel
+       cp $@ $@.tmp
+       sh $(TOPDIR)/scripts/ubinize-image.sh \
+               --kernel $@.tmp \
+               $@ \
+               -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
+               $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
+               $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \
+               $(UBINIZE_OPTS)
+       rm $@.tmp
+endef
+
 define Build/append-uboot
        dd if=$(UBOOT_PATH) >> $@
 endef
@@ -175,6 +196,10 @@ define Build/check-size
        }
 endef
 
+define Build/copy-file
+       cat "$(1)" > "$@"
+endef
+
 define Build/elecom-product-header
        $(eval product=$(word 1,$(1)))
        $(eval fw=$(if $(word 2,$(1)),$(word 2,$(1)),$@))
@@ -187,6 +212,19 @@ define Build/elecom-product-header
        mv $(fw).new $(fw)
 endef
 
+define Build/elecom-wrc-gs-factory
+       $(eval product=$(word 1,$(1)))
+       $(eval version=$(word 2,$(1)))
+       $(eval hash_opt=$(word 3,$(1)))
+       $(MKHASH) md5 $(hash_opt) $@ >> $@
+       ( \
+               echo -n "ELECOM $(product) v$(version)" | \
+                       dd bs=32 count=1 conv=sync; \
+               dd if=$@; \
+       ) > $@.new
+       mv $@.new $@
+endef
+
 define Build/elx-header
        $(eval hw_id=$(word 1,$(1)))
        $(eval xor_pattern=$(word 2,$(1)))
@@ -361,7 +399,7 @@ define Build/patch-cmdline
 endef
 
 # Convert a raw image into a $1 type image.
-# E.g. | qemu-image vdi
+# E.g. | qemu-image vdi <optional extra arguments to qemu-img binary>
 define Build/qemu-image
        if command -v qemu-img; then \
                qemu-img convert -f raw -O $1 $@ $@.new; \
@@ -490,12 +528,14 @@ define Build/xor-image
 endef
 
 define Build/zip
+       rm -rf $@.tmp
        mkdir $@.tmp
-       mv $@ $@.tmp/$(1)
+       mv $@ $@.tmp/$(word 1,$(1))
 
-       zip -j -X \
+       $(STAGING_DIR_HOST)/bin/zip -j -X \
                $(if $(SOURCE_DATE_EPOCH),--mtime="$(SOURCE_DATE_EPOCH)") \
-               $@ $@.tmp/$(if $(1),$(1),$@)
+               $(wordlist 2,$(words $(1)),$(1)) \
+               $@ $@.tmp/$(if $(word 1,$(1)),$(word 1,$(1)),$$(basename $@))
        rm -rf $@.tmp
 endef