From patchwork Tue Jul 14 14:28:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1328932 X-Patchwork-Delegate: freifunk@adrianschmutzler.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=MobyysAS; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5jdM1CqCz9sRk for ; Wed, 15 Jul 2020 00:31:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hp8HlW9f1yzKAo07+FzYRZOcxHS1/rsdEAJh35jschs=; b=MobyysAS8TNcR4GglnOo5d6vho IfDMSSpzQSqT3jTUsp8xaVFeC3N523Dqi15pHgQpIATR7MBX4ToNcqfcj1a2oKt81y2YiwnuPPWVW 6/uXRAxmoV0pz65UEqPyPRgHlsTdLbyc4I0p+Dgdlktvglsavi7xg+FY/6tE6i3/NgPt3//+K7Fhc uAJ4Mp++MaZ5VvUiKvHlwSuuRn955vixGCzGYcNdDN5QDT3oDU3dYwzRNk5BcvkW7iR2XUhMV0KDL JQN4K83SaN6j5Zx6RVUrPwgcKN/5XlG/xqmMuyloMmP0MADKDs29nLtbe+Uek+R3EdQL+8wxfzUnU azMjy7OA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvLvy-0000N3-9b; Tue, 14 Jul 2020 14:29:26 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvLvn-0000FR-LB for openwrt-devel@lists.openwrt.org; Tue, 14 Jul 2020 14:29:19 +0000 Received: from buildfff.adridolf.com ([188.192.134.246]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MYNW8-1kQgZp2Mk6-00VRsB for ; Tue, 14 Jul 2020 16:29:11 +0200 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Subject: [PATCH v2 2/6] base-files: add support for compat_version on device Date: Tue, 14 Jul 2020 16:28:21 +0200 Message-Id: <20200714142825.16889-3-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200714142825.16889-1-freifunk@adrianschmutzler.de> References: <20200714142825.16889-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:9bMo/O3/nk9zIBU4DGWEvubaLHm919fOTu6gtPiBBFkUo8HqMIO 7SHvR2gSRtUmEbCI+OId0YQEr7Vv2ElYAzNnP10+E/EmR8O8idOoLhTGRl2lsfvAovgigx6 spo5VgtVR4ZFejEo8Ys3IPD5xrz0xabA2MmyG3si2x1exRHF7gdktNFGEugf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-CacheID: sfid-20200714_102916_070875_491054BF X-CRM114-Status: GOOD ( 10.48 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.17.24 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.17.24 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org 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 --- package/base-files/files/bin/config_generate | 7 +++++++ package/base-files/files/lib/functions/uci-defaults.sh | 6 ++++++ 2 files changed, 13 insertions(+) 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}" }