diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2014-04-22 12:07:35 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-06-25 13:51:45 +0100 |
commit | 2b4e1506f054fded57dd361c347bdb25ddd9e245 (patch) | |
tree | 3572b1196bac1686df976507e0081e76de9dd2e7 /scripts/contrib/list-packageconfig-flags.py | |
parent | 3c7b5ec1cae6186a64e0be2c05b64b05add08c97 (diff) | |
download | poky-2b4e1506f054fded57dd361c347bdb25ddd9e245.tar.gz |
scripts: consolidate code to find bitbake path
Several of these scripts were using duplicated code (and slightly
different methods) to find the path to bitbake and add its lib
subdirectory to the Python import path. Add some common code to do this
and change the scripts to use it.
Fixes [YOCTO #5076].
(From OE-Core rev: 0b5e94e168819134dcda0433c8ae893df4ab13ce)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.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 | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/scripts/contrib/list-packageconfig-flags.py b/scripts/contrib/list-packageconfig-flags.py index 371033a3d8..615f91fdc7 100755 --- a/scripts/contrib/list-packageconfig-flags.py +++ b/scripts/contrib/list-packageconfig-flags.py | |||
@@ -23,26 +23,19 @@ import sys | |||
23 | import getopt | 23 | import getopt |
24 | import os | 24 | import os |
25 | 25 | ||
26 | def search_bitbakepath(): | 26 | |
27 | bitbakepath = "" | 27 | scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0]))) |
28 | 28 | lib_path = os.path.abspath(scripts_path + '/../lib') | |
29 | # Search path to bitbake lib dir in order to load bb modules | 29 | sys.path = sys.path + [lib_path] |
30 | if os.path.exists(os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib/bb')): | 30 | |
31 | bitbakepath = os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib') | 31 | import scriptpath |
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 | 32 | ||
44 | # For importing the following modules | 33 | # For importing the following modules |
45 | sys.path.insert(0, search_bitbakepath()) | 34 | bitbakepath = scriptpath.add_bitbake_lib_path() |
35 | if not bitbakepath: | ||
36 | sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") | ||
37 | sys.exit(1) | ||
38 | |||
46 | import bb.cache | 39 | import bb.cache |
47 | import bb.cooker | 40 | import bb.cooker |
48 | import bb.providers | 41 | import bb.providers |