[oe] SRCPV migration
Martin Jansa
martin.jansa at gmail.com
Fri Nov 20 10:20:30 UTC 2009
Even better fix for builders with BB_GIT_CLONE_FOR_SRCREV enabled.
--
uin:136542059 jid:Martin.Jansa at gmail.com
Jansa Martin sip:jamasip at voip.wengo.fr
JaMa
-------------- next part --------------
>From b2a572666d6cf31c2c39b3123b97e972f01bbb36 Mon Sep 17 00:00:00 2001
From: Martin Jansa <Martin.Jansa at gmail.com>
Date: Tue, 17 Nov 2009 15:44:43 +0100
Subject: [PATCH 2/2] BB_GIT_CLONE_FOR_SRCREV using only _sortable_buildnumber() for known revision
* Sortable_buildnumber: return old count value if new isn't available
* Protects before putting wrong number (ie 0) to persistent cache when
git repo is not available, or something happen to local git checkout
* Buildnumber shouldn't go backwards ever
* If this error happen always for some recipe SRCPV cannot ensure
upgradeable versions
---
lib/bb/fetch/__init__.py | 18 ++++++++++--------
lib/bb/fetch/git.py | 36 +++++++++++++-----------------------
2 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py
index 9508908..3e04f2e 100644
--- a/lib/bb/fetch/__init__.py
+++ b/lib/bb/fetch/__init__.py
@@ -553,21 +553,20 @@ class Fetch(object):
"""
"""
- has_want_sortable = hasattr(self, "_want_sortable_revision")
- has_sortable = hasattr(self, "_sortable_revision")
+ has_want_sortable_buildnumber = hasattr(self, "_want_sortable_buildnumber")
+ has_sortable_buildnumber = hasattr(self, "_sortable_buildnumber")
+ has_sortable_revision = hasattr(self, "_sortable_revision")
- if not has_want_sortable and has_sortable:
+ if has_sortable_revision:
return self._sortable_revision(url, ud, d)
- elif has_want_sortable and self._want_sortable_revision(url, ud, d) and has_sortable:
- return self._sortable_revision(url, ud, d)
-
-
+
pd = persist_data.PersistData(d)
key = self.generate_revision_key(url, ud, d)
latest_rev = self._build_revision(url, ud, d)
last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev")
uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False
+ usesortable_buildnumber = has_sortable_buildnumber and has_want_sortable_buildnumber and self._want_sortable_buildnumber(url, ud, d)
count = None
if uselocalcount:
count = Fetch.localcount_internal_helper(ud, d)
@@ -577,9 +576,12 @@ class Fetch(object):
if last_rev == latest_rev:
return str(count + "+" + latest_rev)
+ if usesortable_buildnumber:
+ count = self._sortable_buildnumber(url, ud, d, latest_rev, count)
+
if count is None:
count = "0"
- elif uselocalcount:
+ elif uselocalcount or usesortable_buildnumber:
count = str(count)
else:
count = str(int(count) + 1)
diff --git a/lib/bb/fetch/git.py b/lib/bb/fetch/git.py
index 5cdf656..23fc377 100644
--- a/lib/bb/fetch/git.py
+++ b/lib/bb/fetch/git.py
@@ -146,44 +146,34 @@ class Git(Fetch):
def _build_revision(self, url, ud, d):
return ud.tag
- def _want_sortable_revision(self, url, ud, d):
+ def _want_sortable_buildnumber(self, url, ud, d):
return bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True) or False
- def _sortable_revision(self, url, ud, d):
+ def _sortable_buildnumber(self, url, ud, d, rev, count):
"""
- This is only called when _want_sortable_revision called true
+ This is only called when _want_sortable_buildnumber called true
- We will have to get the updated revision.
+ Latest revision is already known, we need only to count revisions in git repo.
"""
gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
- key = "GIT_CACHED_REVISION-%s-%s" % (gitsrcname, ud.tag)
- if bb.data.getVar(key, d):
- return bb.data.getVar(key, d)
-
-
- # Runtime warning on wrongly configured sources
- if ud.tag == "1":
- bb.msg.error(1, bb.msg.domain.Fetcher, "SRCREV is '1'. This indicates a configuration error of %s" % url)
- return "0+1"
-
cwd = os.getcwd()
# Check if we have the rev already
if not os.path.exists(repodir):
- print "no repo"
- self.go(None, ud, d)
+ bb.msg.error(bb.msg.domain.Fetcher, "GIT repository for %s doesn't exist in %s, cannot get sortable buildnumber, using old value" % (url, repodir))
+ return count
os.chdir(repodir)
- if not self._contains_ref(ud.tag, d):
- self.go(None, ud, d)
- output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % ud.tag, d, quiet=True)
+ output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True)
os.chdir(cwd)
- sortable_revision = "%s+%s" % (output.split()[0], ud.tag)
- bb.data.setVar(key, sortable_revision, d)
- return sortable_revision
-
+ sortable_buildnumber= "%s" % (output.split()[0])
+ bb.msg.debug(1, bb.msg.domain.Fetcher, "GIT repository for %s in %s is returning %s revisions in rev-list before %s, old valued is %s" % (url, repodir, sortable_buildnumber, rev, count))
+ if sortable_buildnumber < count:
+ bb.msg.error(bb.msg.domain.Fetcher, "GIT repository for %s in %s is returning %s revisions in rev-list before %s which is lower than previous count %s, using old value" % (url, repodir, sortable_buildnumber, rev, count))
+ return count
+ return sortable_buildnumber
--
1.6.5.3
More information about the Openembedded-devel
mailing list