From 984e90f4d71d866580131c4927b0a77baf1bb9bd Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 4 Feb 2011 13:20:28 +0000 Subject: meta/classes: Update classes to use new fetcher API Signed-off-by: Richard Purdie --- meta/classes/sstate.bbclass | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'meta/classes/sstate.bbclass') diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass index a754821c08..e4564e4b07 100644 --- a/meta/classes/sstate.bbclass +++ b/meta/classes/sstate.bbclass @@ -326,40 +326,40 @@ def sstate_package(ss, d): return def pstaging_fetch(sstatepkg, d): - import bb.fetch - - # only try and fetch if the user has configured a mirror + # Only try and fetch if the user has configured a mirror mirrors = bb.data.getVar('SSTATE_MIRRORS', d, True) - if mirrors: - # Copy the data object and override DL_DIR and SRC_URI - localdata = bb.data.createCopy(d) - bb.data.update_data(localdata) + if not mirrors: + return - dldir = bb.data.expand("${SSTATE_DIR}", localdata) - srcuri = "file://" + os.path.basename(sstatepkg) + import bb.fetch2 + # Copy the data object and override DL_DIR and SRC_URI + localdata = bb.data.createCopy(d) + bb.data.update_data(localdata) - bb.mkdirhier(dldir) + dldir = bb.data.expand("${SSTATE_DIR}", localdata) + srcuri = "file://" + os.path.basename(sstatepkg) - bb.data.setVar('DL_DIR', dldir, localdata) - bb.data.setVar('PREMIRRORS', mirrors, localdata) - bb.data.setVar('SRC_URI', srcuri, localdata) + bb.mkdirhier(dldir) - # Try a fetch from the sstate mirror, if it fails just return and - # we will build the package - try: - bb.fetch.init([srcuri], localdata) - if bb.fetch.__version__ == "1": - bb.fetch.go(localdata, [srcuri]) - else: - bb.fetch.download(localdata, [srcuri]) - # Need to optimise this, if using file:// urls, the fetcher just changes the local path - # For now work around by symlinking - localpath = bb.data.expand(bb.fetch.localpath(srcuri, localdata), localdata) - if localpath != sstatepkg and os.path.exists(localpath): - os.symlink(localpath, sstatepkg) - except: - pass + bb.data.setVar('DL_DIR', dldir, localdata) + bb.data.setVar('PREMIRRORS', mirrors, localdata) + bb.data.setVar('SRC_URI', srcuri, localdata) + + # Try a fetch from the sstate mirror, if it fails just return and + # we will build the package + try: + fetcher = bb.fetch2.Fetch([srcuri], localdata) + fetcher.download() + + # Need to optimise this, if using file:// urls, the fetcher just changes the local path + # For now work around by symlinking + localpath = bb.data.expand(fetcher.localpath(srcuri), localdata) + if localpath != sstatepkg and os.path.exists(localpath) and not os.path.exists(sstatepkg): + os.symlink(localpath, sstatepkg) + + except bb.fetch2.BBFetchException: + pass def sstate_setscene(d): shared_state = sstate_state_fromvars(d) -- cgit v1.2.3-54-g00ecf