- if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
- # get partitions table from boot device
- get_partitions "/dev/$diskdev" bootdisk
-
- # get partitions table from sysupgrade.bin
- dd if="$1" of=/tmp/image.bs bs=512b count=1 > /dev/null 2>&1
- sync
- get_partitions /tmp/image.bs image
-
- # compare tables
- diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
- else
- diff=1
- fi
-
- if [ -n "$diff" ]; then
- dd if="$1" of="/dev/$diskdev" bs=1024 count=4 > /dev/null 2>&1
- echo "Writing image to /dev/$diskdev..."
- dd if="$1" of="/dev/$diskdev" bs=1024 skip=15360 seek=15360 > /dev/null 2>&1
- sync
-
- # Separate removal and addtion is necessary; otherwise, partition 1
- # will be missing if it overlaps with the old partition 2
- partx -d - "/dev/$diskdev"
- partx -a - "/dev/$diskdev"
-
- return 0
+ if export_partdevice partdev 1; then
+ mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt 2>&1
+ echo "Writing kernel..."
+ tar xf $tar_file ${board_dir}/kernel -O > /mnt/fitImage
+ umount /mnt