meta/conf/bitbake.conf: enable SRCPV support for AUTOREV

Message ID 20230414085742.844733-1-srinuvasan_a@mentor.com
State Superseded, archived
Headers show
Series meta/conf/bitbake.conf: enable SRCPV support for AUTOREV | expand

Commit Message

Srinuvasan Arjunan April 14, 2023, 8:57 a.m. UTC
From: Srinuvasan A <srinuvasan_a@mentor.com>

One of our downstream project recipe uses `SRCREV = "${AUTOREV}"` to get
the latest changes always, but this not works after bitbake 2 migration,
it throws the below error.

do_fetch: Fetcher failure: Recipe uses a floating tag/branch without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).

Till now we don't have support for SRCPV in ISAR, hence add this support
as like OE.

Signed-off-by: Srinuvasan A <srinuvasan_a@mentor.com>
---
 meta/classes/base.bbclass | 4 ++++
 meta/conf/bitbake.conf    | 4 ++++
 2 files changed, 8 insertions(+)

Comments

Jan Kiszka April 14, 2023, 9 a.m. UTC | #1
On 14.04.23 10:57, Srinuvasan Arjunan wrote:
> From: Srinuvasan A <srinuvasan_a@mentor.com>
> 
> One of our downstream project recipe uses `SRCREV = "${AUTOREV}"` to get
> the latest changes always, but this not works after bitbake 2 migration,
> it throws the below error.
> 
> do_fetch: Fetcher failure: Recipe uses a floating tag/branch without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).
> 
> Till now we don't have support for SRCPV in ISAR, hence add this support
> as like OE.
> 
> Signed-off-by: Srinuvasan A <srinuvasan_a@mentor.com>
> ---
>  meta/classes/base.bbclass | 4 ++++
>  meta/conf/bitbake.conf    | 4 ++++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index 53550ae..819f8a2 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -120,6 +120,10 @@ root_cleandirs() {
>  python() {
>      import re
>  
> +    srcuri = d.getVar('SRC_URI')
> +    if srcuri:
> +        d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
> +

Still not the logic that OE uses - why?

Jan
Srinuvasan Arjunan April 14, 2023, 9:12 a.m. UTC | #2
On Fri, Apr 14, 2023 at 2:30 PM 'Jan Kiszka' via isar-users <
isar-users@googlegroups.com> wrote:

> On 14.04.23 10:57, Srinuvasan Arjunan wrote:
> > From: Srinuvasan A <srinuvasan_a@mentor.com>
> >
> > One of our downstream project recipe uses `SRCREV = "${AUTOREV}"` to get
> > the latest changes always, but this not works after bitbake 2 migration,
> > it throws the below error.
> >
> > do_fetch: Fetcher failure: Recipe uses a floating tag/branch without a
> fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for
> OE).
> >
> > Till now we don't have support for SRCPV in ISAR, hence add this support
> > as like OE.
> >
> > Signed-off-by: Srinuvasan A <srinuvasan_a@mentor.com>
> > ---
> >  meta/classes/base.bbclass | 4 ++++
> >  meta/conf/bitbake.conf    | 4 ++++
> >  2 files changed, 8 insertions(+)
> >
> > diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> > index 53550ae..819f8a2 100644
> > --- a/meta/classes/base.bbclass
> > +++ b/meta/classes/base.bbclass
> > @@ -120,6 +120,10 @@ root_cleandirs() {
> >  python() {
> >      import re
> >
> > +    srcuri = d.getVar('SRC_URI')
> > +    if srcuri:
> > +        d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
> > +
>
> Still not the logic that OE uses - why?
>
> Jan
>

  I thought it would be enable when SRC_URI contains any SCM
  They have a logic like get the uri and validating the uri.scheme against
with many SCM , and set the needsrcrev variable if needed
  f.e : git

if uri.scheme in ("git", "gitsm"):
            needsrcrev = True

 Would we need to check like this?

>
> --
> Siemens AG, Technology
> Competence Center Embedded Linux
>
> --
> You received this message because you are subscribed to the Google Groups
> "isar-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to isar-users+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/isar-users/b58e37e2-00db-d2db-9955-cdcce8ae3f26%40siemens.com
> .
>
Jan Kiszka April 14, 2023, 9:16 a.m. UTC | #3
On 14.04.23 11:12, Srinuvasan Arjunan wrote:
> 
> 
> On Fri, Apr 14, 2023 at 2:30 PM 'Jan Kiszka' via isar-users
> <isar-users@googlegroups.com <mailto:isar-users@googlegroups.com>> wrote:
> 
>     On 14.04.23 10:57, Srinuvasan Arjunan wrote:
>     > From: Srinuvasan A <srinuvasan_a@mentor.com
>     <mailto:srinuvasan_a@mentor.com>>
>     >
>     > One of our downstream project recipe uses `SRCREV = "${AUTOREV}"`
>     to get
>     > the latest changes always, but this not works after bitbake 2
>     migration,
>     > it throws the below error.
>     >
>     > do_fetch: Fetcher failure: Recipe uses a floating tag/branch
>     without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use
>     SRCPV in PV for OE).
>     >
>     > Till now we don't have support for SRCPV in ISAR, hence add this
>     support
>     > as like OE.
>     >
>     > Signed-off-by: Srinuvasan A <srinuvasan_a@mentor.com
>     <mailto:srinuvasan_a@mentor.com>>
>     > ---
>     >  meta/classes/base.bbclass | 4 ++++
>     >  meta/conf/bitbake.conf    | 4 ++++
>     >  2 files changed, 8 insertions(+)
>     >
>     > diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
>     > index 53550ae..819f8a2 100644
>     > --- a/meta/classes/base.bbclass
>     > +++ b/meta/classes/base.bbclass
>     > @@ -120,6 +120,10 @@ root_cleandirs() {
>     >  python() {
>     >      import re
>     > 
>     > +    srcuri = d.getVar('SRC_URI')
>     > +    if srcuri:
>     > +        d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
>     > +
> 
>     Still not the logic that OE uses - why?
> 
>     Jan
> 
>  
>   I thought it would be enable when SRC_URI contains any SCM
>   They have a logic like get the uri and validating the uri.scheme
> against with many SCM , and set the needsrcrev variable if needed
>   f.e : git
>  
> if uri.scheme in ("git", "gitsm"):
>             needsrcrev = True
> 	
> 
>  Would we need to check like this?
> 

Counter question: Does your solution also work if SRC_URI is only
containing "file://"?

Jan

Patch

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 53550ae..819f8a2 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -120,6 +120,10 @@  root_cleandirs() {
 python() {
     import re
 
+    srcuri = d.getVar('SRC_URI')
+    if srcuri:
+        d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
+
     for e in d.keys():
         flags = d.getVarFlags(e)
         if flags and flags.get('task'):
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index f421050..124bf49 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -36,6 +36,10 @@  PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
 PROVIDES = ""
 S = "${WORKDIR}/${P}"
 AUTOREV = "${@bb.fetch2.get_autorev(d)}"
+AUTOREV[vardepvalue] = "${SRCPV}"
+# Set Dynamically in base.bbclass
+# SRCPV = "${@bb.fetch2.get_srcrev(d)}"
+SRCPV[vardepvalue] = "${SRCPV}"
 SRC_URI = ""
 STAMPS_DIR ?= "${TMPDIR}/stamps"
 STAMP = "${STAMPS_DIR}/${DISTRO}-${DISTRO_ARCH}/${PN}/${PV}-${PR}"