From: Mateusz Moscicki Date: Fri, 9 Feb 2024 12:03:26 +0000 (+0100) Subject: Use blkid-print from delta file during OS Upgrade X-Git-Tag: accepted/tizen/unified/20240214.163949~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec9e035aa15b4cc06adfde1059e346b7f556c6d0;p=platform%2Fcore%2Fsystem%2Fupgrade.git Use blkid-print from delta file during OS Upgrade 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 --- diff --git a/scripts/upgrade-support/upgrade-common.inc b/scripts/upgrade-support/upgrade-common.inc index 229ac6b..98cad56 100644 --- a/scripts/upgrade-support/upgrade-common.inc +++ b/scripts/upgrade-support/upgrade-common.inc @@ -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 diff --git a/scripts/upgrade-support/upgrade-partial.sh b/scripts/upgrade-support/upgrade-partial.sh index 2bcb6ca..258673f 100755 --- a/scripts/upgrade-support/upgrade-partial.sh +++ b/scripts/upgrade-support/upgrade-partial.sh @@ -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 diff --git a/scripts/upgrade-support/upgrade-prepare-partitions.sh b/scripts/upgrade-support/upgrade-prepare-partitions.sh index 0b0761a..1c23c8a 100755 --- a/scripts/upgrade-support/upgrade-prepare-partitions.sh +++ b/scripts/upgrade-support/upgrade-prepare-partitions.sh @@ -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 diff --git a/scripts/upgrade-support/upgrade-trigger.sh b/scripts/upgrade-support/upgrade-trigger.sh index 638e8af..656e0d8 100644 --- a/scripts/upgrade-support/upgrade-trigger.sh +++ b/scripts/upgrade-support/upgrade-trigger.sh @@ -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"