From patchwork Wed Dec 21 06:21:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1718151 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=R5MST5WY; 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=L4GEb7L0; 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 4NcNhy6xktz23dP for ; Wed, 21 Dec 2022 17:25:05 +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=mSljTRtLU7ffMViNhuzmF9bLFVLCg/sTZO7RN+qC7xo=; b=R5MST5WY30bOu+ +XnswrHoo1tO4wJLUPp1d+nnoopeB920KY3/gDnrTfJI28USsPO/GCluVaV3NsyCJIv64lWceKh3F iIXG4S/gh/yhHiV1QEXSckc0u4iBOm8IO25HA7LYxxPdXVVouo5sc1d2j+sLMYecPTMJk2IUJdwCd 0Nf+UPeAa6wQdPrWjxZlonspT9lV/z8Qd9uZuECJT51GqwvKIuJ3nd9qsYg+ffzXu/AWYCTgA/m80 zf6E/azhVDnvYeImyIjXY2pC0VhWKMrpmuVyMVrWwDbEF6mlJLB3Rol3RXUJbAuwlOMfGpgoq9J6z QwPqGwGyxWI7jYEUolAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7sTz-00AboC-AZ; Wed, 21 Dec 2022 06:21:39 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7sTu-00Abja-T2 for openwrt-devel@lists.openwrt.org; Wed, 21 Dec 2022 06:21:36 +0000 Received: by mail-pl1-x635.google.com with SMTP id u7so6393958plq.11 for ; Tue, 20 Dec 2022 22:21:31 -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=cQaWgD4eehUxQFpitsdvKf5qwrS+vUIGYs5r9hNxiOQ=; b=L4GEb7L099tGlq+xZB/ftpDHSLygf46lRf8pjWS3f38fVx4liWPuDOusGEWR2WV+Hb jh/wW6wRMhP6iPu7u6bf2GvMwazezEBzcIQGf5FHR+u4FjThe0TXWqHbTq162t3+xO2D teo1yTPS2sNcF7Hm0e1U1yvCUZIwpM+1u/+bab3BsG/Z70xiw1zsgyIX+QRUs6wIgN1Q JA69UaxL0fuRaaHaqgUWHRP7K/uwq4XkqKqS4OCnxG5kBuZXi296Pc200Pl5CztCIoxC hNluugqWAALy0lGvWQJbpxUtKe2GTm6amkhyeafE09JcY0XWwiGyit8iIN5Itln3vqMS GFLg== 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=cQaWgD4eehUxQFpitsdvKf5qwrS+vUIGYs5r9hNxiOQ=; b=x1NpHuCmG4uG48Jo4FNifZhQsgXlX2RbIUefCeaib3ENQpOJGCGddJYb5iq5MFVeI7 zAo9/3Kxih82voSoDt0F/NH7uTbn8pmElR/3QBP5XhSDyhGzMqxK5DtLwA61j2HgtGRG UKhV+q6YKDRCyswbL8fF0dfmVJdKmoQuFqLsYoEDWpSh1xPN9SdTcuJ/1PT1t1lzpJ5z NS5azo2PCAiR+HHHpY4EvgSGTNqZp568tmXHa1ijo7olRP+VCc2o61jdmXhaHi5cjHZo tKmySLbgV0JFs6KyurgsGRhOQX2fTOL2ykXjf3p7lXTYCG3s3CcrrE/AEyUtS/2YsYxa V0ow== X-Gm-Message-State: AFqh2kr6djeJfOnvP6Fof2ud1PflCLeclPJ/KtblpCnB5iFzq5/8NQ0m U6crgo5XgBHsQ7eIWoziw4uto9x3SUI= X-Google-Smtp-Source: AMrXdXsF6CzGOHt+03p4d/rR0BT+INXAZ6fVUniPcsZ4xeXk7Y+AKIZpqR6/3+lYaMXhMLZEXQbaZQ== X-Received: by 2002:a17:903:3241:b0:189:47a8:e9d0 with SMTP id ji1-20020a170903324100b0018947a8e9d0mr757386plb.51.1671603690987; Tue, 20 Dec 2022 22:21:30 -0800 (PST) Received: from localhost ([2600:1700:38c1:1d7f:f66d:4ff:fe3c:3ceb]) by smtp.gmail.com with ESMTPSA id b13-20020a170902650d00b001868bf6a7b8sm10496215plk.146.2022.12.20.22.21.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2022 22:21:30 -0800 (PST) From: Brian Norris To: openwrt-devel@lists.openwrt.org Cc: Brian Norris Subject: [PATCH] base-files: Remove nand.sh dependency from emmc upgrade Date: Tue, 20 Dec 2022 22:21:20 -0800 Message-Id: <20221221062120.1955254-1-computersforpeace@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221220_222135_015192_06467878 X-CRM114-Status: UNSURE ( 8.57 ) 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 [...] 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:635 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 1019b9927c02..3907d868f879 100644 --- a/package/base-files/files/lib/upgrade/nand.sh +++ b/package/base-files/files/lib/upgrade/nand.sh @@ -63,40 +63,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() {