diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-10-22 17:22:21 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-10-22 17:22:35 +0200 |
commit | b33e880f23525b4f75cf35e39aa5082addef0fb7 (patch) | |
tree | 12eef7bf171f7dcd114bc675a8386707669db36e | |
parent | 7939184660ed562f4b41c7a3983c7a4f69da52c7 (diff) |
Added support of new image_url field
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>
-rw-r--r-- | lib/xsapiv1/sdks.go | 1 | ||||
-rw-r--r-- | scripts/sdks/README.md | 2 | ||||
-rwxr-xr-x | scripts/sdks/agl/db-dump | 1 | ||||
-rwxr-xr-x | scripts/sdks/agl/get-sdk-info | 24 |
4 files changed, 27 insertions, 1 deletions
diff --git a/lib/xsapiv1/sdks.go b/lib/xsapiv1/sdks.go index 54b941b..d91d335 100644 --- a/lib/xsapiv1/sdks.go +++ b/lib/xsapiv1/sdks.go @@ -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"` diff --git a/scripts/sdks/README.md b/scripts/sdks/README.md index c887293..0b11b5f 100644 --- a/scripts/sdks/README.md +++ b/scripts/sdks/README.md @@ -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", diff --git a/scripts/sdks/agl/db-dump b/scripts/sdks/agl/db-dump index d375177..fecdcd3 100755 --- a/scripts/sdks/agl/db-dump +++ b/scripts/sdks/agl/db-dump @@ -184,6 +184,7 @@ for one_sdk in INSTALLED_SDK: 'arch': ARCH, 'path': DIR, 'url': '', + 'image_url': '', 'status': 'Installed', 'date': SDK_DATE, 'size': '', diff --git a/scripts/sdks/agl/get-sdk-info b/scripts/sdks/agl/get-sdk-info index 485d5fe..12892ac 100755 --- a/scripts/sdks/agl/get-sdk-info +++ b/scripts/sdks/agl/get-sdk-info @@ -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}", |