Added support of new image_url field 61/17361/1
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Mon, 22 Oct 2018 15:22:21 +0000 (17:22 +0200)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Mon, 22 Oct 2018 15:22:35 +0000 (17:22 +0200)
Since commit ecef0475a0a9d51, url to download AGL image matching a
SDK has been introduced in SDK definition file. This commit adds
ImageURL field (json:image_url) in return json object of GET /sdks

Change-Id: If52c39292ac3d5e44c4f61b8b51c48d9661beb2d
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
lib/xsapiv1/sdks.go
scripts/sdks/README.md
scripts/sdks/agl/db-dump
scripts/sdks/agl/get-sdk-info

index 54b941b..d91d335 100644 (file)
@@ -37,6 +37,7 @@ type SDK struct {
        Arch        string `json:"arch"`
        Path        string `json:"path"`
        URL         string `json:"url"`
+       ImageURL    string `json:"image_url"`
        Status      string `json:"status"`
        Date        string `json:"date"`
        Size        string `json:"size"`
index c887293..0b11b5f 100644 (file)
@@ -42,6 +42,7 @@ Returned the list all SDKs (available and installed) using JSON format.
     "arch":         "architecture",
     "path":         "path where sdk installed locally",
     "url":          "https://website.url.to.download.sdk",
+    "image_url":    "https://website.url.to.download.image",
     "status":       "Not Installed | Installed",
     "date":         "2017-12-25 00:00",
     "size":         "123 MB",
@@ -110,6 +111,7 @@ returned the following JSON structure:
     "arch":         "architecture",
     "path":         "",
     "url":          "https://website.url.to.download.sdk",
+    "image_url":    "https://website.url.to.download.image",
     "status":       "Not Installed",
     "date":         "2017-12-25 00:00",
     "size":         "123 MB",
index d375177..fecdcd3 100755 (executable)
@@ -184,6 +184,7 @@ for one_sdk in INSTALLED_SDK:
             'arch': ARCH,
             'path': DIR,
             'url': '',
+            'image_url': '',
             'status': 'Installed',
             'date': SDK_DATE,
             'size': '',
index 485d5fe..12892ac 100755 (executable)
@@ -89,6 +89,7 @@ if [ "${SDK_FILE}" != "" ]; then
 
     filename=$(basename "${SDK_FILE}")
     sdkUrl=file://${SDK_FILE}
+    imageUrl=""
     sdkDate=$(stat -c %y "${SDK_FILE}")
     sdkSize=$(/bin/ls -sh "${SDK_FILE}" |cut -d' ' -f1)
 
@@ -96,6 +97,7 @@ elif [ "${URL}" != "" ]; then
 
     filename=$(basename "${URL}")
     sdkUrl=${URL}
+    imageUrl=""
     sdkDate=""
     sdkSize=""
 
@@ -124,6 +126,8 @@ installPath=${SDK_ROOT_DIR}/${profile}/${version}/${arch}
 [ "${version}" = "" ] && { echo "version not set"; exit 8; }
 [ "${arch}" = "" ] && { echo " arch not set"; exit 9; }
 
+sdkName=${profile}_${arch}_${version}
+
 # Define a unique ID to be able to distinguish for example corei7-64 from qemux86-64
 if [ "${UUID}" = "" ]; then
     curInstDir=$(ls -d "${installPath}/*" 2> /dev/null)
@@ -146,9 +150,26 @@ if [ -d "${installPath}" ]; then
     [ "${envFile}" != "" ] && status="Installed"
 fi
 
+sdkDef=""
+if [ "${UUID}" != "" ]; then
+    sdkDef=$($(dirname "$0")/db-dump | jq '.[] | select(.uuid=="'${UUID}'")')
+elif [ "${URL}" != "" ]; then
+    sdkDef=$($(dirname "$0")/db-dump | jq '.[] | select(.url=="'${URL}'")')
+fi
+
+if [ "${sdkDef}" != "" ]; then
+    sdkName=$(echo "$sdkDef" | jq -r .name)
+    [ "$UUID" = "" ] && UUID=$(echo "$sdkDef" | jq -r .uuid)
+    [ "$sdkUrl" = "" ] && sdkUrl=$(echo "$sdkDef" | jq -r .url)
+    [ "$imageUrl" = "" ] && imageUrl=$(echo "$sdkDef" | jq -r .image_url)
+    [ "$sdkDate" = "" ] && sdkDate=$(echo "$sdkDef" | jq -r .date)
+    [ "$sdkSize" = "" ] && sdkSize=$(echo "$sdkDef" | jq -r .size)
+    [ "$MD5VAL" = "" ] && MD5VAL=$(echo "$sdkDef" | jq -r .md5sum)
+fi
+
 read -r -d '' res <<- EndOfMessage
 {
-    "name":         "${profile}_${arch}_${version}",
+    "name":         "${sdkName}",
     "uuid":         "${UUID}",
     "description":  "AGL SDK ${arch} (version ${version})",
     "profile":      "${profile}",
@@ -156,6 +177,7 @@ read -r -d '' res <<- EndOfMessage
     "arch":         "${arch}",
     "path":         "${installPath}",
     "url":          "${sdkUrl}",
+    "image_url":    "${imageUrl}",
     "status":       "${status}",
     "date":         "${sdkDate}",
     "size":         "${sdkSize}",