Simplify the invocation of partition cloning 24/276724/1
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 23 Jun 2022 10:18:07 +0000 (12:18 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 23 Jun 2022 10:18:07 +0000 (12:18 +0200)
Change-Id: I15dcced02fd0d9f468616212e7715ce4e18a202f

clone_partitions/clone_partitions.sh
scripts/upgrade-common.inc
scripts/upgrade-prepare-partitions.sh

index 1d6630f..5519009 100644 (file)
@@ -30,15 +30,19 @@ log() {
 }
 
 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(){
index 422f88a..82854f7 100644 (file)
@@ -119,7 +119,7 @@ background_copy() {
                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"
@@ -129,6 +129,7 @@ background_copy() {
                /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() {
index d7dc786..a50cb06 100755 (executable)
@@ -11,11 +11,7 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
 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"
@@ -42,5 +38,7 @@ cleanup_files() {
 check_ab_partition_scheme
 check_used_block_device
 load_background_copy_list
-background_copy
+if ! background_copy; then
+       exit_error
+fi
 cleanup_files