Message ID | 20230811130453.29278-1-richard.purdie@linuxfoundation.org |
---|---|
State | Accepted, archived |
Commit | ae4dfa2a31c74c0c6c2b14cece822ed1f3d79723 |
Headers | show |
Series | fetch2: Add new srcrev fetcher API | expand |
Hello, On 11/08/2023 14:04:53+0100, Richard Purdie wrote: > 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. > > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> > --- > lib/bb/fetch2/__init__.py | 29 ++++++++++++++++++++++++----- > 1 file changed, 24 insertions(+), 5 deletions(-) > > diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py > index 2428a26fa6..c42961cb04 100644 > --- a/lib/bb/fetch2/__init__.py > +++ b/lib/bb/fetch2/__init__.py > @@ -753,7 +753,7 @@ def get_autorev(d): > d.setVar("__BBAUTOREV_SEEN", True) > return "AUTOINC" > > -def get_srcrev(d, method_name='sortable_revision'): > +def _get_srcrev(d, method_name='sortable_revision'): > """ > Return the revision string, usually for use in the version string (PV) of the current package > 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'): > d.setVar("__BBINSRCREV", True) > > scms = [] > + revs = [] > fetcher = Fetch(d.getVar('SRC_URI').split(), d) > urldata = fetcher.ud > for u in urldata: > @@ -781,16 +782,19 @@ def get_srcrev(d, method_name='sortable_revision'): > scms.append(u) > > if not scms: > - raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI") > + d.delVar("__BBINSRCREV") > + return "", revs > + > > if len(scms) == 1 and len(urldata[scms[0]].names) == 1: > autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0]) > + revs.append(rev) > if len(rev) > 10: > rev = rev[:10] > d.delVar("__BBINSRCREV") > if autoinc: > - return "AUTOINC+" + rev > - return rev > + return "AUTOINC+" + rev, revs > + return rev, revs > > # > # Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT > @@ -806,6 +810,7 @@ def get_srcrev(d, method_name='sortable_revision'): > ud = urldata[scm] > for name in ud.names: > autoinc, rev = getattr(ud.method, method_name)(ud, d, name) > + revs.append(rev) > seenautoinc = seenautoinc or autoinc > if len(rev) > 10: > rev = rev[:10] > @@ -823,7 +828,21 @@ def get_srcrev(d, method_name='sortable_revision'): > format = "AUTOINC+" + format > > d.delVar("__BBINSRCREV") > - return format > + return format, revs > + > +def get_hashvalue(d, method_name='sortable_revision'): > + pkgv, revs = _get_srcrev(d, method_name=method_name) > + return " ".join(revs) > + I guess you already know but this causes: ERROR: Failure expanding variable fetcher_hashes_dummyfunc[vardepvalue], expression was ${@bb.fetch.get_hashvalue(d)} which triggered exception AttributeError: module 'bb.fetch2' has no attribute 'get_hashvalue' The variable dependency chain for the failure is: fetcher_hashes_dummyfunc[vardepvalue] > +def get_pkgv_string(d, method_name='sortable_revision'): > + pkgv, revs = _get_srcrev(d, method_name=method_name) > + return pkgv > + > +def get_srcrev(d, method_name='sortable_revision'): > + pkgv, revs = _get_srcrev(d, method_name=method_name) > + if not pkgv: > + raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI") > + return pkgv > > def localpath(url, d): > fetcher = bb.fetch2.Fetch([url], d) > -- > 2.39.2 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#14936): https://lists.openembedded.org/g/bitbake-devel/message/14936 > Mute This Topic: https://lists.openembedded.org/mt/100683001/3617179 > Group Owner: bitbake-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/leave/10431315/3617179/474273136/xyzzy [alexandre.belloni@bootlin.com] > -=-=-=-=-=-=-=-=-=-=-=- >
On Wed, 2023-08-16 at 20:05 +0200, Alexandre Belloni wrote: > Hello, > > On 11/08/2023 14:04:53+0100, Richard Purdie wrote: > > 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. > > > > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> > > --- > > lib/bb/fetch2/__init__.py | 29 ++++++++++++++++++++++++----- > > 1 file changed, 24 insertions(+), 5 deletions(-) > > > > diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py > > index 2428a26fa6..c42961cb04 100644 > > --- a/lib/bb/fetch2/__init__.py > > +++ b/lib/bb/fetch2/__init__.py > > @@ -753,7 +753,7 @@ def get_autorev(d): > > d.setVar("__BBAUTOREV_SEEN", True) > > return "AUTOINC" > > > > -def get_srcrev(d, method_name='sortable_revision'): > > +def _get_srcrev(d, method_name='sortable_revision'): > > """ > > Return the revision string, usually for use in the version string (PV) of the current package > > 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'): > > d.setVar("__BBINSRCREV", True) > > > > scms = [] > > + revs = [] > > fetcher = Fetch(d.getVar('SRC_URI').split(), d) > > urldata = fetcher.ud > > for u in urldata: > > @@ -781,16 +782,19 @@ def get_srcrev(d, method_name='sortable_revision'): > > scms.append(u) > > > > if not scms: > > - raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI") > > + d.delVar("__BBINSRCREV") > > + return "", revs > > + > > > > if len(scms) == 1 and len(urldata[scms[0]].names) == 1: > > autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0]) > > + revs.append(rev) > > if len(rev) > 10: > > rev = rev[:10] > > d.delVar("__BBINSRCREV") > > if autoinc: > > - return "AUTOINC+" + rev > > - return rev > > + return "AUTOINC+" + rev, revs > > + return rev, revs > > > > # > > # Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT > > @@ -806,6 +810,7 @@ def get_srcrev(d, method_name='sortable_revision'): > > ud = urldata[scm] > > for name in ud.names: > > autoinc, rev = getattr(ud.method, method_name)(ud, d, name) > > + revs.append(rev) > > seenautoinc = seenautoinc or autoinc > > if len(rev) > 10: > > rev = rev[:10] > > @@ -823,7 +828,21 @@ def get_srcrev(d, method_name='sortable_revision'): > > format = "AUTOINC+" + format > > > > d.delVar("__BBINSRCREV") > > - return format > > + return format, revs > > + > > +def get_hashvalue(d, method_name='sortable_revision'): > > + pkgv, revs = _get_srcrev(d, method_name=method_name) > > + return " ".join(revs) > > + > > I guess you already know but this causes: > > ERROR: Failure expanding variable fetcher_hashes_dummyfunc[vardepvalue], expression was ${@bb.fetch.get_hashvalue(d)} which triggered exception AttributeError: module 'bb.fetch2' has no attribute 'get_hashvalue' > The variable dependency chain for the failure is: fetcher_hashes_dummyfunc[vardepvalue] It needs the corresponding patch on the bitbake list and which is in bitbake master-next. Cheers, Richard
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py index 2428a26fa6..c42961cb04 100644 --- a/lib/bb/fetch2/__init__.py +++ b/lib/bb/fetch2/__init__.py @@ -753,7 +753,7 @@ def get_autorev(d): d.setVar("__BBAUTOREV_SEEN", True) return "AUTOINC" -def get_srcrev(d, method_name='sortable_revision'): +def _get_srcrev(d, method_name='sortable_revision'): """ Return the revision string, usually for use in the version string (PV) of the current package 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'): d.setVar("__BBINSRCREV", True) scms = [] + revs = [] fetcher = Fetch(d.getVar('SRC_URI').split(), d) urldata = fetcher.ud for u in urldata: @@ -781,16 +782,19 @@ def get_srcrev(d, method_name='sortable_revision'): scms.append(u) if not scms: - raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI") + d.delVar("__BBINSRCREV") + return "", revs + if len(scms) == 1 and len(urldata[scms[0]].names) == 1: autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0]) + revs.append(rev) if len(rev) > 10: rev = rev[:10] d.delVar("__BBINSRCREV") if autoinc: - return "AUTOINC+" + rev - return rev + return "AUTOINC+" + rev, revs + return rev, revs # # Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT @@ -806,6 +810,7 @@ def get_srcrev(d, method_name='sortable_revision'): ud = urldata[scm] for name in ud.names: autoinc, rev = getattr(ud.method, method_name)(ud, d, name) + revs.append(rev) seenautoinc = seenautoinc or autoinc if len(rev) > 10: rev = rev[:10] @@ -823,7 +828,21 @@ def get_srcrev(d, method_name='sortable_revision'): format = "AUTOINC+" + format d.delVar("__BBINSRCREV") - return format + return format, revs + +def get_hashvalue(d, method_name='sortable_revision'): + pkgv, revs = _get_srcrev(d, method_name=method_name) + return " ".join(revs) + +def get_pkgv_string(d, method_name='sortable_revision'): + pkgv, revs = _get_srcrev(d, method_name=method_name) + return pkgv + +def get_srcrev(d, method_name='sortable_revision'): + pkgv, revs = _get_srcrev(d, method_name=method_name) + if not pkgv: + raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI") + return pkgv def localpath(url, d): fetcher = bb.fetch2.Fetch([url], d)
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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- lib/bb/fetch2/__init__.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)