From patchwork Sun Jul 1 09:52:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [bitbake-devel] fetch2: try PREMIRRORS when calculating latest_revision Date: Sun, 01 Jul 2012 09:52:00 -0000 From: Enrico Scholz X-Patchwork-Id: 30967 Message-Id: <1341136320-6242-1-git-send-email-enrico.scholz@sigma-chemnitz.de> To: bitbake-devel@lists.openembedded.org Cc: Enrico Scholz 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- = ${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 --- 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