bitbake: Update SRCREV fetcher code to cope better with multiple SCM packages

git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3145 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
Richard Purdie 2007-11-13 23:03:21 +00:00
parent 0fa37f2d05
commit e13102cd66
3 changed files with 48 additions and 14 deletions

View File

@ -194,6 +194,7 @@ def get_srcrev(d):
return "SRCREVINACTION"
scms = []
# Only call setup_localpath on URIs which suppports_srcrev()
urldata = init(bb.data.getVar('SRC_URI', d, 1).split(), d, False)
for u in urldata:
@ -365,6 +366,34 @@ class Fetch(object):
return data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1)
getSRCDate = staticmethod(getSRCDate)
def srcrev_internal_helper(ud, d):
"""
Return:
a) a source revision if specified
b) True if auto srcrev is in action
c) False otherwise
"""
if 'rev' in ud.parm:
return ud.parm['rev']
if 'tag' in ud.parm:
return ud.parm['tag']
rev = None
if 'name' in ud.parm:
pn = data.getVar("PN", d, 1)
rev = data.getVar("SRCREV_pn-" + pn + "_" + ud.parm['name'], d, 1)
if not rev:
rev = data.getVar("SRCREV", d, 1)
if not rev:
return False
if rev is "SRCREVINACTION":
return True
return rev
srcrev_internal_helper = staticmethod(srcrev_internal_helper)
def try_mirror(d, tarfn):
"""
Try to use a mirrored version of the sources. We do this
@ -454,7 +483,7 @@ class Fetch(object):
pd = persist_data.PersistData(d)
key = self._revision_key(url, ud, d)
latest_rev = self.latest_revision(url, ud, d)
latest_rev = self._build_revision(url, ud, d)
last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev")
count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count")

View File

@ -50,13 +50,14 @@ class Git(Fetch):
if 'protocol' in ud.parm:
ud.proto = ud.parm['protocol']
tag = data.getVar("SRCREV", d, 1)
if 'tag' in ud.parm:
ud.tag = ud.parm['tag']
elif tag is "SRCREVINACTION":
ud.tag = self.latest_revision(url, ud, d)
else:
ud.tag = tag
tag = Fetch.srcrev_internal_helper(ud, d)
if tag is True:
ud.tag = self.latest_revision(url, ud, d)
elif tag:
ud.tag = tag
if not ud.tag:
ud.tag = self.latest_revision(url, ud, d)
if ud.tag == "master":
ud.tag = self.latest_revision(url, ud, d)
@ -132,3 +133,5 @@ class Git(Fetch):
output = runfetchcmd("git ls-remote %s://%s%s" % (ud.proto, ud.host, ud.path), d, True)
return output.split()[0]
def _build_revision(self, url, ud, d):
return ud.tag

View File

@ -70,10 +70,11 @@ class Svn(Fetch):
if "DATE" in pv:
ud.revision = ""
else:
rev = data.getVar("SRCREV", d, 1)
if rev is "SRCREVINACTION":
rev = self.latest_revision(url, ud, d)
if rev:
rev = Fetch.srcrev_internal_helper(ud, d)
if rev is True:
ud.revision = self.latest_revision(url, ud, d)
ud.date = ""
elif rev:
ud.revision = rev
ud.date = ""
else:
@ -195,8 +196,9 @@ class Svn(Fetch):
def _sortable_revision(self, url, ud, d):
"""
Return a sortable revision number which in our case is the revision number
(use the cached version to avoid network access)
"""
return self.latest_revision(url, ud, d)
return self._build_revision(url, ud, d)
def _build_revision(self, url, ud, d):
return ud.revision