<div dir="ltr">Could someone please take a look on this?<br><br>Thank you,<div><br></div><div>Zoltan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 4 November 2015 at 05:04, Zoltan Kuscsik <span dir="ltr"><<a href="mailto:zoltan.kuscsik@linaro.org" target="_blank">zoltan.kuscsik@linaro.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Gclient is tool for updating source code from<br>
multiple SCM repository locations.<br>
<br>
Signed-off-by: Zoltan Kuscsik <<a href="mailto:zoltan.kuscsik@linaro.org">zoltan.kuscsik@linaro.org</a>><br>
---<br>
lib/bb/fetch2/__init__.py | 2 +<br>
lib/bb/fetch2/gclient.py | 151 ++++++++++++++++++++++++++++++++++++++++++++++<br>
2 files changed, 153 insertions(+)<br>
create mode 100644 lib/bb/fetch2/gclient.py<br>
<br>
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py<br>
index 288a1c8..f93446f 100644<br>
--- a/lib/bb/fetch2/__init__.py<br>
+++ b/lib/bb/fetch2/__init__.py<br>
@@ -1775,6 +1775,7 @@ from . import hg<br>
from . import osc<br>
from . import repo<br>
from . import clearcase<br>
+from . import gclient<br>
<br>
methods.append(local.Local())<br>
methods.append(wget.Wget())<br>
@@ -1791,3 +1792,4 @@ methods.append(hg.Hg())<br>
methods.append(osc.Osc())<br>
methods.append(repo.Repo())<br>
methods.append(clearcase.ClearCase())<br>
+methods.append(gclient.Gclient())<br>
diff --git a/lib/bb/fetch2/gclient.py b/lib/bb/fetch2/gclient.py<br>
new file mode 100644<br>
index 0000000..bc46509<br>
--- /dev/null<br>
+++ b/lib/bb/fetch2/gclient.py<br>
@@ -0,0 +1,151 @@<br>
+# ex:ts=4:sw=4:sts=4:et<br>
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-<br>
+"""<br>
+BitBake "Fetch" gclient implementation<br>
+<br>
+gclient fetcher support the SRC_URI in the following format:<br>
+<br>
+ SRC_URI = "gclient://some.host/path/;optionA=xxx,optionB=xy"<br>
+<br>
+Supported SRC_UIR options are:<br>
+<br>
+- branch<br>
+ The git branch of the root gclient project. The default is<br>
+ "master".<br>
+<br>
+- tag<br>
+ Git tag for gclient to retrieve.<br>
+<br>
+- protocol<br>
+ The method to use for accessing the gclient core project. The default<br>
+ is https.<br>
+<br>
+- project-name<br>
+ Pass --name command line argument to gclient. Not default is empty.<br>
+<br>
+- rev<br>
+ Specify git commit id for gclient. Default is empty.<br>
+<br>
+- deps-file<br>
+ Set the --deps-file command line argument for gclient.<br>
+<br>
+"""<br>
+<br>
+# Copyright (C) 2015 Zoltan Kuscsik <<a href="mailto:zoltan.kuscsik@linaro.org">zoltan.kuscsik@linaro.org</a>><br>
+#<br>
+# Based on git.py which is:<br>
+# Copyright (C) 2005 Richard Purdie<br>
+#<br>
+# This program is free software; you can redistribute it and/or modify<br>
+# it under the terms of the GNU General Public License version 2 as<br>
+# published by the Free Software Foundation.<br>
+#<br>
+# This program is distributed in the hope that it will be useful,<br>
+# but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
+# GNU General Public License for more details.<br>
+#<br>
+# You should have received a copy of the GNU General Public License along<br>
+# with this program; if not, write to the Free Software Foundation, Inc.,<br>
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.<br>
+<br>
+import os<br>
+import bb<br>
+from bb import data<br>
+from bb.fetch2 import FetchMethod<br>
+from bb.fetch2 import runfetchcmd<br>
+import string<br>
+<br>
+class Gclient(FetchMethod):<br>
+ """Class to fetch a module or modules using gclient"""<br>
+<br>
+ def __fetch_url(self, ud):<br>
+ return "%s://%s%s" % (ud.proto, ud.host, ud.path)<br>
+<br>
+ def supports(self, ud, d):<br>
+ """<br>
+ Check to see if a given url can be fetched with gclient.<br>
+ """<br>
+ return ud.type in ["gclient"]<br>
+<br>
+ def urldata_init(self, ud, d):<br>
+ """<br>
+ Init gclient<br>
+ """<br>
+ ud.proto = ud.parm.get('protocol', 'https')<br>
+<br>
+ ud.branch = ud.parm.get('branch', 'master')<br>
+ ud.tag = ud.parm.get('tag','')<br>
+ ud.rev = ud.parm.get('rev','')<br>
+<br>
+ ud.deps_file = ud.parm.get('deps-file', '')<br>
+ ud.project_name = ud.parm.get('project-name', '')<br>
+<br>
+ if( ( ('tag' in ud.parm) + ('branch' in ud.parm) + ('res' in ud.parm)) > 1):<br>
+ raise bb.fetch2.ParameterError("Conflicting revision setting SRC_URI. Specify only one of the options: 'branch', 'tag', 'res'.", ud.url)<br>
+<br>
+ dldir = d.getVar("DL_DIR", True)<br>
+<br>
+ gclient_src_name = 'gclient_%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.'))<br>
+<br>
+ ud.syncdir = os.path.join(dldir, gclient_src_name)<br>
+ ud.localfile = ud.syncdir<br>
+<br>
+ if ud.tag:<br>
+ ud.revision = "refs/tags/%s" % ud.tag<br>
+ elif ud.rev:<br>
+ ud.revision = ud.rev<br>
+ else:<br>
+ ud.revision = "refs/heads/%s" % ud.branch<br>
+<br>
+ def download(self, ud, d):<br>
+ """Fetch url"""<br>
+<br>
+ if not os.path.exists(ud.localpath):<br>
+ bb.utils.mkdirhier(ud.localpath)<br>
+ os.chdir(ud.localpath)<br>
+ gclient_url = self.__fetch_url(ud)<br>
+<br>
+<br>
+ # Add optional parameters<br>
+ extra_params=[]<br>
+ if ud.deps_file:<br>
+ extra_params.append("--deps-file=%s" % ud.deps_file)<br>
+<br>
+ if ud.project_name:<br>
+ extra_params.append("--name=%s" % ud.project_name)<br>
+<br>
+ extra_args = string.join(extra_params, sep = " ")<br>
+<br>
+ runfetchcmd("gclient config %s %s " % (gclient_url, extra_args), d)<br>
+<br>
+ # Gclient parameters used<br>
+ # -f - force sync<br>
+ # -nohooks - skip hooks execution at this time<br>
+ # --with_branch_heads - gclient can't find a commit ID if it is not in a branch<br>
+ #<br>
+ # Note: We should enable --no-history after some more testing<br>
+<br>
+ runfetchcmd("gclient sync --with_branch_heads -f --nohooks --revision %s" % ud.revision, d)<br>
+<br>
+ def unpack(self, ud, destdir, d):<br>
+ """ Unpack the src to destdir """<br>
+ destsuffix = "gclient/"<br>
+ destdir = ud.destdir = os.path.join(destdir, destsuffix)<br>
+ # Use rsync for copying. Creating a tar package here would be very<br>
+ # time consuming.<br>
+ runfetchcmd("rsync -av %s/ %s/" %(ud.syncdir, destdir), d)<br>
+ return True<br>
+<br>
+ def need_update(self, ud, d):<br>
+ return True<br>
+<br>
+ def clean(self, ud, d):<br>
+ """ Clean the gclient directory """<br>
+ bb.utils.remove(ud.localpath, True)<br>
+<br>
+ def localpath(self, ud, dr):<br>
+ return ud.syncdir<br>
+<br>
+ def supports_srcrev(self):<br>
+ return False<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div style="color:rgb(136,136,136)">Zoltan Kuscsik</div><div style="color:rgb(136,136,136)"><br></div><div style="color:rgb(136,136,136)">Senior Software Developer, Linaro Digital Home Group</div><div style="color:rgb(136,136,136)">email: <a href="mailto:zoltan.kuscsik@linaro.org" target="_blank">zoltan.kuscsik@linaro.org</a></div><div style="color:rgb(136,136,136)"><span style="font-size:12.8000001907349px">IRC: zoli_ on </span><a href="http://irc.linaro.org/" style="font-size:12.8000001907349px;color:rgb(17,85,204)" target="_blank">irc.linaro.org</a><br></div></div></div>
</div>