Ver código fonte

bitbake/fetch2: Instrument fetchers when making network access

Signed-off-by: Yu Ke <ke.yu@intel.com>
Yu Ke 14 anos atrás
pai
commit
029f8584d5

+ 4 - 0
bitbake/lib/bb/fetch2/bzr.py

@@ -85,11 +85,13 @@ class Bzr(Fetch):
         if os.access(os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir), '.bzr'), os.R_OK):
             bzrcmd = self._buildbzrcommand(ud, d, "update")
             logger.debug(1, "BZR Update %s", loc)
+            bb.fetch2.check_network_access(d, bzrcmd)
             os.chdir(os.path.join (ud.pkgdir, os.path.basename(ud.path)))
             runfetchcmd(bzrcmd, d)
         else:
             bb.utils.remove(os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir)), True)
             bzrcmd = self._buildbzrcommand(ud, d, "fetch")
+            bb.fetch2.check_network_access(d, bzrcmd)
             logger.debug(1, "BZR Checkout %s", loc)
             bb.mkdirhier(ud.pkgdir)
             os.chdir(ud.pkgdir)
@@ -130,6 +132,8 @@ class Bzr(Fetch):
         """
         logger.debug(2, "BZR fetcher hitting network for %s", url)
 
+        bb.fetch2.check_network_access(d, self._buildbzrcommand(ud, d, "revno"))
+
         output = runfetchcmd(self._buildbzrcommand(ud, d, "revno"), d, True)
 
         return output.strip()

+ 2 - 0
bitbake/lib/bb/fetch2/cvs.py

@@ -131,6 +131,7 @@ class Cvs(Fetch):
         moddir = os.path.join(pkgdir, localdir)
         if os.access(os.path.join(moddir, 'CVS'), os.R_OK):
             logger.info("Update " + loc)
+            bb.fetch2.check_network_access(d, cvsupdatecmd)
             # update sources there
             os.chdir(moddir)
             myret = os.system(cvsupdatecmd)
@@ -140,6 +141,7 @@ class Cvs(Fetch):
             bb.mkdirhier(pkgdir)
             os.chdir(pkgdir)
             logger.debug(1, "Running %s", cvscmd)
+            bb.fetch2.check_network_access(d, cvscmd)
             myret = os.system(cvscmd)
 
         if myret != 0 or not os.access(moddir, os.R_OK):

+ 3 - 0
bitbake/lib/bb/fetch2/git.py

@@ -124,12 +124,14 @@ class Git(Fetch):
 
         # If the repo still doesn't exist, fallback to cloning it
         if not os.path.exists(ud.clonedir):
+            bb.fetch2.check_network_access(d, "git clone %s%s" % (ud.host, ud.path))
             runfetchcmd("%s clone -n %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.clonedir), d)
 
         os.chdir(ud.clonedir)
         # Update the checkout if needed
         if not self._contains_ref(ud.tag, d) or 'fullclone' in ud.parm:
             # Remove all but the .git directory
+            bb.fetch2.check_network_access(d, "git fetch %s%s" %(ud.host, ud.path))
             runfetchcmd("rm * -Rf", d)
             if 'fullclone' in ud.parm:
                 runfetchcmd("%s fetch --all" % (ud.basecmd), d)
@@ -215,6 +217,7 @@ class Git(Fetch):
         else:
             username = ""
 
+        bb.fetch2.check_network_access(d, "git ls-remote %s%s %s" % (ud.host, ud.path, ud.branch))
         basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
         cmd = "%s ls-remote %s://%s%s%s %s" % (basecmd, ud.proto, username, ud.host, ud.path, ud.branch)
         output = runfetchcmd(cmd, d, True)

+ 3 - 0
bitbake/lib/bb/fetch2/hg.py

@@ -123,6 +123,7 @@ class Hg(Fetch):
             # update sources there
             os.chdir(ud.moddir)
             logger.debug(1, "Running %s", updatecmd)
+            bb.fetch2.check_network_access(d, updatecmd)
             runfetchcmd(updatecmd, d)
 
         else:
@@ -132,6 +133,7 @@ class Hg(Fetch):
             bb.mkdirhier(ud.pkgdir)
             os.chdir(ud.pkgdir)
             logger.debug(1, "Running %s", fetchcmd)
+            bb.fetch2.check_network_access(d, fetchcmd)
             runfetchcmd(fetchcmd, d)
 
         # Even when we clone (fetch), we still need to update as hg's clone
@@ -165,6 +167,7 @@ class Hg(Fetch):
         """
         Compute tip revision for the url
         """
+        bb.fetch2.check_network_access(d, self._buildhgcommand(ud, d, "info"))
         output = runfetchcmd(self._buildhgcommand(ud, d, "info"), d)
         return output.strip()
 

+ 2 - 0
bitbake/lib/bb/fetch2/osc.py

@@ -92,6 +92,7 @@ class Osc(Fetch):
             # update sources there
             os.chdir(ud.moddir)
             logger.debug(1, "Running %s", oscupdatecmd)
+            bb.fetch2.check_network_access(d, oscupdatecmd)
             runfetchcmd(oscupdatecmd, d)
         else:
             oscfetchcmd = self._buildosccommand(ud, d, "fetch")
@@ -100,6 +101,7 @@ class Osc(Fetch):
             bb.mkdirhier(ud.pkgdir)
             os.chdir(ud.pkgdir)
             logger.debug(1, "Running %s", oscfetchcmd)
+            bb.fetch2.check_network_access(d, oscfetchcmd)
             runfetchcmd(oscfetchcmd, d)
 
         os.chdir(os.path.join(ud.pkgdir + ud.path))

+ 2 - 0
bitbake/lib/bb/fetch2/repo.py

@@ -74,8 +74,10 @@ class Repo(Fetch):
         bb.mkdirhier(os.path.join(codir, "repo"))
         os.chdir(os.path.join(codir, "repo"))
         if not os.path.exists(os.path.join(codir, "repo", ".repo")):
+            bb.fetch2.check_network_access(d, "repo init -m %s -b %s -u %s://%s%s%s" % (ud.manifest, ud.branch, ud.proto, username, ud.host, ud.path))
             runfetchcmd("repo init -m %s -b %s -u %s://%s%s%s" % (ud.manifest, ud.branch, ud.proto, username, ud.host, ud.path), d)
 
+        bb.fetch2.check_network_access(d, "repo sync %s" % ud.url)
         runfetchcmd("repo sync", d)
         os.chdir(codir)
 

+ 2 - 0
bitbake/lib/bb/fetch2/ssh.py

@@ -112,6 +112,8 @@ class SSH(Fetch):
             commands.mkarg(ldir)
         )
 
+        bb.fetch2.check_network_access(d, cmd)
+
         (exitstatus, output) = commands.getstatusoutput(cmd)
         if exitstatus != 0:
             print(output)

+ 3 - 1
bitbake/lib/bb/fetch2/svn.py

@@ -139,6 +139,7 @@ class Svn(Fetch):
             # update sources there
             os.chdir(ud.moddir)
             logger.debug(1, "Running %s", svnupdatecmd)
+            bb.fetch2.check_network_access(d, svnupdatecmd)
             runfetchcmd(svnupdatecmd, d)
         else:
             svnfetchcmd = self._buildsvncommand(ud, d, "fetch")
@@ -147,6 +148,7 @@ class Svn(Fetch):
             bb.mkdirhier(ud.pkgdir)
             os.chdir(ud.pkgdir)
             logger.debug(1, "Running %s", svnfetchcmd)
+            bb.fetch2.check_network_access(d, svnfetchcmd)
             runfetchcmd(svnfetchcmd, d)
 
         scmdata = ud.parm.get("scmdata", "")
@@ -180,7 +182,7 @@ class Svn(Fetch):
         """
         Return the latest upstream revision number
         """
-        logger.debug(2, "SVN fetcher hitting network for %s", url)
+        bb.fetch2.check_network_access(d, self._buildsvncommand(ud, d, "info"))
 
         output = runfetchcmd("LANG=C LC_ALL=C " + self._buildsvncommand(ud, d, "info"), d, True)
 

+ 1 - 0
bitbake/lib/bb/fetch2/wget.py

@@ -69,6 +69,7 @@ class Wget(Fetch):
             fetchcmd = fetchcmd.replace("${FILE}", ud.basename)
             logger.info("fetch " + uri)
             logger.debug(2, "executing " + fetchcmd)
+            bb.fetch2.check_network_access(d, fetchcmd)
             runfetchcmd(fetchcmd, d)
 
             # Sanity check since wget can pretend it succeed when it didn't