]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake/fetch: add try_premirror method and special case git fetcher
authorJoshua Lock <josh@linux.intel.com>
Wed, 8 Sep 2010 13:03:41 +0000 (14:03 +0100)
committerJoshua Lock <josh@linux.intel.com>
Wed, 8 Sep 2010 13:25:24 +0000 (14:25 +0100)
Add a new method, try_premirror, to the Fetch object which checks to see
whether the file needs to be fetched from a premirror.
Override this in the Git fetcher to only require a pre-mirror fetch when the
clone directory does not exist.

Fixes [BUGID 290]

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

index 8d7ec8036c72b2475f335a11525f804c1b0e8865..2b0b288df0d26f69d5f3a46c62758c6f86751824 100644 (file)
@@ -222,6 +222,18 @@ def init(urls, d, setup = True):
     urldata_cache[fn] = urldata
     return urldata
 
+def try_premirror(u, ud, d):
+    """
+    Should we try premirrors for this url, u?
+    We should if forcefetch is set or the localfile and md5 don't exist
+    """
+    if ud.method.forcefetch(u, ud, d):
+        return True
+    elif os.path.exists(ud.md5) and os.path.exists(ud.localfile):
+        return False
+    else:
+        return True
+
 def go(d, urls = None):
     """
     Fetch all urls
@@ -235,7 +247,7 @@ def go(d, urls = None):
         ud = urldata[u]
         m = ud.method
         if ud.localfile:
-            if not m.forcefetch(u, ud, d) and os.path.exists(ud.md5) and os.path.exists(ud.localfile):
+            if not m.try_premirror(u, ud, d):
                 # File already present along with md5 stamp file
                 # Touch md5 file to show activity
                 try:
@@ -245,7 +257,7 @@ def go(d, urls = None):
                     pass
                 continue
             lf = bb.utils.lockfile(ud.lockfile)
-            if not m.forcefetch(u, ud, d) and os.path.exists(ud.md5) and os.path.exists(ud.localfile):
+            if not m.try_premirror(u, ud, d):
                 # If someone else fetched this before we got the lock,
                 # notice and don't try again
                 try:
index b6126cbe9169bb79f02c58f252679cbe7aa500b5..938e0c08ba2512cbf3af7194b1dd8423a90d036c 100644 (file)
@@ -90,6 +90,12 @@ class Git(Fetch):
             return True
         return False
 
+    def try_premirror(self, d, ud):
+        if os.path.exists(ud.clonedir):
+            return False
+
+        return True
+
     def go(self, loc, ud, d):
         """Fetch url"""