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

Message ID 20230417132734.1023825-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 17, 2023, 1:27 p.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 | 26 ++++++++++++++++++++++++++
 meta/conf/bitbake.conf    |  4 ++++
 2 files changed, 30 insertions(+)

Comments

Jan Kiszka April 17, 2023, 2:10 p.m. UTC | #1
Make sure to always version your patches!

On 17.04.23 15:27, 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 | 26 ++++++++++++++++++++++++++
>  meta/conf/bitbake.conf    |  4 ++++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index 53550ae..f631483 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -120,6 +120,32 @@ root_cleandirs() {
>  python() {
>      import re
>  
> +    needsrcrev = False
> +    srcuri = d.getVar('SRC_URI')
> +    for uri_string in srcuri.split():
> +        uri = bb.fetch.URI(uri_string)
> +        # Svn packages should DEPEND on subversion-native

The comments is not fully accurate for Isar (we are not building such
tools natively). Same below.

> +        if uri.scheme == "svn":
> +            needsrcrev = True
> +
> +        # Git packages should DEPEND on git-native
> +        elif uri.scheme in ("git", "gitsm"):
> +            needsrcrev = True
> +
> +        # Mercurial packages should DEPEND on mercurial-native
> +        elif uri.scheme == "hg":
> +            needsrcrev = True
> +
> +        # Perforce packages support SRCREV = "${AUTOREV}"
> +        elif uri.scheme == "p4":
> +            needsrcrev = True
> +
> +        elif uri.scheme == "repo":
> +            needsrcrev = True
> +
> +    if needsrcrev:
> +        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}"

Except for the comments, this looks good to me now.

Just wondering if we could somehow stress this path in Isar upstream as
well - though that should not block this fix for AUTOREV.

Jan
Srinuvasan Arjunan April 18, 2023, 6:25 a.m. UTC | #2
On Mon, Apr 17, 2023 at 7:40 PM 'Jan Kiszka' via isar-users <
isar-users@googlegroups.com> wrote:

> Make sure to always version your patches!
>
> On 17.04.23 15:27, 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 | 26 ++++++++++++++++++++++++++
> >  meta/conf/bitbake.conf    |  4 ++++
> >  2 files changed, 30 insertions(+)
> >
> > diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> > index 53550ae..f631483 100644
> > --- a/meta/classes/base.bbclass
> > +++ b/meta/classes/base.bbclass
> > @@ -120,6 +120,32 @@ root_cleandirs() {
> >  python() {
> >      import re
> >
> > +    needsrcrev = False
> > +    srcuri = d.getVar('SRC_URI')
> > +    for uri_string in srcuri.split():
> > +        uri = bb.fetch.URI(uri_string)
> > +        # Svn packages should DEPEND on subversion-native
>
> The comments is not fully accurate for Isar (we are not building such
> tools natively). Same below.
>
> > +        if uri.scheme == "svn":
> > +            needsrcrev = True
> > +
> > +        # Git packages should DEPEND on git-native
> > +        elif uri.scheme in ("git", "gitsm"):
> > +            needsrcrev = True
> > +
> > +        # Mercurial packages should DEPEND on mercurial-native
> > +        elif uri.scheme == "hg":
> > +            needsrcrev = True
> > +
> > +        # Perforce packages support SRCREV = "${AUTOREV}"
> > +        elif uri.scheme == "p4":
> > +            needsrcrev = True
> > +
> > +        elif uri.scheme == "repo":
> > +            needsrcrev = True
> > +
> > +    if needsrcrev:
> > +        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}"
>
> Except for the comments, this looks good to me now.
>
> Just wondering if we could somehow stress this path in Isar upstream as
> well - though that should not block this fix for AUTOREV.
>

    Stress this path meant, this one you are saying
    # Also check downloadfilename as the URL path might not be useful for
sniffing
    path = uri.params.get("downloadfilename", uri.path)

>
> Jan
>
> --
> 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/7c8c6715-0ecd-35ab-4865-9b549f833ccf%40siemens.com
> .
>
Uladzimir Bely April 18, 2023, 7:06 a.m. UTC | #3
In the email from Monday, 17 April 2023 17:10:03 +03 user 'Jan Kiszka' via isar-users wrote:
> Make sure to always version your patches!
> 
> On 17.04.23 15:27, 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 | 26 ++++++++++++++++++++++++++
> >  meta/conf/bitbake.conf    |  4 ++++
> >  2 files changed, 30 insertions(+)
> > 
> > diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> > index 53550ae..f631483 100644
> > --- a/meta/classes/base.bbclass
> > +++ b/meta/classes/base.bbclass
> > @@ -120,6 +120,32 @@ root_cleandirs() {
> >  python() {
> >      import re
> >  
> > +    needsrcrev = False
> > +    srcuri = d.getVar('SRC_URI')
> > +    for uri_string in srcuri.split():
> > +        uri = bb.fetch.URI(uri_string)
> > +        # Svn packages should DEPEND on subversion-native
> 
> The comments is not fully accurate for Isar (we are not building such
> tools natively). Same below.
> 

If comments below are to be removed, it would be probably better to collapse all the stuff to

if uri.scheme in ("svn", "git", "gitsm", "hg", "p4", "repo"):
    needsrcrev = True


> > +        if uri.scheme == "svn":
> > +            needsrcrev = True
> > +
> > +        # Git packages should DEPEND on git-native
> > +        elif uri.scheme in ("git", "gitsm"):
> > +            needsrcrev = True
> > +
> > +        # Mercurial packages should DEPEND on mercurial-native
> > +        elif uri.scheme == "hg":
> > +            needsrcrev = True
> > +
> > +        # Perforce packages support SRCREV = "${AUTOREV}"
> > +        elif uri.scheme == "p4":
> > +            needsrcrev = True
> > +
> > +        elif uri.scheme == "repo":
> > +            needsrcrev = True
> > +
> > +    if needsrcrev:
> > +        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}"
> 
> Except for the comments, this looks good to me now.
> 
> Just wondering if we could somehow stress this path in Isar upstream as
> well - though that should not block this fix for AUTOREV.
> 
> Jan
> 
>

Patch

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 53550ae..f631483 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -120,6 +120,32 @@  root_cleandirs() {
 python() {
     import re
 
+    needsrcrev = False
+    srcuri = d.getVar('SRC_URI')
+    for uri_string in srcuri.split():
+        uri = bb.fetch.URI(uri_string)
+        # Svn packages should DEPEND on subversion-native
+        if uri.scheme == "svn":
+            needsrcrev = True
+
+        # Git packages should DEPEND on git-native
+        elif uri.scheme in ("git", "gitsm"):
+            needsrcrev = True
+
+        # Mercurial packages should DEPEND on mercurial-native
+        elif uri.scheme == "hg":
+            needsrcrev = True
+
+        # Perforce packages support SRCREV = "${AUTOREV}"
+        elif uri.scheme == "p4":
+            needsrcrev = True
+
+        elif uri.scheme == "repo":
+            needsrcrev = True
+
+    if needsrcrev:
+        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}"