Skip to contentSkip to conversation

tinfoil.py: Check if BUILDDIR or .devtoolbase exists

PATCH New Amanda Brindle 1 participant 2 messages Feb 7, 2018

lore
Share & tools
lore
#0 lore raw

v2 cover tinfoil.py: Check if BUILDDIR or .devtoolbase exists

In v2, if the build environment is not initialised, raise an exception instead of printing out a message.

Also, check if .devtoolbase exists. This will determine if an sdk environment has been sourced. If .devtoolbase exists, an exception should not be raised.

The following changes since commit 902b77bf91d96517b935bce00a11003604dc3d54:

lib/oe/package_manager/sdk: Ensure do_populate_sdk_ext and do_populate_sdk repos don't conflict (2018-01-22 10:39:10 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib abrindle/tinfoil
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=abrindle/tinfoil

Amanda Brindle (1):
tinfoil.py: Check if BUILDDIR or .devtoolbase exists

 bitbake/lib/bb/tinfoil.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 tinfoil.py: Check if BUILDDIR or .devtoolbase exists

Check if either BUILDDIR or .devtoolbase exists in order to deterimine if a tinfoil using script is running without having called oe-init-build-env (or similar). If not, raise an exception that a tinfoil using application can catch to produce an error message. Before, tinfoil would hang for 30s before erroring out.

Fixes [YOCTO #12096]

---
 bitbake/lib/bb/tinfoil.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
bitbake/lib/bb/tinfoil.py +17 -0
index 368264f..013e7f6 100644
@@ -54,6 +54,9 @@ class TinfoilUIException(Exception):
 class TinfoilCommandFailed(Exception):
     """Exception raised when run_command fails"""
 
+class TinfoilBuildEnvironmentException(Exception):
+    """Exception raised when build environment is not initialised"""
+
 class TinfoilDataStoreConnector:
     """Connector object used to enable access to datastore objects via tinfoil"""
 
@@ -372,6 +375,20 @@ class Tinfoil:
         """
         self.quiet = quiet
 
+        fixed_setup = False
+        basepath = os.path.dirname(os.path.abspath(__file__))
+        pth = basepath
+        while pth != '' and pth != os.sep:
+            if os.path.exists(os.path.join(pth, '.devtoolbase')):
+                fixed_setup = True
+                basepath = pth
+                break
+            pth = os.path.dirname(pth)
+        if not fixed_setup:
+            basepath = os.environ.get('BUILDDIR')
+            if not basepath:
+                raise TinfoilBuildEnvironmentException('Build environment not initialised')
+
         if self.tracking:
             extrafeatures = [bb.cooker.CookerFeatures.BASEDATASTORE_TRACKING]
         else:
Signature · 1 line
2.7.4