]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake: Test premirrors and mirrors in checkstatus()
authorJoshua Lock <josh@linux.intel.com>
Fri, 5 Feb 2010 12:08:15 +0000 (12:08 +0000)
committerJoshua Lock <josh@linux.intel.com>
Fri, 5 Feb 2010 12:19:05 +0000 (12:19 +0000)
checkstatus() is used to ensure we can fetch a copy of each file, so it makes
sense to also test PREMIRRORS and MIRRORS in the method.

This patch adds calls to try_mirrors() to the Fetch.checkstatus() method and
changes the try_mirrors() method to take a check argument, which is False by
default. When check is True try_mirrors() will call a fetchers checkstatus()
with the replaced uri.

Signed-off-by: Joshua Lock <josh@linux.intel.com>
bitbake/lib/bb/fetch/__init__.py

index 58fa41b4dcc1abee65dbd0120cf92e58f8d9f53f..4b1203d605c7dd8df3c6b6486f9ebcb2fce95169 100644 (file)
@@ -219,7 +219,18 @@ def checkstatus(d):
         ud = urldata[u]
         m = ud.method
         bb.msg.note(1, bb.msg.domain.Fetcher, "Testing URL %s" % u)
-        ret = m.checkstatus(u, ud, d)
+        # First try checking uri, u, from PREMIRRORS
+        mirrors = [ i.split() for i in (bb.data.getVar('PREMIRRORS', d, 1) or "").split('\n') if i ]
+        ret = try_mirrors(d, u, mirrors, True)
+        if not ret:
+            # Next try checking from the original uri, u
+            try:
+                ret = m.checkstatus(u, ud, d)
+            except:
+                # Finally, try checking uri, u, from MIRRORS
+                mirrors = [ i.split() for i in (bb.data.getVar('MIRRORS', d, 1) or "").split('\n') if i ]
+                ret = try_mirrors (d, u, mirrors, True)
+
         if not ret:
             bb.msg.fatal(bb.msg.domain.Fetcher, "URL %s doesn't work" % u)
 
@@ -348,7 +359,7 @@ def runfetchcmd(cmd, d, quiet = False):
 
     return output
 
-def try_mirrors(d, uri, mirrors):
+def try_mirrors(d, uri, mirrors, check = False):
     """
     Try to use a mirrored version of the sources.
     This method will be automatically called before the fetchers go.
@@ -358,7 +369,7 @@ def try_mirrors(d, uri, mirrors):
     mirrors is the list of mirrors we're going to try
     """
     fpath = os.path.join(data.getVar("DL_DIR", d, 1), os.path.basename(uri))
-    if os.access(fpath, os.R_OK):
+    if not check and os.access.path(fpath, os.R_OK):
         bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists, skipping checkout." % fpath)
         return fpath
 
@@ -375,7 +386,10 @@ def try_mirrors(d, uri, mirrors):
             ud.setup_localpath(ld)
 
             try:
-                ud.method.go(newuri, ud, ld)
+                if check:
+                    ud.method.go(newuri, ud, ld)
+                else:
+                    ud.method.checkstatus(newuri, ud, ld)
                 return ud.localpath
             except (bb.fetch.MissingParameterError,
                     bb.fetch.FetchError,