base-files: improve lib/upgrade/common.sh
[openwrt/staging/hauke.git] / target / linux / sunxi / base-files / lib / upgrade / platform.sh
index 88ef4790e9c1452f8ce57fe1c265ce47810830ee..abe910b154c7de928687abde7707ee58da8d59d5 100644 (file)
@@ -1,7 +1,7 @@
 platform_check_image() {
        local diskdev partdev diff
 
-       export_bootdevice && export_partdevice diskdev -2 || {
+       export_bootdevice && export_partdevice diskdev 0 || {
                echo "Unable to determine upgrade device"
                return 1
        }
@@ -28,7 +28,7 @@ platform_check_image() {
 platform_copy_config() {
        local partdev
 
-       if export_partdevice partdev -1; then
+       if export_partdevice partdev 1; then
                mount -t vfat -o rw,noatime "/dev/$partdev" /mnt
                cp -af "$CONF_TAR" /mnt/
                umount /mnt
@@ -38,7 +38,7 @@ platform_copy_config() {
 platform_do_upgrade() {
        local diskdev partdev diff
 
-       export_bootdevice && export_partdevice diskdev -2 || {
+       export_bootdevice && export_partdevice diskdev 0 || {
                echo "Unable to determine upgrade device"
                return 1
        }
@@ -74,7 +74,6 @@ platform_do_upgrade() {
        get_image "$@" | dd of="$diskdev" bs=1024 skip=8 seek=8 count=1016 conv=fsync
        #iterate over each partition from the image and write it to the boot disk
        while read part start size; do
-               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