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 ###########################################################################
22 [ -z "$SDK_BASEURL" ] && SDK_BASEURL="http://iot.bzh/download/public/XDS/sdk/"
23 [ -z "$XDT_SDK" ] && XDT_SDK=/xdt/sdk
25 # Support only poky_agl profile for now
28 # Dynamically retreive SDKs (reduce timeout in case of iot website is not available)
29 SDKS=$(curl -s ${SDK_BASEURL} --connect-timeout 10 | grep -oP 'href="[^"]*.sh"' | cut -d '"' -f 2) || echo "WARNING: IoT.bzh download site not available."
32 echo "Usage: $(basename $0) [-h|--help] [-clean] [-f|--file <agl-sdk-filename>] [-a|--arch <arch name>] [-l|--list]"
33 echo "For example, arch name is: aarch64, armv7vehf or corei7-64"
39 for sdk in ${SDKS}; do
40 echo $sdk | grep "${PROFILE}.*${arch}.*.sh" > /dev/null 2>&1
41 if [ "$?" = "0" ]; then
46 echo "No SDK tarball found for arch $arch"
53 while [ $# -ne 0 ]; do
67 echo "Available SDKs tarballs:"
68 for sdk in $SDKS; do echo " $sdk"; done
75 echo "Invalid argument: $1"
82 if [ "$ARCH" = "x86-64" ]; then
83 echo "Warning x86-64 architure name is deprecated, please use corei7-64 instead !"
87 [ ! -d ${XDT_SDK} ] && mkdir -p ${XDT_SDK}
89 if [ "$FILE" = "" ]; then
91 if [ "$?" != "0" ]; then
95 SDK_FILE=${XDT_SDK}/${FILE}
96 elif [ ! -f "$FILE" ]; then
97 echo "SDK file not found: $FILE"
100 DIR=$(cd $(dirname $FILE); pwd)
101 FILE=$(basename $FILE)
102 SDK_FILE=${DIR}/${FILE}
105 if [ "$ARCH" = "" ]; then
106 echo "Option -a|--arch must be set"
110 # Check that ARCH name matching SDK tarball filename
111 echo "$FILE" | grep "$ARCH" > /dev/null 2>&1
112 if [ "$?" = "1" ]; then
113 echo "ARCH and provided filename doesn't match !"
117 cd ${XDT_SDK} || exit 1
120 trap "cleanExit" 0 1 2 15
123 if ($do_cleanup); then
124 [[ -f ${SDK_FILE} ]] && rm -f ${SDK_FILE}
129 if [ ! -f "${SDK_FILE}" ]; then
131 wget "$SDK_BASEURL/$FILE" -O "${SDK_FILE}" || exit 1
134 # Retreive default install dir to extract version
135 offset=$(grep -na -m1 "^MARKER:$" "${SDK_FILE}" | cut -d':' -f1)
136 eval $(head -n $offset "${SDK_FILE}" | grep ^DEFAULT_INSTALL_DIR= )
137 VERSION=$(basename $DEFAULT_INSTALL_DIR)
139 [ "$PROFILE" = "" ] && { echo "PROFILE is not set"; exit 1; }
140 [ "$VERSION" = "" ] && { echo "VERSION is not set"; exit 1; }
142 DESTDIR=${XDT_SDK}/${PROFILE}/${VERSION}/${ARCH}
144 # Cleanup previous install
145 rm -rf ${DESTDIR} && mkdir -p ${DESTDIR} || exit 1
149 ${SDK_FILE} -y -d ${DESTDIR}