Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] bitbake: fetch2: Make SRCREV_FORMAT name substitution safer
@ 2016-09-12 20:11 Ulf Magnusson
  2016-09-12 20:18 ` Ulf Magnusson
  0 siblings, 1 reply; 2+ messages in thread
From: Ulf Magnusson @ 2016-09-12 20:11 UTC (permalink / raw)
  To: openembedded-core; +Cc: dev

Given two names "foo" and "foobar" and SRCREV_FORMAT = "foo_foobar",
"foo" might currently get substituted twice. Work around the issue by
sorting the list of names by length and substituting longer names first.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
---
 bitbake/lib/bb/fetch2/__init__.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 11c75cc..4ca024e 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -764,7 +764,10 @@ def get_srcrev(d, method_name='sortable_revision'):
     seenautoinc = False
     for scm in scms:
         ud = urldata[scm]
-        for name in ud.names:
+        # Sort the list of names and replace the longest names first. Given two
+        # names "foo" and "foobar", this prevents "foo" being substituted twice
+        # in "foo_foobar" (and "foobar" from not being substituted at all).
+        for name in sorted(ud.names, key=len, reverse=True):
             autoinc, rev = getattr(ud.method, method_name)(ud, d, name)
             seenautoinc = seenautoinc or autoinc
             if len(rev) > 10:
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bitbake: fetch2: Make SRCREV_FORMAT name substitution safer
  2016-09-12 20:11 [PATCH] bitbake: fetch2: Make SRCREV_FORMAT name substitution safer Ulf Magnusson
@ 2016-09-12 20:18 ` Ulf Magnusson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Magnusson @ 2016-09-12 20:18 UTC (permalink / raw)
  To: OE-core

On Mon, Sep 12, 2016 at 10:11 PM, Ulf Magnusson <ulfalizer@gmail.com> wrote:
> Given two names "foo" and "foobar" and SRCREV_FORMAT = "foo_foobar",
> "foo" might currently get substituted twice. Work around the issue by
> sorting the list of names by length and substituting longer names first.
>
> Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
> ---
>  bitbake/lib/bb/fetch2/__init__.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
> index 11c75cc..4ca024e 100644
> --- a/bitbake/lib/bb/fetch2/__init__.py
> +++ b/bitbake/lib/bb/fetch2/__init__.py
> @@ -764,7 +764,10 @@ def get_srcrev(d, method_name='sortable_revision'):
>      seenautoinc = False
>      for scm in scms:
>          ud = urldata[scm]
> -        for name in ud.names:
> +        # Sort the list of names and replace the longest names first. Given two
> +        # names "foo" and "foobar", this prevents "foo" being substituted twice
> +        # in "foo_foobar" (and "foobar" from not being substituted at all).
> +        for name in sorted(ud.names, key=len, reverse=True):
>              autoinc, rev = getattr(ud.method, method_name)(ud, d, name)
>              seenautoinc = seenautoinc or autoinc
>              if len(rev) > 10:
> --
> 2.5.0
>

Hrm... the bitbake-devel mailing list would be a better fit. Sent it there too.

Cheers,
Ulf


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-12 20:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-12 20:11 [PATCH] bitbake: fetch2: Make SRCREV_FORMAT name substitution safer Ulf Magnusson
2016-09-12 20:18 ` Ulf Magnusson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox