From patchwork Fri Jul 12 09:36:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1959734 X-Patchwork-Delegate: zajec5@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=U0fHRl4H; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=dNSgxNyP; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WL63p4M85z1xqc for ; Fri, 12 Jul 2024 19:38:46 +1000 (AEST) 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:References:In-Reply-To: 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: List-Owner; bh=LiitchfT4++bqqDBOT/r4j6bbUs8fdkRDoA9Vw9SEZs=; b=U0fHRl4HnA/GIK kWEwIizr1RG+9PmZ9I7OzZYD28jEOucO0O32WXEI9meQDoPSk4rfOTyu4GxmQH+Alb73ymj1unCKJ +FRHLVczoY0cQ3SWH4oLAoEODlR2TnipyPdUGlomAf7WPQxbN0rhLdrNN4Pv25KV9IoDFRz/9/Z4a uVlIn5UTwOUshU2pzdY5DeBsoZGLseIOjxWJboBzGVPLDCnhzqFo6sxA8PMGjwhyoYH3veNFTCeFY wz491qe7T6Ox32dPJGI9bBiWEI3TQuidSfdWsYiHf55lalTfyaW7nrH/0bpfPdM1/luU7YEK9ogBB Dl0D1dLqvllq25zOCalA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSCi8-0000000H8AB-08ac; Fri, 12 Jul 2024 09:37:04 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSCi4-0000000H88u-1KWR for openwrt-devel@lists.openwrt.org; Fri, 12 Jul 2024 09:37:01 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a77b60cafecso226542266b.1 for ; Fri, 12 Jul 2024 02:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720777018; x=1721381818; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G3FyqlO+QF7lZ32oyOpG8AN1cXKHBe0elHZku9qT/lE=; b=dNSgxNyPqfnnSJnr8oSj5iv9yYCfolu5qkaHiI4fnBHWOYyBRJdr0njwFrJhti5DX5 ZoaEZhRUHx2Ef8WWNg7v9BBfQiA32wA2xwuvbAk0YODKAi83+0LACvlAwNgbN40JiiLL fqvhu9QqDgVUnX2N+LLjHcX1vV+E0IhZk+amneQhZfmw2mtdZ8hsL5cvXmZK16iJjPYQ Z21078HLt8wACxGqtU1Kd3cWT1M9jiI7U0XRCzgXmOwXznA1vBWM6ZiprJSB7u43cjo8 XXBnMs10z8s67T2fL/FY+Sw2C5LY7MxPIiQV3/wgK8SBDJI4llwSVMCE+Ga4tusVf1aO +pVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720777018; x=1721381818; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G3FyqlO+QF7lZ32oyOpG8AN1cXKHBe0elHZku9qT/lE=; b=eitPbQaC1Pv7xguhNOt38c2Lc9LEBETbGLlvckEKbudoT0JAQ0CBZLod+t0sDTccNe k9XK0iobjXsTWCWDHnNCCnD5TWkcfwUS2zSRMWRdqFPMr5UtBcsYC8OY4knZqlldB61s 010WKPeIJNKI9NlWxPDsemmXT3LesP5FnqqMQRZtxdOS9XXvm9gqY2ugrN5LSVOS9iGE EQ6rF38on3A1nxznHAya7yMIY8gL24XvK6WlpTEZujRebQ5unQMumOIUfWCBJx1HV9hL Jp2M9MR9QYiHTv69vL+oldwpeMRK4dx7C9Ne93B/G+hd3KQ8UBvEgjtBIzZgjrIwQHAb 5RyQ== X-Gm-Message-State: AOJu0YzDkWuxXuS10K8Ub1WrmdPhTY3E4PTKxL8frS0c3f0CDkRFP5Jw kHtoYkAXcP2MMfK7T1ZD6BvXp2dJ9Jh15nE8KzWhPnfUYKakjFNv6UXALw== X-Google-Smtp-Source: AGHT+IEjr/1Sus/vg0VwQBUYF7UZg8K2LFV+oZnY2eb6jI3i4AaB1D5XzZ+UJSNAy+UzPmcR3C0Daw== X-Received: by 2002:a17:907:94d1:b0:a77:b726:4fc with SMTP id a640c23a62f3a-a780b6883ffmr986339666b.1.1720777017818; Fri, 12 Jul 2024 02:36:57 -0700 (PDT) Received: from localhost.lan (031011218106.poznan.vectranet.pl. [31.11.218.106]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a87213dsm327228066b.221.2024.07.12.02.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 02:36:57 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 3/3] base-files: upgrade: nand: allow custom fw extraction in nand_do_upgrade() Date: Fri, 12 Jul 2024 11:36:48 +0200 Message-Id: <20240712093648.20748-3-zajec5@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240712093648.20748-1-zajec5@gmail.com> References: <20240712093648.20748-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_023700_381054_2C0E5064 X-CRM114-Status: GOOD ( 10.46 ) X-Spam-Score: -1.8 (-) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Rafa=C5=82_Mi=C5=82ecki_By_def?= =?unknown-8bit?q?ault_nand=5Fdo=5Fupgrade=28=29_can_only?= =?unknown-8bit?q?_deal_with_raw_and_gzipped_firmware_files=2E_Vendors_often_?= =?unknown-8bit?q?use_custom_firmware?= =?unknown-8bit?q?_containers=2E_Allow_passing_custom_extraction_command_to_a?= =?unknown-8bit?q?llow_using_nand=5Fdo=5Fupgrade=28=29?= =?unknown-8bit?b?IHcgWy4uLl0g?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=28-1=2E8_points=2C_5=2E0_re?= =?unknown-8bit?q?quired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C_no?= =?unknown-8bit?q?_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo2MzAgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_envelope-from_domain?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily_valid?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from_author=27s?= =?unknown-8bit?q?_domain?= =?unknown-8bit?q?_-1=2E9_BAYES=5F00_______________BODY=3A_Bayes_spam_probabi?= =?unknown-8bit?q?lity_is_0_to_1=25?= =?unknown-8bit?q?_=5Bscore=3A_0=2E0000=5D?= =?unknown-8bit?q?_0=2E0_FREEMAIL=5FFROM__________Sender_email_is_commonly_ab?= =?unknown-8bit?q?used_enduser_mail_provider?= =?unknown-8bit?q?_=5Bzajec5=28at=29gmail=2Ecom=5D?= =?unknown-8bit?q?_0=2E2_FREEMAIL=5FENVFROM=5FEND=5FDIGIT_Envelope-from_freem?= =?unknown-8bit?q?ail_username_ends_in?= =?unknown-8bit?q?_digit?= =?unknown-8bit?q?_=5Bzajec5=28at=29gmail=2Ecom=5D?= 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 From: Rafał Miłecki By default nand_do_upgrade() can only deal with raw and gzipped firmware files. Vendors often use custom firmware containers. Allow passing custom extraction command to allow using nand_do_upgrade() with vendor firmwares. Signed-off-by: Rafał Miłecki --- package/base-files/files/lib/upgrade/nand.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh index 0b76486ee7..f821a82c60 100644 --- a/package/base-files/files/lib/upgrade/nand.sh +++ b/package/base-files/files/lib/upgrade/nand.sh @@ -387,9 +387,11 @@ nand_verify_tar_file() { nand_do_flash_file() { local file="$1" + local cmd="$2" + local file_type - local cmd="$(identify_if_gzip "$file")cat" - local file_type="$(identify "$file" "$cmd" "")" + [ -z "$cmd" ] && cmd="$(identify_if_gzip "$file")cat" + file_type="$(identify "$file" "$cmd" "")" [ ! "$(find_mtd_index "$CI_UBIPART")" ] && CI_UBIPART=rootfs @@ -423,17 +425,22 @@ nand_do_restore_config() { # Supported firmware containers: # 1. Raw file # 2. Gzip +# 3. Custom (requires passing extracting command) # # Supported data formats: # 1. Tar with kernel/rootfs # 2. UBI image (built using "ubinized") # 3. UBIFS image (to update UBI volume with) # 4. FIT image (to update UBI volume with) +# +# $(1): firmware file path +# $(2): (optional) pipe command to extract firmware nand_do_upgrade() { local file="$1" + local cmd="$2" sync - nand_do_flash_file "$file" && nand_do_upgrade_success + nand_do_flash_file "$file" "$cmd" && nand_do_upgrade_success nand_do_upgrade_failed }