From patchwork Wed Jan 11 07:06:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1724479 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=gXOZnsdl; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=MHWvRisJ; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NsJkB33Krz23fj for ; Wed, 11 Jan 2023 18:10:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Xh9N7b5RpuNCrQXGYUE2OlK8oEIbGJ4lMQcrz69ML8k=; b=gXOZnsdlWeClxG kQvR6LVU1mj5Rj8WIt/HTldNIoHIYfsnRhYa06/WpC9PfFhZ/Mg1UeQ5xxsH9U65QZkouK2+pANTX SiU5I+n1vzWEGTZGi5kIfvzQ6euzUB0QT2XqRpxyBuca0h7mJZp/oDWNM/p+0A1t56+5/02LSkcP8 mYls4xHwlmoypTR6E513FvRzP4Mu9VVXjn6sx1d0zB4SluWWAl26OCPqf+B+VOYZAUqN2MFIhnpue AiycR6okAroOnjmeiPLypKZWfyWJ6905C9kQzRwH4BxVUISy8GBLYHyaa2vwzwZCt19XcmqUhwDa8 ylB69Rc77Lyi5nB+TxbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFVCY-009xWB-2L; Wed, 11 Jan 2023 07:07:10 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFVCT-009xUe-Hy for openwrt-devel@lists.openwrt.org; Wed, 11 Jan 2023 07:07:06 +0000 Received: by mail-pj1-x1031.google.com with SMTP id dw9so13513359pjb.5 for ; Tue, 10 Jan 2023 23:07:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ITbd7OSQ0J/tdcJFQbhi6tcZvERbi0qwyDp0NIV2IYw=; b=MHWvRisJOarTPbpvhnpIieJDNYu4TTjEPnCREioJgsDUv70PXUF6gBoEzrKpt1b4Iv AeJtwg+kgb8nGpAOvhTIuIHr8ypUWkT5PTlLzWc2Wbn/EeqZi9+yjH3ATcf+AuCxpK9U DP/sD6cLR46ANb8uqJasLZCI6tHfww23cRoqQtGlyoLSEBI30D6fQqDpni4u1MGuWkPS owwwcy60um6o9dIiJJM6cWYVmKNdTc/jajy/2+EfBUJdEHd5zNEyyIEQOYBbUyRiH8jh GiUHqV/DkqDBoNztPvQeWjBE40L8dT3nqclYQrgK1b/Tb91S4O+bD+YI1ZgwbQ8RuMa0 ZFoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ITbd7OSQ0J/tdcJFQbhi6tcZvERbi0qwyDp0NIV2IYw=; b=HDZuvjiZt2qPeMzKFzLp/XWK8rO3vorLBJL4qqzHe21KpKIDvUhnX6cFua3lhJStew 4vopTDzyO1XywD4NrsYzMZIDSQVxKgTXUZjAf79aTCBnJ4CRGEvvQQVERW5LIrYdPOay gMOUlp+DkWY3CyEwczVbQ4oAopfV5qXURadiBFYhXvw0TMqzG1idgIxmnX63fGCcAx9Y Sxw6R7tZ0lgDdw+cFqP0K7qidI67yNRaixhrDFpWj7TiZu0ymyXlRVXfI9TZRVP4LtnV SfDHw4GC5irh75FMtUT2H64SA8sWVYPdwSqJX7OR2C/9pN92QuvYwek1Z6nGOipAlOaQ 9xPQ== X-Gm-Message-State: AFqh2kokz7a0EvTjzUdo8/izAWmFDvw82Qsg7D6SUxZshjwpKSZZH3s4 ITguAtMu/SxGx4RSsZLFcBGP6iXWHI0= X-Google-Smtp-Source: AMrXdXuHx4QeK0m1TpLVc90VN8BTUhJ99IKDaxqsKfISSy3nmG3FKNqjruXFpb3pvTcKLgNr3GfWsQ== X-Received: by 2002:a17:90a:55c1:b0:226:e640:229f with SMTP id o1-20020a17090a55c100b00226e640229fmr17043982pjm.28.1673420822309; Tue, 10 Jan 2023 23:07:02 -0800 (PST) Received: from localhost (104-50-1-205.lightspeed.sntcca.sbcglobal.net. [104.50.1.205]) by smtp.gmail.com with ESMTPSA id p10-20020a17090a348a00b00218d894fac3sm10228761pjb.3.2023.01.10.23.07.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2023 23:07:01 -0800 (PST) From: Brian Norris To: openwrt-devel@lists.openwrt.org Cc: Brian Norris Subject: [PATCH v3 1/7] base-files: Remove nand.sh dependency from emmc upgrade Date: Tue, 10 Jan 2023 23:06:46 -0800 Message-Id: <20230111070652.1200657-1-computersforpeace@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_230705_627226_B71B1CD6 X-CRM114-Status: GOOD ( 10.09 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: emmc_do_upgrade() relies on identify() from the nand.sh upgrade helper. This only works because FEATURES=emmc targets also tend to include FEATURES=nand. Rename identify_magic() to identify_magic_long() to match the common.sh style and make it clear it pairs with other *_long() variants (and not, say *_word()). Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1031 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [computersforpeace[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 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 emmc_do_upgrade() relies on identify() from the nand.sh upgrade helper. This only works because FEATURES=emmc targets also tend to include FEATURES=nand. Rename identify_magic() to identify_magic_long() to match the common.sh style and make it clear it pairs with other *_long() variants (and not, say *_word()). Signed-off-by: Brian Norris --- (no changes since v1) .../base-files/files/lib/upgrade/common.sh | 27 ++++++++++++++++ package/base-files/files/lib/upgrade/emmc.sh | 2 +- package/base-files/files/lib/upgrade/nand.sh | 32 ++----------------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index 5af061f6a439..53b8865a5788 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -127,6 +127,33 @@ get_magic_fat32() { (get_image "$@" | dd bs=1 count=5 skip=82) 2>/dev/null } +identify_magic_long() { + local magic=$1 + case "$magic" in + "55424923") + echo "ubi" + ;; + "31181006") + echo "ubifs" + ;; + "68737173") + echo "squashfs" + ;; + "d00dfeed") + echo "fit" + ;; + "4349"*) + echo "combined" + ;; + "1f8b"*) + echo "gzip" + ;; + *) + echo "unknown $magic" + ;; + esac +} + part_magic_efi() { local magic=$(get_magic_gpt "$@") [ "$magic" = "EFI PART" ] diff --git a/package/base-files/files/lib/upgrade/emmc.sh b/package/base-files/files/lib/upgrade/emmc.sh index c3b02864aa91..49cffe1c658b 100644 --- a/package/base-files/files/lib/upgrade/emmc.sh +++ b/package/base-files/files/lib/upgrade/emmc.sh @@ -58,7 +58,7 @@ emmc_copy_config() { } emmc_do_upgrade() { - local file_type=$(identify $1) + local file_type=$(identify_magic_long "$(get_magic_long "$1")") case "$file_type" in "fit") emmc_upgrade_fit $1;; diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh index a8e3cab0b8b1..a1dbd6e2663d 100644 --- a/package/base-files/files/lib/upgrade/nand.sh +++ b/package/base-files/files/lib/upgrade/nand.sh @@ -65,40 +65,12 @@ get_magic_long_tar() { (tar xO${3}f "$1" "$2" | dd bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2> /dev/null } -identify_magic() { - local magic=$1 - case "$magic" in - "55424923") - echo "ubi" - ;; - "31181006") - echo "ubifs" - ;; - "68737173") - echo "squashfs" - ;; - "d00dfeed") - echo "fit" - ;; - "4349"*) - echo "combined" - ;; - "1f8b"*) - echo "gzip" - ;; - *) - echo "unknown $magic" - ;; - esac -} - - identify() { - identify_magic $(nand_get_magic_long "$@") + identify_magic_long $(nand_get_magic_long "$@") } identify_tar() { - identify_magic $(get_magic_long_tar "$@") + identify_magic_long $(get_magic_long_tar "$@") } identify_if_gzip() {