Use PARTLABEL based on LABEL from update.cfg and /hal/etc/upgrade/label_map.list 28/267528/2
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Mon, 6 Dec 2021 16:44:30 +0000 (17:44 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 9 Dec 2021 13:13:54 +0000 (14:13 +0100)
Change-Id: I25edbad79770baa298bd0f404e9ba0d1acc08eb3

scripts/upgrade-partial.sh

index 2acc604..212a7df 100644 (file)
@@ -8,6 +8,8 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin
 SCRIPT_NAME="upgrade-partial.sh"
 LOG_FILE="/tmp/upgrade-partial.log"
 FOTA_DIR="/opt/usr/data/fota"
+HAL_UPGRADE_CFG_DIR="/hal/etc/upgrade/"
+HAL_PART_MAP_FILE="label_map.list"
 
 untrap() {
        trap '' ERR
@@ -108,6 +110,11 @@ upgrade_images() {
        flog "[Info] Flash images for update..."
        CONFIG_FILE="update.cfg"
 
+       LABEL_MAP_PATH=${HAL_UPGRADE_CFG_DIR}/${HAL_}
+       while read LABEL PARTLABEL; do
+               declare "LABEL_MAP_${LABEL}=${PARTLABEL}"
+       done < <(grep -v -e "^#" -e "^#" ${LABEL_MAP_PATH}/${HAL_PART_MAP_FILE})
+
        /bin/tar xvfp "$DELTA_TAR" -C "$FOTA_DIR" "$CONFIG_FILE"
        if [ ! -e "$FOTA_DIR/$CONFIG_FILE" ]; then
                flog "[Error] There is no $CONFIG_FILE"
@@ -115,18 +122,23 @@ upgrade_images() {
        fi
        rm -f "$FOTA_DIR/delta.ua"
        # _OFFSET _SIZE _HASH1 _HASH2
-       while read -r PART_NAME DELTA_NAME TYPE DEV _ _ _ _
+       while read -r LABEL_NAME DELTA_NAME TYPE DEV _ _ _ _
        do
-               PART_NAME="$(echo "$PART_NAME" | /bin/awk '{print tolower($0)}')"
+               LABEL_NAME="$(echo "$LABEL_NAME" | /bin/awk '{print tolower($0)}')"
+
+               # Translate LABEL to PARTLABEL using label_map.list
+               TMP="LABEL_MAP_${LABEL_NAME}"
+               PART_NAME=${!TMP}
+               if [ -z "${PART_NAME}" ]; then
+                       PART_NAME=${LABEL_NAME}
+               fi
+
                if [ "$TYPE" == "PRE_UA" ]; then
                        /bin/tar xvfp "$DELTA_TAR" -C "$FOTA_DIR" "$DELTA_NAME"
                        if [ ! -e "$FOTA_DIR/$DELTA_NAME" ]; then
-                               flog "[Info] There is no delta $DELTA_NAME for $PART_NAME"
+                               flog "[Info] There is no delta $DELTA_NAME for label $LABEL_NAME from part $PART_NAME"
                                continue
                        fi
-                       if [ "$PART_NAME" == "ramdisk-recovery" ]; then
-                               PART_NAME="recovery"
-                       fi
 
                        NEXT_PARTITION="$(/usr/bin/blkid-print "$EMMC_DEVICE" "$PART_NAME" "$NEXT_AB" |\
                                /bin/sed -E 's|(part_nr: [0-9]+ )\((.*)\): (.*)|\3|')"