From fbd4214bb0727268aa535af5b600d38939ec8dbc Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 6 Aug 2020 15:14:49 +0200 Subject: [PATCH] build: improve message for incompatible image on "legacy" devices 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 --- include/image-commands.mk | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/image-commands.mk b/include/image-commands.mk index 8ed705a7f4f2..9516801c8dfd 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -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))", \ -- 2.30.2