summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 11c75cc723..06f1eb4e81 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -761,6 +761,7 @@ def get_srcrev(d, method_name='sortable_revision'):
761 if not format: 761 if not format:
762 raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.") 762 raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.")
763 763
764 name_to_rev = {}
764 seenautoinc = False 765 seenautoinc = False
765 for scm in scms: 766 for scm in scms:
766 ud = urldata[scm] 767 ud = urldata[scm]
@@ -769,7 +770,16 @@ def get_srcrev(d, method_name='sortable_revision'):
769 seenautoinc = seenautoinc or autoinc 770 seenautoinc = seenautoinc or autoinc
770 if len(rev) > 10: 771 if len(rev) > 10:
771 rev = rev[:10] 772 rev = rev[:10]
772 format = format.replace(name, rev) 773 name_to_rev[name] = rev
774 # Replace names by revisions in the SRCREV_FORMAT string. The approach used
775 # here can handle names being prefixes of other names and names appearing
776 # as substrings in revisions (in which case the name should not be
777 # expanded). The '|' regular expression operator tries matches from left to
778 # right, so we need to sort the names with the longest ones first.
779 names_descending_len = sorted(name_to_rev, key=len, reverse=True)
780 name_to_rev_re = "|".join(re.escape(name) for name in names_descending_len)
781 format = re.sub(name_to_rev_re, lambda match: name_to_rev[match.group(0)], format)
782
773 if seenautoinc: 783 if seenautoinc:
774 format = "AUTOINC+" + format 784 format = "AUTOINC+" + format
775 785