<div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 8 oct. 2019 à 22:54, Mark Hatle &lt;<a href="mailto:mark.hatle@kernel.crashing.org">mark.hatle@kernel.crashing.org</a>&gt; a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 10/8/19 1:45 PM, Aníbal Limón wrote:<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>
<br>
When I have done this before, I&#39;ve -always- defined it as a git repository by<br>
SRCURI:<br>
<br>
git://&lt;local file path&gt;;protocol=file<br>
<br>
Then it does exactly what this patch appears to do and uses the git logic to<br>
handle everything automatically.  (The file protocol is already implemented.)<br>
<br>
Wouldn&#39;t this be better then specifying file:// and then attempting to infer<br>
what file refers to?</blockquote><div dir="auto"><br></div><div dir="auto">Anibal and I are working on the same use case / problem. Folks who rely on this setup also use it as a workspace, eg. They make local changes in the sources workspace. So when doing fetch again the local changes are used. So this is not strictly equivalent to what you propose, right?</div><div dir="auto"><br></div><div dir="auto">Another major flaw with the current file:// with a git folder is that doing a git fetch in the source tree will invalidate the fetch task even if the actual sources haven’t changed!</div><div dir="auto"><br></div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
--MArk<br>
<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>
&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>
-- <br>
_______________________________________________<br>
bitbake-devel mailing list<br>
<a href="mailto:bitbake-devel@lists.openembedded.org" target="_blank">bitbake-devel@lists.openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/bitbake-devel" rel="noreferrer" target="_blank">http://lists.openembedded.org/mailman/listinfo/bitbake-devel</a><br>
</blockquote></div></div>