path: root/scripts
diff options
authorHongxu Jia <>2013-08-28 04:30:01 (GMT)
committerRichard Purdie <>2013-08-30 15:23:47 (GMT)
commit926a11748696c955b9684c9cac3a2e65e51528fc (patch)
tree4c5889d74ffcfe58b935aefb351ede25bd10f703 /scripts
parent1370927687cdc7bbc1de329744b33771345e395f (diff)
downloadpoky-926a11748696c955b9684c9cac3a2e65e51528fc.tar.gz fix searching bitbake module failed
Run on wrlinux's platform in which the oe-core layer and bitbake layer in different directories: ---- ../layers/oe-core/scripts/contrib/ Traceback (most recent call last): File "../layers/oe-core/scripts/contrib/", line 28, in <module> import bb.cache ImportError: No module named bb.cache ---- The script import bb module from bitbake lib dir, the previous lib dir was hardcode and only worked on poky but not for others. In this situation, look for bitbake/bin dir in PATH could fix this issue. [YOCTO #5060] (From OE-Core rev: 9e749c430f97b1a30cdf0c13dacd2a985ef7b433) Signed-off-by: Hongxu Jia <> Signed-off-by: Richard Purdie <>
Diffstat (limited to 'scripts')
1 files changed, 25 insertions, 7 deletions
diff --git a/scripts/contrib/ b/scripts/contrib/
index 149922d..371033a 100755
--- a/scripts/contrib/
+++ b/scripts/contrib/
@@ -23,8 +23,26 @@ import sys
23import getopt 23import getopt
24import os 24import os
25 25
26def search_bitbakepath():
27 bitbakepath = ""
29 # Search path to bitbake lib dir in order to load bb modules
30 if os.path.exists(os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib/bb')):
31 bitbakepath = os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib')
32 bitbakepath = os.path.abspath(bitbakepath)
33 else:
34 # Look for bitbake/bin dir in PATH
35 for pth in os.environ['PATH'].split(':'):
36 if os.path.exists(os.path.join(pth, '../lib/bb')):
37 bitbakepath = os.path.abspath(os.path.join(pth, '../lib'))
38 break
39 if not bitbakepath:
40 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
41 sys.exit(1)
42 return bitbakepath
26# For importing the following modules 44# For importing the following modules
27sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), '../../bitbake/lib')) 45sys.path.insert(0, search_bitbakepath())
28import bb.cache 46import bb.cache
29import bb.cooker 47import bb.cooker
30import bb.providers 48import bb.providers
@@ -39,12 +57,12 @@ OPTION:
39 -p, --prefer list pkgs with preferred version 57 -p, --prefer list pkgs with preferred version
40 58
41EXAMPLE: 59EXAMPLE: poky/meta poky/meta-yocto -f poky/meta poky/meta-yocto -f -a poky/meta poky/meta-yocto -a -p poky/meta poky/meta-yocto -p -f -p poky/meta poky/meta-yocto -f -p -a -p poky/meta poky/meta-yocto -a -p
48''' 66'''
49 67
50def usage(): 68def usage():