From patchwork Mon Jan 2 23:25:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1720847 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=ue1ndfer; 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=NcYQihKz; 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 4NmBzc3GR1z23f3 for ; Tue, 3 Jan 2023 10:34:52 +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=xm/W00YbF7K40cBrt/bLneAAumdsXJX7+X/VTsnZ41U=; b=ue1ndferpgDVKR YDQweWLMRH48MmRfaFyexvwOJ7GQpGEBnmm+9Q77u5GaXug53J0wyZKiZMtwxhOvNPEQ/XaQ032PE YBI4f9/M7/NOsEQlHXl+xxM3E31blbBIVt5C43+TX3lsgtnrC1zYi9a2CHh2RCdTBoCwx/w+k0rPC /n3drQlMji6P2vr8iTZyEmZsWBH7JPvfIQdzvyjC008hFKvmhjS0vG/wEwZLu7YNBsZhtwf94PRYI aA7NtysRNkPj3fWQObzEuKDac8VieNPgoReu4XQF1xyHA0ooieg0qMaMztOhtbUAIROE6R1y2nmUM QI7DWnXFOHfFSqsDOEqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCUHJ-00EslA-1L; Mon, 02 Jan 2023 23:31:37 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCUBg-00Eqoy-58 for openwrt-devel@lists.openwrt.org; Mon, 02 Jan 2023 23:25:50 +0000 Received: by mail-pl1-x630.google.com with SMTP id p24so8370480plw.11 for ; Mon, 02 Jan 2023 15:25:41 -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=hQOQQ5L+pTj0NTcV0fw3gM8p7Ktxxvnxmn/A5kpHZn0=; b=NcYQihKzaX1eokPNq+EL+QNTXwZPsmZTgg2+GmrfqSkwW385B2GZUf6Ggpjeri/AEA QrYe6ob4+4pfzg5r/wS6QuJ1GcrC7eMLx/A4F0es1wql6gl2Pave0EOzsjvOQYmSyUAs K9JUJdmn3VsULSEzOOy8WZdw2UZIvEagDPun5R2iQnuadmBjMV75WUlIaBQCRAjrnQVT tXyS1Zuo57oapqFhH61L06lsptcHgKaxMRoWaXFnrFflPYycyHWzCUbT/A0XpyF/GpMW gAE5FCVN82nkddGib8azUSVy6i/L4n94vG7OA+dj5wiSGRRJGKyw7PMOVxjKvb/0GJdT tWkw== 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=hQOQQ5L+pTj0NTcV0fw3gM8p7Ktxxvnxmn/A5kpHZn0=; b=GJY9cpK23ZDe70m2SW3+ITSZKqjpLUIOxPXrn67FLFj1cNjrosrEWAfWCIiR1VVAL7 g8lSpy6G6ClwsnSXiLp4tUpIN0mpCsxt+qDRpcd7aW26ln90YI4eYYYitSUMROHjMwqR qprap6b2amXntUnj9YjDf08Gtu78jqamO5x4Jk3VK3ZzcapW7vTL2vY86MfngGVRg5OS aJJqJ+77IidvRGZPw6OXL3lIK0C5YpPmCr2EftedY+PIJjc4/QZqo/RCbqrOvZnNyMuG Um2ZBNFA1liQ26DVorpkbWd7hT8snemoHCjpLtRM/Rcolsi5SXYNiLKw65fafc1zgTh2 3YTw== X-Gm-Message-State: AFqh2kormJNwSLjrIkcPQSsHAgzW1lc+DRl1vvSIZRfxwG/RmMNWqZlv B+3lSKF/jOS+aoWW7HRpUVb/T+KwhRo= X-Google-Smtp-Source: AMrXdXv6ERzkFcB9I4SW+5wCAVn/l8YGM48noUg8MIwX+KdTmvCE7FZJkNlVlUEqFxTq+vlCJ86UUA== X-Received: by 2002:a17:902:8481:b0:192:b5b3:b800 with SMTP id c1-20020a170902848100b00192b5b3b800mr11925201plo.39.1672701941048; Mon, 02 Jan 2023 15:25:41 -0800 (PST) Received: from localhost ([2600:1700:38c1:1d7f:f66d:4ff:fe3c:3ceb]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b0018b025d9a40sm20628315plx.256.2023.01.02.15.25.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jan 2023 15:25:40 -0800 (PST) From: Brian Norris To: openwrt-devel@lists.openwrt.org Cc: Brian Norris Subject: [PATCH 1/8] base-files: Remove nand.sh dependency from emmc upgrade Date: Mon, 2 Jan 2023 15:25:27 -0800 Message-Id: <20230102232534.592501-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-20230102_152548_261196_E5BB9F8E X-CRM114-Status: UNSURE ( 9.74 ) 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. Signed-off-by: Brian Norris --- .../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 chan [...] 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:630 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. Signed-off-by: Brian Norris --- .../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() {