3 # copied from x86's platform.sh
5 mbl_do_platform_check
() {
6 local diskdev partdev
diff
8 [ "$#" -gt 1 ] && return 1
10 export_bootdevice
&& export_partdevice diskdev
-2 ||
{
11 echo "Unable to determine upgrade device"
15 get_partitions
"/dev/$diskdev" bootdisk
17 #extract the boot sector from the image
18 get_image
"$@" |
dd of
=/tmp
/image.bs count
=1 bs
=512b
2>/dev
/null
20 get_partitions
/tmp
/image.bs image
23 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
25 rm -f /tmp
/image.bs
/tmp
/partmap.bootdisk
/tmp
/partmap.image
27 if [ -n "$diff" ]; then
28 echo "Partition layout has changed. Full image will be written."
29 ask_bool
0 "Abort" && exit 1
37 local diskdev partdev
diff
39 export_bootdevice
&& export_partdevice diskdev
-2 ||
{
40 echo "Unable to determine upgrade device"
46 if [ "$SAVE_PARTITIONS" = "1" ]; then
47 get_partitions
"/dev/$diskdev" bootdisk
49 #extract the boot sector from the image
50 get_image
"$@" |
dd of
=/tmp
/image.bs count
=1 bs
=512b
52 get_partitions
/tmp
/image.bs image
55 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
60 if [ -n "$diff" ]; then
61 get_image
"$@" |
dd of
="/dev/$diskdev" bs
=4096 conv
=fsync
63 # Separate removal and addtion is necessary; otherwise, partition 1
64 # will be missing if it overlaps with the old partition 2
65 partx
-d - "/dev/$diskdev"
66 partx
-a - "/dev/$diskdev"
71 #iterate over each partition from the image and write it to the boot disk
72 while read part start size
; do
73 # root is /dev/sd[a|b]2 and not /dev/sd[a|b] this causes some problem
74 # one of which is this offset, I'm not sure what's the best fix, so
76 let part
=$
((part
- 2))
77 if export_partdevice partdev
$part; then
78 echo "Writing image to /dev/$partdev..."
79 get_image
"$@" |
dd of
="/dev/$partdev" ibs
="512" obs
=1M skip
="$start" count
="$size" conv
=fsync
81 echo "Unable to find partition $part device, skipped."
83 done < /tmp
/partmap.image
86 echo "Writing new UUID to /dev/$diskdev..."
87 get_image
"$@" |
dd of
="/dev/$diskdev" bs
=1 skip
=440 count
=4 seek
=440 conv
=fsync
93 # Same as above /dev/sd[a|b]2 is root, so /boot is -1
94 if export_partdevice partdev
-1; then
95 mount
-t ext4
-o rw
,noatime
"/dev/$partdev" /mnt
96 cp -af "$CONF_TAR" /mnt
/