diff mbox series

[v2] recipeutils: use UPSTREAM_CHECK_URI in get_recipe_upstream_version

Message ID 20240402180900.2306005-1-jdmason@kudzu.us
State New
Headers show
Series [v2] recipeutils: use UPSTREAM_CHECK_URI in get_recipe_upstream_version | expand

Commit Message

Jon Mason April 2, 2024, 6:09 p.m. UTC
Currently, get_recipe_upstream_version blindly takes the first entry in
SRC_URI to see if the recipe is at the latest version.  If
UPSTREAM_CHECK_URI is specified in a recipe, it is probably what should
be used to check for the latest version.  Use that as the first check,
otherwise default back to the first entry in SRC_URI.

wget was doing it's own check for UPSTREAM_CHECK_URI.  Removing this in
favor of the common one now being done in recipeutils.py.

Signed-off-by: Jon Mason <jdmason@kudzu.us>
---
 bitbake/lib/bb/fetch2/wget.py | 37 +++++++++++++++--------------------
 meta/lib/oe/recipeutils.py    |  9 +++++++--
 2 files changed, 23 insertions(+), 23 deletions(-)

Comments

Alexander Kanavin April 2, 2024, 6:22 p.m. UTC | #1
Have you confirmed that this does not break 'devtool check-upgrade-status' ?

Alex

On Tue, 2 Apr 2024 at 20:09, Jon Mason <jdmason@kudzu.us> wrote:
>
> Currently, get_recipe_upstream_version blindly takes the first entry in
> SRC_URI to see if the recipe is at the latest version.  If
> UPSTREAM_CHECK_URI is specified in a recipe, it is probably what should
> be used to check for the latest version.  Use that as the first check,
> otherwise default back to the first entry in SRC_URI.
>
> wget was doing it's own check for UPSTREAM_CHECK_URI.  Removing this in
> favor of the common one now being done in recipeutils.py.
>
> Signed-off-by: Jon Mason <jdmason@kudzu.us>
> ---
>  bitbake/lib/bb/fetch2/wget.py | 37 +++++++++++++++--------------------
>  meta/lib/oe/recipeutils.py    |  9 +++++++--
>  2 files changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
> index dc025800e659..0342f895646d 100644
> --- a/bitbake/lib/bb/fetch2/wget.py
> +++ b/bitbake/lib/bb/fetch2/wget.py
> @@ -629,27 +629,22 @@ class Wget(FetchMethod):
>              return ('', '')
>          bb.debug(3, "latest_versionstring, regex: %s" % (package_regex.pattern))
>
> -        uri = ""
> -        regex_uri = d.getVar("UPSTREAM_CHECK_URI")
> -        if not regex_uri:
> -            path = ud.path.split(package)[0]
> -
> -            # search for version matches on folders inside the path, like:
> -            # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
> -            dirver_regex = re.compile(r"(?P<dirver>[^/]*(\d+\.)*\d+([-_]r\d+)*)/")
> -            m = dirver_regex.findall(path)
> -            if m:
> -                pn = d.getVar('PN')
> -                dirver = m[-1][0]
> -
> -                dirver_pn_regex = re.compile(r"%s\d?" % (re.escape(pn)))
> -                if not dirver_pn_regex.search(dirver):
> -                    return (self._check_latest_version_by_dir(dirver,
> -                        package, package_regex, current_version, ud, d), '')
> -
> -            uri = bb.fetch.encodeurl([ud.type, ud.host, path, ud.user, ud.pswd, {}])
> -        else:
> -            uri = regex_uri
> +        path = ud.path.split(package)[0]
> +
> +        # search for version matches on folders inside the path, like:
> +        # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
> +        dirver_regex = re.compile(r"(?P<dirver>[^/]*(\d+\.)*\d+([-_]r\d+)*)/")
> +        m = dirver_regex.findall(path)
> +        if m:
> +            pn = d.getVar('PN')
> +            dirver = m[-1][0]
> +
> +            dirver_pn_regex = re.compile(r"%s\d?" % (re.escape(pn)))
> +            if not dirver_pn_regex.search(dirver):
> +                return (self._check_latest_version_by_dir(dirver,
> +                    package, package_regex, current_version, ud, d), '')
> +
> +        uri = bb.fetch.encodeurl([ud.type, ud.host, path, ud.user, ud.pswd, {}])
>
>          return (self._check_latest_version(uri, package, package_regex,
>                  current_version, ud, d), '')
> diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
> index de1fbdd3a8c8..a42609060cd9 100644
> --- a/meta/lib/oe/recipeutils.py
> +++ b/meta/lib/oe/recipeutils.py
> @@ -1041,8 +1041,13 @@ def get_recipe_upstream_version(rd):
>          ru['datetime'] = datetime.now()
>          return ru
>
> -    # XXX: we suppose that the first entry points to the upstream sources
> -    src_uri = src_uris.split()[0]
> +    # If UPSTREAM_CHECK_URI is specified, assume it is correct and use
> +    # it.  Otherwise, use the first SRC_URI specified to determine the
> +    # latest version.
> +    if rd.getVar('UPSTREAM_CHECK_URI'):
> +        src_uri = str(rd.getVar('UPSTREAM_CHECK_URI'))
> +    else:
> +        src_uri = src_uris.split()[0]
>      uri_type, _, _, _, _, _ =  decodeurl(src_uri)
>
>      (pv, pfx, sfx) = get_recipe_pv_with_pfx_sfx(rd.getVar('PV'), uri_type)
> --
> 2.30.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#197876): https://lists.openembedded.org/g/openembedded-core/message/197876
> Mute This Topic: https://lists.openembedded.org/mt/105293221/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Jon Mason April 2, 2024, 8:26 p.m. UTC | #2
Depends on your definition of "does not break".  Does it run without
throwing errors?  Yes.  Does it give the same output?  No.
Originally, I only tested on a couple of recipes, and not the world.
So, I admit to not running this test prior to you asking.

This output is very noisy.  So, it is difficult to get an accurate
idea of whether the differences are regressions or not.  Also, the
output of the individual recipes and versions is not outputted in the
same order.  Looking at the output (after a rough sort), I do see
different values for some.  Like:
-acpica                    20230628        UNKNOWN         Ross Burton
<ross.burton@arm.com>
+acpica                    20230628        KNOWN_BROKEN    Ross Burton
<ross.burton@arm.com>
-gnuplot                   5.4.3           6.0.0           None
+gnuplot                   5.4.3           UNKNOWN_BROKEN  None
-icu                       74-1            74-2            Alexander
Kanavin <alex.kanavin@gmail.com>
+icu                       74-1            74.1            Alexander
Kanavin <alex.kanavin@gmail.com>

Let me poke around with this output to try to make more sense of it
and see if there are real regressions or if it is something else.

Thanks,
Jon


On Tue, Apr 2, 2024 at 2:22 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>
> Have you confirmed that this does not break 'devtool check-upgrade-status' ?
>
> Alex
>
> On Tue, 2 Apr 2024 at 20:09, Jon Mason <jdmason@kudzu.us> wrote:
> >
> > Currently, get_recipe_upstream_version blindly takes the first entry in
> > SRC_URI to see if the recipe is at the latest version.  If
> > UPSTREAM_CHECK_URI is specified in a recipe, it is probably what should
> > be used to check for the latest version.  Use that as the first check,
> > otherwise default back to the first entry in SRC_URI.
> >
> > wget was doing it's own check for UPSTREAM_CHECK_URI.  Removing this in
> > favor of the common one now being done in recipeutils.py.
> >
> > Signed-off-by: Jon Mason <jdmason@kudzu.us>
> > ---
> >  bitbake/lib/bb/fetch2/wget.py | 37 +++++++++++++++--------------------
> >  meta/lib/oe/recipeutils.py    |  9 +++++++--
> >  2 files changed, 23 insertions(+), 23 deletions(-)
> >
> > diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
> > index dc025800e659..0342f895646d 100644
> > --- a/bitbake/lib/bb/fetch2/wget.py
> > +++ b/bitbake/lib/bb/fetch2/wget.py
> > @@ -629,27 +629,22 @@ class Wget(FetchMethod):
> >              return ('', '')
> >          bb.debug(3, "latest_versionstring, regex: %s" % (package_regex.pattern))
> >
> > -        uri = ""
> > -        regex_uri = d.getVar("UPSTREAM_CHECK_URI")
> > -        if not regex_uri:
> > -            path = ud.path.split(package)[0]
> > -
> > -            # search for version matches on folders inside the path, like:
> > -            # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
> > -            dirver_regex = re.compile(r"(?P<dirver>[^/]*(\d+\.)*\d+([-_]r\d+)*)/")
> > -            m = dirver_regex.findall(path)
> > -            if m:
> > -                pn = d.getVar('PN')
> > -                dirver = m[-1][0]
> > -
> > -                dirver_pn_regex = re.compile(r"%s\d?" % (re.escape(pn)))
> > -                if not dirver_pn_regex.search(dirver):
> > -                    return (self._check_latest_version_by_dir(dirver,
> > -                        package, package_regex, current_version, ud, d), '')
> > -
> > -            uri = bb.fetch.encodeurl([ud.type, ud.host, path, ud.user, ud.pswd, {}])
> > -        else:
> > -            uri = regex_uri
> > +        path = ud.path.split(package)[0]
> > +
> > +        # search for version matches on folders inside the path, like:
> > +        # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
> > +        dirver_regex = re.compile(r"(?P<dirver>[^/]*(\d+\.)*\d+([-_]r\d+)*)/")
> > +        m = dirver_regex.findall(path)
> > +        if m:
> > +            pn = d.getVar('PN')
> > +            dirver = m[-1][0]
> > +
> > +            dirver_pn_regex = re.compile(r"%s\d?" % (re.escape(pn)))
> > +            if not dirver_pn_regex.search(dirver):
> > +                return (self._check_latest_version_by_dir(dirver,
> > +                    package, package_regex, current_version, ud, d), '')
> > +
> > +        uri = bb.fetch.encodeurl([ud.type, ud.host, path, ud.user, ud.pswd, {}])
> >
> >          return (self._check_latest_version(uri, package, package_regex,
> >                  current_version, ud, d), '')
> > diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
> > index de1fbdd3a8c8..a42609060cd9 100644
> > --- a/meta/lib/oe/recipeutils.py
> > +++ b/meta/lib/oe/recipeutils.py
> > @@ -1041,8 +1041,13 @@ def get_recipe_upstream_version(rd):
> >          ru['datetime'] = datetime.now()
> >          return ru
> >
> > -    # XXX: we suppose that the first entry points to the upstream sources
> > -    src_uri = src_uris.split()[0]
> > +    # If UPSTREAM_CHECK_URI is specified, assume it is correct and use
> > +    # it.  Otherwise, use the first SRC_URI specified to determine the
> > +    # latest version.
> > +    if rd.getVar('UPSTREAM_CHECK_URI'):
> > +        src_uri = str(rd.getVar('UPSTREAM_CHECK_URI'))
> > +    else:
> > +        src_uri = src_uris.split()[0]
> >      uri_type, _, _, _, _, _ =  decodeurl(src_uri)
> >
> >      (pv, pfx, sfx) = get_recipe_pv_with_pfx_sfx(rd.getVar('PV'), uri_type)
> > --
> > 2.30.2
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#197876): https://lists.openembedded.org/g/openembedded-core/message/197876
> > Mute This Topic: https://lists.openembedded.org/mt/105293221/1686489
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
diff mbox series

Patch

diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index dc025800e659..0342f895646d 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -629,27 +629,22 @@  class Wget(FetchMethod):
             return ('', '')
         bb.debug(3, "latest_versionstring, regex: %s" % (package_regex.pattern))
 
-        uri = ""
-        regex_uri = d.getVar("UPSTREAM_CHECK_URI")
-        if not regex_uri:
-            path = ud.path.split(package)[0]
-
-            # search for version matches on folders inside the path, like:
-            # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
-            dirver_regex = re.compile(r"(?P<dirver>[^/]*(\d+\.)*\d+([-_]r\d+)*)/")
-            m = dirver_regex.findall(path)
-            if m:
-                pn = d.getVar('PN')
-                dirver = m[-1][0]
-
-                dirver_pn_regex = re.compile(r"%s\d?" % (re.escape(pn)))
-                if not dirver_pn_regex.search(dirver):
-                    return (self._check_latest_version_by_dir(dirver,
-                        package, package_regex, current_version, ud, d), '')
-
-            uri = bb.fetch.encodeurl([ud.type, ud.host, path, ud.user, ud.pswd, {}])
-        else:
-            uri = regex_uri
+        path = ud.path.split(package)[0]
+
+        # search for version matches on folders inside the path, like:
+        # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
+        dirver_regex = re.compile(r"(?P<dirver>[^/]*(\d+\.)*\d+([-_]r\d+)*)/")
+        m = dirver_regex.findall(path)
+        if m:
+            pn = d.getVar('PN')
+            dirver = m[-1][0]
+
+            dirver_pn_regex = re.compile(r"%s\d?" % (re.escape(pn)))
+            if not dirver_pn_regex.search(dirver):
+                return (self._check_latest_version_by_dir(dirver,
+                    package, package_regex, current_version, ud, d), '')
+
+        uri = bb.fetch.encodeurl([ud.type, ud.host, path, ud.user, ud.pswd, {}])
 
         return (self._check_latest_version(uri, package, package_regex,
                 current_version, ud, d), '')
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index de1fbdd3a8c8..a42609060cd9 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -1041,8 +1041,13 @@  def get_recipe_upstream_version(rd):
         ru['datetime'] = datetime.now()
         return ru
 
-    # XXX: we suppose that the first entry points to the upstream sources
-    src_uri = src_uris.split()[0]
+    # If UPSTREAM_CHECK_URI is specified, assume it is correct and use
+    # it.  Otherwise, use the first SRC_URI specified to determine the
+    # latest version.
+    if rd.getVar('UPSTREAM_CHECK_URI'):
+        src_uri = str(rd.getVar('UPSTREAM_CHECK_URI'))
+    else:
+        src_uri = src_uris.split()[0]
     uri_type, _, _, _, _, _ =  decodeurl(src_uri)
 
     (pv, pfx, sfx) = get_recipe_pv_with_pfx_sfx(rd.getVar('PV'), uri_type)