diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/scriptutils.py | 65 |
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 | |||
21 | import glob | 21 | import glob |
22 | import argparse | 22 | import argparse |
23 | import subprocess | 23 | import subprocess |
24 | import tempfile | ||
25 | import shutil | ||
24 | 26 | ||
25 | def logger_create(name, stream=None): | 27 | def logger_create(name, stream=None): |
26 | logger = logging.getLogger(name) | 28 | logger = logging.getLogger(name) |
@@ -78,32 +80,47 @@ def git_convert_standalone_clone(repodir): | |||
78 | 80 | ||
79 | def fetch_uri(d, uri, destdir, srcrev=None): | 81 | def fetch_uri(d, uri, destdir, srcrev=None): |
80 | """Fetch a URI to a local directory""" | 82 | """Fetch a URI to a local directory""" |
81 | import bb.data | 83 | import bb |
82 | bb.utils.mkdirhier(destdir) | 84 | tmpparent = d.getVar('BASE_WORKDIR') |
83 | localdata = bb.data.createCopy(d) | 85 | bb.utils.mkdirhier(tmpparent) |
84 | localdata.setVar('BB_STRICT_CHECKSUM', '') | 86 | tmpworkdir = tempfile.mkdtemp(dir=tmpparent) |
85 | localdata.setVar('SRCREV', srcrev) | ||
86 | ret = (None, None) | ||
87 | olddir = os.getcwd() | ||
88 | try: | 87 | try: |
89 | fetcher = bb.fetch2.Fetch([uri], localdata) | 88 | bb.utils.mkdirhier(destdir) |
90 | for u in fetcher.ud: | 89 | localdata = bb.data.createCopy(d) |
91 | ud = fetcher.ud[u] | 90 | |
92 | ud.ignore_checksums = True | 91 | # Set some values to allow extend_recipe_sysroot to work here we're we are not running from a task |
93 | fetcher.download() | 92 | localdata.setVar('WORKDIR', tmpworkdir) |
94 | for u in fetcher.ud: | 93 | localdata.setVar('BB_RUNTASK', 'do_fetch') |
95 | ud = fetcher.ud[u] | 94 | localdata.setVar('PN', 'dummy') |
96 | if ud.localpath.rstrip(os.sep) == localdata.getVar('DL_DIR').rstrip(os.sep): | 95 | localdata.setVar('BB_LIMITEDDEPS', '1') |
97 | raise Exception('Local path is download directory - please check that the URI "%s" is correct' % uri) | 96 | bb.build.exec_func("extend_recipe_sysroot", localdata) |
98 | fetcher.unpack(destdir) | 97 | |
99 | for u in fetcher.ud: | 98 | # Set some values for the benefit of the fetcher code |
100 | ud = fetcher.ud[u] | 99 | localdata.setVar('BB_STRICT_CHECKSUM', '') |
101 | if ud.method.recommends_checksum(ud): | 100 | localdata.setVar('SRCREV', srcrev) |
102 | md5value = bb.utils.md5_file(ud.localpath) | 101 | ret = (None, None) |
103 | sha256value = bb.utils.sha256_file(ud.localpath) | 102 | olddir = os.getcwd() |
104 | ret = (md5value, sha256value) | 103 | try: |
104 | fetcher = bb.fetch2.Fetch([uri], localdata) | ||
105 | for u in fetcher.ud: | ||
106 | ud = fetcher.ud[u] | ||
107 | ud.ignore_checksums = True | ||
108 | fetcher.download() | ||
109 | for u in fetcher.ud: | ||
110 | ud = fetcher.ud[u] | ||
111 | if ud.localpath.rstrip(os.sep) == localdata.getVar('DL_DIR').rstrip(os.sep): | ||
112 | raise Exception('Local path is download directory - please check that the URI "%s" is correct' % uri) | ||
113 | fetcher.unpack(destdir) | ||
114 | for u in fetcher.ud: | ||
115 | ud = fetcher.ud[u] | ||
116 | if ud.method.recommends_checksum(ud): | ||
117 | md5value = bb.utils.md5_file(ud.localpath) | ||
118 | sha256value = bb.utils.sha256_file(ud.localpath) | ||
119 | ret = (md5value, sha256value) | ||
120 | finally: | ||
121 | os.chdir(olddir) | ||
105 | finally: | 122 | finally: |
106 | os.chdir(olddir) | 123 | shutil.rmtree(tmpworkdir) |
107 | return ret | 124 | return ret |
108 | 125 | ||
109 | def run_editor(fn): | 126 | def run_editor(fn): |