Fixed sdk uuid setting during install [SPEC-1377]
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 4 Apr 2018 19:11:07 +0000 (21:11 +0200)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 4 Apr 2018 23:30:31 +0000 (01:30 +0200)
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
lib/xdsserver/sdk.go
scripts/sdks/agl/add
scripts/sdks/agl/db-update
scripts/sdks/agl/get-sdk-info

index c1bf043..7c912c4 100644 (file)
@@ -329,6 +329,7 @@ func (s *CrossSDK) Install(file string, force bool, timeout int, args []string,
                        if s.sdk.SetupFile == "" {
                                sdkDef, err := GetSDKInfo(s.sdk.FamilyConf.ScriptsDir, s.sdk.URL, "", "", s.Log)
                                if err != nil || sdkDef.SetupFile == "" {
+                                       s.Log.Errorf("GetSDKInfo error: %v", err)
                                        code = 1
                                        s.sdk.LastError = "Installation failed (cannot init SetupFile path)"
                                        s.sdk.Status = xsapiv1.SdkStatusNotInstalled
index 80a0487..839d647 100755 (executable)
@@ -29,6 +29,7 @@ TMPDIR=""
 SDK_FILE=""
 URL=""
 DEBUG_OPT=""
+UUID=""
 do_cleanup=true
 do_force=false
 while [ $# -ne 0 ]; do
@@ -48,6 +49,10 @@ while [ $# -ne 0 ]; do
             shift
             URL=$1
             ;;
+        --uuid)
+            shift
+            UUID=$1
+            ;;
         -no-clean)
             do_cleanup=false
             ;;
@@ -85,8 +90,16 @@ if [ "$URL" != "" ]; then
     wget --no-check-certificate "$URL" -O "${SDK_FILE}" || exit 1
 fi
 
+# Compute uuid when needed
+if [ "$UUID" = "" ] && [ "$URL" != "" ]; then
+    UUID=$(echo "$URL" | md5sum |cut -d' ' -f1)
+else
+    echo "UUID value must be specify using --uuid option."
+    exit 1
+fi
+
 # Retreive SDK info
-sdkNfo=$(${SCRIPTS_DIR}/get-sdk-info --file "${SDK_FILE}")
+sdkNfo=$(${SCRIPTS_DIR}/get-sdk-info --file "${SDK_FILE}" --uuid "${UUID}")
 if [ "$?" != "0" ]; then
     echo "$sdkNfo"
     exit 1
index 7ebd928..a1f949e 100755 (executable)
@@ -34,18 +34,18 @@ OnExit ()
     fi
 }
 
-# Backup previous file
-[ -f "${sdksDBFile}" ] && mv "${sdksDBFile}" "${sdksDBFile}.old"
-
 # Create destination directory when needed
 instDir=$(dirname "${sdksDBFile}")
 [ ! -d "${instDir}" ] && mkdir -p "${instDir}"
 
 # Get database
 echo "Updating AGL SDK database..."
-wget --no-verbose --connect-timeout=30 "${SDK_DATABASE}" -O "${sdksDBFile}"
-exitCode=$?
+wget --no-verbose --connect-timeout=30 "${SDK_DATABASE}" -O "${sdksDBFile}.new" || exit $?
+
+# Backup previous file
+[ -f "${sdksDBFile}" ] && cp -f "${sdksDBFile}" "${sdksDBFile}.old"
 
-[ "${exitCode}" = "0" ] && echo "Done: AGL SDK database is up-to-date"
+mv --update "${sdksDBFile}.new" "${sdksDBFile}"
+[ -f "${sdksDBFile}.new" ] && rm -f "${sdksDBFile}.new"
 
-exit $exitCode
+echo "Done: AGL SDK database is up-to-date"
index 8840bf0..c28f2e4 100755 (executable)
@@ -27,6 +27,7 @@ usage() {
 SDK_FILE=""
 MD5VAL=""
 URL=""
+UUID=""
 
 while [ $# -ne 0 ]; do
     case $1 in
@@ -45,6 +46,10 @@ while [ $# -ne 0 ]; do
             shift
             URL=$1
             ;;
+        --uuid)
+            shift
+            UUID=$1
+            ;;
         *)
             echo "Invalid argument: $1"
             usage
@@ -113,15 +118,25 @@ fi
 profile=$(echo "${filename}" | sed -r 's/(.*)-glibc.*/\1/')
 version=$(echo "${filename}" | sed -r 's/.*toolchain-(.*).sh/\1/')
 arch=$(echo "${filename}" | sed -r 's/.*crosssdk-(.*)-toolchain.*/\1/')
+installPath=${SDK_ROOT_DIR}/${profile}/${version}/${arch}
 
 [ "${profile}" = "" ] && { echo "profile not set"; exit 7; }
 [ "${version}" = "" ] && { echo "version not set"; exit 8; }
 [ "${arch}" = "" ] && { echo " arch not set"; exit 9; }
 
 # Define a unique ID to be able to distinguish for example corei7-64 from qemux86-64
-uuid=$(echo "${sdkUrl}" | md5sum |cut -d' ' -f1)
-
-installPath=${SDK_ROOT_DIR}/${profile}/${version}/${arch}/${uuid}
+if [ "${UUID}" = "" ]; then
+    curInstDir=$(ls -d "${installPath}/*" 2> /dev/null)
+    if [ -d "${curInstDir}" ]; then
+        UUID="basename ${curInstDir}"
+    elif [ "$URL" != "" ]; then
+        UUID=$(echo "$URL" | md5sum |cut -d' ' -f1)
+    else
+        echo "UUID value must be specify using --uuid option."
+        exit 1
+    fi
+fi
+installPath="${installPath}/${UUID}"
 
 status="Not Installed"
 if [ -d "${installPath}" ]; then