[source] build: add support code for appending metadata to images
LEDE Commits
lede-commits at lists.infradead.org
Sat Nov 19 02:26:54 PST 2016
nbd pushed a commit to source.git, branch master:
https://git.lede-project.org/77265e00c70a7f6c01d2bc68c3a41de34b18deb3
commit 77265e00c70a7f6c01d2bc68c3a41de34b18deb3
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Mon Nov 14 17:31:53 2016 +0100
build: add support code for appending metadata to images
Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
include/image-commands.mk | 18 ++++++++++++++++++
include/image.mk | 5 ++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/include/image-commands.mk b/include/image-commands.mk
index 6386e55..083a389 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -172,3 +172,21 @@ define Build/sysupgrade-tar
--rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \
$@
endef
+
+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)) \
+ "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))" \
+ } \
+ }'
+
+define Build/append-metadata
+ $(if $(SUPPORTED_DEVICES),echo $(call metadata_json,$(SUPPORTED_DEVICES)) | fwtool -I - $@)
+endef
diff --git a/include/image.mk b/include/image.mk
index 8b183ab..d1dcdd6 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -346,6 +346,8 @@ define Device/Init
BOARD_NAME :=
UIMAGE_NAME :=
+ SUPPORTED_DEVICES :=
+ IMAGE_METADATA :=
FILESYSTEMS := $(TARGET_FILESYSTEMS)
endef
@@ -355,7 +357,8 @@ DEFAULT_DEVICE_VARS := \
DEVICE_DTS DEVICE_DTS_DIR BOARD_NAME CMDLINE \
UBOOTENV_IN_UBI KERNEL_IN_UBI \
BLOCKSIZE PAGESIZE SUBPAGESIZE VID_HDR_OFFSET \
- UBINIZE_OPTS UIMAGE_NAME UBINIZE_PARTS
+ UBINIZE_OPTS UIMAGE_NAME UBINIZE_PARTS \
+ SUPPORTED_DEVICES IMAGE_METADATA
define Device/ExportVar
$(1) : $(2):=$$($(2))
More information about the lede-commits
mailing list