build: image: add pad-to and pad-rootfs-squashfs helpers
[oweals/openwrt.git] / include / image-commands.mk
index 47d7193434d16c39cb2fb0c87bef93dd29169a1d..06c084c48b0eeb54c15a69569dc84beaa8da8ff8 100644 (file)
@@ -230,8 +230,7 @@ define Build/append-uboot
 endef
 
 define Build/pad-to
-       dd if=$@ of=$@.new bs=$(1) conv=sync
-       mv $@.new $@
+       $(call Image/pad-to,$@,$(1))
 endef
 
 define Build/pad-extra
@@ -297,14 +296,14 @@ endef
 define Build/qsdk-ipq-factory-nand
        $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
                $@.its ubi $@
-       mkimage -f $@.its $@.new
+       PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
        @mv $@.new $@
 endef
 
 define Build/qsdk-ipq-factory-nor
        $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
                $@.its hlos $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS)
-       mkimage -f $@.its $@.new
+       PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
        @mv $@.new $@
 endef
 
@@ -355,12 +354,14 @@ json_quote=$(subst ','\'',$(subst ",\",$(1)))
 metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))"))))
 metadata_json = \
        '{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
+               "metadata_version": "1.0", \
                "supported_devices":[$(call metadata_devices,$(1))], \
                "version": { \
                        "dist": "$(call json_quote,$(VERSION_DIST))", \
                        "version": "$(call json_quote,$(VERSION_NUMBER))", \
                        "revision": "$(call json_quote,$(REVISION))", \
-                       "board": "$(call json_quote,$(BOARD))" \
+                       "target": "$(call json_quote,$(TARGETID))", \
+                       "board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
                } \
        }'