summaryrefslogtreecommitdiffstats
path: root/scripts/bitbake-whatchanged
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2014-04-22 12:07:35 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-06-25 11:48:13 +0100
commit0b5e94e168819134dcda0433c8ae893df4ab13ce (patch)
tree6b0e91abf56d7da60c20fb3f25e547adc0d66a5a /scripts/bitbake-whatchanged
parent41bd9dbf6f3e0add6a9e2cb20cfcbff44d785ea4 (diff)
downloadopenembedded-core-0b5e94e168819134dcda0433c8ae893df4ab13ce.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]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'scripts/bitbake-whatchanged')
-rwxr-xr-xscripts/bitbake-whatchanged18
1 files changed, 9 insertions, 9 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
import subprocess
from optparse import OptionParser
-# Figure out where is the bitbake/lib/bb since we need bb.siggen and bb.process
-p = subprocess.Popen("bash -c 'echo $(dirname $(which bitbake-diffsigs | grep -v \'^alias\'))/../lib'",
- shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
+lib_path = scripts_path + '/lib'
+sys.path = sys.path + [lib_path]
-err = p.stderr.read()
-if err:
- print("ERROR: Failed to locate bitbake-diffsigs:", file=sys.stderr)
- print(err, file=sys.stderr)
- sys.exit(1)
+import scriptpath
-sys.path.insert(0, p.stdout.read().rstrip('\n'))
+# Figure out where is the bitbake/lib/bb since we need bb.siggen and bb.process
+bitbakepath = scriptpath.add_bitbake_lib_path()
+if not bitbakepath:
+ sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
+ sys.exit(1)
import bb.siggen
import bb.process