2 ###########################################################################
3 # Copyright 2017 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/sdk"
23 # Define urls where SDKs can be downloaded
25 ${SDK_AGL_BASEURL}/snapshots/master/latest/*/deploy/sdk
27 ${SDK_AGL_BASEURL}/release/dab/3.99.3/m3ulcb-nogfx/deploy/sdk
28 ${SDK_AGL_BASEURL}/release/dab/4.0.2/*/deploy/sdk
30 ${SDK_AGL_BASEURL}/release/eel/4.99.4/*/deploy/sdk
31 ${SDK_AGL_BASEURL}/release/eel/latest/*/deploy/sdk
33 ${SDK_AGL_IOTBZH_BASEURL}
39 # Compute full urls list (parse '*' characters)
41 for url in $(echo $DOWNLOADABLE_URLS); do
42 if [[ "$url" = *"*"* ]]; then
43 bUrl=$(echo $url | cut -d'*' -f 1)
44 eUrl=$(echo $url | cut -d'*' -f 2)
45 dirs=$(curl -s ${bUrl} | grep '\[DIR\]' | grep -oP 'href="[^"]*"' | cut -d'"' -f 2)
46 for dir in $(echo $dirs); do
47 urls="$urls ${bUrl::-1}/${dir::-1}/${eUrl:1}"
54 # Compute list of available/installable SDKs
56 for url in $(echo $urls); do
57 htmlPage=$(curl -s --connect-timeout 10 "${url}/")
58 files=$(echo ${htmlPage} | egrep -o 'href="[^"]*.sh"' | cut -d '"' -f 2)
59 if [ "$?" != "0" ] || [ "${files}" = "" ]; then
60 echo " IGNORED ${url}: no valid files found"
64 for sdkFile in $(echo ${files}); do
66 # assume that sdk name follow this format :
67 # _PROFILE_-_COMPILER_ARCH_-_TARGET_-crosssdk-_ARCH_-toolchain-_VERSION_.sh
69 # poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-corei7-64-toolchain-4.0.1.sh
71 [[ "${sdkFile}" != *"crosssdk"* ]] && { echo " IGNORED ${sdkFile}, not a valid sdk file"; continue; }
73 echo "Processing ${sdkFile}"
74 profile=$(echo "${sdkFile}" | sed -r 's/(.*)-glibc.*/\1/')
75 version=$(echo "${sdkFile}" | sed -r 's/.*toolchain-(.*).sh/\1/')
76 arch=$(echo "${sdkFile}" | sed -r 's/.*crosssdk-(.*)-toolchain.*/\1/')
78 endUrl=${url#$SDK_AGL_BASEURL}
79 if [ "${endUrl::4}" = "http" ]; then
80 name=${profile}_${arch}_${version}
82 name=$(echo "AGL-$(echo ${endUrl} | cut -d'/' -f2,3,4,5)" | sed s:/:-:g)
85 [ "${profile}" = "" ] && { echo " ERROR: profile not set" continue; }
86 [ "${version}" = "" ] && { echo " ERROR: version not set" continue; }
87 [ "${arch}" = "" ] && { echo " ERROR: arch not set" continue; }
88 [ "${name}" = "" ] && { name=${profile}_${arch}_${version}; }
90 sdkDate="$(echo "${htmlPage}" |egrep -o ${sdkFile/+/\\+}'</a>.*[0-9\-]+ [0-9]+:[0-9]+' |cut -d'>' -f 4|cut -d' ' -f1,2)"
91 sdkSize="$(echo "${htmlPage}" |egrep -o "${sdkFile/+/\\+}.*${sdkDate}.*[0-9\.MG]+</td>" |cut -d'>' -f7 |cut -d'<' -f1)"
92 md5sum="$(wget -q -O - ${url}/${sdkFile/.sh/.md5} |cut -d' ' -f1)"
94 read -r -d '' res <<- EndOfMessage
97 "description": "AGL SDK ${arch} (version ${version})",
98 "profile": "${profile}",
99 "version": "${version}",
102 "url": "${url}/${sdkFile}",
103 "status": "Not Installed",
104 "date": "${sdkDate}",
105 "size": "${sdkSize}",
106 "md5sum": "${md5sum}",
111 sdksList="${sdksList}${res}"
115 OUT_FILE=$(dirname "$0")/sdks_$(date +"%F_%H%m").json
117 echo "[" > ${OUT_FILE}
118 echo "${sdksList::-1}" >> ${OUT_FILE}
119 echo "]" >> ${OUT_FILE}
121 echo "SDKs list successfully saved in ${OUT_FILE}"