-#!/bin/sh
+#!/bin/bash
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
REBOOT="/sbin/reboot"
BLKID="/usr/sbin/blkid"
CP="/bin/cp"
+BOW_RESTORE="/sbin/bow-restore"
#------------------------------------------------
# mount_partitions
done
}
+#------------------------------------------------
+# restore_checkpoint
+#------------------------------------------------
+restore_checkpoint() {
+ # Any existing checkpoint means that the RW update was unexpectedly
+ # aborded, so we must roll back the changes and update again.
+ echo "Checkpoint restore"
+ PART="${1}"
+ FS_TYPE="$(blkid -o value -s TYPE "${PART}")"
+ if [ "$FS_TYPE" = "ext4" ]; then
+ "$BOW_RESTORE" "${PART}"
+ else
+ echo "Checkpoint restore error: unknown filesystem ${FS_TYPE} on ${PART}"
+ fi
+}
+
+#------------------------------------------------
+# restore_partitions
+#------------------------------------------------
+restore_partitions() {
+ echo "Restore partitions"
+ . /usr/libexec/upgrade-support/upgrade-common.inc
+ if [[ "${P_SLOT}" == "" ]]
+ then
+ # We have only one slot, so it is likely that rootfs also has
+ # a checkpoint
+ restore_checkpoint "${PART_ROOTFS}"
+ if [ ! "z${PART_HAL}" = "z" ]; then
+ restore_checkpoint "${PART_HAL}"
+ fi
+ fi
+ if [ ! "z${PART_USER}" = "z" ]; then
+ restore_checkpoint "${PART_USER}"
+ fi
+ if [ ! "z${PART_SYSTEM_DATA}" = "z" ]; then
+ restore_checkpoint "${PART_SYSTEM_DATA}"
+ fi
+}
+
#------------------------------------------------
# Main Routine Start
#------------------------------------------------
mount_partitions
mount_inform
+get_partition_id
+restore_partitions
copy_hal_data
cd /