diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-09-08 11:39:07 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-09-09 14:27:50 +0100 |
commit | ee0c11d9889cc5abbffbec512d7232416a6e6319 (patch) | |
tree | c280fb65d876c853af8fbf7def31ad196f54c775 /scripts/lib | |
parent | 3690281efbd3770cc36aa6a65cf2e6999c7b9f9e (diff) | |
download | poky-ee0c11d9889cc5abbffbec512d7232416a6e6319.tar.gz |
scriptutils: split out simple fetching function from recipetool
This will now also be used by "devtool upgrade".
(From OE-Core rev: 0d0b8425eaf74a6d7f3d9f6471e6edca1a273c06)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/recipetool/create.py | 30 | ||||
-rw-r--r-- | scripts/lib/scriptutils.py | 27 |
2 files changed, 28 insertions, 29 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index ec6e107e62..c4754dbcdd 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
@@ -58,34 +58,6 @@ class RecipeHandler(): | |||
58 | 58 | ||
59 | 59 | ||
60 | 60 | ||
61 | def fetch_source(uri, destdir, srcrev): | ||
62 | import bb.data | ||
63 | bb.utils.mkdirhier(destdir) | ||
64 | localdata = bb.data.createCopy(tinfoil.config_data) | ||
65 | bb.data.update_data(localdata) | ||
66 | localdata.setVar('BB_STRICT_CHECKSUM', '') | ||
67 | localdata.setVar('SRCREV', srcrev) | ||
68 | ret = (None, None) | ||
69 | olddir = os.getcwd() | ||
70 | try: | ||
71 | fetcher = bb.fetch2.Fetch([uri], localdata) | ||
72 | for u in fetcher.ud: | ||
73 | ud = fetcher.ud[u] | ||
74 | ud.ignore_checksums = True | ||
75 | fetcher.download() | ||
76 | fetcher.unpack(destdir) | ||
77 | for u in fetcher.ud: | ||
78 | ud = fetcher.ud[u] | ||
79 | if ud.method.recommends_checksum(ud): | ||
80 | md5value = bb.utils.md5_file(ud.localpath) | ||
81 | sha256value = bb.utils.sha256_file(ud.localpath) | ||
82 | ret = (md5value, sha256value) | ||
83 | except bb.fetch2.BBFetchException, e: | ||
84 | raise bb.build.FuncFailed(e) | ||
85 | finally: | ||
86 | os.chdir(olddir) | ||
87 | return ret | ||
88 | |||
89 | def supports_srcrev(uri): | 61 | def supports_srcrev(uri): |
90 | localdata = bb.data.createCopy(tinfoil.config_data) | 62 | localdata = bb.data.createCopy(tinfoil.config_data) |
91 | # This is a bit sad, but if you don't have this set there can be some | 63 | # This is a bit sad, but if you don't have this set there can be some |
@@ -123,7 +95,7 @@ def create_recipe(args): | |||
123 | tempsrc = tempfile.mkdtemp(prefix='recipetool-') | 95 | tempsrc = tempfile.mkdtemp(prefix='recipetool-') |
124 | srctree = tempsrc | 96 | srctree = tempsrc |
125 | logger.info('Fetching %s...' % srcuri) | 97 | logger.info('Fetching %s...' % srcuri) |
126 | checksums = fetch_source(args.source, srctree, srcrev) | 98 | checksums = scriptutils.fetch_uri(tinfoil.config_data, args.source, srctree, srcrev) |
127 | dirlist = os.listdir(srctree) | 99 | dirlist = os.listdir(srctree) |
128 | if 'git.indirectionsymlink' in dirlist: | 100 | if 'git.indirectionsymlink' in dirlist: |
129 | dirlist.remove('git.indirectionsymlink') | 101 | dirlist.remove('git.indirectionsymlink') |
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index fdf4b5d55d..5d103a58fe 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py | |||
@@ -69,3 +69,30 @@ def git_convert_standalone_clone(repodir): | |||
69 | # of the contents is shared | 69 | # of the contents is shared |
70 | bb.process.run('git repack -a', cwd=repodir) | 70 | bb.process.run('git repack -a', cwd=repodir) |
71 | os.remove(alternatesfile) | 71 | os.remove(alternatesfile) |
72 | |||
73 | def fetch_uri(d, uri, destdir, srcrev=None): | ||
74 | """Fetch a URI to a local directory""" | ||
75 | import bb.data | ||
76 | bb.utils.mkdirhier(destdir) | ||
77 | localdata = bb.data.createCopy(d) | ||
78 | localdata.setVar('BB_STRICT_CHECKSUM', '') | ||
79 | localdata.setVar('SRCREV', srcrev) | ||
80 | ret = (None, None) | ||
81 | olddir = os.getcwd() | ||
82 | try: | ||
83 | fetcher = bb.fetch2.Fetch([uri], localdata) | ||
84 | for u in fetcher.ud: | ||
85 | ud = fetcher.ud[u] | ||
86 | ud.ignore_checksums = True | ||
87 | fetcher.download() | ||
88 | fetcher.unpack(destdir) | ||
89 | for u in fetcher.ud: | ||
90 | ud = fetcher.ud[u] | ||
91 | if ud.method.recommends_checksum(ud): | ||
92 | md5value = bb.utils.md5_file(ud.localpath) | ||
93 | sha256value = bb.utils.sha256_file(ud.localpath) | ||
94 | ret = (md5value, sha256value) | ||
95 | finally: | ||
96 | os.chdir(olddir) | ||
97 | return ret | ||
98 | |||