<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#943634;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#943634'>You seem to have missed a couple of comments.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#943634'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#943634'>//Peter<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#943634'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Zoltan Kuscsik [mailto:zoltan.kuscsik@linaro.org] <br><b>Sent:</b> den 4 november 2015 05:08<br><b>To:</b> Peter Kjellerstedt<br><b>Cc:</b> bitbake-devel@lists.openembedded.org<br><b>Subject:</b> Re: [bitbake-devel] [PATCH] bb.fetch2: added support for gclient<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>Thanks Peter, all comments addressed in PATCHv2. <o:p></o:p></p></div><div><p class=MsoNormal>I also created a test for the patch:<o:p></o:p></p><div><div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><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><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div></div><div><p class=MsoNormal>Br,<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Z<o:p></o:p></p></div></div></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On 4 November 2015 at 01:36, Peter Kjellerstedt <<a href="mailto:peter.kjellerstedt@axis.com" target="_blank">peter.kjellerstedt@axis.com</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><p class=MsoNormal>> -----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>Restore the empty line.<o:p></o:p></p><div><div><p class=MsoNormal><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:<o:p></o:p></p></div></div><p class=MsoNormal> ^^^^^^^^<br>Correct the spelling of SRC_URI.<br><br>> +<br>> + SRC_URI = "gclient://some.host/path/;optionA=xxx,optionB=xy"<br>> +<br>> +Supported SRC_UIR options are:<br> ^^^^^^^<br>Correct the spelling of SRC_URI.<br><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>Change "Passing" to "Pass" and "Not" to "The".<o:p></o:p></p><div><div><p class=MsoNormal><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.<o:p></o:p></p></div></div><p class=MsoNormal> ^^^^<br>Repo? I thought this was for gclient...<br><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>Rewrite as:<br><br> if ('tag' in ud.parm) + ('branch' in ud.parm) + ('res' in ud.parm) > 1:<br><br>> + raise bb.fetch2.ParameterError("Confliting revision setting SRC_URI. Setting only one of the options: 'branch', 'tag', 'res'.", ud.url)<br> ^^^^^^^^^^<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><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> ^<br>Remove unnecessary space.<br><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>Rewrite as:<br><br> if ud.deps_file:<br><br>> + extra_params.append("--deps-file=%s" % ud.deps_file)<br>> +<br>> + if(ud.project_name):<br><br>Rewrite as:<br><br> if ud.project_name:<o:p></o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'><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<o:p></o:p></p></div></div><p class=MsoNormal style='margin-bottom:12.0pt'><span class=hoenzb><span style='color:#888888'>//Peter</span></span><o:p></o:p></p></blockquote></div><p class=MsoNormal><br><br clear=all><o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>-- <o:p></o:p></p><div><div><div><p class=MsoNormal><span style='color:#888888'>Zoltan Kuscsik<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#888888'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='color:#888888'>Senior Software Developer, Linaro Digital Home Group<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#888888'>email: <a href="mailto:zoltan.kuscsik@linaro.org" target="_blank">zoltan.kuscsik@linaro.org</a><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:9.5pt;color:#888888'>IRC: zoli_ on </span><span style='color:#888888'><a href="http://irc.linaro.org/" target="_blank"><span style='font-size:9.5pt;color:#1155CC'>irc.linaro.org</span></a><o:p></o:p></span></p></div></div></div></div></div></div></body></html>