diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2007-07-25 21:26:43 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2007-07-25 21:26:43 +0000 |
commit | fabea4d6a6e061b8144810324b0ebb9ffb7b9e54 (patch) | |
tree | 43ba072b57be9a785c8fa2b2041a70a63c295b67 | |
parent | 4eb393be0873f73882d3c48dd80d86aa73cc7b93 (diff) | |
download | bitbake-fabea4d6a6e061b8144810324b0ebb9ffb7b9e54.tar.gz |
svn.py: Fix #2624 and #2644 by changing svn layout in SVNDIR (backport)
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/bb/fetch/svn.py | 75 |
2 files changed, 47 insertions, 32 deletions
@@ -1,4 +1,8 @@ Changes in Bitbake 1.8.x: + - Rewrite svn fetcher to make adding extra operations easier + as part of future SRCDATE="now" fixes + (requires new FETCHCMD_svn definition in bitbake.conf) + - Change SVNDIR layout to be more unique (fixes #2644 and #2624) Changes in Bitbake 1.8.6: - Correctly redirect stdin when forking diff --git a/lib/bb/fetch/svn.py b/lib/bb/fetch/svn.py index 120f4f853..23ca262bc 100644 --- a/lib/bb/fetch/svn.py +++ b/lib/bb/fetch/svn.py @@ -1,17 +1,12 @@ # ex:ts=4:sw=4:sts=4:et # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- """ -BitBake 'Fetch' implementations - -This implementation is for svn. It is based on the cvs implementation. +BitBake 'Fetch' implementation for svn. """ -# Copyright (C) 2004 Marcin Juszkiewicz -# -# Classes for obtaining upstream sources for the -# BitBake build tools. -# Copyright (C) 2003, 2004 Chris Larson +# Copyright (C) 2003, 2004 Chris Larson +# Copyright (C) 2004 Marcin Juszkiewicz # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -47,8 +42,9 @@ class Svn(Fetch): def localpath(self, url, ud, d): if not "module" in ud.parm: raise MissingParameterError("svn method needs a 'module' parameter") - else: - ud.module = ud.parm["module"] + + ud.module = ud.parm["module"] + ud.moddir = ud.module.replace('/', '.') ud.revision = "" if 'rev' in ud.parm: @@ -57,7 +53,7 @@ class Svn(Fetch): if ud.revision: ud.date = "" - ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d) + ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.moddir, ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d) return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) @@ -66,13 +62,13 @@ class Svn(Fetch): return True return False - def go(self, loc, ud, d): - """Fetch url""" + def _buildsvncommand(self, ud, d, command): + """ + Build up an svn commandline based on ud + command is "fetch", "update", "info" + """ - # try to use the tarball stash - if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile): - bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping svn checkout." % ud.localpath) - return + basecmd = data.expand('${FETCHCMD_svn}', d) proto = "svn" if "proto" in ud.parm: @@ -97,38 +93,52 @@ class Svn(Fetch): if ud.pswd: options.append("--password %s" % ud.pswd) - localdata = data.createCopy(d) - data.setVar('OVERRIDES', "svn:%s" % data.getVar('OVERRIDES', localdata), localdata) - data.update_data(localdata) - - data.setVar('SVNROOT', "%s://%s/%s" % (proto, svnroot, ud.module), localdata) - data.setVar('SVNCOOPTS', " ".join(options), localdata) - data.setVar('SVNMODULE', ud.module, localdata) - svncmd = data.getVar('FETCHCOMMAND', localdata, 1) - svnupcmd = data.getVar('UPDATECOMMAND', localdata, 1) + if command is "fetch": + svncmd = "%s co %s %s://%s/%s %s" % (basecmd, " ".join(options), proto, svnroot, ud.module, ud.module) + elif command is "update": + svncmd = "%s update %s" % (basecmd, " ".join(options)) + elif command is "info": + svncmd = "%s info %s %s://%s/%s" % (basecmd, " ".join(options), proto, svnroot, ud.module) + else: + raise FetchError("Invalid svn command %s" % command) if svn_rsh: svncmd = "svn_RSH=\"%s\" %s" % (svn_rsh, svncmd) - svnupcmd = "svn_RSH=\"%s\" %s" % (svn_rsh, svnupcmd) + + return svncmd + + def go(self, loc, ud, d): + """Fetch url""" + + # try to use the tarball stash + if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile): + bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping svn checkout." % ud.localpath) + return pkg = data.expand('${PN}', d) - pkgdir = os.path.join(data.expand('${SVNDIR}', localdata), pkg) + relpath = ud.path + if relpath.startswith('/'): + # Remove leading slash as os.path.join can't cope + relpath = relpath[1:] + pkgdir = os.path.join(data.expand('${SVNDIR}', d), ud.host, relpath) moddir = os.path.join(pkgdir, ud.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): + svnupdatecmd = self._buildsvncommand(ud, d, "update") 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) + bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svnupdatecmd) + myret = os.system(svnupdatecmd) else: + svnfetchcmd = self._buildsvncommand(ud, d, "fetch") 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) + bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svnfetchcmd) + myret = os.system(svnfetchcmd) if myret != 0: raise FetchError(ud.module) @@ -142,3 +152,4 @@ class Svn(Fetch): except OSError: pass raise FetchError(ud.module) + |