base-files: pass "save_config" option to the "sysupgrade" method
authorRafał Miłecki <rafal@milecki.pl>
Fri, 16 Aug 2019 14:54:38 +0000 (16:54 +0200)
committerRISCi_ATOM <bob@bobcall.me>
Fri, 13 Sep 2019 20:10:30 +0000 (16:10 -0400)
This explicitly lets stage2 know if config should be preserved.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
(cherry picked from commit b534ba96110012d2697d19d71b7dcd60bd4cd375)

package/base-files/files/lib/upgrade/common.sh
package/base-files/files/lib/upgrade/do_stage2
package/base-files/files/lib/upgrade/stage2
package/base-files/files/sbin/sysupgrade

index 2afa0addb46ceda225d365a82df5fcf11a6f1f35..efa301cd950e664965fab3887602777045c79e0f 100644 (file)
@@ -218,7 +218,7 @@ indicate_upgrade() {
 # $(2): (optional) pipe command to extract firmware, e.g. dd bs=n skip=m
 default_do_upgrade() {
        sync
-       if [ "$SAVE_CONFIG" -eq 1 ]; then
+       if [ "$UPGRADE_OPT_SAVE_CONFIG" -eq 1 ]; then
                get_image "$1" "$2" | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j "$CONF_TAR" write - "${PART_NAME:-image}"
        else
                get_image "$1" "$2" | mtd $MTD_ARGS write - "${PART_NAME:-image}"
index 8aae45256081a01e2134557145dbd6cbdad2b816..0e6cc1bfc360993a64fe50653433e0d9e3489810 100755 (executable)
@@ -11,7 +11,7 @@ else
        default_do_upgrade "$IMAGE"
 fi
 
-if [ "$SAVE_CONFIG" -eq 1 ] && type 'platform_copy_config' >/dev/null 2>/dev/null; then
+if [ "$UPGRADE_OPT_SAVE_CONFIG" -eq 1 ] && type 'platform_copy_config' >/dev/null 2>/dev/null; then
        platform_copy_config
 fi
 
index fef121f37ce70043a1f4c699fd7050bfbdcfb0b1..4e5837af833dd7217ca8d9946584a02751eb0138 100755 (executable)
@@ -6,7 +6,6 @@
 export IMAGE="$1"
 COMMAND="$2"
 
-export SAVE_CONFIG=1
 export SAVE_PARTITIONS=1
 
 export INTERACTIVE=0
@@ -18,7 +17,6 @@ RAMFS_COPY_BIN=               # extra programs for temporary ramfs root
 RAMFS_COPY_DATA=       # extra data files
 
 
-[ -f "$CONF_TAR" ] || export SAVE_CONFIG=0
 [ -f /tmp/sysupgrade.always.overwrite.bootdisk.partmap ] && export SAVE_PARTITIONS=0
 
 include /lib/upgrade
index 001e6444760628c350213983a4d0505ac5ef1ec2..15514159b35fd22f4feb2fdec4e69d48815d8d28 100755 (executable)
@@ -369,6 +369,9 @@ else
        ubus call system sysupgrade "{
                \"prefix\": $(json_string "$RAM_ROOT"),
                \"path\": $(json_string "$IMAGE"),
-               \"command\": $(json_string "$COMMAND")
+               \"command\": $(json_string "$COMMAND"),
+               \"options\": {
+                       \"save_config\": $SAVE_CONFIG
+               }
        }"
 fi