diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2006-11-12 00:12:32 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2006-11-12 00:12:32 +0000 |
commit | e8c28acecb269b3f115f5a548f5f3897f38d9296 (patch) | |
tree | b0a1369d22336b29ccb19c8faa4f8a545956da2e /lib/bb/fetch/svn.py | |
parent | e9cd560307a02c33452f13f4cd3ab0280af28b69 (diff) | |
download | bitbake-e8c28acecb269b3f115f5a548f5f3897f38d9296.tar.gz |
fetchers: Refactor interating through urls into the fetcher core (preparing for common md5/tarball stash code)
Diffstat (limited to 'lib/bb/fetch/svn.py')
-rw-r--r-- | lib/bb/fetch/svn.py | 197 |
1 files changed, 96 insertions, 101 deletions
diff --git a/lib/bb/fetch/svn.py b/lib/bb/fetch/svn.py index ad36b017f..79d7d3d29 100644 --- a/lib/bb/fetch/svn.py +++ b/lib/bb/fetch/svn.py @@ -63,111 +63,106 @@ class Svn(Fetch): 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) - def go(self, d, urls = []): - """Fetch urls""" - if not urls: - urls = self.urls + def go(self, d, loc): + """Fetch url""" localdata = data.createCopy(d) data.setVar('OVERRIDES', "svn:%s" % data.getVar('OVERRIDES', localdata), localdata) data.update_data(localdata) - for loc in urls: - (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, localdata)) - if not "module" in parm: - raise MissingParameterError("svn method needs a 'module' parameter") - else: - module = parm["module"] - - dlfile = self.localpath(loc, localdata) - dldir = data.getVar('DL_DIR', localdata, 1) -# if local path contains the svn -# module, consider the dir above it to be the -# download directory -# pos = dlfile.find(module) -# if pos: -# dldir = dlfile[:pos] -# else: -# dldir = os.path.dirname(dlfile) - -# setup svn options - options = [] - if 'rev' in parm: - revision = parm['rev'] - else: - revision = "" - - date = Fetch.getSRCDate(d) - - if "proto" in parm: - proto = parm["proto"] - else: - proto = "svn" - - svn_rsh = None - if proto == "svn+ssh" and "rsh" in parm: - svn_rsh = parm["rsh"] - - tarfn = data.expand('%s_%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, path.replace('/', '.'), revision, date), localdata) - data.setVar('TARFILES', dlfile, localdata) - data.setVar('TARFN', tarfn, localdata) - - # try to use the tarball stash - if Fetch.check_for_tarball(d, tarfn, dldir, date): - bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping svn checkout." % tarfn) - continue - - olddir = os.path.abspath(os.getcwd()) - os.chdir(data.expand(dldir, localdata)) - - svnroot = host + path - - # either use the revision, or SRCDATE in braces, or nothing for SRCDATE = "now" - if revision: - options.append("-r %s" % revision) - elif date != "now": - options.append("-r {%s}" % date) - - data.setVar('SVNROOT', "%s://%s/%s" % (proto, svnroot, module), localdata) - data.setVar('SVNCOOPTS', " ".join(options), localdata) - data.setVar('SVNMODULE', module, localdata) - svncmd = data.getVar('FETCHCOMMAND', localdata, 1) - svnupcmd = data.getVar('UPDATECOMMAND', localdata, 1) - - if svn_rsh: - svncmd = "svn_RSH=\"%s\" %s" % (svn_rsh, svncmd) - svnupcmd = "svn_RSH=\"%s\" %s" % (svn_rsh, svnupcmd) - - pkg=data.expand('${PN}', d) - pkgdir=os.path.join(data.expand('${SVNDIR}', localdata), pkg) - moddir=os.path.join(pkgdir, module) - bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: checking for module directory '" + moddir + "'") - - if os.access(os.path.join(moddir,'.svn'), os.R_OK): - bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc) - # update sources there - os.chdir(moddir) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svnupcmd) - myret = os.system(svnupcmd) - else: - bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) - # check out sources there - bb.mkdirhier(pkgdir) - os.chdir(pkgdir) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svncmd) - myret = os.system(svncmd) - - if myret != 0: - raise FetchError(module) + (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, localdata)) + if not "module" in parm: + raise MissingParameterError("svn method needs a 'module' parameter") + else: + module = parm["module"] + dlfile = self.localpath(loc, localdata) + dldir = data.getVar('DL_DIR', localdata, 1) +# if local path contains the svn +# module, consider the dir above it to be the +# download directory +# pos = dlfile.find(module) +# if pos: +# dldir = dlfile[:pos] +# else: +# dldir = os.path.dirname(dlfile) + +# setup svn options + options = [] + if 'rev' in parm: + revision = parm['rev'] + else: + revision = "" + + date = Fetch.getSRCDate(d) + + if "proto" in parm: + proto = parm["proto"] + else: + proto = "svn" + + svn_rsh = None + if proto == "svn+ssh" and "rsh" in parm: + svn_rsh = parm["rsh"] + + tarfn = data.expand('%s_%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, path.replace('/', '.'), revision, date), localdata) + data.setVar('TARFILES', dlfile, localdata) + data.setVar('TARFN', tarfn, localdata) + + # try to use the tarball stash + if Fetch.check_for_tarball(d, tarfn, dldir, date): + bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping svn checkout." % tarfn) + return + + olddir = os.path.abspath(os.getcwd()) + os.chdir(data.expand(dldir, localdata)) + + svnroot = host + path + + # either use the revision, or SRCDATE in braces, or nothing for SRCDATE = "now" + if revision: + options.append("-r %s" % revision) + elif date != "now": + options.append("-r {%s}" % date) + + data.setVar('SVNROOT', "%s://%s/%s" % (proto, svnroot, module), localdata) + data.setVar('SVNCOOPTS', " ".join(options), localdata) + data.setVar('SVNMODULE', module, localdata) + svncmd = data.getVar('FETCHCOMMAND', localdata, 1) + svnupcmd = data.getVar('UPDATECOMMAND', localdata, 1) + + if svn_rsh: + svncmd = "svn_RSH=\"%s\" %s" % (svn_rsh, svncmd) + svnupcmd = "svn_RSH=\"%s\" %s" % (svn_rsh, svnupcmd) + + pkg=data.expand('${PN}', d) + pkgdir=os.path.join(data.expand('${SVNDIR}', localdata), pkg) + moddir=os.path.join(pkgdir, module) + bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: checking for module directory '" + moddir + "'") + + if os.access(os.path.join(moddir,'.svn'), os.R_OK): + bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc) + # update sources there + os.chdir(moddir) + bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svnupcmd) + myret = os.system(svnupcmd) + else: + bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) + # check out sources there + bb.mkdirhier(pkgdir) os.chdir(pkgdir) - # 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 - os.chdir(olddir) - - del localdata + bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svncmd) + myret = os.system(svncmd) + + if myret != 0: + raise FetchError(module) + + os.chdir(pkgdir) + # 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 + os.chdir(olddir) |