tools/tar: Update to 1.31
[openwrt/openwrt.git] / include / image-commands.mk
index 8db046b..56bad53 100644 (file)
@@ -7,7 +7,7 @@ define Build/uImage
        mkimage -A $(LINUX_KARCH) \
                -O linux -T kernel \
                -C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
-               -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION))' -d $@ $@.new
+               -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' -d $@ $@.new
        mv $@.new $@
 endef
 
@@ -49,6 +49,31 @@ define Build/eva-image
        mv $@.new $@
 endef
 
+define Build/seama
+       $(STAGING_DIR_HOST)/bin/seama -i $@ \
+               -m "dev=/dev/mtdblock/$(SEAMA_MTDBLOCK)" -m "type=firmware"
+       mv $@.seama $@
+endef
+
+define Build/seama-seal
+       $(STAGING_DIR_HOST)/bin/seama -i $@ -s $@.seama \
+               -m "signature=$(SEAMA_SIGNATURE)"
+       mv $@.seama $@
+endef
+
+define Build/zyxel-ras-image
+       let \
+               newsize="$(subst k,* 1024,$(RAS_ROOTFS_SIZE))"; \
+               $(STAGING_DIR_HOST)/bin/mkrasimage \
+                       -b $(RAS_BOARD) \
+                       -v $(RAS_VERSION) \
+                       -r $@ \
+                       -s $$newsize \
+                       -o $@.new \
+                       $(if $(findstring separate-kernel,$(word 1,$(1))),-k $(IMAGE_KERNEL)) \
+               && mv $@.new $@
+endef
+
 define Build/netgear-chk
        $(STAGING_DIR_HOST)/bin/mkchkimg \
                -o $@.new \
@@ -60,7 +85,7 @@ endef
 
 define Build/netgear-dni
        $(STAGING_DIR_HOST)/bin/mkdniimg \
-               -B $(NETGEAR_BOARD_ID) -v LEDE.$(REVISION) \
+               -B $(NETGEAR_BOARD_ID) -v $(VERSION_DIST).$(firstword $(subst -, ,$(REVISION))) \
                $(if $(NETGEAR_HW_ID),-H $(NETGEAR_HW_ID)) \
                -r "$(1)" \
                -i $@ -o $@.new
@@ -77,16 +102,21 @@ define Build/append-squashfs-fakeroot-be
        cat $@.fakesquashfs >> $@
 endef
 
-# append a fake/empty rootfs uImage header, to fool the bootloaders
-# rootfs integrity check
-define Build/append-uImage-fakeroot-hdr
-       rm -f $@.fakeroot
+define Build/append-string
+       echo -n $(1) >> $@
+endef
+
+# append a fake/empty uImage header, to fool bootloaders rootfs integrity check
+# for example
+define Build/append-uImage-fakehdr
+       touch $@.fakehdr
        $(STAGING_DIR_HOST)/bin/mkimage \
-               -A $(LINUX_KARCH) -O linux -T filesystem -C none \
-               -n '$(call toupper,$(LINUX_KARCH)) LEDE fakeroot' \
+               -A $(LINUX_KARCH) -O linux -T $(1) -C none \
+               -n '$(VERSION_DIST) fake $(1)' \
+               -d $@.fakehdr \
                -s \
-               $@.fakeroot
-       cat $@.fakeroot >> $@
+               $@.fakehdr
+       cat $@.fakehdr >> $@
 endef
 
 define Build/tplink-safeloader
@@ -113,16 +143,12 @@ define Build/install-dtb
        )
 endef
 
-define Build/install-zImage
-    $(CP) $(KDIR)/zImage \
-      $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage
-endef
-
 define Build/fit
        $(TOPDIR)/scripts/mkits.sh \
                -D $(DEVICE_NAME) -o $@.its -k $@ \
                $(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
                -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
+               -c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config@1") \
                -A $(LINUX_KARCH) -v $(LINUX_VERSION)
        PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
        @mv $@.new $@
@@ -138,10 +164,20 @@ define Build/lzma-no-dict
 endef
 
 define Build/gzip
-       gzip -9n -c $@ $(1) > $@.new
+       gzip -f -9n -c $@ $(1) > $@.new
        @mv $@.new $@
 endef
 
+define Build/zip
+       mkdir $@.tmp
+       mv $@ $@.tmp/$(1)
+
+       zip -j -X \
+               $(if $(SOURCE_DATE_EPOCH),--mtime="$(SOURCE_DATE_EPOCH)") \
+               $@ $@.tmp/$(if $(1),$(1),$@)
+       rm -rf $@.tmp
+endef
+
 define Build/jffs2
        rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
                mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \
@@ -189,6 +225,10 @@ define Build/append-ubi
        rm $@.tmp
 endef
 
+define Build/append-uboot
+       dd if=$(UBOOT_PATH) >> $@
+endef
+
 define Build/pad-to
        dd if=$@ of=$@.new bs=$(1) conv=sync
        mv $@.new $@
@@ -214,6 +254,11 @@ define Build/pad-offset
        mv $@.new $@
 endef
 
+define Build/xor-image
+       $(STAGING_DIR_HOST)/bin/xorimage -i $@ -o $@.xor $(1)
+       mv $@.xor $@
+endef
+
 define Build/check-size
        @[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $@)" ] || { \
                echo "WARNING: Image file $@ is too big" >&2; \
@@ -229,6 +274,31 @@ define Build/combined-image
        @mv $@.new $@
 endef
 
+define Build/linksys-image
+       $(TOPDIR)/scripts/linksys-image.sh \
+               "$(call param_get_default,type,$(1),$(DEVICE_NAME))" \
+               $@ $@.new
+               mv $@.new $@
+endef
+
+define Build/openmesh-image
+       $(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \
+               "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" \
+               "$@-fwupgrade.cfg" \
+               "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" \
+               "$(call param_get_default,rootfs,$(1),$@)"
+       $(TOPDIR)/scripts/combined-ext-image.sh \
+               "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" "$@" \
+               "$@-fwupgrade.cfg" "fwupgrade.cfg" \
+               "$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" "kernel" \
+               "$(call param_get_default,rootfs,$(1),$@)" "rootfs"
+endef
+
+define Build/senao-header
+       $(STAGING_DIR_HOST)/bin/mksenaofw $(1) -e $@ -o $@.new
+       mv $@.new $@
+endef
+
 define Build/sysupgrade-tar
        sh $(TOPDIR)/scripts/sysupgrade-tar.sh \
                --board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
@@ -282,6 +352,12 @@ metadata_json = \
 
 define Build/append-metadata
        $(if $(SUPPORTED_DEVICES),-echo $(call metadata_json,$(SUPPORTED_DEVICES)) | fwtool -I - $@)
+       [ ! -s "$(BUILD_KEY)" -o ! -s "$(BUILD_KEY).ucert" -o ! -s "$@" ] || { \
+               cp "$(BUILD_KEY).ucert" "$@.ucert" ;\
+               usign -S -m "$@" -s "$(BUILD_KEY)" -x "$@.sig" ;\
+               ucert -A -c "$@.ucert" -x "$@.sig" ;\
+               fwtool -S "$@.ucert" "$@" ;\
+       }
 endef
 
 define Build/kernel2minor