Support specifying target for multi device env.
authorSunmin Lee <sunm.lee@samsung.com>
Thu, 2 Nov 2017 00:42:27 +0000 (09:42 +0900)
committerSunmin Lee <sunm.lee@samsung.com>
Thu, 2 Nov 2017 00:55:33 +0000 (09:55 +0900)
Make upgrade-automation script use serial option of sdb
in order to support multi device connected environment.

Change-Id: Iebc5ae247df97e4f27feccb3a339addb6ded6261
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
scripts/upgrade-automation.sh

index 82b43d5..b18302a 100755 (executable)
 
 # Get argument
 if [ $# -lt 1 ]; then
-       echo "Usage: upgrade-automation.sh UPDATE_PACKAGE"
+       echo "Usage: upgrade-automation.sh UPDATE_PACKAGE [SERIAL]"
        exit
+elif [ $# -lt 2 ]; then
+       # Connect to first device if there is no SERIAL argument
+       DEVS=$(sdb devices)
+       DEV1=$(echo "$DEVS" | tail -n -1 | head -n 1)
+       SERIAL=$(echo "$DEV1" | awk '{print $1}')
+else
+       SERIAL=$2
 fi
 
 UPKG=$1
 
 TOTA_DIR=/opt/usr/data/fota
-sdb root on
-sdb shell mkdir -p ${TOTA_DIR}
+sdb -s ${SERIAL} root on
+sdb -s ${SERIAL} shell mkdir -p ${TOTA_DIR}
 
 #  4. Download delta to target
-sdb push ${UPKG} ${TOTA_DIR}/delta.tar
+sdb -s ${SERIAL} push ${UPKG} ${TOTA_DIR}/delta.tar
 
 #  5. Execute upgrade manager
-sdb shell tar xvfp ${TOTA_DIR}/delta.tar -C ${TOTA_DIR} upgrade-trigger.sh
-sdb shell ${TOTA_DIR}/upgrade-trigger.sh ${TOTA_DIR}/delta.tar
+sdb -s ${SERIAL} shell tar xvfp ${TOTA_DIR}/delta.tar -C ${TOTA_DIR} upgrade-trigger.sh
+sdb -s ${SERIAL} shell ${TOTA_DIR}/upgrade-trigger.sh ${TOTA_DIR}/delta.tar