<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"><<a href="mailto:peter.kjellerstedt@axis.com" target="_blank">peter.kjellerstedt@axis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> -----Original Message-----<br>
> 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>
> <a href="mailto:devel-bounces@lists.openembedded.org">devel-bounces@lists.openembedded.org</a>] On Behalf Of Zoltan Kuscsik<br>
> Sent: den 3 november 2015 17:11<br>
> To: <a href="mailto:bitbake-devel@lists.openembedded.org">bitbake-devel@lists.openembedded.org</a><br>
> Subject: [bitbake-devel] [PATCH] bb.fetch2: added support for gclient<br>
><br>
> 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 | 3 +-<br>
> lib/bb/fetch2/gclient.py | 151<br>
> ++++++++++++++++++++++++++++++++++++++++++++++<br>
> 2 files changed, 153 insertions(+), 1 deletion(-)<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..5ca3bc7 100644<br>
> --- a/lib/bb/fetch2/__init__.py<br>
> +++ b/lib/bb/fetch2/__init__.py<br>
> @@ -1529,7 +1529,6 @@ class Fetch(object):<br>
> fn = d.getVar('FILE', True)<br>
> if cache and fn and fn in urldata_cache:<br>
> self.ud = urldata_cache[fn]<br>
> -<br>
<br>
</span>Restore the empty line.<br>
<div><div class="h5"><br>
> for url in urls:<br>
> if url not in self.ud:<br>
> try:<br>
> @@ -1775,6 +1774,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 +1791,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..de06eb5<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 SRCU_URI in the following format:<br>
</div></div> ^^^^^^^^<br>
Correct the spelling of SRC_URI.<br>
<span class=""><br>
> +<br>
> + SRC_URI = "gclient://some.host/path/;optionA=xxx,optionB=xy"<br>
> +<br>
> +Supported SRC_UIR options are:<br>
</span> ^^^^^^^<br>
Correct the spelling of SRC_URI.<br>
<span class=""><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>
> + Passing the --name command line argument to gclient. Not default is empty.<br>
<br>
</span>Change "Passing" to "Pass" and "Not" to "The".<br>
<div><div class="h5"><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 repo.<br>
</div></div> ^^^^<br>
Repo? I thought this was for gclient...<br>
<span class=""><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>
<br>
</span>Rewrite as:<br>
<br>
if ('tag' in ud.parm) + ('branch' in ud.parm) + ('res' in ud.parm) > 1:<br>
<span class=""><br>
> + raise bb.fetch2.ParameterError("Confliting revision setting SRC_URI. Setting only one of the options: 'branch', 'tag', 'res'.", ud.url)<br>
</span> ^^^^^^^^^^<br>
Correct the spelling of "Conflicting". Change "revision setting SRC_URI"<br>
to "revisions specified in SRC_URI" and "Setting only" to "Specify only".<br>
<span class=""><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>
</span> ^<br>
Remove unnecessary space.<br>
<span class=""><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>
<br>
</span>Rewrite as:<br>
<br>
if ud.deps_file:<br>
<span class=""><br>
> + extra_params.append("--deps-file=%s" % ud.deps_file)<br>
> +<br>
> + if(ud.project_name):<br>
<br>
</span>Rewrite as:<br>
<br>
if ud.project_name:<br>
<div class="HOEnZb"><div class="h5"><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>
> --<br>
> 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>