build: add DEVICE_COMPAT_VERSION and DEVICE_COMPAT_MESSAGE
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Thu, 9 Jul 2020 17:14:45 +0000 (19:14 +0200)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Fri, 31 Jul 2020 09:40:15 +0000 (11:40 +0200)
We regularly encounter the situation that devices are subject to
changes that will make them incompatible to previous versions.
Removing SUPPORTED_DEVICES will not really be helpful in most of these
cases, as this only helps after a rename.

To solve this situation, this patchset introduces a compatibility
version for devices. It will be implemented via a per-device
Make variable DEVICE_COMPAT_VERSION, which will be set to 1.0
globally by default and then can be overwritten as needed.

Furthermore, a variable DEVICE_COMPAT_MESSAGE is added, where
a message to be displayed during sysupgrade may be specified
optionally.

This patch only implements the build variables and adds them
to the sysupgrade metadata, the evaluation will be addressed
in a subsequent patch.

To set it, one would just need to add the following to a device node:

define Device/somedevice
  ...
  DEVICE_COMPAT_VERSION := 1.1
  DEVICE_COMPAT_MESSAGE := Config cannot be migrated from swconfig to DSA
endef

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
include/image-commands.mk
include/image.mk

index e7db7128b4cac775ca424c96bebf1405db6937b4..9da712e73360708bcdf6c0d5d57c38cf66ac2e54 100644 (file)
@@ -384,13 +384,16 @@ define Build/tplink-v2-image
        rm -rf $@.new
 endef
 
+compat_version=$(if $(DEVICE_COMPAT_VERSION),$(DEVICE_COMPAT_VERSION),1.0)
 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))], \
+               "compat_version": "$(call json_quote,$(compat_version))", \
+               $(if $(DEVICE_COMPAT_MESSAGE),"compat_message": "$(call json_quote,$(DEVICE_COMPAT_MESSAGE))"$(comma)) \
+               "supported_devices":[$(call metadata_devices,$(SUPPORTED_DEVICES))], \
                "version": { \
                        "dist": "$(call json_quote,$(VERSION_DIST))", \
                        "version": "$(call json_quote,$(VERSION_NUMBER))", \
@@ -401,7 +404,7 @@ metadata_json = \
        }'
 
 define Build/append-metadata
-       $(if $(SUPPORTED_DEVICES),-echo $(call metadata_json,$(SUPPORTED_DEVICES)) | fwtool -I - $@)
+       $(if $(SUPPORTED_DEVICES),-echo $(call metadata_json) | 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" ;\
index be934e94d34c754e7a866cb594ddc42217be99b6..e8c2cf7100d684a81347183f5fc4c8ae7c7ad70b 100644 (file)
@@ -419,6 +419,8 @@ define Device/Init
 
   BOARD_NAME :=
   UIMAGE_NAME :=
+  DEVICE_COMPAT_VERSION := 1.0
+  DEVICE_COMPAT_MESSAGE :=
   SUPPORTED_DEVICES :=
   IMAGE_METADATA :=
 
@@ -436,6 +438,7 @@ DEFAULT_DEVICE_VARS := \
   VID_HDR_OFFSET UBINIZE_OPTS UBINIZE_PARTS MKUBIFS_OPTS DEVICE_DTS \
   DEVICE_DTS_CONFIG DEVICE_DTS_DIR SOC BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \
   IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR UBOOT_PATH IMAGE_SIZE \
+  DEVICE_COMPAT_VERSION DEVICE_COMPAT_MESSAGE \
   DEVICE_VENDOR DEVICE_MODEL DEVICE_VARIANT \
   DEVICE_ALT0_VENDOR DEVICE_ALT0_MODEL DEVICE_ALT0_VARIANT \
   DEVICE_ALT1_VENDOR DEVICE_ALT1_MODEL DEVICE_ALT1_VARIANT \