Use blkid-print from delta file during OS Upgrade 60/305860/1
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 9 Feb 2024 12:03:26 +0000 (13:03 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 9 Feb 2024 13:44:21 +0000 (14:44 +0100)
During OS Upgrade we can not rely on the scripts and programs available
on the system, so from this point on, instead of using blkid-print that
is on the system, we use the one provided in the delta file.

Change-Id: I94d0a6dd86f229a4e53184d7ca300e6dcb03d6bb

scripts/upgrade-support/upgrade-common.inc
scripts/upgrade-support/upgrade-partial.sh
scripts/upgrade-support/upgrade-prepare-partitions.sh
scripts/upgrade-support/upgrade-trigger.sh

index 229ac6bb77ac76acbb2c59cedc9d07b446d20e42..98cad56e83f78eec958f80a4289720b090ffdb89 100644 (file)
@@ -10,6 +10,10 @@ TRUE=0
 FALSE=1
 SUPERFS=""
 
+if [ -z $BLKID_PRINT ]; then
+       BLKID_PRINT="/usr/bin/blkid-print"
+fi
+
 #------------------------------------------------
 #       critical_log msg [file]
 #------------------------------------------------
@@ -126,7 +130,7 @@ map_from_super() {
 }
 
 check_if_super() {
-       if SUPERFS="$(/usr/bin/blkid-print "$EMMC_DEVICE" super a)"; then
+       if SUPERFS="$("$BLKID_PRINT" "$EMMC_DEVICE" super a)"; then
                local MAPPED_DEVICES=""
                MAPPED_DEVICES=$(dmsetup ls)
 
@@ -178,13 +182,13 @@ background_copy() {
                        CURRENT_PARTITION="/dev/mapper/${partition_name}_${CURRENT_AB}"
                        NEXT_PARTITION="/dev/mapper/${partition_name}_${NEXT_AB}"
                else
-                       if ! CURRENT_PARTITION="$(/usr/bin/blkid-print "$EMMC_DEVICE" "$partition_name" "$CURRENT_AB")"; then
+                       if ! CURRENT_PARTITION="$("$BLKID_PRINT" "$EMMC_DEVICE" "$partition_name" "$CURRENT_AB")"; then
                                flog "[Error] Unable to find: $partition_name current partition on $EMMC_DEVICE device on $CURRENT_AB slot"
                                check_optional_partition "$partition_name" 1
                                continue
                        fi
 
-                       if ! NEXT_PARTITION="$(/usr/bin/blkid-print "$EMMC_DEVICE" "$partition_name" "$NEXT_AB")"; then
+                       if ! NEXT_PARTITION="$("$BLKID_PRINT" "$EMMC_DEVICE" "$partition_name" "$NEXT_AB")"; then
                                flog "[Error] Unable to find: $partition_name next partition on $EMMC_DEVICE device on $CURRENT_AB slot"
                                check_optional_partition "$partition_name" 1
                                continue
@@ -264,8 +268,8 @@ upgrade_images() {
                        NEXT_PARTITION="/dev/mapper/${PART_NAME}_${NEXT_AB}"
                        CURR_PARTITION="/dev/mapper/${PART_NAME}_${CURRENT_AB}"
                else
-                       NEXT_PARTITION="$(/usr/bin/blkid-print "$EMMC_DEVICE" "$PART_NAME" "$NEXT_AB")"
-                       CURR_PARTITION="$(/usr/bin/blkid-print "$EMMC_DEVICE" "$PART_NAME" "$CURRENT_AB")"
+                       NEXT_PARTITION="$("$BLKID_PRINT" "$EMMC_DEVICE" "$PART_NAME" "$NEXT_AB")"
+                       CURR_PARTITION="$("$BLKID_PRINT" "$EMMC_DEVICE" "$PART_NAME" "$CURRENT_AB")"
                fi
 
                flog "[Info] Flashing $DELTA_NAME... to $NEXT_PARTITION"
@@ -388,7 +392,7 @@ mount_partition() {
        local DST="$2"
        local MOUNT_OPTIONS="$3"
        local SRC
-       if ! SRC="$(/usr/bin/blkid-print "$EMMC_DEVICE" "$GPT_LABEL" "$NEXT_AB")"; then
+       if ! SRC="$("$BLKID_PRINT" "$EMMC_DEVICE" "$GPT_LABEL" "$NEXT_AB")"; then
                flog "[Error] Unable to find $GPT_LABEL partition on $EMMC_DEVICE device for $NEXT_AB slot"
                return 1
        fi
index 2bcb6ca0a3c6fbcf6c4874b5a6ddd7233fe07ddf..258673f7370cbbcccc1a4bf9024c56a01fcf3b54 100755 (executable)
@@ -51,6 +51,7 @@ unpack_file "$DELTA_TAR" "upgrade-apply"
 /bin/chmod +x "$FOTA_DIR/upgrade-apply"
 unpack_file "$DELTA_TAR" "upgrade-apply-deltafs"
 /bin/chmod +x "$FOTA_DIR/upgrade-apply-deltafs"
+BLKID_PRINT="$FOTA_DIR/blkid-print"
 if ! upgrade_images "$DELTA_TAR"; then
        critical_flog "[Error] Unable to upgrade_images"
        cleanup
index 0b0761a1d3519c391f71ba0ae0202f66e2cec4fb..1c23c8a99daa817f72ad52d1450451e25062a228 100755 (executable)
@@ -35,6 +35,7 @@ cleanup_files() {
 check_ab_partition_scheme
 check_used_block_device
 load_background_copy_list
+
 if ! background_copy; then
        exit_error
 fi
index 638e8aff6156b5af00a20f85ffdb2b7058b03605..656e0d8f55dd98894c8b83f5b41a431198bf881b 100644 (file)
@@ -17,8 +17,10 @@ LOG_FILE="/tmp/upgrade-trigger.log"
 SCRIPT_UPGRADE_PREPARE_PARTITIONS="upgrade-prepare-partitions.sh"
 SCRIPT_UPGRADE_PARTIAL="upgrade-partial.sh"
 SCRIPT_UPGRADE_FOTA="upgrade-fota.sh"
+BLKID_PRINT_FILE="blkid-print"
 FLOCK_PATH="/var/lock/clone_partitions.lock"
 DELTA_VERIFIER="/usr/bin/delta-verifier"
+export BLKID_PRINT="$FOTA_DIR/$BLKID_PRINT_FILE"
 
 prepare_fota_dir() {
        if [ -d "$FOTA_DIR" ]; then
@@ -64,6 +66,9 @@ do_update() {
        if is_ab_upgrade; then
                set_upgrade_status 5
 
+               unpack_file "${DOWNLOAD_DELTA}" "${BLKID_PRINT_FILE}"
+               chmod +x "$FOTA_DIR/$BLKID_PRINT_FILE"
+
                if [ "$(device_board_get_partition_ab_cloned)" -eq 0 ]; then
                        log "Starting to prepare the partitions for upgrade.." "$LOG_FILE"