<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">&lt;<a href="mailto:zoltan.kuscsik@linaro.org" target="_blank">zoltan.kuscsik@linaro.org</a>&gt;</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 &lt;<a href="mailto:zoltan.kuscsik@linaro.org">zoltan.kuscsik@linaro.org</a>&gt;<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>
+&quot;&quot;&quot;<br>
+BitBake &quot;Fetch&quot; gclient implementation<br>
+<br>
+gclient fetcher support the SRC_URI in the following format:<br>
+<br>
+    SRC_URI = &quot;gclient://some.host/path/;optionA=xxx,optionB=xy&quot;<br>
+<br>
+Supported SRC_UIR options are:<br>
+<br>
+- branch<br>
+  The git branch of the root gclient project. The default is<br>
+  &quot;master&quot;.<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>
+&quot;&quot;&quot;<br>
+<br>
+# Copyright (C) 2015 Zoltan Kuscsik &lt;<a href="mailto:zoltan.kuscsik@linaro.org">zoltan.kuscsik@linaro.org</a>&gt;<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>
+    &quot;&quot;&quot;Class to fetch a module or modules using gclient&quot;&quot;&quot;<br>
+<br>
+    def __fetch_url(self, ud):<br>
+        return &quot;%s://%s%s&quot; % (ud.proto, ud.host, ud.path)<br>
+<br>
+    def supports(self, ud, d):<br>
+        &quot;&quot;&quot;<br>
+        Check to see if a given url can be fetched with gclient.<br>
+        &quot;&quot;&quot;<br>
+        return ud.type in [&quot;gclient&quot;]<br>
+<br>
+    def urldata_init(self, ud, d):<br>
+        &quot;&quot;&quot;<br>
+        Init gclient<br>
+        &quot;&quot;&quot;<br>
+        ud.proto = ud.parm.get(&#39;protocol&#39;, &#39;https&#39;)<br>
+<br>
+        ud.branch = ud.parm.get(&#39;branch&#39;, &#39;master&#39;)<br>
+        ud.tag = ud.parm.get(&#39;tag&#39;,&#39;&#39;)<br>
+        ud.rev = ud.parm.get(&#39;rev&#39;,&#39;&#39;)<br>
+<br>
+        ud.deps_file = ud.parm.get(&#39;deps-file&#39;, &#39;&#39;)<br>
+        ud.project_name = ud.parm.get(&#39;project-name&#39;, &#39;&#39;)<br>
+<br>
+        if( ( (&#39;tag&#39; in ud.parm) + (&#39;branch&#39; in ud.parm) + (&#39;res&#39; in ud.parm)) &gt; 1):<br>
+            raise bb.fetch2.ParameterError(&quot;Conflicting revision setting SRC_URI. Specify only one of the options: &#39;branch&#39;, &#39;tag&#39;, &#39;res&#39;.&quot;, ud.url)<br>
+<br>
+        dldir = d.getVar(&quot;DL_DIR&quot;, True)<br>
+<br>
+        gclient_src_name = &#39;gclient_%s%s&#39; % (ud.host.replace(&#39;:&#39;, &#39;.&#39;), ud.path.replace(&#39;/&#39;, &#39;.&#39;).replace(&#39;*&#39;, &#39;.&#39;))<br>
+<br>
+        ud.syncdir = os.path.join(dldir, gclient_src_name)<br>
+        ud.localfile = ud.syncdir<br>
+<br>
+        if ud.tag:<br>
+            ud.revision =  &quot;refs/tags/%s&quot; % ud.tag<br>
+        elif ud.rev:<br>
+            ud.revision = ud.rev<br>
+        else:<br>
+            ud.revision = &quot;refs/heads/%s&quot; % ud.branch<br>
+<br>
+    def download(self, ud, d):<br>
+        &quot;&quot;&quot;Fetch url&quot;&quot;&quot;<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(&quot;--deps-file=%s&quot; % ud.deps_file)<br>
+<br>
+        if ud.project_name:<br>
+            extra_params.append(&quot;--name=%s&quot; % ud.project_name)<br>
+<br>
+        extra_args = string.join(extra_params, sep = &quot; &quot;)<br>
+<br>
+        runfetchcmd(&quot;gclient config %s %s &quot; % (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&#39;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(&quot;gclient sync --with_branch_heads -f  --nohooks --revision %s&quot; % ud.revision, d)<br>
+<br>
+    def unpack(self, ud, destdir, d):<br>
+        &quot;&quot;&quot; Unpack the src to destdir &quot;&quot;&quot;<br>
+        destsuffix = &quot;gclient/&quot;<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(&quot;rsync -av %s/ %s/&quot; %(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>
+        &quot;&quot;&quot; Clean the gclient directory &quot;&quot;&quot;<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>