treewide: don't hardcode "sysupgrade.tgz" file name
authorRafał Miłecki <rafal@milecki.pl>
Wed, 4 Sep 2019 14:57:39 +0000 (16:57 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Thu, 5 Sep 2019 12:33:19 +0000 (14:33 +0200)
1) Add BACKUP_FILE and use it when copying an archive to be restored
   after sysupgrade (on the next preinit).
2) Use CONF_TAR for copying backup prepared by the /sbin/sysupgrade

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
17 files changed:
package/base-files/files/lib/upgrade/common.sh
package/base-files/files/lib/upgrade/nand.sh
target/linux/apm821xx/base-files/lib/preinit/79_move_config
target/linux/brcm2708/base-files/lib/preinit/79_move_config
target/linux/imx6/base-files/lib/preinit/79_move_config
target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
target/linux/mediatek/base-files/lib/preinit/79_move_config
target/linux/mvebu/base-files/lib/preinit/79_move_config
target/linux/mvebu/base-files/lib/preinit/81_linksys_syscfg
target/linux/mvebu/base-files/lib/preinit/82_uDPU
target/linux/mvebu/base-files/lib/upgrade/linksys.sh
target/linux/mvebu/base-files/lib/upgrade/uDPU.sh
target/linux/octeon/base-files/lib/preinit/79_move_config
target/linux/omap/base-files/lib/preinit/79_move_config
target/linux/sunxi/base-files/lib/preinit/79_move_config
target/linux/tegra/base-files/lib/preinit/79_move_config
target/linux/x86/base-files/lib/preinit/79_move_config

index efa301cd950e664965fab3887602777045c79e0f..279470fcd8c166e7b6e2894e98d2e26ed986b171 100644 (file)
@@ -2,6 +2,8 @@
 
 RAM_ROOT=/tmp/root
 
+export BACKUP_FILE=sysupgrade.tgz      # file extracted by preinit
+
 [ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
 libs() { ldd $* 2>/dev/null | sed -r 's/(.* => )?(.*) .*/\2/'; }
 
index fbc2b5c19a07ff91f67a7ffdccaa63d4b6edc5a8..e7d7bf8d13ae43e330abefbc9c678707e6a03bc9 100644 (file)
@@ -109,7 +109,7 @@ nand_restore_config() {
                rmdir /tmp/new_root
                return 1
        fi
-       mv "$1" "/tmp/new_root/sysupgrade.tgz"
+       mv "$1" "/tmp/new_root/$BACKUP_FILE"
        umount /tmp/new_root
        sync
        rmdir /tmp/new_root
index cb5e5c759db1fbd68a781f6c10e1c36d93d9ffd4..37d35b663b4ce40b0ea8d2eb2ff3b9d0eb424230 100644 (file)
@@ -4,13 +4,14 @@ BOOTPART=/dev/sda1
 
 move_config() {
        . /lib/functions.sh
+       . /lib/upgrade/common.sh
 
        case "$(board_name)" in
        wd,mybooklive)
                if [ -b $BOOTPART ]; then
                        mkdir -p /boot
                        mount -t ext4 -o rw,noatime $BOOTPART /boot
-                       [ -f /boot/sysupgrade.tgz ] && mv -f /boot/sysupgrade.tgz /
+                       [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
                fi
                ;;
        *)
index b0ee62a8092dc7437a25b23489b6087aef934e9b..b8738b645ed74ecfe7593c5337a83e251b9570a4 100644 (file)
@@ -1,6 +1,8 @@
 #!/bin/sh
 # Copyright (C) 2015 OpenWrt.org
 
+. /lib/upgrade/common.sh
+
 BOOTPART=/dev/mmcblk0p1
 
 move_config() {
@@ -11,7 +13,7 @@ move_config() {
                insmod vfat
                mkdir -p /boot
                mount -t vfat -o rw,noatime $BOOTPART /boot
-               [ -f /boot/sysupgrade.tgz ] && mv -f /boot/sysupgrade.tgz /
+               [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
        fi
 }
 
index 6b66fbd42d4f9a69165a650e4ab5484becae8ccb..bdf397c4fc076e855d306e13a23759ff40c64bd6 100644 (file)
@@ -2,6 +2,7 @@
 
 . /lib/imx6.sh
 . /lib/functions.sh
+. /lib/upgrade/common.sh
 
 move_config() {
        local board=$(board_name)
@@ -10,7 +11,7 @@ move_config() {
        apalis*)
                if [ -b $(bootpart_from_uuid) ]; then
                        apalis_mount_boot
-                       [ -f /boot/sysupgrade.tgz ] && mv -f /boot/sysupgrade.tgz /
+                       [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
                        umount /boot
                fi
                ;;
index 33cd98339c3df73208434de0279d9bb441191c68..8888ec7d0465ef7ac10b40cc49e4ecaf3d102c99 100644 (file)
@@ -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 /tmp/sysupgrade.tgz /tmp/new_root/
+               cp -v "$CONF_TAR" /tmp/new_root/
                umount /tmp/new_root
        }
 
index e8e62883dc64298af2509f5ac74bbf005ce436df..617336583ee37a4ae4d89b308f77564e35613dd0 100644 (file)
@@ -1,6 +1,8 @@
 #!/bin/sh
 # Copyright (C) 2015 OpenWrt.org
 
+. /lib/upgrade/common.sh
+
 RECOVERY_PART=/dev/mmcblk0p1
 
 move_config() {
@@ -11,7 +13,7 @@ move_config() {
                insmod vfat
                mkdir -p /recovery
                mount -o rw,noatime $RECOVERY_PART /recovery
-               [ -f /recovery/sysupgrade.tgz ] && mv -f /recovery/sysupgrade.tgz /
+               [ -f "/recovery/$BACKUP_FILE" ] && mv -f "/recovery/$BACKUP_FILE" /
                umount /recovery
        fi
 }
index 640fb5cdad01c17876e79ba26eeeb83f1a374011..195be0e137de6953ed922f48706fcfdaeb5e8710 100644 (file)
@@ -18,7 +18,7 @@ move_config() {
                esac
                mkdir -p /boot
                mount -o rw,noatime "/dev/$partdev" /boot
-               [ -f /boot/sysupgrade.tgz ] && mv -f /boot/sysupgrade.tgz /
+               [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
                umount /boot
        fi
 }
index b107eacb1146c588c14171187b804287ecf02e71..83448e5ace5f2f7dd5bbd1af2226608d77fb8766 100644 (file)
@@ -4,8 +4,8 @@
 #
 
 preinit_mount_syscfg() {
-
        . /lib/functions.sh
+       . /lib/upgrade/common.sh
 
        case $(board_name) in
        linksys,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom)
@@ -22,12 +22,12 @@ preinit_mount_syscfg() {
                fi
                mkdir /tmp/syscfg
                mount -t ubifs ubi1:syscfg /tmp/syscfg
-               [ -f /tmp/syscfg/sysupgrade.tgz ] && {
+               [ -f "/tmp/syscfg/$BACKUP_FILE" ] && {
                echo "- config restore -"
                cd /
-               mv /tmp/syscfg/sysupgrade.tgz /tmp
-               tar xzf /tmp/sysupgrade.tgz
-               rm -f /tmp/sysupgrade.tgz
+               mv "/tmp/syscfg/$BACKUP_FILE" /tmp
+               tar xzf "/tmp/$BACKUP_FILE"
+               rm -f "/tmp/$BACKUP_FILE"
                sync
                }
                ;;
index 937a0a5f2174c4aa6e6898e1793c891b75e776c7..12bbfc3725818a589d32263845a55f3825bbc1e9 100644 (file)
@@ -4,8 +4,8 @@
 #
 
 preinit_mount_udpu() {
-
        . /lib/functions.sh
+       . /lib/upgrade/common.sh
 
        case $(board_name) in
        methode,udpu)
@@ -15,10 +15,10 @@ preinit_mount_udpu() {
                if [ -b "${mmcdev}p4" ]; then
                        mkdir /misc
                        mount -t f2fs ${mmcdev}p4 /misc
-                       [ -f "/misc/sysupgrade.tgz" ] && {
+                       [ -f "/misc/$BACKUP_FILE" ] && {
                                echo "- Restoring configuration files -"
-                               tar xzf /misc/sysupgrade.tgz -C /
-                               rm -f /misc/sysupgrade.tgz
+                               tar xzf "/misc/$BACKUP_FILE" -C /
+                               rm -f "/misc/$BACKUP_FILE"
                                sync
                        }
                        [ -f "/misc/firmware/recovery.itb" ] && {
index 3f45d6cac5e879f050442b76cf7b4270dc177207..857c550c73defc0c4accad171a4521f4fd816b0b 100644 (file)
@@ -93,6 +93,6 @@ platform_do_upgrade_linksys() {
 }
 
 platform_copy_config_linksys() {
-       cp -f /tmp/sysupgrade.tgz /tmp/syscfg/sysupgrade.tgz
+       cp -f "$CONF_TAR" /tmp/syscfg/
        sync
 }
index 48c3209a99dadf9d01c5b05d5ef5617a71f6b186..f87ff4f9ca0550f0f25955b392ca0616ffa1d280 100644 (file)
@@ -149,8 +149,8 @@ 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 "/tmp/sysupgrade.tgz" ]; then
-               cp -f /tmp/sysupgrade.tgz /misc
+       if [ -f "$CONF_TAR" ]; then
+               cp -f "$CONF_TAR" /misc
                sync
        fi
 }
index ec63d9f5ff1d51774c18d32c5a534b15ee66d645..a4130e26d848afba70787fa6bfaa2f9addb3ad7c 100644 (file)
@@ -3,11 +3,12 @@
 
 move_config() {
        . /lib/functions.sh
+       . /lib/upgrade/common.sh
 
        case "$(board_name)" in
                erlite)
                        mount -t vfat /dev/sda1 /mnt
-                       [ -f /mnt/sysupgrade.tgz ] && mv -f /mnt/sysupgrade.tgz /
+                       [ -f "/mnt/$BACKUP_FILE" ] && mv -f "/mnt/$BACKUP_FILE" /
                        umount /mnt
                        ;;
        esac
index 83171b3ba9dcc7edcf54139f9428b7ca880b3bd2..74caee8a8a71ff8021af6cd7496e0d191042afff 100644 (file)
@@ -8,8 +8,8 @@ move_config() {
 
        if export_bootdevice && export_partdevice partdev 1; then
                if mount -t vfat -o rw,noatime "/dev/$partdev" /mnt; then
-                       if [ -f /mnt/sysupgrade.tgz ]; then
-                               mv -f /mnt/sysupgrade.tgz /
+                       if [ -f "/mnt/$BACKUP_FILE" ]; then
+                               mv -f "/mnt/$BACKUP_FILE" /
                        fi
                        umount /mnt
                fi
index 83171b3ba9dcc7edcf54139f9428b7ca880b3bd2..74caee8a8a71ff8021af6cd7496e0d191042afff 100644 (file)
@@ -8,8 +8,8 @@ move_config() {
 
        if export_bootdevice && export_partdevice partdev 1; then
                if mount -t vfat -o rw,noatime "/dev/$partdev" /mnt; then
-                       if [ -f /mnt/sysupgrade.tgz ]; then
-                               mv -f /mnt/sysupgrade.tgz /
+                       if [ -f "/mnt/$BACKUP_FILE" ]; then
+                               mv -f "/mnt/$BACKUP_FILE" /
                        fi
                        umount /mnt
                fi
index 2a451a5efdbed06d9e3ef10aac5799bd96c7e60a..d17e734ac80f63f38fd306107c15dd8cdab32a91 100644 (file)
@@ -8,9 +8,9 @@ move_config() {
        if export_bootdevice && export_partdevice partdev 1; then
                mkdir -p /boot
                if mount -o ro,noatime "/dev/$partdev" /boot; then
-                       if [ -f /boot/sysupgrade.tgz ]; then
+                       if [ -f "/boot/$BACKUP_FILE" ]; then
                                mount /boot -o remount,rw,noatime
-                               mv -f /boot/sysupgrade.tgz /
+                               mv -f "/boot/$BACKUP_FILE" /
                        fi
                        umount /boot
                        rm -fR /boot
index aff720a52c5afc6e4a1dee5a67d14b953f975eae..702da9e873d5a47cec80352fea5a719c2ffbcbc5 100644 (file)
@@ -9,8 +9,8 @@ move_config() {
        if export_bootdevice && export_partdevice partdev 1; then
                mkdir -p /boot
                mount -t ext4 -o rw,noatime "/dev/$partdev" /boot
-               if [ -f /boot/sysupgrade.tgz ]; then
-                       mv -f /boot/sysupgrade.tgz /
+               if [ -f "/boot/$BACKUP_FILE" ]; then
+                       mv -f "/boot/$BACKUP_FILE" /
                fi
                mount --bind /boot/boot /boot
        fi