mirror of
https://git.yoctoproject.org/poky
synced 2026-04-27 03:32:12 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
3c7b5ec1ca
commit
2b4e1506f0
@@ -23,26 +23,19 @@ import sys
|
||||
import getopt
|
||||
import os
|
||||
|
||||
def search_bitbakepath():
|
||||
bitbakepath = ""
|
||||
|
||||
# Search path to bitbake lib dir in order to load bb modules
|
||||
if os.path.exists(os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib/bb')):
|
||||
bitbakepath = os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib')
|
||||
bitbakepath = os.path.abspath(bitbakepath)
|
||||
else:
|
||||
# Look for bitbake/bin dir in PATH
|
||||
for pth in os.environ['PATH'].split(':'):
|
||||
if os.path.exists(os.path.join(pth, '../lib/bb')):
|
||||
bitbakepath = os.path.abspath(os.path.join(pth, '../lib'))
|
||||
break
|
||||
if not bitbakepath:
|
||||
sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
|
||||
sys.exit(1)
|
||||
return bitbakepath
|
||||
scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
|
||||
lib_path = os.path.abspath(scripts_path + '/../lib')
|
||||
sys.path = sys.path + [lib_path]
|
||||
|
||||
import scriptpath
|
||||
|
||||
# For importing the following modules
|
||||
sys.path.insert(0, search_bitbakepath())
|
||||
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.cache
|
||||
import bb.cooker
|
||||
import bb.providers
|
||||
|
||||
Reference in New Issue
Block a user