From: Rafał Miłecki <ra...@milecki.pl>

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 <j...@mein.io>
Signed-off-by: Rafał Miłecki <ra...@milecki.pl>
---
 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

Reply via email to