aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lib/scriptutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/scriptutils.py')
-rw-r--r--scripts/lib/scriptutils.py65
1 files changed, 41 insertions, 24 deletions
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py
index 4ccbe5c108..92b601c7e8 100644
--- a/scripts/lib/scriptutils.py
+++ b/scripts/lib/scriptutils.py
@@ -21,6 +21,8 @@ import logging
import glob
import argparse
import subprocess
+import tempfile
+import shutil
def logger_create(name, stream=None):
logger = logging.getLogger(name)
@@ -78,32 +80,47 @@ def git_convert_standalone_clone(repodir):
def fetch_uri(d, uri, destdir, srcrev=None):
"""Fetch a URI to a local directory"""
- import bb.data
- bb.utils.mkdirhier(destdir)
- localdata = bb.data.createCopy(d)
- localdata.setVar('BB_STRICT_CHECKSUM', '')
- localdata.setVar('SRCREV', srcrev)
- ret = (None, None)
- olddir = os.getcwd()
+ import bb
+ tmpparent = d.getVar('BASE_WORKDIR')
+ bb.utils.mkdirhier(tmpparent)
+ tmpworkdir = tempfile.mkdtemp(dir=tmpparent)
try:
- fetcher = bb.fetch2.Fetch([uri], localdata)
- for u in fetcher.ud:
- ud = fetcher.ud[u]
- ud.ignore_checksums = True
- fetcher.download()
- for u in fetcher.ud:
- ud = fetcher.ud[u]
- if ud.localpath.rstrip(os.sep) == localdata.getVar('DL_DIR').rstrip(os.sep):
- raise Exception('Local path is download directory - please check that the URI "%s" is correct' % uri)
- fetcher.unpack(destdir)
- for u in fetcher.ud:
- ud = fetcher.ud[u]
- if ud.method.recommends_checksum(ud):
- md5value = bb.utils.md5_file(ud.localpath)
- sha256value = bb.utils.sha256_file(ud.localpath)
- ret = (md5value, sha256value)
+ bb.utils.mkdirhier(destdir)
+ localdata = bb.data.createCopy(d)
+
+ # Set some values to allow extend_recipe_sysroot to work here we're we are not running from a task
+ localdata.setVar('WORKDIR', tmpworkdir)
+ localdata.setVar('BB_RUNTASK', 'do_fetch')
+ localdata.setVar('PN', 'dummy')
+ localdata.setVar('BB_LIMITEDDEPS', '1')
+ bb.build.exec_func("extend_recipe_sysroot", localdata)
+
+ # Set some values for the benefit of the fetcher code
+ localdata.setVar('BB_STRICT_CHECKSUM', '')
+ localdata.setVar('SRCREV', srcrev)
+ ret = (None, None)
+ olddir = os.getcwd()
+ try:
+ fetcher = bb.fetch2.Fetch([uri], localdata)
+ for u in fetcher.ud:
+ ud = fetcher.ud[u]
+ ud.ignore_checksums = True
+ fetcher.download()
+ for u in fetcher.ud:
+ ud = fetcher.ud[u]
+ if ud.localpath.rstrip(os.sep) == localdata.getVar('DL_DIR').rstrip(os.sep):
+ raise Exception('Local path is download directory - please check that the URI "%s" is correct' % uri)
+ fetcher.unpack(destdir)
+ for u in fetcher.ud:
+ ud = fetcher.ud[u]
+ if ud.method.recommends_checksum(ud):
+ md5value = bb.utils.md5_file(ud.localpath)
+ sha256value = bb.utils.sha256_file(ud.localpath)
+ ret = (md5value, sha256value)
+ finally:
+ os.chdir(olddir)
finally:
- os.chdir(olddir)
+ shutil.rmtree(tmpworkdir)
return ret
def run_editor(fn):