Rework SDK default directory.
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 4 Apr 2018 19:59:45 +0000 (21:59 +0200)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 4 Apr 2018 23:30:31 +0000 (01:30 +0200)
Default SDK directory is $HOME/xds-workspace/.sdks expect if /xdt/sdk
exists (backward compatibility).
Default SDK directory can be set by defining XDT_SDK variable in
/etc/xdtrc file

Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
scripts/sdks/agl/_env-init.sh
scripts/sdks/agl/db-dump

index a08f798..921f319 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
  ###########################################################################
-# Copyright 2017 IoT.bzh
+# Copyright 2017-2018 IoT.bzh
 #
 # author: Sebastien Douheret <sebastien@iot.bzh>
 #
 
 [ -f /etc/xdtrc ] && . /etc/xdtrc
 
-[ -z "$XDT_SDK" ] && XDT_SDK=/xdt/sdk
+if [ -z "$XDT_SDK" ]; then
+    # For backward compatibility and compliance with AGL DevKit docker image
+       [ -d "/xdt/sdk" ] && export XDT_SDK=/xdt/sdk || export XDT_SDK=$HOME/xds-workspace/.sdks
+fi
 
 export SDK_FAMILY_NAME="agl"
 export SDK_ROOT_DIR="$XDT_SDK"
index 5c040ea..379be3e 100755 (executable)
@@ -49,7 +49,7 @@ ENV = subprocess.check_output(
 for elt in ENV:
     k, v = elt.split('=', 1)
     if k == 'SDK_ROOT_DIR':
-        SDK_ROOT_DIR = v
+        SDK_ROOT_DIR = v.rstrip('/')
     elif k == 'SDK_ENV_SETUP_FILENAME':
         SDK_ENV_SETUP_FILENAME = v
 
@@ -96,9 +96,10 @@ for root, dirs, files in os.walk(SDK_ROOT_DIR):
 
 for one_sdk in INSTALLED_SDK:
     logging.debug("Processing %s", one_sdk['ENV_FILE'])
-    PROFILE = one_sdk['ENV_FILE'].split('/')[3]
-    VERSION = one_sdk['ENV_FILE'].split('/')[4]
-    ARCH = one_sdk['ENV_FILE'].split('/')[5]
+    envFile = one_sdk['ENV_FILE'].split(SDK_ROOT_DIR+'/')[1]
+    PROFILE = envFile.split('/')[0]
+    VERSION = envFile.split('/')[1]
+    ARCH = envFile.split('/')[2]
     DIR = os.path.dirname(one_sdk['ENV_FILE'])
     if PROFILE == '' or VERSION == '' or ARCH == '' or DIR == '':
         logging.debug('Path not compliant, skipping')