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"