2 ###########################################################################
3 # Copyright 2017-2018 IoT.bzh
5 # author: Sebastien Douheret <sebastien@iot.bzh>
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 ###########################################################################
20 SDK_AGL_BASEURL="https://download.automotivelinux.org/AGL"
21 SDK_AGL_IOTBZH_BASEURL="http://iot.bzh/download/public/XDS"
23 # Define urls where SDKs can be downloaded
25 ${SDK_AGL_BASEURL}/snapshots/master/latest/*/deploy/sdk
27 ${SDK_AGL_BASEURL}/release/dab/4.0.3/*/deploy/sdk
29 ${SDK_AGL_BASEURL}/release/eel/5.1.0/*/deploy/sdk
30 ${SDK_AGL_BASEURL}/release/eel/latest/*/deploy/sdk
32 ${SDK_AGL_BASEURL}/release/flounder/6.0.0/*/deploy/sdk
33 ${SDK_AGL_BASEURL}/release/flounder/latest/*/deploy/sdk
35 ${SDK_AGL_IOTBZH_BASEURL}/images/dab-m3ulcb/*/sdk
37 ${SDK_AGL_IOTBZH_BASEURL}/images/eel-intel-corei7-64/*/sdk
38 ${SDK_AGL_IOTBZH_BASEURL}/images/eel-m3ulcb/*/sdk
40 ${SDK_AGL_IOTBZH_BASEURL}/images/flounder-h3ulcb/*/sdk
41 ${SDK_AGL_IOTBZH_BASEURL}/images/flounder-m3ulcb/*/sdk
43 ${SDK_AGL_IOTBZH_BASEURL}/images/master-m3ulcb/*/sdk
48 # Compute full urls list (parse '*' characters)
50 for url in $(echo $DOWNLOADABLE_URLS); do
51 if [[ "$url" = *"*"* ]]; then
52 bUrl=$(echo $url | cut -d'*' -f 1)
53 eUrl=$(echo $url | cut -d'*' -f 2)
54 dirs=$(curl -s ${bUrl} | grep '\[DIR\]' | grep -oP 'href="[^"]*"' | cut -d'"' -f 2)
55 for dir in $(echo $dirs); do
56 urls="$urls ${bUrl::-1}/${dir::-1}/${eUrl:1}"
63 # Compute list of available/installable SDKs
65 for url in $(echo $urls); do
66 htmlPage=$(curl -s --connect-timeout 10 "${url}/")
67 files=$(echo ${htmlPage} | egrep -o 'href="[^"]*.sh"' | cut -d '"' -f 2)
68 if [ "$?" != "0" ] || [ "${files}" = "" ]; then
69 echo " IGNORED ${url}: no valid files found"
73 for sdkFile in $(echo ${files}); do
75 # Ignored silent some known files
76 [[ "${sdkFile}" = "agl-sdk-latest.sh" ]] && continue
78 # assume that sdk name follow this format :
79 # _PROFILE_-_COMPILER_ARCH_-_TARGET_-crosssdk-_ARCH_-toolchain-_VERSION_.sh
81 # poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-corei7-64-toolchain-4.0.1.sh
83 [[ "${sdkFile}" != *"crosssdk"* ]] && { echo " IGNORED ${sdkFile}, not a valid sdk file"; echo " (url: ${url})"; continue; }
85 echo "Processing ${sdkFile}"
86 profile=$(echo "${sdkFile}" | sed -r 's/(.*)-glibc.*/\1/')
87 version=$(echo "${sdkFile}" | sed -r 's/.*toolchain-(.*).sh/\1/')
88 arch=$(echo "${sdkFile}" | sed -r 's/.*crosssdk-(.*)-toolchain.*/\1/')
90 endUrl=${url#$SDK_AGL_BASEURL}
91 if [ "${url::14}" = "http://iot.bzh" ]; then
92 endUrl=${url#$SDK_AGL_IOTBZH_BASEURL}
93 name=$(echo "IoTbzh-$(echo ${endUrl} | cut -d'/' -f3,4 | sed s:/:-:g)-${version}")
94 elif [ "${endUrl::4}" = "http" ]; then
95 name="${profile}_${arch}_${version}"
97 name=$(echo "AGL-$(echo ${endUrl} | cut -d'/' -f2,3,4,5)" | sed s:/:-:g)
100 # Distringuish qemux86-64 and corei7-64
101 if [[ "$name" == *"qemux86-64"* && "$arch" == "corei7-64" ]]; then
106 [ "${profile}" = "" ] && { echo " ERROR: profile not set" continue; }
107 [ "${version}" = "" ] && { echo " ERROR: version not set" continue; }
108 [ "${arch}" = "" ] && { echo " ERROR: arch not set" continue; }
109 [ "${name}" = "" ] && { name=${profile}_${arch}_${version}; }
111 sdkDate="$(echo "${htmlPage}" |egrep -o ${sdkFile/+/\\+}'</a>.*[0-9\-]+ [0-9]+:[0-9]+' |cut -d'>' -f 4|cut -d' ' -f1,2)"
112 sdkSize="$(echo "${htmlPage}" |egrep -o "${sdkFile/+/\\+}.*${sdkDate}.*[0-9\.MG]+</td>" |cut -d'>' -f7 |cut -d'<' -f1)"
113 md5sum="$(wget -q -O - ${url}/${sdkFile/.sh/.md5} |cut -d' ' -f1)"
115 read -r -d '' res <<- EndOfMessage
118 "description": "AGL SDK ${arch} (version ${version})",
119 "profile": "${profile}",
120 "version": "${version}",
123 "url": "${url}/${sdkFile}",
124 "status": "Not Installed",
125 "date": "${sdkDate}",
126 "size": "${sdkSize}",
127 "md5sum": "${md5sum}",
132 sdksList="${sdksList}${res}"
136 OUT_FILE=$(dirname "$0")/sdks_$(date +"%F_%H%m").json
138 echo "[" > ${OUT_FILE}
139 echo "${sdksList::-1}" >> ${OUT_FILE}
140 echo "]" >> ${OUT_FILE}
142 echo "SDKs list successfully saved in ${OUT_FILE}"