From patchwork Fri Jan 13 05:32:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1725694 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=bJs0RmbZ; 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=Ns0hIhXf; 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 4NtVYC42vNz23g9 for ; Fri, 13 Jan 2023 16:37:19 +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=bJs0RmbZgPvrY6 Rv4JZudggYpzGc27aTlUayp3H3bQkEZ2HPvOFPnyVVAkSClgX45KDs6Sq9lFCEILIgYrYuHTzNNxr YZjJlGE2/DPC4HHVy71GnfekGwXRQLEC1MRzV45BfeRyId159iTfLPdjTLFQ/LMgJMYwM84HxZw13 xvkL13aMO0MGai0Ppq+VI+K6vEanPId3aMV0EDPKTC39MHIav96vR6eV+N/QMFHvKk+/bAK4SfI/T PCGgTP/bsAT22yIhG26vhtTPPLx7d+tfhG3cHV77Mn4tm0M4BwuCIsOmj0cBsFva8dioNgL3BgywH gkluAa0OanLZdqQgt4lQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGCg7-000VQh-B2; Fri, 13 Jan 2023 05:32:35 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGCg2-000VPE-51 for openwrt-devel@lists.openwrt.org; Fri, 13 Jan 2023 05:32:31 +0000 Received: by mail-pj1-x102f.google.com with SMTP id b9-20020a17090a7ac900b00226ef160dcaso21592164pjl.2 for ; Thu, 12 Jan 2023 21:32:26 -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=Ns0hIhXfdZYWjdgtyBIdXl2OEyrSqsuCNDonJUH4EENUWTZNT3xe2Pj0jRZFNPtvrr OJ0BSGC+6BAWSwzOjvU3vEsncs/IpywZwLcNVieiAjfvN/9/PZM3X4r6+qewzmDufrqR PuZP74OhP2PrGrBhdxdU/83CrSamwtBBL1NxfY4/eYs3Vh9mlERx4zKEDAkZ6YP0togE A5y8yxuLcdHsH40TFOz3ZCLVKo04Ocd0EiDmbTUPReKljKtyFYRr/8eY8W72DIzVbm8+ 9zNxmc8PCnmfxABzU0+Os87Xl25NBB3cTUUPNJHpNvfUbsvBIrw1gzDIXJXELNua/qEq 3/BA== 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=SvswQVfPfvdFynWSSNfN4PkbddS5DzQeYq3QiO+n38A2riZX0GmYvUZv3+mi9eMJnJ ZKQeYQJLwh54+oE4N96RTu7vxEnB+kaJoB2+L7mU2UfEiGk/svQxsZzXTub1qpExoRjg D7bt2tp5ueZIZE3FfALJGmrChzYwmbOC/93BN/pyogKOCwviYDtnmPkH7ZidgM5N0roe CmIfU+6dN7c7Xp2/VtOtrioBEQTW7rM74jMe4bRIFEvH/P1p585n2+oObxZCmh/yrn1O rotJwiuhGhxTXzXsxyFPxR9OG6NvkqhH6zDgLb96Tnai3W49DH2P1wZBlkeZE7b3HFJP ohQA== X-Gm-Message-State: AFqh2kqNkxcqbf0LafI5CyGZ5S5zEAgsT2ao5f/ipPGfe21ZlyBWZXzU mxc+c/pP9SsRqSXe/L3JxA8IcrcHo9k= X-Google-Smtp-Source: AMrXdXuh+96qImalkXU0/1r1DSm5aSKE7/orNFydqj6QeYiokAQpLzvlOFGpvV7MdgteDajQzPtg2A== X-Received: by 2002:a17:902:ccc4:b0:186:e434:6265 with SMTP id z4-20020a170902ccc400b00186e4346265mr93334110ple.2.1673587946106; Thu, 12 Jan 2023 21:32:26 -0800 (PST) Received: from localhost ([2600:1700:38c1:1d7f:f66d:4ff:fe3c:3ceb]) by smtp.gmail.com with ESMTPSA id n6-20020a170903110600b00192d9258532sm13149174plh.150.2023.01.12.21.32.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jan 2023 21:32:25 -0800 (PST) From: Brian Norris To: openwrt-devel@lists.openwrt.org Cc: Brian Norris Subject: [PATCH v4 1/7] base-files: Remove nand.sh dependency from emmc upgrade Date: Thu, 12 Jan 2023 21:32:16 -0800 Message-Id: <20230113053222.2011958-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-20230112_213230_235728_9BA175FA X-CRM114-Status: UNSURE ( 9.73 ) 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:102f 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() {