diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-08-11 13:52:48 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-08-24 16:49:38 +0100 |
commit | c9400d01575c2a93762b71bf790d0edd6e2acb6f (patch) | |
tree | 1e411db7c81c1609f59347f916363c011006905b /bitbake/lib/bb/fetch2/__init__.py | |
parent | 65cd9697f95901c45984e4f7c21c64b0ef4845a0 (diff) | |
download | poky-c9400d01575c2a93762b71bf790d0edd6e2acb6f.tar.gz |
bitbake: fetch2: Add new srcrev fetcher API
Add new functions to return some of the get_srcrev data in new and different
ways. We need two different forms of the data, one is a string to inject into
PKGV, the other is the full revisions as a string to include in hash computations
so that the hash changes when the input revisions change.
This allows us to clean up and simplify the code in OE-Core and move the
version information from PV to PKGV.
(Bitbake rev: ae4dfa2a31c74c0c6c2b14cece822ed1f3d79723)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/__init__.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index e4c1d20627..765aedd51d 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -753,7 +753,7 @@ def get_autorev(d): | |||
753 | d.setVar("__BBAUTOREV_SEEN", True) | 753 | d.setVar("__BBAUTOREV_SEEN", True) |
754 | return "AUTOINC" | 754 | return "AUTOINC" |
755 | 755 | ||
756 | def get_srcrev(d, method_name='sortable_revision'): | 756 | def _get_srcrev(d, method_name='sortable_revision'): |
757 | """ | 757 | """ |
758 | Return the revision string, usually for use in the version string (PV) of the current package | 758 | Return the revision string, usually for use in the version string (PV) of the current package |
759 | Most packages usually only have one SCM so we just pass on the call. | 759 | Most packages usually only have one SCM so we just pass on the call. |
@@ -774,6 +774,7 @@ def get_srcrev(d, method_name='sortable_revision'): | |||
774 | d.setVar("__BBINSRCREV", True) | 774 | d.setVar("__BBINSRCREV", True) |
775 | 775 | ||
776 | scms = [] | 776 | scms = [] |
777 | revs = [] | ||
777 | fetcher = Fetch(d.getVar('SRC_URI').split(), d) | 778 | fetcher = Fetch(d.getVar('SRC_URI').split(), d) |
778 | urldata = fetcher.ud | 779 | urldata = fetcher.ud |
779 | for u in urldata: | 780 | for u in urldata: |
@@ -781,16 +782,19 @@ def get_srcrev(d, method_name='sortable_revision'): | |||
781 | scms.append(u) | 782 | scms.append(u) |
782 | 783 | ||
783 | if not scms: | 784 | if not scms: |
784 | raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI") | 785 | d.delVar("__BBINSRCREV") |
786 | return "", revs | ||
787 | |||
785 | 788 | ||
786 | if len(scms) == 1 and len(urldata[scms[0]].names) == 1: | 789 | if len(scms) == 1 and len(urldata[scms[0]].names) == 1: |
787 | autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0]) | 790 | autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0]) |
791 | revs.append(rev) | ||
788 | if len(rev) > 10: | 792 | if len(rev) > 10: |
789 | rev = rev[:10] | 793 | rev = rev[:10] |
790 | d.delVar("__BBINSRCREV") | 794 | d.delVar("__BBINSRCREV") |
791 | if autoinc: | 795 | if autoinc: |
792 | return "AUTOINC+" + rev | 796 | return "AUTOINC+" + rev, revs |
793 | return rev | 797 | return rev, revs |
794 | 798 | ||
795 | # | 799 | # |
796 | # Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT | 800 | # Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT |
@@ -806,6 +810,7 @@ def get_srcrev(d, method_name='sortable_revision'): | |||
806 | ud = urldata[scm] | 810 | ud = urldata[scm] |
807 | for name in ud.names: | 811 | for name in ud.names: |
808 | autoinc, rev = getattr(ud.method, method_name)(ud, d, name) | 812 | autoinc, rev = getattr(ud.method, method_name)(ud, d, name) |
813 | revs.append(rev) | ||
809 | seenautoinc = seenautoinc or autoinc | 814 | seenautoinc = seenautoinc or autoinc |
810 | if len(rev) > 10: | 815 | if len(rev) > 10: |
811 | rev = rev[:10] | 816 | rev = rev[:10] |
@@ -823,7 +828,21 @@ def get_srcrev(d, method_name='sortable_revision'): | |||
823 | format = "AUTOINC+" + format | 828 | format = "AUTOINC+" + format |
824 | 829 | ||
825 | d.delVar("__BBINSRCREV") | 830 | d.delVar("__BBINSRCREV") |
826 | return format | 831 | return format, revs |
832 | |||
833 | def get_hashvalue(d, method_name='sortable_revision'): | ||
834 | pkgv, revs = _get_srcrev(d, method_name=method_name) | ||
835 | return " ".join(revs) | ||
836 | |||
837 | def get_pkgv_string(d, method_name='sortable_revision'): | ||
838 | pkgv, revs = _get_srcrev(d, method_name=method_name) | ||
839 | return pkgv | ||
840 | |||
841 | def get_srcrev(d, method_name='sortable_revision'): | ||
842 | pkgv, revs = _get_srcrev(d, method_name=method_name) | ||
843 | if not pkgv: | ||
844 | raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI") | ||
845 | return pkgv | ||
827 | 846 | ||
828 | def localpath(url, d): | 847 | def localpath(url, d): |
829 | fetcher = bb.fetch2.Fetch([url], d) | 848 | fetcher = bb.fetch2.Fetch([url], d) |