[bitbake-devel] [PATCH] fetch2: try PREMIRRORS when calculating latest_revision

Enrico Scholz enrico.scholz at sigma-chemnitz.de
Sun Jul 1 09:52:00 UTC 2012


Since support for native git mirrors was added in recent bitbake, it
is possible to use local mirrors for calculating ${AUTOREV}.  This is
very useful for development: recipes SRCREV can be overridden locally
by 'SRCREV_pn-<recipe> = ${AUTOREV}' and a PREMIRROR which refers to a
local repository can be added for the SRC_URI .

Patch checks PREMIRRORS only but not normal MIRRORS because:

a) it can break things when upstream is temporarily unavailable while
   calling latest_revision() (--> MIRRORS will be consulted) but comes
   back when fetching source.

b) it makes the error reporting more complicated (only errors for
   upstream should be shown to user, not the MIRROR's ones).

Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
---
 lib/bb/fetch2/__init__.py |   25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index e3e03e5..2da5e99 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -616,6 +616,29 @@ def try_mirrors(d, origud, mirrors, check = False):
             return ret
     return None
 
+def latest_revision(ud, d, name):
+    mirrors = mirror_from_string(d.getVar('PREMIRRORS', True))
+    ld = d.createCopy()
+    rev = None
+    uris, uds = build_mirroruris(ud, mirrors, ld)
+
+    for index, uri in enumerate(uris):
+        if not hasattr(uds[index].method, '_latest_revision'):
+            continue
+
+        try:
+            rev = uds[index].method.latest_revision(uri, uds[index], d, name)
+            break
+        except bb.fetch2.NetworkAccess:
+            pass
+        except bb.fetch2.BBFetchException as e:
+            pass
+
+    if rev == None:
+        rev = ud.method.latest_revision(ud.url, ud, d, name)
+
+    return rev
+
 def srcrev_internal_helper(ud, d, name):
     """
     Return:
@@ -643,7 +666,7 @@ def srcrev_internal_helper(ud, d, name):
     if rev == "INVALID":
         raise FetchError("Please set SRCREV to a valid value", ud.url)
     if rev == "AUTOINC":
-        rev = ud.method.latest_revision(ud.url, ud, d, name)
+        rev = latest_revision(ud, d, name)
 
     return rev
 
-- 
1.7.10.2





More information about the bitbake-devel mailing list