base-files: allow ignoring minor compat-version check
authorDavid Bauer <mail@david-bauer.net>
Fri, 13 May 2022 23:26:02 +0000 (01:26 +0200)
committerDavid Bauer <mail@david-bauer.net>
Sat, 18 Jun 2022 20:11:04 +0000 (22:11 +0200)
Downstream projects might re-generate device-specific configuration
based on OpenWrt's defaults on each upgrade, thus being unaffected by
forward- as well as backwards-breaking configuration.

Add a new sysupgrade parameter, which allows sysupgrades between minor
compat-versions. Upgrades will still fail upon mismatching major compat
versions.

Signed-off-by: David Bauer <mail@david-bauer.net>
package/base-files/files/lib/upgrade/fwtool.sh
package/base-files/files/sbin/sysupgrade

index a45f3bbc731fdda2af38431b68a978e69b1b8107..8bd00a333288d04b749443d7fe97dd6fac55863a 100644 (file)
@@ -71,6 +71,7 @@ fwtool_check_image() {
 
                        # minor compat version -> sysupgrade with -n required
                        if [ "${devicecompat#.*}" != "${imagecompat#.*}" ] && [ "$SAVE_CONFIG" = "1" ]; then
+                               [ "$IGNORE_MINOR_COMPAT" = 1 ] && return 0
                                v "The device is supported, but the config is incompatible to the new image ($devicecompat->$imagecompat). Please upgrade without keeping config (sysupgrade -n)."
                                [ -n "$compatmessage" ] && v "$compatmessage"
                                return 1
index 7e0a00e13b8ee4be7163936fd01a7beff0ce5c99..93150913024fb7c83abbcb2de361ce8c6578642a 100755 (executable)
@@ -19,6 +19,7 @@ export CONF_IMAGE=
 export CONF_BACKUP_LIST=0
 export CONF_BACKUP=
 export CONF_RESTORE=
+export IGNORE_MINOR_COMPAT=0
 export NEED_IMAGE=
 export HELP=0
 export FORCE=0
@@ -44,6 +45,7 @@ while [ -n "$1" ]; do
                -F|--force) export FORCE=1;;
                -T|--test) export TEST=1;;
                -h|--help) export HELP=1; break;;
+               --ignore-minor-compat-version) export IGNORE_MINOR_COMPAT=1;;
                -*)
                        echo "Invalid option: $1" >&2
                        exit 1
@@ -80,6 +82,8 @@ upgrade-option:
                     Verify image and config .tar.gz but do not actually flash.
        -F | --force
                     Flash image even if image checks fail, this is dangerous!
+       --ignore-minor-compat-version
+                    Flash image even if the minor compat version is incompatible.
        -q           less verbose
        -v           more verbose
        -h | --help  display this help