}
do_clone() {
- if /usr/libexec/upgrade-support/upgrade-prepare-partitions.sh; then
- log "[Info] Partitions have been cloned"
+ . /usr/libexec/upgrade-support/upgrade-common.inc
+
+ check_ab_partition_scheme
+ check_used_block_device
+ load_background_copy_list
+ if background_copy; then
device_board_set_partition_ab_cloned
+ log "[Info] Partitions have been cloned"
+ return 0
else
critical_log "[Error] Partitions have not been cloned"
- exit 1
+ return 1
fi
-
- return 0
}
set_partition_status_ok(){
fi
if [ "$CURRENT_PARTITION" == "" ] || [ "$NEXT_PARTITION" = "" ]; then
flog "[Error] current: $CURRENT_PARTITION or next: $NEXT_PARTITION partition is empty on $EMMC_DEVICE device"
- exit_error
+ return $FALSE
fi
if [ "$CURRENT_PARTITION" == "$NEXT_PARTITION" ]; then
flog "[Info] $partition_name partition current and next are the same: $CURRENT_PARTITION on $EMMC_DEVICE device"
/bin/dd if="$CURRENT_PARTITION" of="$NEXT_PARTITION" bs=4096
flog "[Info] Finished background copy $partition_name from $CURRENT_PARTITION to $NEXT_PARTITION"
done
+ return $TRUE
}
load_background_copy_list() {
FOTA_DIR="/opt/usr/data/fota"
-if [ -r "${FOTA_DIR}/upgrade-common.inc" ]; then
- . "$FOTA_DIR"/upgrade-common.inc
-else
- . /usr/libexec/upgrade-support/upgrade-common.inc
-fi
+. "$FOTA_DIR"/upgrade-common.inc
SCRIPT_NAME="upgrade-prepare-partitions.sh"
LOG_FILE="/tmp/upgrade-prepare-partitions.log"
check_ab_partition_scheme
check_used_block_device
load_background_copy_list
-background_copy
+if ! background_copy; then
+ exit_error
+fi
cleanup_files