image-commands.mk: Use ERROR_MESSAGE for imagesize fails
[openwrt/staging/chunkeey.git] / include / image-commands.mk
index 4b5ff36ebeebfb89cc57836780b5876f30fe6c1c..939f5ef2db4db7afeab6f0009d926aef3055d906 100644 (file)
@@ -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
@@ -179,11 +191,15 @@ define Build/check-size
        @imagesize="$$(stat -c%s $@)"; \
        limitsize="$$(($(subst k,* 1024,$(subst m, * 1024k,$(if $(1),$(1),$(IMAGE_SIZE))))))"; \
        [ $$limitsize -ge $$imagesize ] || { \
-               echo "WARNING: Image file $@ is too big: $$imagesize > $$limitsize" >&2; \
+               $(call ERROR_MESSAGE,    WARNING: Image file $@ is too big: $$imagesize > $$limitsize); \
                rm -f $@; \
        }
 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