summaryrefslogtreecommitdiffstats
path: root/scripts/sdks/agl
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-22 21:26:40 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-22 21:29:59 +0100
commitf1c182ede3c4aed0d6196d05b0a64ff93372e755 (patch)
tree2cf95732a06808aac8325bccb5199346b33165a2 /scripts/sdks/agl
parent285332c351777b74abca638b8b2a2cde3c68edc6 (diff)
Added SDKs management support.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'scripts/sdks/agl')
-rwxr-xr-xscripts/sdks/agl/_build-sdks-json.sh121
-rwxr-xr-xscripts/sdks/agl/_env-init.sh29
-rwxr-xr-xscripts/sdks/agl/add103
-rwxr-xr-xscripts/sdks/agl/get-config33
-rwxr-xr-xscripts/sdks/agl/list137
-rwxr-xr-xscripts/sdks/agl/remove32
-rwxr-xr-xscripts/sdks/agl/update22
7 files changed, 477 insertions, 0 deletions
diff --git a/scripts/sdks/agl/_build-sdks-json.sh b/scripts/sdks/agl/_build-sdks-json.sh
new file mode 100755
index 0000000..82cb2f3
--- /dev/null
+++ b/scripts/sdks/agl/_build-sdks-json.sh
@@ -0,0 +1,121 @@
+#!/bin/bash
+###########################################################################
+# Copyright 2017 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/sdk"
+
+# Define urls where SDKs can be downloaded
+DOWNLOADABLE_URLS="
+ ${SDK_AGL_BASEURL}/snapshots/master/latest/*/deploy/sdk
+
+ ${SDK_AGL_BASEURL}/release/dab/3.99.3/m3ulcb-nogfx/deploy/sdk
+ ${SDK_AGL_BASEURL}/release/dab/4.0.2/*/deploy/sdk
+
+ ${SDK_AGL_BASEURL}/release/eel/4.99.4/*/deploy/sdk
+ ${SDK_AGL_BASEURL}/release/eel/latest/*/deploy/sdk
+
+ ${SDK_AGL_IOTBZH_BASEURL}
+"
+
+###
+
+
+# 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
+
+ [ "${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}"
diff --git a/scripts/sdks/agl/_env-init.sh b/scripts/sdks/agl/_env-init.sh
new file mode 100755
index 0000000..0f423c4
--- /dev/null
+++ b/scripts/sdks/agl/_env-init.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+ ###########################################################################
+# Copyright 2017 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.
+###########################################################################
+
+. /etc/xdtrc
+
+[ -z "$XDT_SDK" ] && XDT_SDK=/xdt/sdk
+
+export SDK_FAMILY_NAME="agl"
+export SDK_ROOT_DIR="$XDT_SDK"
+export SDK_ENV_SETUP_FILENAME="environment-setup-*"
+export SDK_DATABASE="http://iot.bzh/download/public/XDS/sdk/sdks_latest.json"
+
+[ "$1" = "-print" ] && { env; }
diff --git a/scripts/sdks/agl/add b/scripts/sdks/agl/add
new file mode 100755
index 0000000..dcb3833
--- /dev/null
+++ b/scripts/sdks/agl/add
@@ -0,0 +1,103 @@
+#!/bin/bash
+ ###########################################################################
+# Copyright 2017 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.
+###########################################################################
+
+. $(dirname "$0")/_env-init.sh
+
+usage() {
+ echo "Usage: $(basename $0) [-h|--help] [-f|--file <sdk-filename>] [-u|--url <https_url>] [--force] [--no-clean]"
+ exit 1
+}
+
+TMPDIR=""
+SDK_FILE=""
+URL=""
+do_cleanup=true
+do_force=false
+while [ $# -ne 0 ]; do
+ case $1 in
+ -f|--file)
+ shift
+ SDK_FILE=$1
+ ;;
+ --force)
+ do_force=true
+ ;;
+ -u|--url)
+ shift
+ URL=$1
+ ;;
+ -no-clean)
+ do_cleanup=false
+ ;;
+ -h|--help)
+ usage
+ ;;
+ *)
+ echo "Invalid argument: $1"
+ usage
+ ;;
+ esac
+ shift
+done
+
+[ "$SDK_FILE" = "" ] && [ "$URL" = "" ] && { echo "--file or --url option must be set"; exit 1; }
+
+# Create SDK root dir if needed
+[ ! -d ${SDK_ROOT_DIR} ] && mkdir -p ${SDK_ROOT_DIR}
+cd ${SDK_ROOT_DIR} || exit 1
+
+# Cleanup
+trap "cleanExit" 0 1 2 15
+cleanExit ()
+{
+ if ($do_cleanup); then
+ [[ -d ${TMPDIR} ]] && rm -rf ${TMPDIR}
+ fi
+}
+
+# Download sdk
+if [ "$URL" != "" ]; then
+ TMPDIR=$(mktemp -d)
+ SDK_FILE=${TMPDIR}/$(basename ${URL})
+ echo "Downloading $(basename ${SDK_FILE}) ..."
+ wget "$URL" -O "${SDK_FILE}" || exit 1
+fi
+
+# Retreive default install dir to extract version
+offset=$(grep -na -m1 "^MARKER:$" "${SDK_FILE}" | cut -d':' -f1)
+eval $(head -n $offset "${SDK_FILE}" | grep ^DEFAULT_INSTALL_DIR= )
+
+PROFILE=$(basename $(dirname $DEFAULT_INSTALL_DIR))
+VERSION=$(basename $DEFAULT_INSTALL_DIR)
+ARCH=$(echo "$SDK_FILE" | sed -r 's/.*crosssdk-(.*)-toolchain.*/\1/')
+
+[ "$PROFILE" = "" ] && { echo "PROFILE is not set"; exit 1; }
+[ "$VERSION" = "" ] && { echo "VERSION is not set"; exit 1; }
+[ "$ARCH" = "" ] && { echo "ARCH is not set"; exit 1; }
+
+DESTDIR=${SDK_ROOT_DIR}/${PROFILE}/${VERSION}/${ARCH}
+
+[ -d ${DESTDIR} ] && [ "$do_force" != "true" ] && { echo "SDK already installed in $DESTDIR"; exit 1; }
+
+# Cleanup previous install
+rm -rf ${DESTDIR} && mkdir -p ${DESTDIR} || exit 1
+
+# Install sdk
+chmod +x ${SDK_FILE}
+${SDK_FILE} -y -d ${DESTDIR}
diff --git a/scripts/sdks/agl/get-config b/scripts/sdks/agl/get-config
new file mode 100755
index 0000000..8d370b8
--- /dev/null
+++ b/scripts/sdks/agl/get-config
@@ -0,0 +1,33 @@
+#!/bin/bash
+ ###########################################################################
+# Copyright 2017 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.
+###########################################################################
+
+SCRIPTS_DIR=$(dirname "$0")
+. ${SCRIPTS_DIR}/_env-init.sh
+
+read -r -d '' res <<- EndOfMessage
+{
+ "familyName": "${SDK_FAMILY_NAME}",
+ "description": "Automotive Grade Linux SDK",
+ "rootDir": "${SDK_ROOT_DIR}",
+ "envSetupFilename": "${SDK_ENV_SETUP_FILENAME}",
+ "scriptsDir": "${SCRIPTS_DIR}"
+}
+EndOfMessage
+
+echo "$res"
diff --git a/scripts/sdks/agl/list b/scripts/sdks/agl/list
new file mode 100755
index 0000000..dc748a4
--- /dev/null
+++ b/scripts/sdks/agl/list
@@ -0,0 +1,137 @@
+#! /usr/bin/env node
+
+/**************************************************************************
+ * Copyright 2017 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.
+ **************************************************************************/
+
+const fs = require('fs');
+const process = require('process');
+const execSync = require('child_process').execSync;
+const path = require('path');
+
+
+// Only used for debug purpose
+const DEBUG = false || (process.argv.length > 2 && process.argv[2] == '-debug');
+dbgPrint = function () {
+ if (DEBUG) console.log.apply(console, arguments);
+}
+// Get env vars
+var envMap = {};
+envData = execSync(path.join(__dirname, '_env-init.sh -print'));
+envData.toString().split('\n').forEach(e => envMap[e.split('=')[0]] = e.split('=')[1]);
+const opts = {
+ cwd: __dirname,
+ env: envMap
+};
+
+// Get list of available SDKs
+sdksDBFile = path.join(__dirname, "sdks_latest.json")
+try {
+ // Fetch SDK Json database file when not existing
+ if (!fs.existsSync(sdksDBFile)) {
+ var data = execSync(path.join(__dirname, 'update'), opts);
+ }
+ // Read SDK Json database file
+ var data = fs.readFileSync(sdksDBFile);
+ var sdks = JSON.parse(data);
+
+ // Force some default fields value
+ sdks.forEach(sdk => {
+ sdk.status = 'Not Installed';
+ });
+} catch (err) {
+ dbgPrint('ERROR: ', err);
+ process.exit(-1)
+}
+
+// Get list of installed SDKs
+try {
+ const cmd = 'find "${SDK_ROOT_DIR}" -maxdepth 4 -name "${SDK_ENV_SETUP_FILENAME}"';
+ var data = execSync(cmd, opts);
+ data.toString().split('\n').forEach(envFile => {
+ if (envFile == '') return;
+
+ dbgPrint('Processing ', envFile);
+ const profile = envFile.split('/')[3];
+ const version = envFile.split('/')[4];
+ const arch = envFile.split('/')[5];
+ const dir = path.dirname(envFile);
+ if (profile == '' || version == '' || arch == '' || dir == '') {
+ return;
+ }
+
+ sdkDate = ''
+ versionFile = path.join(path.dirname(envFile), 'version-*')
+ try {
+ cmdVer = "[ -f " + versionFile + " ] && grep Timestamp " + versionFile + " |cut -d' ' -f2"
+ var data = execSync(cmdVer);
+ } catch (err) {
+ dbgPrint('IGNORING SDK ', dir);
+ dbgPrint(err.toString());
+ if (DEBUG) {
+ process.exit(-1);
+ } else {
+ return;
+ }
+ }
+ d = data.toString()
+ if (d != "") {
+ sdkDate = d.substring(0, 4) + "-" + d.substring(4, 6) + "-" + d.substring(6, 8)
+ sdkDate += " " + d.substring(8, 10) + ":" + d.substring(10, 12)
+ }
+
+ var found = false;
+ sdks.forEach(sdk => {
+ // Update sdk with local info when found
+ if (profile == sdk.profile && version == sdk.version && arch == sdk.arch) {
+ found = true;
+ dbgPrint(" OK found, updating...");
+ sdk.path = dir;
+ sdk.status = 'Installed';
+ sdk.data = sdkDate;
+ sdk.setupFile = envFile;
+ return
+ }
+ });
+ if (found == false) {
+ dbgPrint(" NOT found in database, adding it...");
+ sdks.push({
+ name: profile + '-' + arch + '-' + version,
+ description: 'AGL SDK ' + arch + ' (version ' + version + ')',
+ profile: profile,
+ version: version,
+ arch: arch,
+ path: dir,
+ url: "",
+ status: "Installed",
+ date: sdkDate,
+ size: "",
+ md5sum: "",
+ setupFile: envFile
+ });
+ }
+ });
+
+} catch (err) {
+ dbgPrint('ERROR: ', err);
+ process.exit(-1)
+}
+
+// Print result
+console.log(JSON.stringify(sdks));
+
+process.exit(0)
diff --git a/scripts/sdks/agl/remove b/scripts/sdks/agl/remove
new file mode 100755
index 0000000..99a4022
--- /dev/null
+++ b/scripts/sdks/agl/remove
@@ -0,0 +1,32 @@
+#!/bin/bash
+ ###########################################################################
+# Copyright 2017 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.
+###########################################################################
+
+. $(dirname "$0")/_env-init.sh
+
+if [[ "${1}" == "" || "${1}" != "${SDK_ROOT_DIR}"* ]]; then
+ echo "Invalid sdk root directory"
+ exit 1
+fi
+
+if [ ! -d "${1}" ]; then
+ echo "sdk directory doesn't exist"
+ exit 1
+fi
+
+rm -rf "${1}"
diff --git a/scripts/sdks/agl/update b/scripts/sdks/agl/update
new file mode 100755
index 0000000..e59c8fa
--- /dev/null
+++ b/scripts/sdks/agl/update
@@ -0,0 +1,22 @@
+#!/bin/bash
+ ###########################################################################
+# Copyright 2017 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.
+###########################################################################
+
+. $(dirname "$0")/_env-init.sh
+
+wget -q --connect-timeout=30 ${SDK_DATABASE}