From 607fa1dcb03e482415cf70a50fcd094c8bd88c9d Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Wed, 4 Apr 2018 21:11:07 +0200 Subject: [PATCH] Fixed sdk uuid setting during install [SPEC-1377] Signed-off-by: Sebastien Douheret --- lib/xdsserver/sdk.go | 1 + scripts/sdks/agl/add | 15 ++++++++++++++- scripts/sdks/agl/db-update | 14 +++++++------- scripts/sdks/agl/get-sdk-info | 21 ++++++++++++++++++--- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/lib/xdsserver/sdk.go b/lib/xdsserver/sdk.go index c1bf043..7c912c4 100644 --- a/lib/xdsserver/sdk.go +++ b/lib/xdsserver/sdk.go @@ -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 diff --git a/scripts/sdks/agl/add b/scripts/sdks/agl/add index 80a0487..839d647 100755 --- a/scripts/sdks/agl/add +++ b/scripts/sdks/agl/add @@ -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 diff --git a/scripts/sdks/agl/db-update b/scripts/sdks/agl/db-update index 7ebd928..a1f949e 100755 --- a/scripts/sdks/agl/db-update +++ b/scripts/sdks/agl/db-update @@ -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" diff --git a/scripts/sdks/agl/get-sdk-info b/scripts/sdks/agl/get-sdk-info index 8840bf0..c28f2e4 100755 --- a/scripts/sdks/agl/get-sdk-info +++ b/scripts/sdks/agl/get-sdk-info @@ -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 -- 2.16.6