ramips: add support for ipTIME AX2004M
[openwrt/staging/mans0n.git] / include / image-commands.mk
index 23c7bd6133dfceb173693720b81e6fd09a8fb6c4..485d870f050a83db2fa7a264f600b99e31d1eece 100644 (file)
@@ -112,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)) \
@@ -122,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
@@ -184,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)),$@))
@@ -279,6 +295,16 @@ define Build/install-dtb
        )
 endef
 
+define Build/iptime-crc32
+       $(STAGING_DIR_HOST)/bin/iptime-crc32 $(1) $@ $@.new
+       mv $@.new $@
+endef
+
+define Build/iptime-naspkg
+       $(STAGING_DIR_HOST)/bin/iptime-naspkg $(1) $@ $@.new
+       mv $@.new $@
+endef
+
 define Build/jffs2
        rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
                mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \
@@ -383,7 +409,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; \
@@ -512,12 +538,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