<div dir="ltr"><div>Thanks Peter, all comments addressed in PATCHv2.  <br></div><div>I also created a test for the patch:<div><div><div><br></div><div><a href="https://github.com/kuscsik/meta-testing/tree/master/recipes-core/fetcher">https://github.com/kuscsik/meta-testing/tree/master/recipes-core/fetcher</a><br></div><div><br></div></div></div><div>Br,</div><div><br></div><div>Z</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 4 November 2015 at 01:36, Peter Kjellerstedt <span dir="ltr">&lt;<a href="mailto:peter.kjellerstedt@axis.com" target="_blank">peter.kjellerstedt@axis.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">&gt; -----Original Message-----<br>
&gt; From: <a href="mailto:bitbake-devel-bounces@lists.openembedded.org">bitbake-devel-bounces@lists.openembedded.org</a> [mailto:<a href="mailto:bitbake-">bitbake-</a><br>
&gt; <a href="mailto:devel-bounces@lists.openembedded.org">devel-bounces@lists.openembedded.org</a>] On Behalf Of Zoltan Kuscsik<br>
&gt; Sent: den 3 november 2015 17:11<br>
&gt; To: <a href="mailto:bitbake-devel@lists.openembedded.org">bitbake-devel@lists.openembedded.org</a><br>
&gt; Subject: [bitbake-devel] [PATCH] bb.fetch2: added support for gclient<br>
&gt;<br>
&gt; Gclient is tool for updating source code from<br>
&gt; multiple SCM repository locations.<br>
&gt;<br>
&gt; Signed-off-by: Zoltan Kuscsik &lt;<a href="mailto:zoltan.kuscsik@linaro.org">zoltan.kuscsik@linaro.org</a>&gt;<br>
&gt; ---<br>
&gt;  lib/bb/fetch2/__init__.py |   3 +-<br>
&gt;  lib/bb/fetch2/gclient.py  | 151<br>
&gt; ++++++++++++++++++++++++++++++++++++++++++++++<br>
&gt;  2 files changed, 153 insertions(+), 1 deletion(-)<br>
&gt;  create mode 100644 lib/bb/fetch2/gclient.py<br>
&gt;<br>
&gt; diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py<br>
&gt; index 288a1c8..5ca3bc7 100644<br>
&gt; --- a/lib/bb/fetch2/__init__.py<br>
&gt; +++ b/lib/bb/fetch2/__init__.py<br>
&gt; @@ -1529,7 +1529,6 @@ class Fetch(object):<br>
&gt;          fn = d.getVar(&#39;FILE&#39;, True)<br>
&gt;          if cache and fn and fn in urldata_cache:<br>
&gt;              self.ud = urldata_cache[fn]<br>
&gt; -<br>
<br>
</span>Restore the empty line.<br>
<div><div class="h5"><br>
&gt;          for url in urls:<br>
&gt;              if url not in self.ud:<br>
&gt;                  try:<br>
&gt; @@ -1775,6 +1774,7 @@ from . import hg<br>
&gt;  from . import osc<br>
&gt;  from . import repo<br>
&gt;  from . import clearcase<br>
&gt; +from . import gclient<br>
&gt;<br>
&gt;  methods.append(local.Local())<br>
&gt;  methods.append(wget.Wget())<br>
&gt; @@ -1791,3 +1791,4 @@ methods.append(hg.Hg())<br>
&gt;  methods.append(osc.Osc())<br>
&gt;  methods.append(repo.Repo())<br>
&gt;  methods.append(clearcase.ClearCase())<br>
&gt; +methods.append(gclient.Gclient())<br>
&gt; diff --git a/lib/bb/fetch2/gclient.py b/lib/bb/fetch2/gclient.py<br>
&gt; new file mode 100644<br>
&gt; index 0000000..de06eb5<br>
&gt; --- /dev/null<br>
&gt; +++ b/lib/bb/fetch2/gclient.py<br>
&gt; @@ -0,0 +1,151 @@<br>
&gt; +# ex:ts=4:sw=4:sts=4:et<br>
&gt; +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-<br>
&gt; +&quot;&quot;&quot;<br>
&gt; +BitBake &quot;Fetch&quot; gclient implementation<br>
&gt; +<br>
&gt; +gclient fetcher support the SRCU_URI in the following format:<br>
</div></div>                               ^^^^^^^^<br>
Correct the spelling of SRC_URI.<br>
<span class=""><br>
&gt; +<br>
&gt; +    SRC_URI = &quot;gclient://some.host/path/;optionA=xxx,optionB=xy&quot;<br>
&gt; +<br>
&gt; +Supported SRC_UIR options are:<br>
</span>             ^^^^^^^<br>
Correct the spelling of SRC_URI.<br>
<span class=""><br>
&gt; +<br>
&gt; +- branch<br>
&gt; +  The git branch of the root gclient project. The default is<br>
&gt; +  &quot;master&quot;.<br>
&gt; +<br>
&gt; +- tag<br>
&gt; +  Git tag for gclient to retrieve.<br>
&gt; +<br>
&gt; +- protocol<br>
&gt; +  The method to use for accessing the gclient core project. The default<br>
&gt; +   is https.<br>
&gt; +<br>
&gt; +- project-name<br>
&gt; +  Passing the --name command line argument to gclient. Not default is empty.<br>
<br>
</span>Change &quot;Passing&quot; to &quot;Pass&quot; and &quot;Not&quot; to &quot;The&quot;.<br>
<div><div class="h5"><br>
&gt; +<br>
&gt; +- rev<br>
&gt; +  Specify git commit id for gclient. Default is empty.<br>
&gt; +<br>
&gt; +- deps-file<br>
&gt; +  Set the --deps-file command line argument for gclient.<br>
&gt; +<br>
&gt; +&quot;&quot;&quot;<br>
&gt; +<br>
&gt; +# Copyright (C) 2015 Zoltan Kuscsik &lt;<a href="mailto:zoltan.kuscsik@linaro.org">zoltan.kuscsik@linaro.org</a>&gt;<br>
&gt; +#<br>
&gt; +# Based on git.py which is:<br>
&gt; +# Copyright (C) 2005 Richard Purdie<br>
&gt; +#<br>
&gt; +# This program is free software; you can redistribute it and/or modify<br>
&gt; +# it under the terms of the GNU General Public License version 2 as<br>
&gt; +# published by the Free Software Foundation.<br>
&gt; +#<br>
&gt; +# This program is distributed in the hope that it will be useful,<br>
&gt; +# but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
&gt; +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>
&gt; +# GNU General Public License for more details.<br>
&gt; +#<br>
&gt; +# You should have received a copy of the GNU General Public License along<br>
&gt; +# with this program; if not, write to the Free Software Foundation, Inc.,<br>
&gt; +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.<br>
&gt; +<br>
&gt; +import os<br>
&gt; +import bb<br>
&gt; +from   bb    import data<br>
&gt; +from   bb.fetch2 import FetchMethod<br>
&gt; +from   bb.fetch2 import runfetchcmd<br>
&gt; +import string<br>
&gt; +<br>
&gt; +class Gclient(FetchMethod):<br>
&gt; +    &quot;&quot;&quot;Class to fetch a module or modules using gclient&quot;&quot;&quot;<br>
&gt; +<br>
&gt; +    def __fetch_url(self, ud):<br>
&gt; +        return &quot;%s://%s%s&quot; % (ud.proto, ud.host, ud.path)<br>
&gt; +<br>
&gt; +    def supports(self, ud, d):<br>
&gt; +        &quot;&quot;&quot;<br>
&gt; +        Check to see if a given url can be fetched with repo.<br>
</div></div>                                                           ^^^^<br>
Repo? I thought this was for gclient...<br>
<span class=""><br>
&gt; +        &quot;&quot;&quot;<br>
&gt; +        return ud.type in [&quot;gclient&quot;]<br>
&gt; +<br>
&gt; +    def urldata_init(self, ud, d):<br>
&gt; +        &quot;&quot;&quot;<br>
&gt; +        Init gclient<br>
&gt; +        &quot;&quot;&quot;<br>
&gt; +        ud.proto = ud.parm.get(&#39;protocol&#39;, &#39;https&#39;)<br>
&gt; +<br>
&gt; +        ud.branch = ud.parm.get(&#39;branch&#39;, &#39;master&#39;)<br>
&gt; +        ud.tag = ud.parm.get(&#39;tag&#39;,&#39;&#39;)<br>
&gt; +        ud.rev = ud.parm.get(&#39;rev&#39;,&#39;&#39;)<br>
&gt; +<br>
&gt; +        ud.deps_file = ud.parm.get(&#39;deps-file&#39;, &#39;&#39;)<br>
&gt; +        ud.project_name = ud.parm.get(&#39;project-name&#39;, &#39;&#39;)<br>
&gt; +<br>
&gt; +        if( ( (&#39;tag&#39; in ud.parm) + (&#39;branch&#39; in ud.parm) + (&#39;res&#39; in ud.parm)) &gt; 1):<br>
<br>
</span>Rewrite as:<br>
<br>
        if (&#39;tag&#39; in ud.parm) + (&#39;branch&#39; in ud.parm) + (&#39;res&#39; in ud.parm) &gt; 1:<br>
<span class=""><br>
&gt; +            raise bb.fetch2.ParameterError(&quot;Confliting revision setting SRC_URI. Setting only one of the options: &#39;branch&#39;, &#39;tag&#39;, &#39;res&#39;.&quot;, ud.url)<br>
</span>                                               ^^^^^^^^^^<br>
Correct the spelling of &quot;Conflicting&quot;. Change &quot;revision setting SRC_URI&quot;<br>
to &quot;revisions specified in SRC_URI&quot; and &quot;Setting only&quot; to &quot;Specify only&quot;.<br>
<span class=""><br>
&gt; +<br>
&gt; +        dldir = d.getVar(&quot;DL_DIR&quot;, True)<br>
&gt; +<br>
&gt; +        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>
&gt; +<br>
&gt; +        ud.syncdir = os.path.join(dldir, gclient_src_name)<br>
&gt; +        ud.localfile = ud.syncdir<br>
&gt; +<br>
&gt; +        if ud.tag:<br>
&gt; +            ud.revision =  &quot;refs/tags/%s&quot; % ud.tag<br>
</span>                             ^<br>
Remove unnecessary space.<br>
<span class=""><br>
&gt; +        elif ud.rev:<br>
&gt; +            ud.revision = ud.rev<br>
&gt; +        else:<br>
&gt; +            ud.revision = &quot;refs/heads/%s&quot; % ud.branch<br>
&gt; +<br>
&gt; +    def download(self, ud, d):<br>
&gt; +        &quot;&quot;&quot;Fetch url&quot;&quot;&quot;<br>
&gt; +<br>
&gt; +        if not os.path.exists(ud.localpath):<br>
&gt; +            bb.utils.mkdirhier(ud.localpath)<br>
&gt; +        os.chdir(ud.localpath)<br>
&gt; +        gclient_url = self.__fetch_url(ud)<br>
&gt; +<br>
&gt; +<br>
&gt; +        # Add optional parameters<br>
&gt; +        extra_params=[]<br>
&gt; +        if(ud.deps_file):<br>
<br>
</span>Rewrite as:<br>
<br>
        if ud.deps_file:<br>
<span class=""><br>
&gt; +            extra_params.append(&quot;--deps-file=%s&quot; % ud.deps_file)<br>
&gt; +<br>
&gt; +        if(ud.project_name):<br>
<br>
</span>Rewrite as:<br>
<br>
        if ud.project_name:<br>
<div class="HOEnZb"><div class="h5"><br>
&gt; +            extra_params.append(&quot;--name=%s&quot; % ud.project_name)<br>
&gt; +<br>
&gt; +        extra_args = string.join(extra_params, sep = &quot; &quot;)<br>
&gt; +<br>
&gt; +        runfetchcmd(&quot;gclient config %s %s &quot; % (gclient_url, extra_args), d)<br>
&gt; +<br>
&gt; +        # Gclient parameters used<br>
&gt; +        # -f                    - force sync<br>
&gt; +        # -nohooks              - skip hooks execution at this time<br>
&gt; +        # --with_branch_heads   - gclient can&#39;t find a commit ID if it is not in a branch<br>
&gt; +        #<br>
&gt; +        # Note: We should enable --no-history after some more testing<br>
&gt; +<br>
&gt; +        runfetchcmd(&quot;gclient sync --with_branch_heads -f  --nohooks --revision %s&quot; % ud.revision, d)<br>
&gt; +<br>
&gt; +    def unpack(self, ud, destdir, d):<br>
&gt; +        &quot;&quot;&quot; Unpack the src to destdir &quot;&quot;&quot;<br>
&gt; +        destsuffix = &quot;gclient/&quot;<br>
&gt; +        destdir = ud.destdir = os.path.join(destdir, destsuffix)<br>
&gt; +        # Use rsync for copying. Creating a tar package here would be very<br>
&gt; +        # time consuming.<br>
&gt; +        runfetchcmd(&quot;rsync -av %s/ %s/&quot; %(ud.syncdir, destdir), d)<br>
&gt; +        return True<br>
&gt; +<br>
&gt; +    def need_update(self, ud, d):<br>
&gt; +        return True<br>
&gt; +<br>
&gt; +    def clean(self, ud, d):<br>
&gt; +        &quot;&quot;&quot; Clean the gclient directory &quot;&quot;&quot;<br>
&gt; +        bb.utils.remove(ud.localpath, True)<br>
&gt; +<br>
&gt; +    def localpath(self, ud, dr):<br>
&gt; +        return ud.syncdir<br>
&gt; +<br>
&gt; +    def supports_srcrev(self):<br>
&gt; +        return False<br>
&gt; --<br>
&gt; 1.9.1<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">//Peter<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>