I created this fetcher class for the source code control system that we are
using. I'd be surprised if anyone else uses this, But if someone out there
IS using it, I'd love to know so we can work together.
also, being a Python dummy, I'd love some comments on what I've done (right,
wrong, good, bad, ugly).
note that before running bitbake I call the "ccm start" command and then
"export CCM_ADDR" since that is a one time setup that needs to be done.
for now a url looks like this:
ccm://<project-name>,<project-version/baseline>
Thanks
Mike
diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py
index cf26dc1..f708d9a 100644
--- a/lib/bb/fetch/__init__.py
+++ b/lib/bb/fetch/__init__.py
@@ -734,6 +734,7 @@ import wget
import svk
import ssh
import perforce
+import ccm
import bzr
import hg
import osc
@@ -747,6 +748,7 @@ methods.append(cvs.Cvs())
methods.append(svk.Svk())
methods.append(ssh.SSH())
methods.append(perforce.Perforce())
+methods.append(ccm.Ccm())
methods.append(bzr.Bzr())
methods.append(hg.Hg())
methods.append(osc.Osc())
diff --git a/lib/bb/fetch/ccm.py b/lib/bb/fetch/ccm.py
new file mode 100644
index 0000000..7afae18
--- /dev/null
+++ b/lib/bb/fetch/ccm.py
@@ -0,0 +1,123 @@
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+"""
+BitBake 'Fetch' implementations
+
+Classes for obtaining upstream sources for the
+BitBake build tools.
+CMSYERGY CCM source code control management. URL in the following form:
+
+ccm://<project_spec>
+
+For now we assume that we have called ccm start and that we are only copying
+a project w/ wa_snapshot
+
+"""
+
+# Copyright (C) 2003, 2004 Chris Larson
+#
+# 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
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Based on functions from the base bb module, Copyright 2003 Holger Schurig
+
+import os
+import bb
+from bb import data
+from bb.fetch import Fetch
+from bb.fetch import FetchError
+from bb.fetch import runfetchcmd
+
+class Ccm(Fetch):
+ def supports(self, url, ud, d):
+ return ud.type in ['ccm']
+
+ def doparse(url, d):
+ parm = {}
+ path = url.split("://")[1]
+
+ if path.find(";") != -1:
+ keys=[]
+ values=[]
+ plist = path.split(';')
+ for item in plist:
+ if item.count('='):
+ (key, value) = item.split('=')
+ keys.append(key)
+ values.append(value)
+
+ parm = dict(zip(keys, values))
+
+ host = "localhost"
+ user = data.getVar("USER", d, 1)
+ pswd = "x"
+
+ return host, path, user, pswd, parm
+ doparse = staticmethod(doparse)
+
+ def localpath(self, url, ud, d):
+
+ (host, path, user, pswd, parm) = Ccm.doparse(url, d)
+
+ # If a label is specified, we use that as our filename
+
+ if "label" in parm:
+ ud.localfile = "%s.tar.gz" % (parm["label"])
+ return os.path.join(data.getVar("DL_DIR", d, 1), ud.localfile)
+
+ base = path
+ which = path.find('/...')
+ if which != -1:
+ base = path[:which]
+
+ if base[0] == "/":
+ base = base[1:]
+
+ cset = data.getVar("PN", d, 1)
+
+ ud.localfile = "%s.tar.gz" % cset
+
+ return os.path.join(data.getVar("DL_DIR", d, 1), ud.localfile)
+
+ def go(self, loc, ud, d):
+ """
+ Fetch urls
+ """
+
+ (host, depot, user, pswd, parm) = Ccm.doparse(loc, d)
+ bb.msg.debug(1, bb.msg.domain.Fetcher, "Ccm.doparse %s %s %s %s %s" % (host, depot, user, pswd, parm))
+
+
+ dldir = data.getVar("DL_DIR", d, 1)
+ pn = data.getVar("PN", d, 1)
+ ccmcmd = "/usr/local/ccm/bin/ccm wa_snapshot %s -path %s" % (depot, pn)
+ runfetchcmd(ccmcmd, d)
+
+ bb.msg.debug(1, bb.msg.domain.Fetcher, "done command %s" % ccmcmd)
+ # tar them up to a defined filename
+
+ os.chdir("%s/%s" % (dldir, pn))
+ try:
+ runfetchcmd("tar -czf %s %s" % (ud.localpath, pn), d)
+ bb.msg.debug(1, bb.msg.domain.Fetcher, "done tar" )
+ except:
+ t, v, tb = sys.exc_info()
+ try:
+ os.unlink(ud.localpath)
+ except OSError:
+ pass
+ raise t, v, tb
+
+ os.system('rm -rf %s' % pn)
+
+
_______________________________________________
Bitbake-dev mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/bitbake-dev