summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py55
-rw-r--r--bitbake/lib/bb/fetch2/git.py39
2 files changed, 11 insertions, 83 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 81964f112e..150dc3c18f 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -422,10 +422,18 @@ def get_srcrev(d):
422 if not format: 422 if not format:
423 raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.") 423 raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.")
424 424
425 autoinc = False
426 autoinc_templ = 'AUTOINC+'
425 for scm in scms: 427 for scm in scms:
426 ud = urldata[scm] 428 ud = urldata[scm]
427 for name in ud.names: 429 for name in ud.names:
428 rev = ud.method.sortable_revision(scm, ud, d, name) 430 rev = ud.method.sortable_revision(scm, ud, d, name)
431 if rev.startswith(autoinc_templ):
432 if not autoinc:
433 autoinc = True
434 format = "%s%s" % (autoinc_templ, format)
435 rev = rev[len(autoinc_templ):]
436
429 format = format.replace(name, rev) 437 format = format.replace(name, rev)
430 438
431 return format 439 return format
@@ -1036,23 +1044,6 @@ class FetchMethod(object):
1036 logger.info("URL %s could not be checked for status since no method exists.", url) 1044 logger.info("URL %s could not be checked for status since no method exists.", url)
1037 return True 1045 return True
1038 1046
1039 def localcount_internal_helper(ud, d, name):
1040 """
1041 Return:
1042 a) a locked localcount if specified
1043 b) None otherwise
1044 """
1045
1046 localcount = None
1047 if name != '':
1048 pn = d.getVar("PN", True)
1049 localcount = d.getVar("LOCALCOUNT_" + name, True)
1050 if not localcount:
1051 localcount = d.getVar("LOCALCOUNT", True)
1052 return localcount
1053
1054 localcount_internal_helper = staticmethod(localcount_internal_helper)
1055
1056 def latest_revision(self, url, ud, d, name): 1047 def latest_revision(self, url, ud, d, name):
1057 """ 1048 """
1058 Look in the cache for the latest revision, if not present ask the SCM. 1049 Look in the cache for the latest revision, if not present ask the SCM.
@@ -1075,36 +1066,8 @@ class FetchMethod(object):
1075 if hasattr(self, "_sortable_revision"): 1066 if hasattr(self, "_sortable_revision"):
1076 return self._sortable_revision(url, ud, d) 1067 return self._sortable_revision(url, ud, d)
1077 1068
1078 localcounts = bb.persist_data.persist('BB_URI_LOCALCOUNT', d)
1079 key = self.generate_revision_key(url, ud, d, name)
1080
1081 latest_rev = self._build_revision(url, ud, d, name) 1069 latest_rev = self._build_revision(url, ud, d, name)
1082 last_rev = localcounts.get(key + '_rev') 1070 return 'AUTOINC+%s' % str(latest_rev)
1083 uselocalcount = d.getVar("BB_LOCALCOUNT_OVERRIDE", True) or False
1084 count = None
1085 if uselocalcount:
1086 count = FetchMethod.localcount_internal_helper(ud, d, name)
1087 if count is None:
1088 count = localcounts.get(key + '_count') or "0"
1089
1090 if last_rev == latest_rev:
1091 return str(count + "+" + latest_rev)
1092
1093 buildindex_provided = hasattr(self, "_sortable_buildindex")
1094 if buildindex_provided:
1095 count = self._sortable_buildindex(url, ud, d, latest_rev)
1096
1097 if count is None:
1098 count = "0"
1099 elif uselocalcount or buildindex_provided:
1100 count = str(count)
1101 else:
1102 count = str(int(count) + 1)
1103
1104 localcounts[key + '_rev'] = latest_rev
1105 localcounts[key + '_count'] = count
1106
1107 return str(count + "+" + latest_rev)
1108 1071
1109 def generate_revision_key(self, url, ud, d, name): 1072 def generate_revision_key(self, url, ud, d, name):
1110 key = self._revision_key(url, ud, d, name) 1073 key = self._revision_key(url, ud, d, name)
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index ba9f5fb9ab..63ff00b165 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -71,11 +71,8 @@ from bb.fetch2 import logger
71class Git(FetchMethod): 71class Git(FetchMethod):
72 """Class to fetch a module or modules from git repositories""" 72 """Class to fetch a module or modules from git repositories"""
73 def init(self, d): 73 def init(self, d):
74 # 74 pass
75 # Only enable _sortable revision if the key is set 75
76 #
77 if d.getVar("BB_GIT_CLONE_FOR_SRCREV", True):
78 self._sortable_buildindex = self._sortable_buildindex_disabled
79 def supports(self, url, ud, d): 76 def supports(self, url, ud, d):
80 """ 77 """
81 Check to see if a given url can be fetched with git. 78 Check to see if a given url can be fetched with git.
@@ -316,38 +313,6 @@ class Git(FetchMethod):
316 def _build_revision(self, url, ud, d, name): 313 def _build_revision(self, url, ud, d, name):
317 return ud.revisions[name] 314 return ud.revisions[name]
318 315
319 def _sortable_buildindex_disabled(self, url, ud, d, rev):
320 """
321 Return a suitable buildindex for the revision specified. This is done by counting revisions
322 using "git rev-list" which may or may not work in different circumstances.
323 """
324
325 cwd = os.getcwd()
326
327 # Check if we have the rev already
328
329 if not os.path.exists(ud.clonedir):
330 logger.debug(1, "GIT repository for %s does not exist in %s. \
331 Downloading.", url, ud.clonedir)
332 self.download(None, ud, d)
333 if not os.path.exists(ud.clonedir):
334 logger.error("GIT repository for %s does not exist in %s after \
335 download. Cannot get sortable buildnumber, using \
336 old value", url, ud.clonedir)
337 return None
338
339
340 os.chdir(ud.clonedir)
341 if not self._contains_ref(rev, d):
342 self.download(None, ud, d)
343
344 output = runfetchcmd("%s rev-list %s -- 2> /dev/null | wc -l" % (ud.basecmd, rev), d, quiet=True)
345 os.chdir(cwd)
346
347 buildindex = "%s" % output.split()[0]
348 logger.debug(1, "GIT repository for %s in %s is returning %s revisions in rev-list before %s", url, ud.clonedir, buildindex, rev)
349 return buildindex
350
351 def checkstatus(self, uri, ud, d): 316 def checkstatus(self, uri, ud, d):
352 fetchcmd = "%s ls-remote %s" % (ud.basecmd, uri) 317 fetchcmd = "%s ls-remote %s" % (ud.basecmd, uri)
353 try: 318 try: