treewide: adjust sysupgrade script
This commit is contained in:
parent
787d71db74
commit
715404f8e1
@ -11,7 +11,7 @@ REQUIRE_IMAGE_METADATA=1
|
||||
platform_check_image_sdboot() {
|
||||
local diskdev partdev diff
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
export_bootdevice && export_partdevice diskdev -2 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
@ -38,12 +38,12 @@ platform_check_image_sdboot() {
|
||||
platform_do_upgrade_sdboot() {
|
||||
local diskdev partdev diff
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
export_bootdevice && export_partdevice diskdev -2 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
|
||||
if [ "$SAVE_PARTITIONS" = "1" ]; then
|
||||
# get partitions table from boot device
|
||||
get_partitions "/dev/$diskdev" bootdisk
|
||||
|
||||
@ -77,6 +77,10 @@ platform_do_upgrade_sdboot() {
|
||||
|
||||
# iterate over each partition from the image and write it to the boot disk
|
||||
while read part start size; do
|
||||
# root is /dev/sd[a|b]2 and not /dev/sd[a|b] this causes some problem
|
||||
# one of which is this offset, I'm not sure what's the best fix, so
|
||||
# here's a WA.
|
||||
let part=$((part - 2))
|
||||
if export_partdevice partdev $part; then
|
||||
echo "Writing image to /dev/$partdev..."
|
||||
dd if="$1" of="/dev/$partdev" bs=512 skip="$start" count="$size" > /dev/null 2>&1
|
||||
@ -107,7 +111,8 @@ platform_do_upgrade_traverse_nandubi() {
|
||||
platform_copy_config() {
|
||||
local partdev parttype=ext4
|
||||
|
||||
if export_partdevice partdev 1; then
|
||||
# Same as above /dev/sd[a|b]2 is root, so /boot is -1
|
||||
if export_partdevice partdev -1; then
|
||||
mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt
|
||||
cp -af "$CONF_TAR" "/mnt/$CONF_TAR"
|
||||
umount /mnt
|
||||
|
||||
@ -12,7 +12,7 @@ move_config() {
|
||||
insmod vfat
|
||||
mkdir -p /recovery
|
||||
mount -o rw,noatime $RECOVERY_PART /recovery
|
||||
[ -f "/recovery/$BACKUP_FILE" ] && mv -f "/recovery/$BACKUP_FILE" /
|
||||
[ -f "/recovery/$CONF_TAR" ] && mv -f "/recovery/$CONF_TAR" /
|
||||
umount /recovery
|
||||
fi
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ move_config() {
|
||||
insmod vfat
|
||||
mkdir -p /recovery
|
||||
mount -o rw,noatime "/dev/$partdev" -t vfat /recovery
|
||||
[ -f "/recovery/$BACKUP_FILE" ] && mv -f "/recovery/$BACKUP_FILE" /
|
||||
[ -f "/recovery/$CONF_TAR" ] && mv -f "/recovery/$CONF_TAR" /
|
||||
umount /recovery
|
||||
fi
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ platform_check_image_sdcard() {
|
||||
return 1
|
||||
}
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
export_bootdevice && export_partdevice diskdev -2 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
@ -42,7 +42,7 @@ platform_do_upgrade_sdcard() {
|
||||
local board=$(board_name)
|
||||
local diskdev partdev diff
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
export_bootdevice && export_partdevice diskdev -2 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
@ -75,6 +75,10 @@ platform_do_upgrade_sdcard() {
|
||||
get_image "$@" | dd of="$diskdev" bs=512 skip=1 seek=1 count=2048 conv=fsync
|
||||
#iterate over each partition from the image and write it to the boot disk
|
||||
while read part start size; do
|
||||
# root is /dev/sd[a|b]2 and not /dev/sd[a|b] this causes some problem
|
||||
# one of which is this offset, I'm not sure what's the best fix, so
|
||||
# here's a WA.
|
||||
let part=$((part - 2))
|
||||
if export_partdevice partdev $part; then
|
||||
echo "Writing image to /dev/$partdev..."
|
||||
get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
|
||||
@ -103,7 +107,8 @@ platform_do_upgrade_sdcard() {
|
||||
platform_copy_config_sdcard() {
|
||||
local partdev
|
||||
|
||||
if export_partdevice partdev 1; then
|
||||
# Same as above /dev/sd[a|b]2 is root, so /boot is -1
|
||||
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/
|
||||
|
||||
@ -27,12 +27,12 @@ preinit_mount_syscfg() {
|
||||
fi
|
||||
mkdir /tmp/syscfg
|
||||
mount -t ubifs ubi1:syscfg /tmp/syscfg
|
||||
[ -f "/tmp/syscfg/$BACKUP_FILE" ] && {
|
||||
[ -f "/tmp/syscfg/$CONF_TAR" ] && {
|
||||
echo "- config restore -"
|
||||
cd /
|
||||
mv "/tmp/syscfg/$BACKUP_FILE" /tmp
|
||||
tar xzf "/tmp/$BACKUP_FILE"
|
||||
rm -f "/tmp/$BACKUP_FILE"
|
||||
mv "/tmp/syscfg/$CONF_TAR" /tmp
|
||||
tar xzf "/tmp/$CONF_TAR"
|
||||
rm -f "/tmp/$CONF_TAR"
|
||||
sync
|
||||
}
|
||||
;;
|
||||
|
||||
@ -3,10 +3,10 @@ move_config() {
|
||||
|
||||
. /lib/upgrade/common.sh
|
||||
|
||||
if export_bootdevice && export_partdevice partdev 1; then
|
||||
if export_bootdevice && export_partdevice partdev -1; then
|
||||
if mount -o rw,noatime "/dev/$partdev" /mnt; then
|
||||
if [ -f "/mnt/$BACKUP_FILE" ]; then
|
||||
mv -f "/mnt/$BACKUP_FILE" /
|
||||
if [ -f "/mnt/$CONF_TAR" ]; then
|
||||
mv -f "/mnt/$CONF_TAR" /
|
||||
fi
|
||||
umount /mnt
|
||||
fi
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
platform_check_image() {
|
||||
local diskdev partdev diff
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
export_bootdevice && export_partdevice diskdev -2 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
@ -28,7 +28,8 @@ platform_check_image() {
|
||||
platform_copy_config() {
|
||||
local partdev
|
||||
|
||||
if export_partdevice partdev 1; then
|
||||
# Same as above /dev/sd[a|b]2 is root, so /boot is -1
|
||||
if export_partdevice partdev -1; then
|
||||
mount -o rw,noatime "/dev/$partdev" /mnt
|
||||
cp -af "$CONF_TAR" "/mnt/$CONF_TAR"
|
||||
umount /mnt
|
||||
@ -38,14 +39,14 @@ platform_copy_config() {
|
||||
platform_do_upgrade() {
|
||||
local diskdev partdev diff
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
export_bootdevice && export_partdevice diskdev -2 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
|
||||
sync
|
||||
|
||||
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
|
||||
if [ "$SAVE_PARTITIONS" = "1" ]; then
|
||||
get_partitions "/dev/$diskdev" bootdisk
|
||||
|
||||
#extract the boot sector from the image
|
||||
@ -72,6 +73,10 @@ platform_do_upgrade() {
|
||||
|
||||
#iterate over each partition from the image and write it to the boot disk
|
||||
while read part start size; do
|
||||
# root is /dev/sd[a|b]2 and not /dev/sd[a|b] this causes some problem
|
||||
# one of which is this offset, I'm not sure what's the best fix, so
|
||||
# here's a WA.
|
||||
let part=$((part - 2))
|
||||
if export_partdevice partdev $part; then
|
||||
echo "Writing image to /dev/$partdev..."
|
||||
get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
|
||||
|
||||
Loading…
Reference in New Issue
Block a user