aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/sdks/agl/_build-sdks-json.sh
blob: 4ab5f0ca52968f9e1fe0dbe37ededd65a61af2d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape
#!/bin/bash
###########################################################################
# Copyright 2017-2018 IoT.bzh
#
# author: Sebastien Douheret <sebastien@iot.bzh>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###########################################################################

SDK_AGL_BASEURL="https://download.automotivelinux.org/AGL"
SDK_AGL_IOTBZH_BASEURL="http://iot.bzh/download/public/XDS"

# Define urls where SDKs can be downloaded
DOWNLOADABLE_URLS="
    ${SDK_AGL_BASEURL}/snapshots/master/latest/*/deploy/sdk

    ${SDK_AGL_BASEURL}/release/dab/4.0.2/*/deploy/sdk

    ${SDK_AGL_BASEURL}/release/eel/5.0.0/*/deploy/sdk
    ${SDK_AGL_BASEURL}/release/eel/5.0.1/*/deploy/sdk
    ${SDK_AGL_BASEURL}/release/eel/5.0.2/*/deploy/sdk
    ${SDK_AGL_BASEURL}/release/eel/5.0.3/*/deploy/sdk
    ${SDK_AGL_BASEURL}/release/eel/latest/*/deploy/sdk

    ${SDK_AGL_IOTBZH_BASEURL}/images/dab-m3ulcb/*/sdk
    ${SDK_AGL_IOTBZH_BASEURL}/images/dab-raspi/*/sdk

    ${SDK_AGL_IOTBZH_BASEURL}/images/eel-intel-corei7-64/*/sdk
    ${SDK_AGL_IOTBZH_BASEURL}/images/eel-m3ulcb/*/sdk

    ${SDK_AGL_IOTBZH_BASEURL}/images/master-m3ulcb/*/sdk
    ${SDK_AGL_IOTBZH_BASEURL}/images/master-qemux86-64/*/sdk
"
###


# Compute full urls list  (parse '*' characters)
urls=""
for url in $(echo $DOWNLOADABLE_URLS); do
    if [[ "$url" = *"*"* ]]; then
        bUrl=$(echo $url | cut -d'*' -f 1)
        eUrl=$(echo $url | cut -d'*' -f 2)
        dirs=$(curl -s ${bUrl} | grep '\[DIR\]' | grep -oP  'href="[^"]*"' | cut -d'"' -f 2)
        for dir in $(echo $dirs); do
            urls="$urls ${bUrl::-1}/${dir::-1}/${eUrl:1}"
        done
    else
        urls="$urls $url"
    fi
done

# Compute list of available/installable SDKs
sdksList=" "
for url in $(echo $urls); do
    htmlPage=$(curl -s --connect-timeout 10 "${url}/")
    files=$(echo ${htmlPage} | egrep -o 'href="[^"]*.sh"' | cut -d '"' -f 2)
    if [ "$?" != "0" ] || [ "${files}" = "" ]; then
        echo " IGNORED ${url}: no valid files found"
        continue
    fi

    for sdkFile in $(echo ${files}); do

        # assume that sdk name follow this format :
        #  _PROFILE_-_COMPILER_ARCH_-_TARGET_-crosssdk-_ARCH_-toolchain-_VERSION_.sh
        # for example:
        #  poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-corei7-64-toolchain-4.0.1.sh

        [[ "${sdkFile}" != *"crosssdk"* ]] && { echo " IGNORED ${sdkFile}, not a valid sdk file"; continue; }

        echo "Processing ${sdkFile}"
        profile=$(echo "${sdkFile}" | sed -r 's/(.*)-glibc.*/\1/')
        version=$(echo "${sdkFile}" | sed -r 's/.*toolchain-(.*).sh/\1/')
        arch=$(echo "${sdkFile}" | sed -r 's/.*crosssdk-(.*)-toolchain.*/\1/')

        endUrl=${url#$SDK_AGL_BASEURL}
        if [ "${endUrl::4}" = "http" ]; then
            name=${profile}_${arch}_${version}
        else
            name=$(echo "AGL-$(echo ${endUrl} | cut -d'/' -f2,3,4,5)" | sed s:/:-:g)
        fi

        # Distringuish qemux86-64 and corei7-64
        if [[ "$name" == *"qemux86-64"* && "$arch" == "corei7-64" ]]; then
            arch="qemux86-64"
        fi


        [ "${profile}" = "" ] && { echo " ERROR: profile not set" continue; }
        [ "${version}" = "" ] && { echo " ERROR: version not set" continue; }
        [ "${arch}" = "" ] && { echo " ERROR: arch not set" continue; }
        [ "${name}" = "" ] && { name=${profile}_${arch}_${version}; }

        sdkDate="$(echo "${htmlPage}" |egrep -o ${sdkFile/+/\\+}'</a>.*[0-9\-]+ [0-9]+:[0-9]+' |cut -d'>' -f 4|cut -d' ' -f1,2)"
        sdkSize="$(echo "${htmlPage}" |egrep -o  "${sdkFile/+/\\+}.*${sdkDate}.*[0-9\.MG]+</td>" |cut -d'>' -f7 |cut -d'<' -f1)"
        md5sum="$(wget -q -O - ${url}/${sdkFile/.sh/.md5} |cut -d' ' -f1)"

        read -r -d '' res <<- EndOfMessage
{
    "name":         "${name}",
    "description":  "AGL SDK ${arch} (version ${version})",
    "profile":      "${profile}",
    "version":      "${version}",
    "arch":         "${arch}",
    "path":         "",
    "url":          "${url}/${sdkFile}",
    "status":       "Not Installed",
    "date":         "${sdkDate}",
    "size":         "${sdkSize}",
    "md5sum":       "${md5sum}",
    "setupFile":    ""
},
EndOfMessage

        sdksList="${sdksList}${res}"
    done
done

OUT_FILE=$(dirname "$0")/sdks_$(date +"%F_%H%m").json

echo "[" > ${OUT_FILE}
echo "${sdksList::-1}" >> ${OUT_FILE}
echo "]" >> ${OUT_FILE}

echo "SDKs list successfully saved in ${OUT_FILE}"