diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2007-06-30 23:15:52 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2007-06-30 23:15:52 +0000 |
commit | 279e9499118f47ce4a803c8cfd383161facdc988 (patch) | |
tree | 5400fff31adb0ada0aeb20fe73db9722ba3fcf23 /lib/bb/fetch/svn.py | |
parent | f3666e79440fa93268cf466dad7fab64f04407c5 (diff) | |
download | bitbake-279e9499118f47ce4a803c8cfd383161facdc988.tar.gz |
svn fetcher: Create common 'build svn command' function
Diffstat (limited to 'lib/bb/fetch/svn.py')
-rw-r--r-- | lib/bb/fetch/svn.py | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/lib/bb/fetch/svn.py b/lib/bb/fetch/svn.py index 120f4f853..c7d27a285 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 @@ -66,13 +61,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 +92,48 @@ 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) + pkgdir = os.path.join(data.expand('${SVNDIR}', d), pkg) 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 +147,4 @@ class Svn(Fetch): except OSError: pass raise FetchError(ud.module) + |