logger.error("SRCREV was used yet no valid SCM was found in SRC_URI")
raise ParameterError
- if len(scms) == 1:
- return urldata[scms[0]].method.sortable_revision(scms[0], urldata[scms[0]], d)
+ if len(scms) == 1 and len(urldata[scms[0]].names) == 1:
+ return urldata[scms[0]].method.sortable_revision(scms[0], urldata[scms[0]], d, urldata[scms[0]].names[0])
#
# Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT
raise ParameterError
for scm in scms:
- if 'name' in urldata[scm].parm:
- name = urldata[scm].parm["name"]
- rev = urldata[scm].method.sortable_revision(scm, urldata[scm], d)
+ ud = urldata[scm]
+ for name in ud.names:
+ rev = ud.method.sortable_revision(scm, ud, d, name)
format = format.replace(name, rev)
return format
self.md5_expected = bb.data.getVarFlag("SRC_URI", self.md5_name, d)
self.sha256_expected = bb.data.getVarFlag("SRC_URI", self.sha256_name, d)
+ self.names = self.parm.get("name",'').split(',')
for m in methods:
if m.supports(url, self, d):
self.method = m
if hasattr(m,"urldata_init"):
m.urldata_init(self, d)
if m.supports_srcrev():
- self.revision = Fetch.srcrev_internal_helper(self, d);
+ self.setup_srcrevs(d)
return
raise NoMethodError("Missing implementation for url %s" % url)
+ def setup_srcrevs(self, d):
+ if not self.method.supports_srcrev():
+ return
+
+ self.revisions = {}
+ for name in self.names:
+ self.revisions[name] = Fetch.srcrev_internal_helper(self, d, name)
+
+ # add compatibility code for non name specified case
+ if len(self.names) == 1:
+ self.revision = self.revisions[self.names[0]]
+
def setup_localpath(self, d):
self.setup = True
if "localpath" in self.parm:
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):
+ def srcrev_internal_helper(ud, d, name):
"""
Return:
a) a source revision if specified
return ud.parm['tag']
rev = None
- if 'name' in ud.parm:
+ if name != '':
pn = data.getVar("PN", d, 1)
- rev = data.getVar("SRCREV_%s_pn-%s" % (ud.parm['name'], pn), d, 1)
+ rev = data.getVar("SRCREV_%s_pn-%s" % (name, pn), d, 1)
if not rev:
- rev = data.getVar("SRCREV_pn-%s_%s" % (pn, ud.parm['name']), d, 1)
+ rev = data.getVar("SRCREV_pn-%s_%s" % (pn, name), d, 1)
if not rev:
- rev = data.getVar("SRCREV_%s" % (ud.parm['name']), d, 1)
+ rev = data.getVar("SRCREV_%s" % name, d, 1)
if not rev:
rev = data.getVar("SRCREV", d, 1)
if rev == "INVALID":
raise InvalidSRCREV("Please set SRCREV to a valid value")
if rev == "AUTOINC":
- rev = ud.method.latest_revision(ud.url, ud, d)
+ rev = ud.method.latest_revision(ud.url, ud, d, name)
return rev
srcrev_internal_helper = staticmethod(srcrev_internal_helper)
- def localcount_internal_helper(ud, d):
+ def localcount_internal_helper(ud, d, name):
"""
Return:
a) a locked localcount if specified
"""
localcount = None
- if 'name' in ud.parm:
+ if name != '':
pn = data.getVar("PN", d, 1)
- localcount = data.getVar("LOCALCOUNT_" + ud.parm['name'], d, 1)
+ localcount = data.getVar("LOCALCOUNT_" + name, d, 1)
if not localcount:
localcount = data.getVar("LOCALCOUNT", d, 1)
return localcount
md5out.close()
write_md5sum = staticmethod(write_md5sum)
- def latest_revision(self, url, ud, d):
+ def latest_revision(self, url, ud, d, name):
"""
Look in the cache for the latest revision, if not present ask the SCM.
"""
pd = persist_data.persist(d)
revs = pd['BB_URI_HEADREVS']
- key = self.generate_revision_key(url, ud, d)
+ key = self.generate_revision_key(url, ud, d, name)
rev = revs[key]
if rev != None:
return str(rev)
- revs[key] = rev = self._latest_revision(url, ud, d)
+ revs[key] = rev = self._latest_revision(url, ud, d, name)
return rev
- def sortable_revision(self, url, ud, d):
+ def sortable_revision(self, url, ud, d, name):
"""
"""
pd = persist_data.persist(d)
localcounts = pd['BB_URI_LOCALCOUNT']
- key = self.generate_revision_key(url, ud, d)
+ key = self.generate_revision_key(url, ud, d, name)
- latest_rev = self._build_revision(url, ud, d)
+ latest_rev = self._build_revision(url, ud, d, name)
last_rev = localcounts[key + '_rev']
uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False
count = None
return str(count + "+" + latest_rev)
- def generate_revision_key(self, url, ud, d):
- key = self._revision_key(url, ud, d)
+ def generate_revision_key(self, url, ud, d, name):
+ key = self._revision_key(url, ud, d, name)
return "%s-%s" % (key, bb.data.getVar("PN", d, True) or "")
from . import cvs
def supports_srcrev(self):
return True
- def _revision_key(self, url, ud, d):
+ def _revision_key(self, url, ud, d, name):
"""
Return a unique key for the url
"""
return "bzr:" + ud.pkgdir
- def _latest_revision(self, url, ud, d):
+ def _latest_revision(self, url, ud, d, name):
"""
Return the latest upstream revision number
"""
if 'nocheckout' in ud.parm:
ud.nocheckout = True
- ud.branch = ud.parm.get("branch", "master")
+ branches = ud.parm.get("branch", "master").split(',')
+ if len(branches) != len(ud.names):
+ raise bb.fetch2.ParameterError("SRC_URI (%) name and branch number mismatch" % ud.url)
+ ud.branches = {}
+ for name in ud.names:
+ branch = branches[ud.names.index(name)]
+ ud.branches[name] = branch
gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
ud.mirrortarball = 'git_%s.tar.gz' % (gitsrcname)
ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
def localpath(self, url, ud, d):
- ud.tag = ud.revision
- if not ud.tag or ud.tag == "master":
- ud.tag = self.latest_revision(url, ud, d)
+ for name in ud.names:
+ if not ud.revisions[name] or ud.revisions[name] == "master":
+ ud.revisions[name] = self.latest_revision(url, ud, d, name)
ud.localfile = ud.mirrortarball
- if 'noclone' in ud.parm:
- ud.localfile = None
- return None
-
return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
def forcefetch(self, url, ud, d):
- if 'fullclone' in ud.parm:
- return True
- if 'noclone' in ud.parm:
- return False
- if not self._contains_ref(ud.tag, d):
- return True
+ for name in ud.names:
+ if not self._contains_ref(ud.revisions[name], d):
+ return True
return False
def try_premirror(self, u, ud, d):
os.chdir(ud.clonedir)
# Update the checkout if needed
- if not self._contains_ref(ud.tag, d) or 'fullclone' in ud.parm:
- # Remove all but the .git directory
- bb.fetch2.check_network_access(d, "git fetch %s%s" %(ud.host, ud.path))
- runfetchcmd("rm * -Rf", d)
- if 'fullclone' in ud.parm:
- runfetchcmd("%s fetch --all" % (ud.basecmd), d)
- else:
- runfetchcmd("%s fetch %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branch), d)
- runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d)
- runfetchcmd("%s prune-packed" % ud.basecmd, d)
- runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d)
- ud.repochanged = True
+ for name in ud.names:
+ if not self._contains_ref(ud.revisions[name], d):
+ # Remove all but the .git directory
+ bb.fetch2.check_network_access(d, "git fetch %s%s" %(ud.host, ud.path))
+ runfetchcmd("%s fetch %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branches[name]), d)
+ runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d)
+ runfetchcmd("%s prune-packed" % ud.basecmd, d)
+ runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d)
+ ud.repochanged = True
def build_mirror_data(self, url, ud, d):
# Generate a mirror tarball if needed
os.chdir(ud.clonedir)
mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True)
- if (mirror_tarballs != "0" or 'fullclone' in ud.parm) and ud.repochanged:
+ if mirror_tarballs != "0" and ud.repochanged:
logger.info("Creating tarball of git repository")
runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d)
runfetchcmd("cp -af %s/.git/packed-refs %s/.git/" %(ud.clonedir, destdir), d)
if not ud.nocheckout:
os.chdir(destdir)
- runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d)
+ runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d)
runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d)
return True
output = runfetchcmd("%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag), d, quiet=True)
return output.split()[0] != "0"
- def _revision_key(self, url, ud, d):
+ def _revision_key(self, url, ud, d, name):
"""
Return a unique key for the url
"""
- return "git:" + ud.host + ud.path.replace('/', '.') + ud.branch
+ return "git:" + ud.host + ud.path.replace('/', '.') + ud.branches[name]
- def _latest_revision(self, url, ud, d):
+ def _latest_revision(self, url, ud, d, name):
"""
Compute the HEAD revision for the url
"""
else:
username = ""
- bb.fetch2.check_network_access(d, "git ls-remote %s%s %s" % (ud.host, ud.path, ud.branch))
+ bb.fetch2.check_network_access(d, "git ls-remote %s%s %s" % (ud.host, ud.path, ud.branches[name]))
basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
- cmd = "%s ls-remote %s://%s%s%s %s" % (basecmd, ud.proto, username, ud.host, ud.path, ud.branch)
+ cmd = "%s ls-remote %s://%s%s%s %s" % (basecmd, ud.proto, username, ud.host, ud.path, ud.branches[name])
output = runfetchcmd(cmd, d, True)
if not output:
raise bb.fetch2.FetchError("Fetch command %s gave empty output\n" % (cmd))
return output.split()[0]
- def _build_revision(self, url, ud, d):
- return ud.tag
+ def _build_revision(self, url, ud, d, name):
+ return ud.revisions[name]
def _sortable_buildindex_disabled(self, url, ud, d, rev):
"""
def supports_srcrev(self):
return True
- def _latest_revision(self, url, ud, d):
+ def _latest_revision(self, url, ud, d, name):
"""
Compute tip revision for the url
"""
def _build_revision(self, url, ud, d):
return ud.revision
- def _revision_key(self, url, ud, d):
+ def _revision_key(self, url, ud, d, name):
"""
Return a unique key for the url
"""
def supports_srcrev(self):
return True
- def _revision_key(self, url, ud, d):
+ def _revision_key(self, url, ud, d, name):
"""
Return a unique key for the url
"""
return "svn:" + ud.moddir
- def _latest_revision(self, url, ud, d):
+ def _latest_revision(self, url, ud, d, name):
"""
Return the latest upstream revision number
"""