From patchwork Sat Jan 7 07:49:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1722657 X-Patchwork-Delegate: ynezz@true.cz 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=i3E2Hcuj; 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=NLkGMDnl; 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 4Npss92hY2z23fv for ; Sat, 7 Jan 2023 18:53:33 +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=i3E2HcujiVVNuH OlccjPRYs+fzrbV5pcoDB9SE2gT0rwKjip1kknVqI40sk5CF7BgBM+xS0m6PP2yDihFcL2ti2Ohql e1qECVMOEhwrfepW0b0GrrT0v/7+u9aHVTlbSuzQQ6LrPuAtadPFzslMrtNtRTEecyPFTirv5aB5n NdNsct9ri6rLinqwLb4peVLmLeQButrOxC7sO6jTCCGErQovQfKfG//iiVV67Z+vyyRYnyIt2MD3E f2zK5dk0HIh5dNj8BncYzG40C9+XCqjClpVwdObjeLCwAieqZsGKejwNRe7z5DtFTLv85LzHpDkVC XamWeioNQ1y0D5g9x+cQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pE3xn-003P9p-EJ; Sat, 07 Jan 2023 07:49:59 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pE3xj-003P8G-Ls for openwrt-devel@lists.openwrt.org; Sat, 07 Jan 2023 07:49:57 +0000 Received: by mail-pj1-x1033.google.com with SMTP id bj3so497160pjb.0 for ; Fri, 06 Jan 2023 23:49:53 -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=NLkGMDnlL7RzVCeNEUYFMiM3G3v5mhb0ONF3d4jYgbapJoQF2x3J+OEcTJlVB8wpJs sxpMddEyUCNB6Q7FoT2as5ZHhUcVl5e0xRkE4UikXLDFzDWhnbZ+up/A+VAMnXWWxIxG l3C3qYnLvNCWuyQ8DEcMoSXFcAs8igUg32hirYa0Lzuoldz419b4brWA9KWC1aSvGp06 7ZUYa/fvuX6IpKC0lDrmK7R6jPJw1g13DeZ5YZguV7afULgQ2tNAUcB5hHW0y8Hpur32 vCNF2E2jNfLQVP0S2nRVrDCPLpgEZFbSl1HFhv5HPCKEGOWRAh0535REWBR82fiuxA77 G6Iw== 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=tvR4mcI31GYbxlh+cJJl6YR9eW7yJ5YkUd/CrJAoCmIdU6Xmj/nnnj/uFbsw0bbRpU c/fp5bNrOEEJ3rBx7Uzu7iU9uUtux+MP6/jIIyZa2Ofnj4e0Rn0Olizizw+RlhiUBmKE mPWx0u7laPoJ53riYNKgDcjrqGdvUEPVDJnEJc3vNuKEwUUp/Bj3CKkN+fQwysouE3Fd gO10TX7ZyFXL1iMWN0LyIN/y306S7NCXN02/D/g6DY2i6eqlA1SAh4F3PO6Uj2cgeNhH TP/yL1P5dyUrsR81EmWXMlwzbP8oyMqtTJ6nxU7BQMD9nJgVPdlXWRJO0K5U0a34o6IX QJmg== X-Gm-Message-State: AFqh2koLDv0Oqr5hEfBVz+HphkXvh12NVZCcpc11pZOUIIXkFnmmqCMb hgc1GlgmkInjv3n4qDM2k1xa1Ol8y7s= X-Google-Smtp-Source: AMrXdXsDK5SY0Ss8fBB8ITuCMM+zZu68jcU68QOQWmR08zR/si9M4DhdGuxgU+wAtgI4kDUyk+8lig== X-Received: by 2002:a17:902:6b0c:b0:185:50e4:f59c with SMTP id o12-20020a1709026b0c00b0018550e4f59cmr62338035plk.8.1673077793123; Fri, 06 Jan 2023 23:49:53 -0800 (PST) Received: from localhost ([2600:1700:38c1:1d7f:f66d:4ff:fe3c:3ceb]) by smtp.gmail.com with ESMTPSA id n3-20020a170903110300b00189f2fdbdd0sm2058253plh.234.2023.01.06.23.49.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jan 2023 23:49:52 -0800 (PST) From: Brian Norris To: openwrt-devel@lists.openwrt.org Cc: Brian Norris Subject: [PATCH v2 1/7] base-files: Remove nand.sh dependency from emmc upgrade Date: Fri, 6 Jan 2023 23:49:39 -0800 Message-Id: <20230107074945.2140362-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-20230106_234955_786309_4F7F7CA9 X-CRM114-Status: UNSURE ( 9.28 ) X-CRM114-Notice: Please train this message. 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:1033 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() {