[OpenWrt-Devel,2/2] treewide: sysupgrade: pass "save_partitions" option to the "sysupgrade" method
diff mbox series

Message ID 20190816150517.29633-2-zajec5@gmail.com
State Accepted
Delegated to: Rafał Miłecki
Headers show
Series
  • [OpenWrt-Devel,1/2] base-files: pass "save_config" option to the "sysupgrade" method
Related show

Commit Message

Rafał Miłecki Aug. 16, 2019, 3:05 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

This explicitly lets stage2 know if partitions should be preserved. No
more "touch /tmp/sysupgrade.always.overwrite.bootdisk.partmap" hack.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 package/base-files/files/lib/upgrade/stage2              | 5 -----
 package/base-files/files/sbin/sysupgrade                 | 9 ++-------
 target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh   | 2 +-
 target/linux/brcm2708/base-files/lib/upgrade/platform.sh | 2 +-
 target/linux/mvebu/base-files/lib/upgrade/sdcard.sh      | 2 +-
 target/linux/omap/base-files/lib/upgrade/platform.sh     | 2 +-
 target/linux/sunxi/base-files/lib/upgrade/platform.sh    | 2 +-
 target/linux/tegra/base-files/lib/upgrade/platform.sh    | 2 +-
 target/linux/x86/base-files/lib/upgrade/platform.sh      | 2 +-
 9 files changed, 9 insertions(+), 19 deletions(-)

Patch
diff mbox series

diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2
index 4e5837af83..ff2a9aee05 100755
--- a/package/base-files/files/lib/upgrade/stage2
+++ b/package/base-files/files/lib/upgrade/stage2
@@ -6,8 +6,6 @@ 
 export IMAGE="$1"
 COMMAND="$2"
 
-export SAVE_PARTITIONS=1
-
 export INTERACTIVE=0
 export VERBOSE=1
 export CONFFILES=/tmp/sysupgrade.conffiles
@@ -16,9 +14,6 @@  export CONF_TAR=/tmp/sysupgrade.tgz
 RAMFS_COPY_BIN=		# extra programs for temporary ramfs root
 RAMFS_COPY_DATA=	# extra data files
 
-
-[ -f /tmp/sysupgrade.always.overwrite.bootdisk.partmap ] && export SAVE_PARTITIONS=0
-
 include /lib/upgrade
 
 
diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index 15514159b3..c27c1fbc47 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -351,12 +351,6 @@  if [ $TEST -eq 1 ]; then
 	exit 0
 fi
 
-if [ $SAVE_PARTITIONS -eq 0 ]; then
-	touch /tmp/sysupgrade.always.overwrite.bootdisk.partmap
-else
-	rm -f /tmp/sysupgrade.always.overwrite.bootdisk.partmap
-fi
-
 install_bin /sbin/upgraded
 v "Commencing upgrade. Closing all shell sessions."
 
@@ -371,7 +365,8 @@  else
 		\"path\": $(json_string "$IMAGE"),
 		\"command\": $(json_string "$COMMAND"),
 		\"options\": {
-			\"save_config\": $SAVE_CONFIG
+			\"save_config\": $SAVE_CONFIG,
+			\"save_partitions\": $SAVE_PARTITIONS
 		}
 	}"
 fi
diff --git a/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh b/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh
index c191271149..01327d926a 100644
--- a/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh
+++ b/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh
@@ -43,7 +43,7 @@  mbl_do_upgrade() {
 
 	sync
 
-	if [ "$SAVE_PARTITIONS" = "1" ]; then
+	if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
 		get_partitions "/dev/$diskdev" bootdisk
 
 		#extract the boot sector from the image
diff --git a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh
index 37e479272b..693cde7779 100644
--- a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh
+++ b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh
@@ -45,7 +45,7 @@  platform_do_upgrade() {
 
 	sync
 
-	if [ "$SAVE_PARTITIONS" = "1" ]; then
+	if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
 		get_partitions "/dev/$diskdev" bootdisk
 
 		#extract the boot sector from the image
diff --git a/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh b/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh
index 43fc2504fc..08ab17089d 100644
--- a/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh
+++ b/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh
@@ -49,7 +49,7 @@  platform_do_upgrade_sdcard() {
 
 	sync
 
-	if [ "$SAVE_PARTITIONS" = "1" ]; then
+	if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
 		get_partitions "/dev/$diskdev" bootdisk
 
 		#extract the boot sector from the image
diff --git a/target/linux/omap/base-files/lib/upgrade/platform.sh b/target/linux/omap/base-files/lib/upgrade/platform.sh
index abe910b154..c8b0175fd5 100644
--- a/target/linux/omap/base-files/lib/upgrade/platform.sh
+++ b/target/linux/omap/base-files/lib/upgrade/platform.sh
@@ -45,7 +45,7 @@  platform_do_upgrade() {
 
 	sync
 
-	if [ "$SAVE_PARTITIONS" = "1" ]; then
+	if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
 		get_partitions "/dev/$diskdev" bootdisk
 
 		#extract the boot sector from the image
diff --git a/target/linux/sunxi/base-files/lib/upgrade/platform.sh b/target/linux/sunxi/base-files/lib/upgrade/platform.sh
index abe910b154..c8b0175fd5 100644
--- a/target/linux/sunxi/base-files/lib/upgrade/platform.sh
+++ b/target/linux/sunxi/base-files/lib/upgrade/platform.sh
@@ -45,7 +45,7 @@  platform_do_upgrade() {
 
 	sync
 
-	if [ "$SAVE_PARTITIONS" = "1" ]; then
+	if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
 		get_partitions "/dev/$diskdev" bootdisk
 
 		#extract the boot sector from the image
diff --git a/target/linux/tegra/base-files/lib/upgrade/platform.sh b/target/linux/tegra/base-files/lib/upgrade/platform.sh
index 97dd381041..66e7d91e3c 100644
--- a/target/linux/tegra/base-files/lib/upgrade/platform.sh
+++ b/target/linux/tegra/base-files/lib/upgrade/platform.sh
@@ -62,7 +62,7 @@  platform_do_upgrade() {
 
 	sync
 
-	if [ "$SAVE_PARTITIONS" = "1" ]; then
+	if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
 		get_partitions "/dev/$diskdev" bootdisk
 
 		#extract the boot sector from the image
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
index 439ba8f512..162dbaf3aa 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -54,7 +54,7 @@  platform_do_upgrade() {
 
 	sync
 
-	if [ "$SAVE_PARTITIONS" = "1" ]; then
+	if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
 		get_partitions "/dev/$diskdev" bootdisk
 
 		#extract the boot sector from the image