diff options
author | Adrian Schmutzler <freifunk@adrianschmutzler.de> | 2020-07-09 19:24:11 +0200 |
---|---|---|
committer | Adrian Schmutzler <freifunk@adrianschmutzler.de> | 2020-07-31 11:40:15 +0200 |
commit | 735de53b2aae9be03611715699bf58dff44e8eff (patch) | |
tree | 5f0e892a7d5c67f9d7a214d3aae67ef116d15d12 /package | |
parent | 6867d86e085dd4a284c8ee8878839c9e77546f46 (diff) | |
download | upstream-735de53b2aae9be03611715699bf58dff44e8eff.tar.gz upstream-735de53b2aae9be03611715699bf58dff44e8eff.tar.bz2 upstream-735de53b2aae9be03611715699bf58dff44e8eff.zip |
base-files: add support for compat_version on device
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. To complement the DEVICE_COMPAT_VERSION set
for the image to be flashed, this implements a compat_version on
the device, so it will have something to compare with the image.
The only viable way to achieve this seems to be via board.d files,
i.e. this is technically adding a compat version for the device's
config.
Like for the network setup, this will set up a command
ucidef_set_compat_version to set the compat_version in board.d.
This will then add a string to /etc/board.json, which will be
translated into uci system config by bin/config_generate.
By this, the compat_version, being a version of the config, will
also be exposed to the user.
As with DEVICE_COMPAT_VERSION, missing uci entry will be assumed
as compat_version "1.0", so we only need to add this if a device
needs to be bumped, e.g.
ucidef_set_compat_version "1.1"
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'package')
-rwxr-xr-x | package/base-files/files/bin/config_generate | 7 | ||||
-rwxr-xr-x | package/base-files/files/lib/functions/uci-defaults.sh | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index abb1388ba1..eb6816e519 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -264,6 +264,13 @@ generate_static_system() { uci -q set "system.@system[-1].hostname=$hostname" fi + local compat_version + if json_get_var compat_version compat_version; then + uci -q set "system.@system[-1].compat_version=$compat_version" + else + uci -q set "system.@system[-1].compat_version=1.0" + fi + if json_is_a ntpserver array; then local keys key json_get_keys keys ntpserver diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 12b900031d..27a409fe3b 100755 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -68,6 +68,12 @@ ucidef_set_model_name() { json_select .. } +ucidef_set_compat_version() { + json_select_object system + json_add_string compat_version "${1:-1.0}" + json_select .. +} + ucidef_set_interface_lan() { ucidef_set_interface "lan" ifname "$1" protocol "${2:-static}" } |