echo "$LOG"
}
+do_clone() {
+ if /usr/libexec/upgrade-support/upgrade-prepare-partitions.sh; then
+ log "[Info] Partitions have been cloned"
+ device_board_set_partition_ab_cloned
+ else
+ critical_log "[Error] Partitions have not been cloned"
+ exit 1
+ fi
+
+ return 0
+}
+
+set_partition_status_ok(){
+ CURRENT_AB=$(device_board_get_current_partition)
+
+ if [ "$CURRENT_AB" == "a" ]; then
+ OPPOSITE_AB="b"
+ elif [ "$CURRENT_AB" == "b" ]; then
+ OPPOSITE_AB="a"
+ else
+ exit 1
+ fi
+
+ device_board_set_partition_status $OPPOSITE_AB "ok"
+}
+
set -o errexit
trap 'echo "Aborting due to errexit on ${0##*/}:$LINENO. Exit code: $?" >&2' ERR
set -o errtrace -e -o pipefail
set -x
fi
-if [ "$(device_board_get_partition_ab_cloned)" -eq "1" ]; then
- log "[Info] Partitions already cloned"
- exit 0
-fi
-
-if /usr/libexec/upgrade-support/upgrade-prepare-partitions.sh; then
- log "[Info] Partitions have been cloned"
- device_board_set_partition_ab_cloned
-else
- critical_log "[Error] Partitions have not been cloned"
-fi
+case $1 in
+ "recovery")
+ /bin/device_board_clear_partition_ab_cloned
+ do_clone
+ set_partition_status_ok
+ ;;
+ *)
+ do_clone
+ ;;
+esac
[ ! -z "${AB_SLOT}" ]
}
-check_update_type() {
+do_update() {
+ device_board_clear_partition_ab_cloned
+
if is_ab_upgrade; then
if is_full_upgrade; then
# If the update.cfg file contains only PRE_UA type updates, we consider
set_upgrade_status 1
verify_img "${DOWNLOAD_DELTA}"
-check_update_type
+do_update