summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-09-08 11:39:07 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-09 14:25:03 +0100
commit0d0b8425eaf74a6d7f3d9f6471e6edca1a273c06 (patch)
tree9ab36283c42aaf94cf58d7baea68103a34a47463
parent2355ccc627c0003a14693d1a023a003b7b44ea53 (diff)
downloadopenembedded-core-contrib-0d0b8425eaf74a6d7f3d9f6471e6edca1a273c06.tar.gz
openembedded-core-contrib-0d0b8425eaf74a6d7f3d9f6471e6edca1a273c06.tar.bz2
openembedded-core-contrib-0d0b8425eaf74a6d7f3d9f6471e6edca1a273c06.zip
scriptutils: split out simple fetching function from recipetool
This will now also be used by "devtool upgrade". Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/recipetool/create.py30
-rw-r--r--scripts/lib/scriptutils.py27
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():
-def fetch_source(uri, destdir, srcrev):
- import bb.data
- bb.utils.mkdirhier(destdir)
- localdata = bb.data.createCopy(tinfoil.config_data)
- bb.data.update_data(localdata)
- 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()
- 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)
- except bb.fetch2.BBFetchException, e:
- raise bb.build.FuncFailed(e)
- finally:
- os.chdir(olddir)
- return ret
-
def supports_srcrev(uri):
localdata = bb.data.createCopy(tinfoil.config_data)
# 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):
tempsrc = tempfile.mkdtemp(prefix='recipetool-')
srctree = tempsrc
logger.info('Fetching %s...' % srcuri)
- checksums = fetch_source(args.source, srctree, srcrev)
+ checksums = scriptutils.fetch_uri(tinfoil.config_data, args.source, srctree, srcrev)
dirlist = os.listdir(srctree)
if 'git.indirectionsymlink' in dirlist:
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):
# of the contents is shared
bb.process.run('git repack -a', cwd=repodir)
os.remove(alternatesfile)
+
+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()
+ try:
+ fetcher = bb.fetch2.Fetch([uri], localdata)
+ for u in fetcher.ud:
+ ud = fetcher.ud[u]
+ ud.ignore_checksums = True
+ fetcher.download()
+ 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)
+ return ret
+