From patchwork Wed Feb 28 08:03:02 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: 1905594 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=iWQBy3T4; 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=HIQ38EWH; 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 4Tl6MS4Tqxz23qX for ; Wed, 28 Feb 2024 19:04:36 +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=b1TveZf5dtQw+y/uztNRjIdhYIBbG71mc/vWnJH2K+E=; b=iWQBy3T4RlPwdN JKLVGxn4b79FyNa8hiA8acKgeX6nb3e/mvgKApnkGDqxtZOlbfaNvpzuEAtqb36y/wpiOr6olufmd tBC9972pBUVi6e/OU56CpgLC6KHCc20R2k0oBgALBi3tOdHXxw6EzzFYot05Gz90rMqF1sNweAPZ+ vmb4jwbXzTgeGZWmN652gtzaR7p3rX/B6Cslpe7sxc/TXZe/YBrYOaGSOPJ0uNUpLlQFfxMt37ZLu MICQ8BXuPZRqxlmvm6fnU7dKb2qdGYEYfNCHshNnbZphQQhVQ8aWOKi0h7JFsdMCthVrB5oHKuaij hJ+uI8krwcvL8Ct2jZbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEuO-00000008P1Z-2wsX; Wed, 28 Feb 2024 08:03:20 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEuL-00000008OzM-05U3 for openwrt-devel@lists.openwrt.org; Wed, 28 Feb 2024 08:03:18 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-55a179f5fa1so6386500a12.0 for ; Wed, 28 Feb 2024 00:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709107392; x=1709712192; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/+pMUgLPV68R/lJw6wg0Q7iMG/WgVOM+i1nDh63jSRk=; b=HIQ38EWHVvKuPeHh2tnTT0MNT4ak8UBAiqKn+vAtAo6//WIYaCkXd4v0culQ1zEOBt t6b5HVZDsn47d8RDdYZNHXZbiTHTzQoBgeOfOWBEC5twdg6U+sCksrYAJs0iAlFmYlo6 //oRcb6zjyDk/BPs+5ZRElEuBnpefK3bXMQcz7VJDhUU6ID7IVk8uglkpteAYhHymS2A crXhm8b4gthaVE6I7qE1ezRIOV9+9oKA0GYJk4u0k8tVUD7lTmL6KB7he7HSAJ2efBJs APvn7xcF0IqJJUbTlisuxN18VtsrcqxrigIFQ5knhNz9wUvFdnGBkhMXOZes5Vm7Eqsb rElA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709107392; x=1709712192; 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=/+pMUgLPV68R/lJw6wg0Q7iMG/WgVOM+i1nDh63jSRk=; b=UVVq9dYiJKQzmp4LvilhATUa4WLLRubC134nDQcw/fpybHMJ5BV8mGKvEagK+U2EPf gJOCQ8Kv1pFxjFZ892Xr6W4WKmtmjIXp4oV53aqQ6e88dx2sD9NP+euqRmVR2FSwpn6q U9BiTfYusDR3IOeZmzz5ebMtD5FbGfNQmeEFTpNjZ4aFWBg6fnau5uNJXeDduZvB7z0X bsTyj0J44trDleFej6cAo9mgc9Q+rb+HUoymq9TXzbUrm7vDVz6SbqhF0a10DnjiQ/e4 f9bGCrNrPCH6D08xKFDyS7ccEJs4v6ZdVQWMHSp7cVnopo01NnpNnlgMvfwiq9HDBRu2 3new== X-Gm-Message-State: AOJu0YzZUo1+Ol+pW9TveGExF40Mrq8WjDHZgIsxKgNA8HErQFnx2F0b A3QcIr/NAOGgUVhgA3aNdFxhhsYqe0hAUG0Ns38BYHb7fRNoYIMhQ/o9xlcV X-Google-Smtp-Source: AGHT+IFbIXzagqtKIWj3IIfzNc1QieUkpJEmV8llMH8eucdISeDMjOePC6wNiUsnNTehuQZWuenkKw== X-Received: by 2002:a05:6402:b12:b0:564:3f11:a5bc with SMTP id bm18-20020a0564020b1200b005643f11a5bcmr7570157edb.19.1709107391797; Wed, 28 Feb 2024 00:03:11 -0800 (PST) Received: from localhost.lan (031011218106.poznan.vectranet.pl. [31.11.218.106]) by smtp.gmail.com with ESMTPSA id g2-20020a056402114200b005666465520dsm459547edw.26.2024.02.28.00.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:03:11 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Cc: Jo-Philipp Wich , Luiz Angelo Daros de Luca , =?utf-8?b?UmFmYcWCIE1pxYJl?= =?utf-8?b?Y2tp?= Subject: [PATCH V2 1/3] base-files: sysupgrade: add tar.sh with helpers for building archives Date: Wed, 28 Feb 2024 09:03:02 +0100 Message-Id: <20240228080304.22671-1-zajec5@gmail.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240228_000317_092796_27D2D3C7 X-CRM114-Status: GOOD ( 11.77 ) X-Spam-Score: 0.0 (/) 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_Jo-Philipp_Wich_This_allows_bu?= =?unknown-8bit?q?ilding_uncompressed_tar?= =?unknown-8bit?q?_archives_from_shell_scripts_=28and_compressing_them_later_?= =?unknown-8bit?q?if_needed=29_Signed-off-by=3A?= =?unknown-8bit?q?_Rafa=C5=82_Mi=C5=82ecki_---_V2=3A_Simplify_dd_in_=5F=5Ftar?= =?unknown-8bit?q?=5Fprint=5Fpadding_=28I_still_think?= =?unknown-8bit?q?_helper_is_useful=29_Hardcode_0/0/_root/root_for_now_as_mos?= =?unknown-8bit?q?t_likely_it=27ll_be?= =?unknown-8bit?q?_enough_Simplify_name_validation_=28le_=5B=2E=2E=2E=5D_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E0_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=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?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo1MjkgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?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=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?_-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=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=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?= =?unknown-8bit?q?_-0=2E0_T=5FSCC=5FBODY=5FTEXT=5FLINE___No_description_avail?= =?unknown-8bit?q?able=2E?= 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: Jo-Philipp Wich This allows building uncompressed tar archives from shell scripts (and compressing them later if needed) Signed-off-by: Rafał Miłecki --- V2: Simplify dd in __tar_print_padding (I still think helper is useful) Hardcode 0/0/ root/root for now as most likely it'll be enough Simplify name validation (leasing slash) Reorder some variables package/base-files/files/lib/upgrade/tar.sh | 78 +++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 package/base-files/files/lib/upgrade/tar.sh diff --git a/package/base-files/files/lib/upgrade/tar.sh b/package/base-files/files/lib/upgrade/tar.sh new file mode 100644 index 0000000000..406d5fd71b --- /dev/null +++ b/package/base-files/files/lib/upgrade/tar.sh @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +__tar_print_padding() { + dd if=/dev/zero bs=$1 count=1 2>/dev/null +} + +__tar_make_member() { + local name="$1" + local content="$2" + local mtime="$3" + local mode=644 + local uid=0 + local gid=0 + local size=${#content} + local type=0 + local link="" + local username="root" + local groupname="root" + + # 100 byte of padding bytes, using 0x01 since the shell does not tolerate null bytes in strings + local pad=$'\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1' + + # validate name (strip leading slash if present) + name=${name#/} + + # truncate string header values to their maximum length + name=${name:0:100} + link=${link:0:100} + username=${username:0:32} + groupname=${groupname:0:32} + + # construct header part before checksum field + local header1="${name}${pad:0:$((100 - ${#name}))}" + header1="${header1}$(printf '%07d\1' $mode)" + header1="${header1}$(printf '%07o\1' $uid)" + header1="${header1}$(printf '%07o\1' $gid)" + header1="${header1}$(printf '%011o\1' $size)" + header1="${header1}$(printf '%011o\1' $mtime)" + + # construct header part after checksum field + local header2="$(printf '%d' $type)" + header2="${header2}${link}${pad:0:$((100 - ${#link}))}" + header2="${header2}ustar ${pad:0:1}" + header2="${header2}${username}${pad:0:$((32 - ${#username}))}" + header2="${header2}${groupname}${pad:0:$((32 - ${#groupname}))}" + + # calculate checksum over header fields + local checksum=0 + for byte in $(printf '%s%8s%s' "$header1" "" "$header2" | tr '\1' '\0' | hexdump -ve '1/1 "%u "'); do + checksum=$((checksum + byte)) + done + + # print member header, padded to 512 byte + printf '%s%06o\0 %s' "$header1" $checksum "$header2" | tr '\1' '\0' + __tar_print_padding 183 + + # print content data, padded to multiple of 512 byte + printf "%s" "$content" + __tar_print_padding $((512 - (size % 512))) +} + +tar_make_member_from_file() { + local name="$1" + + __tar_make_member "$name" "$(cat $name)" "$(date +%s -r "$1")" +} + +tar_make_member_inline() { + local name="$1" + local content="$2" + local mtime="${3:-$(date +%s)}" + + __tar_make_member "$name" "$content" "$mtime" +} + +tar_close() { + __tar_print_padding 1024 +} From patchwork Wed Feb 28 08:03:03 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: 1905593 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=Li/3gUU/; 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=GcHXqYoo; 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 4Tl6MS3z77z23qW for ; Wed, 28 Feb 2024 19:04:36 +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: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=fXm49AkvhmE/LjDv8S0hH712mL4JxbueSCsKAI1sRVE=; b=Li/3gUU/eH/MbC RUZw2Kx1NiAxiIqIDp+Iwe85ayfcPmu5vEvR086Ik2WuG2mZJIBpWUWtneH8k6rk9MswqymCW5XGe RGeC2Tqr1R6nuJbDIb8ngQnj0zY8mbUhpietyjDHd/SWB/KGwkHA5Aqrf/Ign0fneBorXJ/+9yEop VOHsOlIXaTKAViwzCT2FOu2LmmE8vAUqtDSl+IFQPxcGqGWE47NfotpzrZpcdZDIW1SRw5FG6Ot1d lRPW7o96bAIL0sFjTpnln8QQdjyC51QZTyVJiMnyrS0sCTk34zIbEWIhYg/jOPCwYz5hszgs87v+D WgmP7AOkahl8U7O1/4JA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEuL-00000008P0g-2LDI; Wed, 28 Feb 2024 08:03:17 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEuJ-00000008OzY-1AiM for openwrt-devel@lists.openwrt.org; Wed, 28 Feb 2024 08:03:16 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-564647bcdbfso5362878a12.2 for ; Wed, 28 Feb 2024 00:03:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709107394; x=1709712194; 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=aAwU2vwxZRBMsmnAGrOtdN2q6hQGTutKd2mxpcjk+jw=; b=GcHXqYoouqQfk4Kq4m2LhssY8vWVOvj42aeRRh3X+y591k31oxOYQ8rcNxlM8vpPlm wiXXwgIDzZEjHseKMfMyKXSfHUEo3NO6Lwa64c71IHcVz+3gOwFgpGCau1YrumYnDbER t2+3tDtozfB8/6gHuw/TAkPIXckBLhD8EoWafHyTn5AcxMYO7Ua5VaaPkloXw/vsQT9G DGEtJ7/cINuNW5gz0hBcw0u8t2T5dwObh/lUOU12zMJCtYKieJ5bVE/2YUXm0qPmosjo 0fGr5yEPbW05boRExLIXxz8Dsukz4zYFDsRPcH6Zn3ZNnkWDAtSNmKy9dSwucJYVxtrR R8nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709107394; x=1709712194; 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=aAwU2vwxZRBMsmnAGrOtdN2q6hQGTutKd2mxpcjk+jw=; b=vDWcchjPkISF/iUC9crki1TjeNSjD83yASJHVN1kXuAEz+NBgc0HrTDs1uAjv7dbKK 4BRyiwUEZouhvhlOsVZ3wQiMB194Fq2r4SRN+tNIPS/QZIZ0p0TbPd+Yy80Zixk70cZl KtHI8Xxeid6p8sCpJDRN7n6qmNG7Qlxr3eUH0Fqbz/ZcdWQdJV4dpWaoKCquFJsVXJvZ UtJbWS4r5FhredZ9pP2S8jbv7RFgvpRazChap6ujHvZSOSGAIC00GD9rTwIFwp8E/mGC pQtRauTk/VK3Lxm0FkPRfQ0sjboIDPpi+4RXhkY1cUV0Unp2d36DpXJf8cicLnzJihwb Rx8g== X-Gm-Message-State: AOJu0YwcYVDYnjrvCPoj2TLuYHdrlhyKd2TvRDavI/TlYlJjX8JGhqBI WmTlM5rn+BGJvEu3pwzwb9RYvFgLxcWXIoUtWAbgqsNa6Gj576lLqEI6P47o X-Google-Smtp-Source: AGHT+IHGW+dDIpPdBOeDjmEkHpGIXvZdHtYs5DP3oHpmymwA/yHyVBj9VPJPQEl4TKTYtOgzkCnwKA== X-Received: by 2002:a05:6402:35ca:b0:565:ba2f:85d7 with SMTP id z10-20020a05640235ca00b00565ba2f85d7mr8591174edc.37.1709107393760; Wed, 28 Feb 2024 00:03:13 -0800 (PST) Received: from localhost.lan (031011218106.poznan.vectranet.pl. [31.11.218.106]) by smtp.gmail.com with ESMTPSA id g2-20020a056402114200b005666465520dsm459547edw.26.2024.02.28.00.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:03:13 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Cc: Jo-Philipp Wich , Luiz Angelo Daros de Luca , =?utf-8?b?UmFmYcWCIE1pxYJl?= =?utf-8?b?Y2tp?= Subject: [PATCH V2 2/3] base-files: sysupgrade: use tar helper to include installed_packages.txt Date: Wed, 28 Feb 2024 09:03:03 +0100 Message-Id: <20240228080304.22671-2-zajec5@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240228080304.22671-1-zajec5@gmail.com> References: <20240228080304.22671-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240228_000315_386059_6289189B X-CRM114-Status: GOOD ( 12.21 ) X-Spam-Score: 0.0 (/) 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_Replac?= =?unknown-8bit?q?e_mount_+_overlay_with_manually?= =?unknown-8bit?q?_built_tar_archive_that_gets_prepended_to_the_actual_config?= =?unknown-8bit?q?_files_backup=2E?= =?unknown-8bit?q?_This_allows_more_flexibility_with_including_extra_backup_f?= =?unknown-8bit?q?iles=2E_They_can_be?= =?unknown-8bit?b?IGluY2x1ZGVkIGF0IGEgWy4uLl0g?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E0_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=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?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo1MmIgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?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=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?_-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=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=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?= =?unknown-8bit?q?_-0=2E0_T=5FSCC=5FBODY=5FTEXT=5FLINE___No_description_avail?= =?unknown-8bit?q?able=2E?= 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 Replace mount + overlay with manually built tar archive that gets prepended to the actual config files backup. This allows more flexibility with including extra backup files. They can be included at any paths and don't require writing to flash or mounting an overlay which has its own limitations (mount points). Signed-off-by: Rafał Miłecki --- package/base-files/files/sbin/sysupgrade | 44 +++++++++--------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index 6b3fb0666f..9d5d736aef 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -237,8 +237,6 @@ include /lib/upgrade create_backup_archive() { local conf_tar="$1" - local umount_etcbackup_dir=0 - [ "$(rootfs_type)" = "tmpfs" ] && { echo "Cannot save config while running from ramdisk." >&2 ask_bool 0 "Abort" && exit @@ -248,41 +246,31 @@ create_backup_archive() { run_hooks "$CONFFILES" $sysupgrade_init_conffiles ask_bool 0 "Edit config file list" && vi "$CONFFILES" - if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then - echo "${INSTALLED_PACKAGES}" >> "$CONFFILES" - mkdir -p "$ETCBACKUP_DIR" - # Avoid touching filesystem on each backup - RAMFS="$(mktemp -d -t sysupgrade.XXXXXX)" - mkdir -p "$RAMFS/upper" "$RAMFS/work" - mount -t overlay overlay -o lowerdir=$ETCBACKUP_DIR,upperdir=$RAMFS/upper,workdir=$RAMFS/work $ETCBACKUP_DIR && - umount_etcbackup_dir=1 || { - echo "Cannot mount '$ETCBACKUP_DIR' as tmpfs to avoid touching disk while saving the list of installed packages." >&2 - ask_bool 0 "Abort" && exit - } - - # Format: pkg-name{rom,overlay,unknown} - # rom is used for pkgs in /rom, even if updated later - find /usr/lib/opkg/info -name "*.control" \( \ - \( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \ - \( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \ - \( -exec echo {} unknown \; \) \ - \) | sed -e 's,.*/,,;s/\.control /\t/' > ${INSTALLED_PACKAGES} - fi - v "Saving config files..." [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" sed -i -e 's,^/,,' "$CONFFILES" - tar c${TAR_V}zf "$conf_tar" -C / -T "$CONFFILES" + { + # Part of archive with installed packages info + if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then + # Format: pkg-name{rom,overlay,unknown} + # rom is used for pkgs in /rom, even if updated later + tar_make_member_inline "$INSTALLED_PACKAGES" "$(find /usr/lib/opkg/info -name "*.control" \( \ + \( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \ + \( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \ + \( -exec echo {} unknown \; \) \ + \) | sed -e 's,.*/,,;s/\.control /\t/')" + fi + + # Rest of archive with config files and ending padding + tar c${TAR_V} -C / -T "$CONFFILES" + } | gzip > "$conf_tar" + local err=$? if [ "$err" -ne 0 ]; then echo "Failed to create the configuration backup." rm -f "$conf_tar" fi - [ "$umount_etcbackup_dir" -eq 1 ] && { - umount "$ETCBACKUP_DIR" - rm -rf "$RAMFS" - } rm -f "$CONFFILES" return "$err" From patchwork Wed Feb 28 08:03:04 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: 1905595 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=S4i+2PBP; 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=B/30WiKH; 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 4Tl6MV5BtSz23qW for ; Wed, 28 Feb 2024 19:04:38 +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: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=3yvmYM2yLybfa0tcMm88UMbR3l8hzbFgGBirilwkmEs=; b=S4i+2PBPtnlg/C dDI4LAQBGQTXN4S/TrzyRWFC7tBV/ZBRgJp7C72T9+LoFgvz1e6faqJeaObpwBA/tszihOwVHjB9O XWM5wjQAIJdnVZFJn/xXiytN4PNXVwHcsq0LflGOsCqs0Lk8kO/SiyWN/Q73Gdewa/b8wN0x4pv/C oq3HOj6o13xRUg0dBjyFNy2Q+k8mnQlNb0p44dr9yKD5mDZ4zWwrzA2bP03sSAusGXz4it7jVgKSR K8wX1GGeYihnvQ8ycOFmOVBKzDWlB5+0uKWvzfzpGsNrLnHh3McLfkU9wEN/fNXYHPIpNWmk54lom 4B07UMxAgFfFttvoiU5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEuQ-00000008P2A-3WeT; Wed, 28 Feb 2024 08:03:22 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEuL-00000008Ozx-0PJc for openwrt-devel@lists.openwrt.org; Wed, 28 Feb 2024 08:03:18 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-55a5e7fa471so7000695a12.1 for ; Wed, 28 Feb 2024 00:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709107395; x=1709712195; 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=TmVe2Le12JTxbRiwVXEe0th5CuzyVA6eUKmL/IoTftw=; b=B/30WiKHxI+alISjdCSRBWNbNKvtf94PL72wI1sd8Ad4xJrRJ5gNNXHy/zvzNdf5UY TLZOE9HTDboUTP0s1Bk+/ntNUN/N746w+vKwJbqk7qNB7qzRgOTzmqg2EXn6wNQPbe4W wZRbK7a0Ty75NNFFusV8XmDJT2Qd8EFQJNe6HFJJznk4IHD1V/exrHKH3xhQKwYQl5xk g+HWpfZQMAPQ0j0iNKe2FVYvKIZ0NVnDAM31ncSVcC29LHFOgJf7jHpYi2lYTKvAtjWP MAn0DwEf+2TljQndEZdLHEEtIacf23R0QYZ1dRUqMDPuNwjW2F0MfAg5yaxrsrt/5s6r Jz/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709107395; x=1709712195; 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=TmVe2Le12JTxbRiwVXEe0th5CuzyVA6eUKmL/IoTftw=; b=o+vGbEZXIQE3WJgbVwCqH1Xt0LhtkDRBoZgwuaE7R74XFmrMJ3Gy2BJ7kdKSHp3js0 sAqMGPbE+9jhDyRPyeR5mJ5zH61YAYfUWeVVSFdJnlKSg+JG5GnKhzA6Xb3BcW8PxYTR DyPbX7r57CUN0eaxazwHTLsT2HI66/JDH5H6URUbA2rBtGKb24DTiObhC6OD1N+n75We 0xoUK18QYL9rKbCEoHCaXeA0A1SVhtPX5pGWSxxxx7JQkl1ylVMjHc2glqFfyzkXwjvG fYfGUM/c5DATz1Kj0KT/nBxnam3zT5yLcmGfxa6m8wBJPXX2RIR4cS4kp1ZpfneR1pd9 k9fg== X-Gm-Message-State: AOJu0YyyY9Yy0YOrgAVLKB4802sGKUb534v00rMqtKT9Hrg9GdCRjc7p PCqDi6L9+9v229A1lF8ZxMBaeJEFXXsHWtuMabe8ZjwrFVckGyzDr7WIdXjY X-Google-Smtp-Source: AGHT+IHkD4D4UANjq1LrGQ+5CJ0f+CyNdk9xji2OgT0fDssxSNQJOZrMpzGYEB9YcXE1I1mr79Y2xQ== X-Received: by 2002:a05:6402:651:b0:565:6911:a82b with SMTP id u17-20020a056402065100b005656911a82bmr7300882edx.40.1709107395503; Wed, 28 Feb 2024 00:03:15 -0800 (PST) Received: from localhost.lan (031011218106.poznan.vectranet.pl. [31.11.218.106]) by smtp.gmail.com with ESMTPSA id g2-20020a056402114200b005666465520dsm459547edw.26.2024.02.28.00.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:03:15 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Cc: Jo-Philipp Wich , Luiz Angelo Daros de Luca , =?utf-8?b?UmFmYcWCIE1pxYJl?= =?utf-8?b?Y2tp?= , Christian Marangi , Jonas Gorski Subject: [PATCH V2 3/3] base-files: sysupgrade: add uci-defaults script disabling services #2 Date: Wed, 28 Feb 2024 09:03:04 +0100 Message-Id: <20240228080304.22671-3-zajec5@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240228080304.22671-1-zajec5@gmail.com> References: <20240228080304.22671-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240228_000317_152699_020F7EC0 X-CRM114-Status: UNSURE ( 9.24 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) 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_Disabl?= =?unknown-8bit?q?ed_services_should_be_kept_disabled?= =?unknown-8bit?q?_after_sysupgrade=2E_This_can_be_easily_handled_using_a_pro?= =?unknown-8bit?q?per_uci-defaults?= =?unknown-8bit?q?_script=2E_Extend_sysupgrade_to_check_for_disabled_services?= =?unknown-8bit?q?=2C_generate_uci-defaults?= =?unknown-8bit?q?_script_disabling_them_and_include_it_in_backup=2E_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E0_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=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?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo1MzIgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?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=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?_-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=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=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?= =?unknown-8bit?q?_-0=2E0_T=5FSCC=5FBODY=5FTEXT=5FLINE___No_description_avail?= =?unknown-8bit?q?able=2E?= 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 Disabled services should be kept disabled after sysupgrade. This can be easily handled using a proper uci-defaults script. Extend sysupgrade to check for disabled services, generate uci-defaults script disabling them and include it in backup. Cc: Christian Marangi Cc: Jo-Philipp Wich Cc: Jonas Gorski Signed-off-by: Rafał Miłecki --- package/base-files/files/sbin/sysupgrade | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index 9d5d736aef..8c6200d7e9 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -236,6 +236,7 @@ include /lib/upgrade create_backup_archive() { local conf_tar="$1" + local disabled [ "$(rootfs_type)" = "tmpfs" ] && { echo "Cannot save config while running from ramdisk." >&2 @@ -250,6 +251,14 @@ create_backup_archive() { [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" sed -i -e 's,^/,,' "$CONFFILES" { + for service in /etc/init.d/*; do + if ! $service enabled; then + disabled="$disabled$service disable\n" + fi + done + disabled="$disabled\nexit 0" + tar_make_member_inline "/etc/uci-defaults/10_disable_services" "$(echo -e $disabled)" + # Part of archive with installed packages info if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then # Format: pkg-name{rom,overlay,unknown}