[v2] meta/conf/bitbake.conf: enable SRCPV support for AUTOREV

Message ID 20230419024032.1263457-1-srinuvasan_a@mentor.com
State Accepted, archived
Headers show
Series [v2] meta/conf/bitbake.conf: enable SRCPV support for AUTOREV | expand

Commit Message

Srinuvasan Arjunan April 19, 2023, 2:40 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 | 10 ++++++++++
 meta/conf/bitbake.conf    |  4 ++++
 2 files changed, 14 insertions(+)

Comments

Jan Kiszka April 19, 2023, 1:43 p.m. UTC | #1
On 19.04.23 04:40, 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 | 10 ++++++++++
>  meta/conf/bitbake.conf    |  4 ++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index 53550ae..17bebe9 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -120,6 +120,16 @@ root_cleandirs() {
>  python() {
>      import re
>  
> +    needsrcrev = False
> +    srcuri = d.getVar('SRC_URI')
> +    for uri_string in srcuri.split():
> +        uri = bb.fetch.URI(uri_string)
> +        if uri.scheme in ("svn", "git", "gitsm", "hg", "p4", "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}"

Looks good to me.

Thanks,
Jan
Anton Mikanovich May 8, 2023, 5:57 p.m. UTC | #2
19/04/2023 05:40, 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>

Applied to next, thanks.

Patch

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 53550ae..17bebe9 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -120,6 +120,16 @@  root_cleandirs() {
 python() {
     import re
 
+    needsrcrev = False
+    srcuri = d.getVar('SRC_URI')
+    for uri_string in srcuri.split():
+        uri = bb.fetch.URI(uri_string)
+        if uri.scheme in ("svn", "git", "gitsm", "hg", "p4", "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}"