build: improve message for incompatible image on "legacy" devices
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Thu, 6 Aug 2020 13:14:49 +0000 (15:14 +0200)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Sat, 8 Aug 2020 14:13:51 +0000 (16:13 +0200)
It has been reported that the current message displayed during
upgrade with compat_version change is misleading for "legacy"
devices, i.e. those without the "new" fwtool. This is partially
caused by the fact that we need to exploit the supported_devices
string to get some message text displayed for these devices.

This patch modifies the message to make it more helpful and
include additional information, e.g.

  Device linksys,wrt3200acm not supported by this image
  Supported devices: linksys,wrt3200acm linksys-whateverelse - Image
  version mismatch: image 1.1, device 1.0. Please wipe config during
  upgrade (force required) or reinstall. Reason: Config cannot be
  migrated from swconfig to DSA

Note that the line breaks (except the one before Supported devices)
are added manually here, I hesitate to hack \n into the
supported_devices as well. The "Reason:" will only be displayed if
DEVICE_COMPAT_MESSAGE is set for the device, otherwise
"Please check documentation ..." will be shown instead.

While at it, also rearrange the code in image-commands.mk to
make lines shorter and remove the double filter-out command.

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

index 8ed705a7f4f29588824fc2b59dcecba9dc7cd77c..9516801c8dfd596e5f2c251b15c013c2a26e0642 100644 (file)
@@ -382,15 +382,20 @@ endef
 compat_version=$(if $(DEVICE_COMPAT_VERSION),$(DEVICE_COMPAT_VERSION),1.0)
 json_quote=$(subst ','\'',$(subst ",\",$(1)))
 #")')
+
+legacy_supported_message=$(SUPPORTED_DEVICES) - Image version mismatch: image $(compat_version), \
+       device 1.0. Please wipe config during upgrade (force required) or reinstall. \
+       $(if $(DEVICE_COMPAT_MESSAGE),Reason: $(DEVICE_COMPAT_MESSAGE),Please check documentation ...)
+
 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.1", \
                "compat_version": "$(call json_quote,$(compat_version))", \
                $(if $(DEVICE_COMPAT_MESSAGE),"compat_message": "$(call json_quote,$(DEVICE_COMPAT_MESSAGE))"$(comma)) \
-               $(if $(filter-out 1.0,$(compat_version)),"new_supported_devices":[$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma)) \
-               $(if $(filter-out 1.0,$(compat_version)),"supported_devices": \
-                       ["$(call json_quote,Image version $(compat_version) incompatible to device: $(if $(DEVICE_COMPAT_MESSAGE),$(DEVICE_COMPAT_MESSAGE),Please check documentation ...))"]$(comma)) \
+               $(if $(filter-out 1.0,$(compat_version)),"new_supported_devices": \
+                       [$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma) \
+                       "supported_devices": ["$(call json_quote,$(legacy_supported_message))"]$(comma)) \
                $(if $(filter 1.0,$(compat_version)),"supported_devices":[$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma)) \
                "version": { \
                        "dist": "$(call json_quote,$(VERSION_DIST))", \