aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-02-08 16:49:02 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-02-08 16:49:02 +0100
commite97eebc18d726aa55738d7e19513491cf58a6e3a (patch)
tree1e668dadc73cbe710cb1aaf059b43ef91defa01f /scripts
parent0a53346ecd92e1281587c724631fdf76dc756fc7 (diff)
Avoid duplicate SDK install dir - SPEC-1252
- install sdk in a directory that includes a unique id (built from install url or path). SDKs are now install under: <SDK_ROOT_DIR>/<PROFILE>/<VERSION>/<ARCH>/<UID> Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sdks/agl/add28
-rwxr-xr-xscripts/sdks/agl/db-dump36
-rwxr-xr-xscripts/sdks/agl/get-sdk-info8
3 files changed, 47 insertions, 25 deletions
diff --git a/scripts/sdks/agl/add b/scripts/sdks/agl/add
index 7c8321c..80a0487 100755
--- a/scripts/sdks/agl/add
+++ b/scripts/sdks/agl/add
@@ -65,8 +65,8 @@ 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
+[ ! -d "${SDK_ROOT_DIR}" ] && mkdir -p "${SDK_ROOT_DIR}"
+cd "${SDK_ROOT_DIR}" || exit 1
# Cleanup
trap "cleanExit" 0 1 2 15
@@ -80,33 +80,33 @@ cleanExit ()
# Download sdk
if [ "$URL" != "" ]; then
TMPDIR=$(mktemp -d)
- SDK_FILE=${TMPDIR}/$(basename ${URL})
- echo "Downloading $(basename ${SDK_FILE}) ..."
+ SDK_FILE=${TMPDIR}/$(basename "${URL}")
+ echo "Downloading $(basename "${SDK_FILE}") ..."
wget --no-check-certificate "$URL" -O "${SDK_FILE}" || exit 1
fi
# Retreive SDK info
sdkNfo=$(${SCRIPTS_DIR}/get-sdk-info --file "${SDK_FILE}")
if [ "$?" != "0" ]; then
- echo $sdkNfo
+ echo "$sdkNfo"
exit 1
fi
-PROFILE=$(echo "$sdkNfo" |egrep -o '"profile"[^,]*' |cut -d'"' -f4)
-VERSION=$(echo "$sdkNfo" |egrep -o '"version"[^,]*' |cut -d'"' -f4)
-ARCH=$(echo "$sdkNfo" |egrep -o '"arch"[^,]*' |cut -d'"' -f4)
+PROFILE=$(echo "$sdkNfo" |grep -Eo '"profile"[^,]*' |cut -d'"' -f4)
+VERSION=$(echo "$sdkNfo" |grep -Eo '"version"[^,]*' |cut -d'"' -f4)
+ARCH=$(echo "$sdkNfo" |grep -Eo '"arch"[^,]*' |cut -d'"' -f4)
+DESTDIR=$(echo "$sdkNfo" |grep -Eo '"path"[^,]*' |cut -d'"' -f4)
[ "$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" = "" ] && { echo "DESTDIR (path) 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; }
+[ -d "${DESTDIR}" ] && [ "$do_force" != "true" ] && { echo "SDK already installed in $DESTDIR"; exit 1; }
# Cleanup previous install
-rm -rf ${DESTDIR} && mkdir -p ${DESTDIR} || exit 1
+rm -rf "${DESTDIR}" && mkdir -p "${DESTDIR}" || exit 1
# Install sdk
-chmod +x ${SDK_FILE}
-${SDK_FILE} ${DEBUG_OPT} -y -d ${DESTDIR} 2>&1
+chmod +x "${SDK_FILE}"
+${SDK_FILE} ${DEBUG_OPT} -y -d "${DESTDIR}" 2>&1
diff --git a/scripts/sdks/agl/db-dump b/scripts/sdks/agl/db-dump
index 77f729e..5c040ea 100755
--- a/scripts/sdks/agl/db-dump
+++ b/scripts/sdks/agl/db-dump
@@ -26,20 +26,25 @@ import fnmatch
import argparse
import subprocess
-PARSER = argparse.ArgumentParser(description='Lists available and installed SDKs')
+PARSER = argparse.ArgumentParser(
+ description='Lists available and installed SDKs')
PARSER.add_argument('-debug', dest='debug', action='store_true',
help='Output debug log messages')
ARGS = PARSER.parse_args()
if ARGS.debug:
- logging.basicConfig(level=logging.DEBUG, format='%(asctime)s:%(levelname)s: %(message)s')
+ logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s:%(levelname)s: %(message)s')
else:
- logging.basicConfig(level=logging.INFO, format='%(asctime)s:%(levelname)s: %(message)s')
+ logging.basicConfig(level=logging.INFO,
+ format='%(asctime)s:%(levelname)s: %(message)s')
-SCRIPT_PATH = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
+SCRIPT_PATH = os.path.dirname(os.path.abspath(
+ inspect.getfile(inspect.currentframe())))
-ENV = subprocess.check_output([os.path.join(SCRIPT_PATH, './_env-init.sh'), '-print']).splitlines()
+ENV = subprocess.check_output(
+ [os.path.join(SCRIPT_PATH, './_env-init.sh'), '-print']).splitlines()
for elt in ENV:
k, v = elt.split('=', 1)
@@ -69,8 +74,13 @@ for one_sdk in SDK_DB_JSON:
INSTALLED_SDK = []
for root, dirs, files in os.walk(SDK_ROOT_DIR):
depth = root[len(SDK_ROOT_DIR) + len(os.path.sep):].count(os.path.sep)
+ # Limit the walking depth of processed directories
if depth >= 4:
dirs[:] = []
+ # Only process SDK dir matching profile/version/arch or
+ # profile/version/arch/tag
+ elif depth != 2 and depth != 3:
+ continue
EF, VF = '', ''
for one_file in files:
if fnmatch.fnmatch(one_file, SDK_ENV_SETUP_FILENAME):
@@ -78,7 +88,11 @@ for root, dirs, files in os.walk(SDK_ROOT_DIR):
if fnmatch.fnmatch(one_file, 'version-*'):
VF = os.path.join(root, one_file)
if EF != '' and VF != '':
+ logging.debug('Adding installed SDK ' + root)
INSTALLED_SDK.append({'ENV_FILE': EF, 'VERSION_FILE': VF})
+ elif (EF == '' and VF != '') or (EF != '' and VF == ''):
+ logging.debug(
+ 'WARNING SDK ignored : root=%s, EnvFile=%s, VersFile=%s', root, EF, VF)
for one_sdk in INSTALLED_SDK:
logging.debug("Processing %s", one_sdk['ENV_FILE'])
@@ -96,12 +110,15 @@ for one_sdk in INSTALLED_SDK:
D = line.split(':')[1]
if D:
D = D.strip()
- SDK_DATE = '{}-{}-{} {}:{}'.format(D[0:4], D[4:6], D[6:8], D[8:10], D[10:12])
+ SDK_DATE = '{}-{}-{} {}:{}'.format(
+ D[0:4], D[4:6], D[6:8], D[8:10], D[10:12])
logging.debug('Found date: %s', SDK_DATE)
found = False
for sdk in SDK_DB_JSON:
if sdk['profile'] == PROFILE and sdk['version'] == VERSION and sdk['arch'] == ARCH:
+ if sdk['status'] == 'Installed':
+ continue
found = True
sdk['status'] = 'Installed'
sdk['date'] = SDK_DATE
@@ -110,7 +127,8 @@ for one_sdk in INSTALLED_SDK:
break
if not found:
- logging.debug('Not found in database, adding it...')
+ logging.debug('Not found in database, add: ' +
+ PROFILE + '-' + ARCH + '-' + VERSION)
NEW_SDK = {
'name': PROFILE + '-' + ARCH + '-' + VERSION,
'description': 'AGL SDK ' + ARCH + ' (version ' + VERSION + ')',
@@ -124,7 +142,7 @@ for one_sdk in INSTALLED_SDK:
'size': "",
'md5sum': "",
'setupFile': one_sdk['ENV_FILE']
- }
+ }
SDK_DB_JSON.append(NEW_SDK)
-print json.dumps(SDK_DB_JSON)
+print(json.dumps(SDK_DB_JSON))
diff --git a/scripts/sdks/agl/get-sdk-info b/scripts/sdks/agl/get-sdk-info
index 19bf685..8840bf0 100755
--- a/scripts/sdks/agl/get-sdk-info
+++ b/scripts/sdks/agl/get-sdk-info
@@ -113,14 +113,18 @@ fi
profile=$(echo "${filename}" | sed -r 's/(.*)-glibc.*/\1/')
version=$(echo "${filename}" | sed -r 's/.*toolchain-(.*).sh/\1/')
arch=$(echo "${filename}" | sed -r 's/.*crosssdk-(.*)-toolchain.*/\1/')
-installPath=${SDK_ROOT_DIR}/${profile}/${version}/${arch}
[ "${profile}" = "" ] && { echo "profile not set"; exit 7; }
[ "${version}" = "" ] && { echo "version not set"; exit 8; }
[ "${arch}" = "" ] && { echo " arch not set"; exit 9; }
+# Define a unique ID to be able to distinguish for example corei7-64 from qemux86-64
+uuid=$(echo "${sdkUrl}" | md5sum |cut -d' ' -f1)
+
+installPath=${SDK_ROOT_DIR}/${profile}/${version}/${arch}/${uuid}
+
status="Not Installed"
-if [ -d ${installPath} ]; then
+if [ -d "${installPath}" ]; then
envFile=$(find "${installPath}" -maxdepth 1 -name "${SDK_ENV_SETUP_FILENAME}")
[ "${envFile}" != "" ] && status="Installed"
fi