From c5223b26a40ae61fc7750bf865464048af328ab1 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Fri, 6 Sep 2019 07:10:52 +0200
Subject: [PATCH] base-files: sysupgrade: pass "backup" ubus attribute
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

This explicitly tells procd what backup file should be used during
sysupgrade (if any). It's much more generic this way compared to the
magic /tmp/sysupgrade.tgz file that had to be created before a call.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 package/base-files/files/sbin/sysupgrade | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index f106c3c98187..f18143bff42e 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -362,10 +362,13 @@ if [ -n "$FAILSAFE" ]; then
 else
 	force_attr=""
 	[ $FORCE -eq 1 ] && force_attr="\"force\": true,"
+	backup_attr=""
+	[ $SAVE_CONFIG -eq 1 ] && backup_attr="\"backup\": $(json_string $CONF_TAR),"
 	ubus call system sysupgrade "{
 		\"prefix\": $(json_string "$RAM_ROOT"),
 		\"path\": $(json_string "$IMAGE"),
 		$force_attr
+		$backup_attr
 		\"command\": $(json_string "$COMMAND"),
 		\"options\": {
 			\"save_config\": $SAVE_CONFIG,
-- 
2.30.2