Skip to contentSkip to conversation

tinfoil.py: Check if BUILDDIR exists

PATCH Superseded Amanda Brindle 3 participants 4 messages Jan 19, 2018 – Jan 22, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover tinfoil.py: Check if BUILDDIR exists

The following changes since commit e153efde9754a650e555f46cba09680baabd7d7e:

multilib.bbclass: deltask populate_sdk and populate_sdk_ext (2018-01-19 12:37:14 +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 exists

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

PATCH 1/1 tinfoil.py: Check if BUILDDIR exists

Check if BUILDDIR exists in order to deterimine if a tinfoil using script is running without having called oe-init-build-env (or similar). If not, instruct user to initialise the build environment, and then error out immediately. Before, tinfoil would hang for 30s before erroring out.

Fixes [YOCTO #12096]

---
 bitbake/lib/bb/tinfoil.py | 5 +++++
 1 file changed, 5 insertions(+)
bitbake/lib/bb/tinfoil.py +5 -0
index 368264f..e156b47 100644
@@ -372,6 +372,11 @@ class Tinfoil:
         """
         self.quiet = quiet
 
+        basepath = os.environ.get('BUILDDIR')
+        if not basepath:
+            print("Tinfoil can only be run after initialising the build environment (e.g. by using oe-init-build-env)")
+            sys.exit(1)
+
         if self.tracking:
             extrafeatures = [bb.cooker.CookerFeatures.BASEDATASTORE_TRACKING]
         else:
Signature · 1 line
2.7.4
#2 lore raw

Hi Amanda,

bitbake/lib/bb/tinfoil.py class Tinfoil: · line 379

Quoted 6 lines · NZDT Amanda Brindle
bitbake/lib/bb/tinfoil.py +3 -0
+        basepath = os.environ.get('BUILDDIR')
+        if not basepath:
+            print("Tinfoil can only be run after initialising the build

environment (e.g. by using oe-init-build-env)")

bitbake/lib/bb/tinfoil.py +2 -0
+            sys.exit(1)
+

We should be raising an exception here - tinfoil is utility code, it shouldn't be calling sys.exit(). Additionally, bitbake shouldn't be referring to oe-init-build-env, that's something from OpenEmbedded; even mentioning Tinfoil isn't going to be much use to the user. I would simply raise a custom exception class with the message "Build environment not initialised" or similar, and if tinfoil-using want to catch that exception and produce a more friendly message they can fairly easily do so.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#3 lore raw
Quoted 11 lines · Paul Eggleton

Hi Amanda,

Quoted 8 lines · NZDT Amanda Brindle

+        basepath = os.environ.get('BUILDDIR')
+        if not basepath:
+            print("Tinfoil can only be run after initialising the build
environment (e.g. by using oe-init-build-env)")
+            sys.exit(1)
+

Quoted 13 lines

We should be raising an exception here - tinfoil is utility code, it shouldn't
be calling sys.exit(). Additionally, bitbake shouldn't be referring to
oe-init-build-env, that's something from OpenEmbedded; even mentioning Tinfoil
isn't going to be much use to the user. I would simply raise a custom
exception class with the message "Build environment not initialised" or
similar, and if tinfoil-using want to catch that exception and produce a more
friendly message they can fairly easily do so.

This was also triggering on the autobuilder tests so something isn't quite right here:

https://autobuilder.yocto.io/builders/nightly-x86-64/builds/744/steps/Running%20ESDK%20Sanity%20Tests/logs/stdio

Cheers,

Richard