diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2006-11-12 14:25:28 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2006-11-12 14:25:28 +0000 |
commit | 9e86f17c8fdbd17ce4b3d0716a6b36fe58dc87d6 (patch) | |
tree | 6d2a9ec23171935115d6eb8fc790957800e50cd8 /lib/bb/fetch/svk.py | |
parent | e8c28acecb269b3f115f5a548f5f3897f38d9296 (diff) | |
download | bitbake-9e86f17c8fdbd17ce4b3d0716a6b36fe58dc87d6.tar.gz |
fetchers: Create a urldata object which is passed between the different url methods. Start to use this to remove duplicate code and duplicate function execution, simplifying the fetchers
Diffstat (limited to 'lib/bb/fetch/svk.py')
-rw-r--r-- | lib/bb/fetch/svk.py | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/lib/bb/fetch/svk.py b/lib/bb/fetch/svk.py index 46366c85a..05e5413e3 100644 --- a/lib/bb/fetch/svk.py +++ b/lib/bb/fetch/svk.py @@ -42,59 +42,49 @@ from bb.fetch import MissingParameterError class Svk(Fetch): """Class to fetch a module or modules from svk repositories""" - def supports(url, d): - """Check to see if a given url can be fetched with svk. - Expects supplied url in list form, as outputted by bb.decodeurl(). + def supports(self, url, ud, d): """ - (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d)) - return type in ['svk'] - supports = staticmethod(supports) - - def localpath(url, d): - (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d)) - if "localpath" in parm: -# if user overrides local path, use it. - return parm["localpath"] + Check to see if a given url can be fetched with cvs. + """ + return ud.type in ['svk'] - if not "module" in parm: + def localpath(self, url, ud, d): + if not "module" in ud.parm: raise MissingParameterError("svk method needs a 'module' parameter") else: - module = parm["module"] - if 'rev' in parm: - revision = parm['rev'] + module = ud.parm["module"] + if 'rev' in ud.parm: + revision = ud.parm['rev'] else: revision = "" - date = Fetch.getSRCDate(d) + ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), revision, ud.date), d) - return os.path.join(data.getVar("DL_DIR", d, 1),data.expand('%s_%s_%s_%s_%s.tar.gz' % ( module.replace('/', '.'), host, path.replace('/', '.'), revision, date), d)) - localpath = staticmethod(localpath) + return os.path.join(data.getVar("DL_DIR", d, 1), ud.localfile) - def go(self, d, loc): + def go(self, loc, ud, d): """Fetch urls""" localdata = data.createCopy(d) data.setVar('OVERRIDES', "svk:%s" % data.getVar('OVERRIDES', localdata), localdata) data.update_data(localdata) - (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, localdata)) - if not "module" in parm: + if not "module" in ud.parm: raise MissingParameterError("svk method needs a 'module' parameter") else: - module = parm["module"] + module = ud.parm["module"] - dlfile = self.localpath(loc, localdata) + dlfile = ud.localpath dldir = data.getVar('DL_DIR', localdata, 1) -# setup svk options + # setup svk options options = [] - if 'rev' in parm: - revision = parm['rev'] + if 'rev' in ud.parm: + revision = ud.parm['rev'] else: revision = "" - date = Fetch.getSRCDate(d) - tarfn = data.expand('%s_%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, path.replace('/', '.'), revision, date), localdata) + tarfn = ud.localfile data.setVar('TARFILES', dlfile, localdata) data.setVar('TARFN', tarfn, localdata) @@ -104,7 +94,7 @@ class Svk(Fetch): olddir = os.path.abspath(os.getcwd()) os.chdir(data.expand(dldir, localdata)) - svkroot = host + path + svkroot = ud.host + ud.path data.setVar('SVKROOT', svkroot, localdata) data.setVar('SVKCOOPTS', " ".join(options), localdata) @@ -114,7 +104,7 @@ class Svk(Fetch): if revision: svkcmd = "svk co -r %s/%s" % (revision, svkroot, module) -# create temp directory + # create temp directory bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: creating temporary directory") bb.mkdirhier(data.expand('${WORKDIR}', localdata)) data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata) @@ -124,7 +114,7 @@ class Svk(Fetch): bb.msg.error(bb.msg.domain.Fetcher, "Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.") raise FetchError(module) -# check out sources there + # check out sources there os.chdir(tmpfile) bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svkcmd) @@ -137,14 +127,14 @@ class Svk(Fetch): raise FetchError(module) os.chdir(os.path.join(tmpfile, os.path.dirname(module))) -# tar them up to a defined filename + # tar them up to a defined filename myret = os.system("tar -czf %s %s" % (os.path.join(dldir,tarfn), os.path.basename(module))) if myret != 0: try: os.unlink(tarfn) except OSError: pass -# cleanup + # cleanup os.system('rm -rf %s' % tmpfile) os.chdir(olddir) |