treewide: don't hardcode "sysupgrade.tgz" file name

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>
(cherry picked from commit bf390478727ac5f4f9d6fb684de48b8150bcec67)
This commit is contained in:
Rafał Miłecki 2019-09-04 16:57:39 +02:00
parent f54bc3985a
commit 37caec2d5e
15 changed files with 31 additions and 22 deletions

View File

@ -2,6 +2,8 @@
RAM_ROOT=/tmp/root RAM_ROOT=/tmp/root
export BACKUP_FILE=sysupgrade.tgz # file extracted by preinit
[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; } [ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
libs() { ldd $* 2>/dev/null | sed -r 's/(.* => )?(.*) .*/\2/'; } libs() { ldd $* 2>/dev/null | sed -r 's/(.* => )?(.*) .*/\2/'; }

View File

@ -109,7 +109,7 @@ nand_restore_config() {
rmdir /tmp/new_root rmdir /tmp/new_root
return 1 return 1
fi fi
mv "$1" "/tmp/new_root/sysupgrade.tgz" mv "$1" "/tmp/new_root/$BACKUP_FILE"
umount /tmp/new_root umount /tmp/new_root
sync sync
rmdir /tmp/new_root rmdir /tmp/new_root

View File

@ -4,13 +4,14 @@ BOOTPART=/dev/sda1
move_config() { move_config() {
. /lib/functions.sh . /lib/functions.sh
. /lib/upgrade/common.sh
case "$(board_name)" in case "$(board_name)" in
wd,mybooklive) wd,mybooklive)
if [ -b $BOOTPART ]; then if [ -b $BOOTPART ]; then
mkdir -p /boot mkdir -p /boot
mount -t ext4 -o rw,noatime $BOOTPART /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 fi
;; ;;
*) *)

View File

@ -1,6 +1,8 @@
#!/bin/sh #!/bin/sh
# Copyright (C) 2015 OpenWrt.org # Copyright (C) 2015 OpenWrt.org
. /lib/upgrade/common.sh
BOOTPART=/dev/mmcblk0p1 BOOTPART=/dev/mmcblk0p1
move_config() { move_config() {
@ -11,7 +13,7 @@ move_config() {
insmod vfat insmod vfat
mkdir -p /boot mkdir -p /boot
mount -t vfat -o rw,noatime $BOOTPART /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 fi
} }

View File

@ -2,6 +2,7 @@
. /lib/imx6.sh . /lib/imx6.sh
. /lib/functions.sh . /lib/functions.sh
. /lib/upgrade/common.sh
move_config() { move_config() {
local board=$(board_name) local board=$(board_name)
@ -10,7 +11,7 @@ move_config() {
apalis*) apalis*)
if [ -b $(bootpart_from_uuid) ]; then if [ -b $(bootpart_from_uuid) ]; then
apalis_mount_boot apalis_mount_boot
[ -f /boot/sysupgrade.tgz ] && mv -f /boot/sysupgrade.tgz / [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
umount /boot umount /boot
fi fi
;; ;;

View File

@ -60,7 +60,7 @@ zyxel_do_flash() {
mkdir /tmp/new_root mkdir /tmp/new_root
mount -t ext4 $loopdev /tmp/new_root && { mount -t ext4 $loopdev /tmp/new_root && {
echo "Saving config to rootfs_data at position ${offset}." 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 umount /tmp/new_root
} }

View File

@ -1,6 +1,8 @@
#!/bin/sh #!/bin/sh
# Copyright (C) 2015 OpenWrt.org # Copyright (C) 2015 OpenWrt.org
. /lib/upgrade/common.sh
RECOVERY_PART=/dev/mmcblk0p1 RECOVERY_PART=/dev/mmcblk0p1
move_config() { move_config() {
@ -11,7 +13,7 @@ move_config() {
insmod vfat insmod vfat
mkdir -p /recovery mkdir -p /recovery
mount -o rw,noatime $RECOVERY_PART /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 umount /recovery
fi fi
} }

View File

@ -18,7 +18,7 @@ move_config() {
esac esac
mkdir -p /boot mkdir -p /boot
mount -o rw,noatime "/dev/$partdev" /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 umount /boot
fi fi
} }

View File

@ -4,8 +4,8 @@
# #
preinit_mount_syscfg() { preinit_mount_syscfg() {
. /lib/functions.sh . /lib/functions.sh
. /lib/upgrade/common.sh
case $(board_name) in case $(board_name) in
linksys,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom) linksys,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom)
@ -22,12 +22,12 @@ preinit_mount_syscfg() {
fi fi
mkdir /tmp/syscfg mkdir /tmp/syscfg
mount -t ubifs ubi1:syscfg /tmp/syscfg mount -t ubifs ubi1:syscfg /tmp/syscfg
[ -f /tmp/syscfg/sysupgrade.tgz ] && { [ -f "/tmp/syscfg/$BACKUP_FILE" ] && {
echo "- config restore -" echo "- config restore -"
cd / cd /
mv /tmp/syscfg/sysupgrade.tgz /tmp mv "/tmp/syscfg/$BACKUP_FILE" /tmp
tar xzf /tmp/sysupgrade.tgz tar xzf "/tmp/$BACKUP_FILE"
rm -f /tmp/sysupgrade.tgz rm -f "/tmp/$BACKUP_FILE"
sync sync
} }
;; ;;

View File

@ -93,6 +93,6 @@ platform_do_upgrade_linksys() {
} }
platform_copy_config_linksys() { platform_copy_config_linksys() {
cp -f /tmp/sysupgrade.tgz /tmp/syscfg/sysupgrade.tgz cp -f "$CONF_TAR" /tmp/syscfg/
sync sync
} }

View File

@ -3,11 +3,12 @@
move_config() { move_config() {
. /lib/functions.sh . /lib/functions.sh
. /lib/upgrade/common.sh
case "$(board_name)" in case "$(board_name)" in
erlite) erlite)
mount -t vfat /dev/sda1 /mnt 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 umount /mnt
;; ;;
esac esac

View File

@ -8,8 +8,8 @@ move_config() {
if export_bootdevice && export_partdevice partdev 1; then if export_bootdevice && export_partdevice partdev 1; then
if mount -t vfat -o rw,noatime "/dev/$partdev" /mnt; then if mount -t vfat -o rw,noatime "/dev/$partdev" /mnt; then
if [ -f /mnt/sysupgrade.tgz ]; then if [ -f "/mnt/$BACKUP_FILE" ]; then
mv -f /mnt/sysupgrade.tgz / mv -f "/mnt/$BACKUP_FILE" /
fi fi
umount /mnt umount /mnt
fi fi

View File

@ -8,8 +8,8 @@ move_config() {
if export_bootdevice && export_partdevice partdev 1; then if export_bootdevice && export_partdevice partdev 1; then
if mount -t vfat -o rw,noatime "/dev/$partdev" /mnt; then if mount -t vfat -o rw,noatime "/dev/$partdev" /mnt; then
if [ -f /mnt/sysupgrade.tgz ]; then if [ -f "/mnt/$BACKUP_FILE" ]; then
mv -f /mnt/sysupgrade.tgz / mv -f "/mnt/$BACKUP_FILE" /
fi fi
umount /mnt umount /mnt
fi fi

View File

@ -8,9 +8,9 @@ move_config() {
if export_bootdevice && export_partdevice partdev 1; then if export_bootdevice && export_partdevice partdev 1; then
mkdir -p /boot mkdir -p /boot
if mount -o ro,noatime "/dev/$partdev" /boot; then 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 mount /boot -o remount,rw,noatime
mv -f /boot/sysupgrade.tgz / mv -f "/boot/$BACKUP_FILE" /
fi fi
umount /boot umount /boot
rm -fR /boot rm -fR /boot

View File

@ -9,8 +9,8 @@ move_config() {
if export_bootdevice && export_partdevice partdev 1; then if export_bootdevice && export_partdevice partdev 1; then
mkdir -p /boot mkdir -p /boot
mount -t ext4 -o rw,noatime "/dev/$partdev" /boot mount -t ext4 -o rw,noatime "/dev/$partdev" /boot
if [ -f /boot/sysupgrade.tgz ]; then if [ -f "/boot/$BACKUP_FILE" ]; then
mv -f /boot/sysupgrade.tgz / mv -f "/boot/$BACKUP_FILE" /
fi fi
mount --bind /boot/boot /boot mount --bind /boot/boot /boot
fi fi