Allow scripts responsible for upgrading to work with upgrade-delta-fs binary 21/282221/2
authorAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Mon, 26 Sep 2022 13:04:56 +0000 (15:04 +0200)
committerAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Mon, 7 Nov 2022 10:02:48 +0000 (11:02 +0100)
Change-Id: I1dfe8f4cb9a9739c18e05cdb988ebe45ef0aaa86

scripts/upgrade-support/upgrade-common.inc
scripts/upgrade-support/upgrade-partial.sh
scripts/upgrade-support/upgrade-trigger.sh
src/upgrade-apply-deltafs/ua.c

index 57ea61f00549d0bfb60fb6eefd48bbc328dc49f4..88473fecf23298aef4947e3b62b29c4c890577d8 100644 (file)
@@ -57,7 +57,7 @@ retrap() {
 verify_file() {
        FILE_NAME="$1"
        FILE_PATH="$FOTA_DIR/$FILE_NAME"
-       VALID_CHECKSUM=$(awk "/$FILE_NAME/ {print \$1}" "$FOTA_DIR/checksum.SHA1")
+       VALID_CHECKSUM=$(awk "\$2 ~ /^$FILE_NAME\$/ {print \$1}" "$FOTA_DIR/checksum.SHA1")
        if [ "$VALID_CHECKSUM" == "" ]; then
                echo "[Error] No $FILE_NAME in checksum.SHA1"
                return $FALSE
@@ -199,8 +199,8 @@ upgrade_images() {
                fi
 
                TYPE_S=(${TYPE//:/ })
-               # We support only FULL_IMAGE  and DELTA_IMAGE
-               if [[ ! "${TYPE_S[0]}" =~ ^(FULL_IMAGE|DELTA_IMAGE)$ ]]; then
+               # We support only FULL_IMAGE, DELTA_IMAGE and DELTA_FS
+               if [[ ! "${TYPE_S[0]}" =~ ^(FULL_IMAGE|DELTA_IMAGE|DELTA_FS)$ ]]; then
                        PARTS_NAME_TO_UPDATE+=( "$PART_NAME:$TYPE" )
                        continue
                fi
@@ -237,6 +237,15 @@ upgrade_images() {
                                                          --patch-orig "$CURR_PARTITION" \
                                                          --dest-sha1 "$NEW_SHA" && UP_RES=$? || UP_RES=$?
                                ;;
+                       DELTA_FS)
+                               mkdir "$FOTA_DIR/partition_mnt"
+                               mount "$NEXT_PARTITION" "$FOTA_DIR/partition_mnt"
+                               "$FOTA_DIR/upgrade-apply-deltafs"   --archive "$DELTA_TAR" \
+                                                                   --dest "$FOTA_DIR/partition_mnt" \
+                                                                   --archive-file "${DELTA_NAME}/" && UP_RES=$? || UP_RES=$?
+                               umount "$NEXT_PARTITION"
+                               rm -rf "$FOTA_DIR/partition_mnt"
+                               ;;
                esac
                retrap
                case $UP_RES in
index ea6aa7d3291d2a0827792b60dd1d828a7e75540c..2bcb6ca0a3c6fbcf6c4874b5a6ddd7233fe07ddf 100755 (executable)
@@ -49,6 +49,8 @@ check_args "$@"
 unpack_file "$DELTA_TAR" "$CONFIG_FILE"
 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"
 if ! upgrade_images "$DELTA_TAR"; then
        critical_flog "[Error] Unable to upgrade_images"
        cleanup
index fedc98b4f9229639bca525e29963187936cfca47..4666a4534f1d61a09b6c47ed7522651ddbd4a612 100644 (file)
@@ -103,7 +103,7 @@ verify_file() {
        FILE_PATH="$1"
        FILE_NAME=$(basename "$FILE_PATH")
 
-       VALID_CHECKSUM=$(awk "/$FILE_NAME/ {print \$1}" "$FOTA_DIR/checksum.SHA1")
+       VALID_CHECKSUM=$(awk "\$2 ~ /^$FILE_NAME\$/ {print \$1}" "$FOTA_DIR/checksum.SHA1")
        if [ "$VALID_CHECKSUM" == "" ]; then
                echo "[Error] No $FILE_NAME in checksum.SHA1"
                device_board_set_upgrade_status -1
index c1409233a6c935f292fd67553ad192d5ed252440..726199c2cc264d41cd552292b823534dffe2cbfe 100755 (executable)
@@ -99,7 +99,7 @@ void print_usage(const char *msg)
        if (msg) {
                printf("%s\n", msg);
        }
-       printf("print_usage: upgrade-apply-deltafs --archive delta_path --dest directory --archive-file label.img\n"
+       printf("print_usage: upgrade-apply-deltafs --archive delta_path --dest directory --archive-file label.img/\n"
        "delta_path: filepath of delta (allowed file extensions: .tar, .tar.gz, .tgz)\n"
        "directory: directory where partition to be upgraded is mounted\n"
        "label.img: name of the directory inside of delta that is to be used during upgrade\n"
@@ -642,7 +642,11 @@ int check_dm_verity_status(void)
 int set_delta_folder(void)
 {
        char *pos = strrchr(delta_path, '/');
-       if ((pos == NULL) || ((pos - delta_path + 1) == strlen(delta_path))) {
+       if (pos == NULL) {
+               snprintf(delta_folder, MAX_FOLDER_PATH, ".", delta_path);       // if no "/" in delta path, assume current directory as delta folder
+               return 0;
+       }
+       if ((pos - delta_path + 1) == strlen(delta_path)) {
                print_usage("Invalid delta path");
                return -1;
        }