[oe-commits] [bitbake] 01/04: fetch2/git: prevent recursion on getting latest revision

git at git.openembedded.org git at git.openembedded.org
Mon Mar 27 10:16:44 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository bitbake.

commit ff1ccd1db5d70b3fc9ad0d3e8f3d7b804c22bf36
Author: Paul Eggleton <paul.eggleton at linux.intel.com>
AuthorDate: Mon Mar 27 13:17:26 2017 +1300

    fetch2/git: prevent recursion on getting latest revision
    
    We call git ls-remote to get the latest revision from a git repository,
    however by calling runfetchcmd() we can end up recursively running
    git ls-remote a number of times with OE e.g. if ${SRCPV} is in PV, ${PV}
    is in WORKDIR, and ${WORKDIR} is in PATH (as a result of recipe-specific
    sysroots), our call to runfetchcmd() exports PATH so _lsremote() will
    get called again - with the end result that we run git ls-remote 30
    times in quick succession (!). Prevent that from happening by using a
    guard variable and returning a dummy value if it's called recursively.
    
    Fixes [YOCTO #11185].
    
    Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/fetch2/git.py | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index a8be859..2550bde 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -379,14 +379,26 @@ class Git(FetchMethod):
         """
         Run git ls-remote with the specified search string
         """
-        repourl = self._get_repo_url(ud)
-        cmd = "%s ls-remote %s %s" % \
-              (ud.basecmd, repourl, search)
-        if ud.proto.lower() != 'file':
-            bb.fetch2.check_network_access(d, cmd, repourl)
-        output = runfetchcmd(cmd, d, True)
-        if not output:
-            raise bb.fetch2.FetchError("The command %s gave empty output unexpectedly" % cmd, ud.url)
+        # Prevent recursion e.g. in OE if SRCPV is in PV, PV is in WORKDIR,
+        # and WORKDIR is in PATH (as a result of RSS), our call to
+        # runfetchcmd() exports PATH so this function will get called again (!)
+        # In this scenario the return call of the function isn't actually
+        # important - WORKDIR isn't needed in PATH to call git ls-remote
+        # anyway.
+        if d.getVar('_BB_GIT_IN_LSREMOTE', False):
+            return ''
+        d.setVar('_BB_GIT_IN_LSREMOTE', '1')
+        try:
+            repourl = self._get_repo_url(ud)
+            cmd = "%s ls-remote %s %s" % \
+                (ud.basecmd, repourl, search)
+            if ud.proto.lower() != 'file':
+                bb.fetch2.check_network_access(d, cmd, repourl)
+            output = runfetchcmd(cmd, d, True)
+            if not output:
+                raise bb.fetch2.FetchError("The command %s gave empty output unexpectedly" % cmd, ud.url)
+        finally:
+            d.delVar('_BB_GIT_IN_LSREMOTE')
         return output
 
     def _latest_revision(self, ud, d, name):

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list