diff mbox series

[OpenWrt-Devel,2/2] treewide: when copying a backup file always specify dest name

Message ID 20190904145740.4444-2-zajec5@gmail.com
State Accepted
Headers show
Series [OpenWrt-Devel,1/2] treewide: don't hardcode "sysupgrade.tgz" file name | expand

Commit Message

Rafał Miłecki Sept. 4, 2019, 2:57 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

$CONF_TAR shouldn't be assumed to always point to the sysupgrade.tgz.
This change makes code more generic and allows refactoring $CONF_TAR.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh   | 2 +-
 target/linux/brcm2708/base-files/lib/upgrade/platform.sh | 2 +-
 target/linux/imx6/base-files/lib/upgrade/platform.sh     | 2 +-
 target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh     | 2 +-
 target/linux/mediatek/base-files/lib/upgrade/platform.sh | 2 +-
 target/linux/mvebu/base-files/lib/upgrade/linksys.sh     | 2 +-
 target/linux/mvebu/base-files/lib/upgrade/sdcard.sh      | 2 +-
 target/linux/mvebu/base-files/lib/upgrade/uDPU.sh        | 2 +-
 target/linux/octeon/base-files/lib/upgrade/platform.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 +-
 13 files changed, 13 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh b/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh
index 01327d926a..e3de6ed0b5 100644
--- a/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh
+++ b/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh
@@ -88,7 +88,7 @@  mbl_copy_config() {
 
 	if export_partdevice partdev 1; then
 		mount -t ext4 -o rw,noatime "/dev/$partdev" /mnt
-		cp -af "$CONF_TAR" /mnt/
+		cp -af "$CONF_TAR" "/mnt/$BACKUP_FILE"
 		umount /mnt
 	fi
 }
diff --git a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh
index 693cde7779..48994ebe07 100644
--- a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh
+++ b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh
@@ -91,7 +91,7 @@  platform_copy_config() {
 	if export_partdevice partdev 1; then
 		mkdir -p /boot
 		[ -f /boot/kernel.img ] || mount -t vfat -o rw,noatime "/dev/$partdev" /boot
-		cp -af "$CONF_TAR" /boot/
+		cp -af "$CONF_TAR" "/boot/$BACKUP_FILE"
 		tar -C / -zxvf "$CONF_TAR" boot/config.txt
 		sync
 		unmount /boot
diff --git a/target/linux/imx6/base-files/lib/upgrade/platform.sh b/target/linux/imx6/base-files/lib/upgrade/platform.sh
index 0dfaf0163d..f72e552a36 100755
--- a/target/linux/imx6/base-files/lib/upgrade/platform.sh
+++ b/target/linux/imx6/base-files/lib/upgrade/platform.sh
@@ -17,7 +17,7 @@  enable_image_metadata_check
 
 apalis_copy_config() {
 	apalis_mount_boot
-	cp -af "$CONF_TAR" /boot/
+	cp -af "$CONF_TAR" "/boot/$BACKUP_FILE"
 	sync
 	umount /boot
 }
diff --git a/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh b/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
index 8888ec7d04..e9fb0ad388 100644
--- a/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
+++ b/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
@@ -60,7 +60,7 @@  zyxel_do_flash() {
 	mkdir /tmp/new_root
 	mount -t ext4 $loopdev /tmp/new_root && {
 		echo "Saving config to rootfs_data at position ${offset}."
-		cp -v "$CONF_TAR" /tmp/new_root/
+		cp -v "$CONF_TAR" "/tmp/new_root/$BACKUP_FILE"
 		umount /tmp/new_root
 	}
 
diff --git a/target/linux/mediatek/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/base-files/lib/upgrade/platform.sh
index d812a48720..d1b9fdeb95 100755
--- a/target/linux/mediatek/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/base-files/lib/upgrade/platform.sh
@@ -54,7 +54,7 @@  platform_check_image() {
 platform_copy_config_emmc() {
 	mkdir -p /recovery
 	mount -o rw,noatime /dev/mmcblk0p1 /recovery
-	cp -af "$CONF_TAR" /recovery/
+	cp -af "$CONF_TAR" "/recovery/$BACKUP_FILE"
 	sync
 	umount /recovery
 }
diff --git a/target/linux/mvebu/base-files/lib/upgrade/linksys.sh b/target/linux/mvebu/base-files/lib/upgrade/linksys.sh
index 857c550c73..5104db31f3 100644
--- a/target/linux/mvebu/base-files/lib/upgrade/linksys.sh
+++ b/target/linux/mvebu/base-files/lib/upgrade/linksys.sh
@@ -93,6 +93,6 @@  platform_do_upgrade_linksys() {
 }
 
 platform_copy_config_linksys() {
-	cp -f "$CONF_TAR" /tmp/syscfg/
+	cp -f "$CONF_TAR" "/tmp/syscfg/$BACKUP_FILE"
 	sync
 }
diff --git a/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh b/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh
index 3bfdce97e8..03f6327657 100644
--- a/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh
+++ b/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh
@@ -106,7 +106,7 @@  platform_copy_config_sdcard() {
 	if export_partdevice partdev 1; then
 		mkdir -p /boot
 		[ -f /boot/kernel.img ] || mount -o rw,noatime /dev/$partdev /boot
-		cp -af "$CONF_TAR" /boot/
+		cp -af "$CONF_TAR" "/boot/$BACKUP_FILE"
 		sync
 		umount /boot
 	fi
diff --git a/target/linux/mvebu/base-files/lib/upgrade/uDPU.sh b/target/linux/mvebu/base-files/lib/upgrade/uDPU.sh
index f87ff4f9ca..dbcff58368 100644
--- a/target/linux/mvebu/base-files/lib/upgrade/uDPU.sh
+++ b/target/linux/mvebu/base-files/lib/upgrade/uDPU.sh
@@ -150,7 +150,7 @@  platform_do_upgrade_uDPU() {
 platform_copy_config_uDPU() {
 	# Config is saved on the /misc partition and copied on the rootfs after the reboot
 	if [ -f "$CONF_TAR" ]; then
-		cp -f "$CONF_TAR" /misc
+		cp -f "$CONF_TAR" "/misc/$BACKUP_FILE"
 		sync
 	fi
 }
diff --git a/target/linux/octeon/base-files/lib/upgrade/platform.sh b/target/linux/octeon/base-files/lib/upgrade/platform.sh
index 0e4ca37629..6233c337bc 100755
--- a/target/linux/octeon/base-files/lib/upgrade/platform.sh
+++ b/target/linux/octeon/base-files/lib/upgrade/platform.sh
@@ -25,7 +25,7 @@  platform_copy_config() {
 	case "$(board_name)" in
 	erlite)
 		mount -t vfat /dev/sda1 /mnt
-		cp -af "$CONF_TAR" /mnt/
+		cp -af "$CONF_TAR" "/mnt/$BACKUP_FILE"
 		umount /mnt
 		;;
 	esac
diff --git a/target/linux/omap/base-files/lib/upgrade/platform.sh b/target/linux/omap/base-files/lib/upgrade/platform.sh
index c8b0175fd5..a5108c4c02 100644
--- a/target/linux/omap/base-files/lib/upgrade/platform.sh
+++ b/target/linux/omap/base-files/lib/upgrade/platform.sh
@@ -30,7 +30,7 @@  platform_copy_config() {
 
 	if export_partdevice partdev 1; then
 		mount -t vfat -o rw,noatime "/dev/$partdev" /mnt
-		cp -af "$CONF_TAR" /mnt/
+		cp -af "$CONF_TAR" "/mnt/$BACKUP_FILE"
 		umount /mnt
 	fi
 }
diff --git a/target/linux/sunxi/base-files/lib/upgrade/platform.sh b/target/linux/sunxi/base-files/lib/upgrade/platform.sh
index c8b0175fd5..a5108c4c02 100644
--- a/target/linux/sunxi/base-files/lib/upgrade/platform.sh
+++ b/target/linux/sunxi/base-files/lib/upgrade/platform.sh
@@ -30,7 +30,7 @@  platform_copy_config() {
 
 	if export_partdevice partdev 1; then
 		mount -t vfat -o rw,noatime "/dev/$partdev" /mnt
-		cp -af "$CONF_TAR" /mnt/
+		cp -af "$CONF_TAR" "/mnt/$BACKUP_FILE"
 		umount /mnt
 	fi
 }
diff --git a/target/linux/tegra/base-files/lib/upgrade/platform.sh b/target/linux/tegra/base-files/lib/upgrade/platform.sh
index 66e7d91e3c..9a8acde9b6 100644
--- a/target/linux/tegra/base-files/lib/upgrade/platform.sh
+++ b/target/linux/tegra/base-files/lib/upgrade/platform.sh
@@ -47,7 +47,7 @@  platform_copy_config() {
 
 	if export_partdevice partdev 1; then
 		mount -o rw,noatime "/dev/$partdev" /mnt
-		cp -af "$CONF_TAR" /mnt/
+		cp -af "$CONF_TAR" "/mnt/$BACKUP_FILE"
 		umount /mnt
 	fi
 }
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
index 162dbaf3aa..855752b5d7 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -39,7 +39,7 @@  platform_copy_config() {
 
 	if export_partdevice partdev 1; then
 		mount -t ext4 -o rw,noatime "/dev/$partdev" /mnt
-		cp -af "$CONF_TAR" /mnt/
+		cp -af "$CONF_TAR" "/mnt/$BACKUP_FILE"
 		umount /mnt
 	fi
 }