<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 5 Nov 2019 at 22:50, Nicolas Dechesne &lt;<a href="mailto:nicolas.dechesne@linaro.org">nicolas.dechesne@linaro.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">hi,<br>
<br>
On Tue, Oct 8, 2019 at 8:42 PM Aníbal Limón &lt;<a href="mailto:anibal.limon@linaro.org" target="_blank">anibal.limon@linaro.org</a>&gt; wrote:<br>
&gt;<br>
&gt; In some cases people/organizations are using a SRC_URI with<br>
&gt; file:///PATH_TO_DIR that contains a git repository for different<br>
&gt; reasons, it is useful when want to do an internal build without<br>
&gt; clone sources from outside.<br>
&gt;<br>
&gt; This could consume a lot of CPU time because the current taskhash<br>
&gt; generation mechanism didn&#39;t identify that the folder is a VCS<br>
&gt; (git, svn, cvs) and makes the cksum for every file including the<br>
&gt; .git repository in this case.<br>
&gt;<br>
&gt; There are different ways to improve the situation,<br>
&gt;<br>
&gt; * Add protocol=gitscm in file:// SRC_URI but the taskhash is<br>
&gt;   calculated before the fetcher identifies the protocol, will require<br>
&gt;   some changes in bitbake codebase.<br>
&gt; * This patch: When directory is a git repository (contains .git)<br>
&gt;   use HEAD rev + git diff to calculate checksum instead of do it<br>
&gt;   in every file, that is hackish because make some assumptions about<br>
&gt;   .git directory contents.<br>
&gt; * Variant of this patch: Make a list of VCS directories (.git, .svn,<br>
&gt;   .cvs) and take out for cksum calculations, same as before making<br>
&gt;   assumptions about the . folders content.<br>
<br>
I&#39;ve discussed with Khem and Richard today (@ELCE) about this patch.<br>
We kind of agreed that the current approach is not really good since<br>
the local fetcher isn&#39;t supposed to &#39;deal&#39; with scm commands. however<br>
we agreed that the last variant proposed above might be a much better<br>
approach. The idea would be to exclude VCS directories from the<br>
checksum computation. It could potentially be extended in a slightly<br>
more generic way, like using a variable to specify a list of<br>
directories to exclude, which could be unset by default, and set in oe<br>
core as<br>
BB_LOCAL_DIRS_EXCLUDE = &quot;.git .cvs .svn&quot;<br>
<br>
Anibal: do you think you can give it a try?<br></blockquote><div><br></div><div>It sounds good, this new variable will be only used for cksum exclude?, if yes may be to change</div><div>for more specific variable  BB_LOCAL_DIRS_TASKHASH_EXCLUDE.</div><div><br></div><div>Regards,</div><div>Anibal</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
&gt;<br>
&gt; Signed-off-by: Aníbal Limón &lt;<a href="mailto:anibal.limon@linaro.org" target="_blank">anibal.limon@linaro.org</a>&gt;<br>
&gt; ---<br>
&gt;  lib/bb/checksum.py | 13 +++++++++++++<br>
&gt;  1 file changed, 13 insertions(+)<br>
&gt;<br>
&gt; diff --git a/lib/bb/checksum.py b/lib/bb/checksum.py<br>
&gt; index 5bc8a8fc..ee125cb5 100644<br>
&gt; --- a/lib/bb/checksum.py<br>
&gt; +++ b/lib/bb/checksum.py<br>
&gt; @@ -86,6 +86,19 @@ class FileChecksumCache(MultiProcessCache):<br>
&gt;              return checksum<br>
&gt;<br>
&gt;          def checksum_dir(pth):<br>
&gt; +            git_dir = os.path.join(pth, &#39;.git&#39;)<br>
&gt; +            if os.path.exists(git_dir):<br>
&gt; +                import subprocess, hashlib<br>
&gt; +                m = hashlib.md5()<br>
&gt; +                head = subprocess.check_output(&quot;cd %s &amp;&amp; git rev-parse HEAD&quot; % pth, shell=True)<br>
&gt; +                diff = subprocess.check_output(&quot;cd %s &amp;&amp; git diff&quot; % pth, shell=True)<br>
&gt; +                m.update(head)<br>
&gt; +                if diff:<br>
&gt; +                    m.update(diff)<br>
&gt; +<br>
&gt; +                return [(pth, m.hexdigest())]<br>
&gt; +<br>
&gt; +<br>
&gt;              # Handle directories recursively<br>
&gt;              if pth == &quot;/&quot;:<br>
&gt;                  bb.fatal(&quot;Refusing to checksum /&quot;)<br>
&gt; --<br>
&gt; 2.23.0<br>
&gt;<br>
</blockquote></div></div>