Re: [PATCH] base-files: sysupgrade: fix generating backup to stdout

2024-03-04 Thread Rafał Miłecki

On 4.03.2024 08:15, Rafał Miłecki wrote:

From: Rafał Miłecki 

Before recent change "tar" command was called with an "-f" argument
which accepts "-" for stdout output. Bring back support for that feature
with new code.

Fixes: e36cc530927c ("base-files: sysupgrade: use tar helper to include 
installed_packages.txt")
Fixes: https://github.com/openwrt/openwrt/issues/14773
Cc: Jo-Philipp Wich 
Signed-off-by: Rafał Miłecki 


Obsoleted by the commit 6f6406a1321b ("base-files: sysupgrade: fix streaming backup 
archives to stdout")

https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=6f6406a1321b4ead1d61abdea450d7c76bd5a927

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] base-files: sysupgrade: fix generating backup to stdout

2024-03-03 Thread Rafał Miłecki
From: Rafał Miłecki 

Before recent change "tar" command was called with an "-f" argument
which accepts "-" for stdout output. Bring back support for that feature
with new code.

Fixes: e36cc530927c ("base-files: sysupgrade: use tar helper to include 
installed_packages.txt")
Fixes: https://github.com/openwrt/openwrt/issues/14773
Cc: Jo-Philipp Wich 
Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 78ec455067..b1a7335bc0 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -236,12 +236,15 @@ include /lib/upgrade
 
 create_backup_archive() {
local conf_tar="$1"
+   local output_file=""
local disabled
 
+   [ "$conf_tar" != "-" ] && output_file="$conf_tar"
+
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
ask_bool 0 "Abort" && exit
-   rm -f "$conf_tar"
+   [ -n "$output_file" ] && rm -f "$output_file"
return 0
}
run_hooks "$CONFFILES" $sysupgrade_init_conffiles
@@ -272,12 +275,12 @@ create_backup_archive() {
 
# Rest of archive with config files and ending padding
tar c${TAR_V} -C / -T "$CONFFILES"
-   } | gzip > "$conf_tar"
+   } | gzip > "${output_file:-/dev/stdout}"
 
local err=$?
if [ "$err" -ne 0 ]; then
echo "Failed to create the configuration backup."
-   rm -f "$conf_tar"
+   [ -n "$output_file" ] && rm -f "$output_file"
fi
 
rm -f "$CONFFILES"
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel