diff options
| author | Hongxu Jia <hongxu.jia@windriver.com> | 2013-08-28 12:30:01 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-08-30 16:23:47 +0100 |
| commit | 926a11748696c955b9684c9cac3a2e65e51528fc (patch) | |
| tree | 4c5889d74ffcfe58b935aefb351ede25bd10f703 /scripts/contrib/list-packageconfig-flags.py | |
| parent | 1370927687cdc7bbc1de329744b33771345e395f (diff) | |
| download | poky-926a11748696c955b9684c9cac3a2e65e51528fc.tar.gz | |
list-packageconfig-flags.py: fix searching bitbake module failed
Run list-packageconfig-flags.py on wrlinux's platform in which
the oe-core layer and bitbake layer in different directories:
----
../layers/oe-core/scripts/contrib/list-packageconfig-flags.py
Traceback (most recent call last):
File "../layers/oe-core/scripts/contrib/list-packageconfig-flags.py", 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 <hongxu.jia@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/contrib/list-packageconfig-flags.py')
| -rwxr-xr-x | scripts/contrib/list-packageconfig-flags.py | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/scripts/contrib/list-packageconfig-flags.py b/scripts/contrib/list-packageconfig-flags.py index 149922dc53..371033a3d8 100755 --- a/scripts/contrib/list-packageconfig-flags.py +++ b/scripts/contrib/list-packageconfig-flags.py | |||
| @@ -23,8 +23,26 @@ import sys | |||
| 23 | import getopt | 23 | import getopt |
| 24 | import os | 24 | import os |
| 25 | 25 | ||
| 26 | def search_bitbakepath(): | ||
| 27 | bitbakepath = "" | ||
| 28 | |||
| 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 | ||
| 43 | |||
| 26 | # For importing the following modules | 44 | # For importing the following modules |
| 27 | sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), '../../bitbake/lib')) | 45 | sys.path.insert(0, search_bitbakepath()) |
| 28 | import bb.cache | 46 | import bb.cache |
| 29 | import bb.cooker | 47 | import bb.cooker |
| 30 | import bb.providers | 48 | import 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 | ||
| 41 | EXAMPLE: | 59 | EXAMPLE: |
| 42 | list-packageconfig-flags.py poky/meta poky/meta-yocto | 60 | list-packageconfig-flags.py |
| 43 | list-packageconfig-flags.py -f poky/meta poky/meta-yocto | 61 | list-packageconfig-flags.py -f |
| 44 | list-packageconfig-flags.py -a poky/meta poky/meta-yocto | 62 | list-packageconfig-flags.py -a |
| 45 | list-packageconfig-flags.py -p poky/meta poky/meta-yocto | 63 | list-packageconfig-flags.py -p |
| 46 | list-packageconfig-flags.py -f -p poky/meta poky/meta-yocto | 64 | list-packageconfig-flags.py -f -p |
| 47 | list-packageconfig-flags.py -a -p poky/meta poky/meta-yocto | 65 | list-packageconfig-flags.py -a -p |
| 48 | ''' | 66 | ''' |
| 49 | 67 | ||
| 50 | def usage(): | 68 | def usage(): |
