Update package with some binaries extracted from image
authorSunmin Lee <sunm.lee@samsung.com>
Mon, 4 Sep 2017 03:30:09 +0000 (12:30 +0900)
committerSunmin Lee <sunm.lee@samsung.com>
Mon, 4 Sep 2017 04:51:47 +0000 (13:51 +0900)
Some binaries which is necessary for upgrade have to be extracted
from image of new version. This patch implements file extracting
function for this reason.

Change-Id: Iecf9598e169bb307d7ec5c02e6deea3ae7d1714b
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
mk_delta/common/bin/mk_delta.sh
mk_delta/common/bin/mk_part_delta.sh
scripts/delta-generation.sh
scripts/upgrade-automation.sh

index a19d894..22d7939 100755 (executable)
@@ -178,6 +178,7 @@ fn_set_default_params()
        PART_CFG_PATH=./cfg/default_part.cfg
        UPDATE_CFG_PATH=./cfg/update.cfg
        DELTA_UA=./data/delta.ua
+       UPDATE_MANAGER=./data/upgrade-trigger.sh
 
        LOG_PATH=./data/Delta.log
        # Getting date and minor version
@@ -356,6 +357,12 @@ do
                sudo rm ${DELTA_UA}
        fi
 
+       #--- move update manager script to delta directory ---
+       if [ -r ${UPDATE_MANAGER} ]; then
+               sudo cp ${UPDATE_MANAGER} ${DELTA_DIR}/upgrade-trigger.sh
+               sudo rm ${UPDATE_MANAGER}
+       fi
+
        #--- archive result directory ---
        cd result/$MONDATE
        echo "tar result directory"
index a4d4189..fb0bc18 100755 (executable)
@@ -450,39 +450,42 @@ fn_get_tar_file_names()
 
 #------------------------------------------------------------------------------
 # Function :
-#      extract_delta_ua
+#      extract_from_image
 #
 # Description :
-#      extract delta binary (delta.ua) from given image
+#      extract some file from given image
 #
 
-fn_extract_delta_ua()
+fn_extract_from_image()
 {
+       IMAGE=$1
+       TARGET_FILE=$2
        MNT_PNT=${PART_NAME}_MNT
        mkdir -p ${MNT_PNT}
 
-       tar xvf ${DATA_DIR}/${NEW_TAR_DIR}/${NEW_TAR_FILE} $1
+       tar xvf ${DATA_DIR}/${NEW_TAR_DIR}/${NEW_TAR_FILE} ${IMAGE}
        if [ "$?" != "0" ]; then
                return 1;
        fi
 
-       sudo mount -t ext4 -o loop $1 ${MNT_PNT}
+       sudo mount -t ext4 -o loop ${IMAGE} ${MNT_PNT}
        if [ "$?" != "0" ]; then
                return 1;
        fi
 
-       DELTA_UA="${MNT_PNT}/usr/bin/delta.ua"
-       if [ -e ${DELTA_UA} ]; then
-               sudo cp ${DELTA_UA} ${DATA_DIR}/delta.ua
+       EXTRACT_FILE="${MNT_PNT}${TARGET_FILE}"
+       if [ -e ${EXTRACT_FILE} ]; then
+               sudo cp ${EXTRACT_FILE} ${DATA_DIR}
        else
-               echo "There is no delta.ua in $1"
+               echo "There is no ${TARGET_FILE} in ${IMAGE}"
        fi
 
        sudo umount ${MNT_PNT}
        sudo rm -rf ${MNT_PNT}
-       sudo rm -f $1
+       sudo rm -f ${IMAGE}
 }
 
+
 ###############################################################################
 #==================
 # Main Start
@@ -544,7 +547,9 @@ NEW_TAR_FILE=
 fn_get_tar_file_names ${PART_BIN}
 
 if [ "${PART_NAME}" = "RAMDISK2" ]; then
-       fn_extract_delta_ua ${PART_BIN}
+       fn_extract_from_image ${PART_BIN} /usr/bin/delta.ua
+elif [ "${PART_NAME}" = "ROOTFS" ]; then
+       fn_extract_from_image ${PART_BIN} /usr/bin/upgrade-trigger.sh
 fi
 
 OLD_TAR_MISSING=
index 2d556a9..b9f7af1 100755 (executable)
@@ -8,6 +8,15 @@
 #  * diff binary and libraries:
 #   ss_bsdiff, lib7zip, libdivsufsort
 #
+# Upgrade procedure
+#  1. Download images (old, new)
+#  2. Download old image to target
+#  3. Generate delta
+#  4. Download delta to target
+#  5. Execute upgrade trigger
+#
+# This script covers step 3
+#
 #---------------------------------------------------------#
 
 # Get argument
index 11e56fe..a3e814e 100755 (executable)
@@ -30,9 +30,14 @@ TOTA_UPG_PATH=$1
 TARGET=$2
 TOTA_UPG_TARGET=${TOTA_UPG_PATH}/mk_delta/${TARGET}
 
+TOTA_DIR=/opt/usr/data/fota
+sdb root on
+sdb -d shell mkdir -p ${TOTA_DIR}
+
 #  4. Download delta to target
 DELTA_DIR=$(ls -1d ${TOTA_UPG_TARGET}/result/* | tail -1)
 sdb -d push ${DELTA_DIR}/FW_DELTA/delta.tar ${TOTA_DIR}
 
-#  5. Execute upgrade trigger
-sdb -d shell /usr/bin/upgrade-trigger-${TARGET}.sh ${TOTA_DIR}/delta.tar
+#  5. Execute upgrade manager
+sdb -d shell tar xvfp ${TOTA_DIR}/delta.tar -C ${TOTA_DIR} upgrade-trigger.sh
+sdb -d shell ${TOTA_DIR}/upgrade-trigger.sh ${TOTA_DIR}/delta.tar