diff options
-rwxr-xr-x | scripts/bitbake-whatchanged | 18 | ||||
-rwxr-xr-x | scripts/buildhistory-diff | 28 | ||||
-rwxr-xr-x | scripts/contrib/list-packageconfig-flags.py | 29 | ||||
-rw-r--r-- | scripts/lib/scriptpath.py | 42 |
4 files changed, 74 insertions, 43 deletions
diff --git a/scripts/bitbake-whatchanged b/scripts/bitbake-whatchanged index e4497e03a8..55cfe4b234 100755 --- a/scripts/bitbake-whatchanged +++ b/scripts/bitbake-whatchanged | |||
@@ -27,17 +27,17 @@ import warnings | |||
27 | import subprocess | 27 | import subprocess |
28 | from optparse import OptionParser | 28 | from optparse import OptionParser |
29 | 29 | ||
30 | # Figure out where is the bitbake/lib/bb since we need bb.siggen and bb.process | 30 | scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0]))) |
31 | p = subprocess.Popen("bash -c 'echo $(dirname $(which bitbake-diffsigs | grep -v \'^alias\'))/../lib'", | 31 | lib_path = scripts_path + '/lib' |
32 | shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 32 | sys.path = sys.path + [lib_path] |
33 | 33 | ||
34 | err = p.stderr.read() | 34 | import scriptpath |
35 | if err: | ||
36 | print("ERROR: Failed to locate bitbake-diffsigs:", file=sys.stderr) | ||
37 | print(err, file=sys.stderr) | ||
38 | sys.exit(1) | ||
39 | 35 | ||
40 | sys.path.insert(0, p.stdout.read().rstrip('\n')) | 36 | # Figure out where is the bitbake/lib/bb since we need bb.siggen and bb.process |
37 | bitbakepath = scriptpath.add_bitbake_lib_path() | ||
38 | if not bitbakepath: | ||
39 | sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") | ||
40 | sys.exit(1) | ||
41 | 41 | ||
42 | import bb.siggen | 42 | import bb.siggen |
43 | import bb.process | 43 | import bb.process |
diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff index ad50414bce..dfebcddf72 100755 --- a/scripts/buildhistory-diff +++ b/scripts/buildhistory-diff | |||
@@ -50,24 +50,20 @@ def main(): | |||
50 | parser.print_help() | 50 | parser.print_help() |
51 | sys.exit(1) | 51 | sys.exit(1) |
52 | 52 | ||
53 | scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0]))) | ||
54 | lib_path = scripts_path + '/lib' | ||
55 | sys.path = sys.path + [lib_path] | ||
56 | |||
57 | import scriptpath | ||
58 | |||
53 | # Set path to OE lib dir so we can import the buildhistory_analysis module | 59 | # Set path to OE lib dir so we can import the buildhistory_analysis module |
54 | basepath = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])) + '/..') | 60 | scriptpath.add_oe_lib_path() |
55 | newpath = basepath + '/meta/lib' | ||
56 | # Set path to bitbake lib dir so the buildhistory_analysis module can load bb.utils | 61 | # Set path to bitbake lib dir so the buildhistory_analysis module can load bb.utils |
57 | if os.path.exists(basepath + '/bitbake/lib/bb'): | 62 | bitbakepath = scriptpath.add_bitbake_lib_path() |
58 | bitbakepath = basepath + '/bitbake' | 63 | if not bitbakepath: |
59 | else: | 64 | sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") |
60 | # look for bitbake/bin dir in PATH | 65 | sys.exit(1) |
61 | bitbakepath = None | 66 | |
62 | for pth in os.environ['PATH'].split(':'): | ||
63 | if os.path.exists(os.path.join(pth, '../lib/bb')): | ||
64 | bitbakepath = os.path.abspath(os.path.join(pth, '..')) | ||
65 | break | ||
66 | if not bitbakepath: | ||
67 | sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") | ||
68 | sys.exit(1) | ||
69 | |||
70 | sys.path[0:0] = [newpath, bitbakepath + '/lib'] | ||
71 | import oe.buildhistory_analysis | 67 | import oe.buildhistory_analysis |
72 | 68 | ||
73 | fromrev = 'build-minus-1' | 69 | fromrev = 'build-minus-1' |
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 |
diff --git a/scripts/lib/scriptpath.py b/scripts/lib/scriptpath.py new file mode 100644 index 0000000000..d00317e18d --- /dev/null +++ b/scripts/lib/scriptpath.py | |||
@@ -0,0 +1,42 @@ | |||
1 | # Path utility functions for OE python scripts | ||
2 | # | ||
3 | # Copyright (C) 2012-2014 Intel Corporation | ||
4 | # Copyright (C) 2011 Mentor Graphics Corporation | ||
5 | # | ||
6 | # This program is free software; you can redistribute it and/or modify | ||
7 | # it under the terms of the GNU General Public License version 2 as | ||
8 | # published by the Free Software Foundation. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License along | ||
16 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | |||
19 | import sys | ||
20 | import os | ||
21 | import os.path | ||
22 | |||
23 | def add_oe_lib_path(): | ||
24 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../..') | ||
25 | newpath = basepath + '/meta/lib' | ||
26 | sys.path.insert(0, newpath) | ||
27 | |||
28 | def add_bitbake_lib_path(): | ||
29 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../..') | ||
30 | bitbakepath = None | ||
31 | if os.path.exists(basepath + '/bitbake/lib/bb'): | ||
32 | bitbakepath = basepath + '/bitbake' | ||
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, '..')) | ||
38 | break | ||
39 | |||
40 | if bitbakepath: | ||
41 | sys.path.insert(0, bitbakepath + '/lib') | ||
42 | return bitbakepath | ||