All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Mason <jdmason@kudzu.us>
To: openembedded-core@lists.openembedded.org
Subject: [RFC] recipeutils: check for SRC_URI name in get_recipe_upstream_version
Date: Wed, 27 Mar 2024 14:45:32 -0400	[thread overview]
Message-ID: <20240327184532.226557-1-jdmason@kudzu.us> (raw)

Previously, get_recipe_upstream_version took whatever the first entry in
SRC_URI was for determining the upstream version.  This does not work
for recipes that append to the SRC_URI, as theirs will never be first.
To work around this, add a new variable to specify the SRC_URI name
field and use that to match.  If nothing is specified, it will use the
first SRC_URI.

Signed-off-by: Jon Mason <jdmason@kudzu.us>
---
 documentation/ref-manual/devtool-reference.rst |  4 ++--
 documentation/ref-manual/variables.rst         |  8 ++++++++
 meta/lib/oe/recipeutils.py                     | 11 +++++++++--
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/documentation/ref-manual/devtool-reference.rst b/documentation/ref-manual/devtool-reference.rst
index 9319addc3c61..b774dcb1092b 100644
--- a/documentation/ref-manual/devtool-reference.rst
+++ b/documentation/ref-manual/devtool-reference.rst
@@ -340,8 +340,8 @@ being able to upgrade it, displayed in a table.
 
 This upgrade checking mechanism relies on the optional :term:`UPSTREAM_CHECK_URI`,
 :term:`UPSTREAM_CHECK_REGEX`, :term:`UPSTREAM_CHECK_GITTAGREGEX`,
-:term:`UPSTREAM_CHECK_COMMITS` and :term:`UPSTREAM_VERSION_UNKNOWN`
-variables in package recipes.
+:term:`UPSTREAM_CHECK_COMMITS`, :term: `UPSTREAM_CHECK_SRCNAME`,  and
+:term:`UPSTREAM_VERSION_UNKNOWN` variables in package recipes.
 
 .. note::
 
diff --git a/documentation/ref-manual/variables.rst b/documentation/ref-manual/variables.rst
index 435481c9aa12..12372c1e67f3 100644
--- a/documentation/ref-manual/variables.rst
+++ b/documentation/ref-manual/variables.rst
@@ -9686,6 +9686,14 @@ system and gives an overview of their function and contents.
 
          UPSTREAM_CHECK_REGEX = "package_regex"
 
+   :term:`UPSTREAM_CHECK_SRCNAME`
+      By default, the first entry in :term:`SRC_URI` is what is used to
+      determine the latest upstream source code version.  If this is not
+      the desired behavior, the :term:`UPSTREAM_CHECK_SRCNAME` variable
+      is used to specify which of the other entries in SRC_URI should be
+      used for this determination.  The value should match the specified
+      name of the :term:`SRC_URI` entry.
+
    :term:`UPSTREAM_CHECK_URI`
       You can perform a per-recipe check for what the latest upstream
       source code version is by calling ``devtool latest-version recipe``. If
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index de1fbdd3a8c8..6fb9fbbc6abc 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -1041,9 +1041,15 @@ def get_recipe_upstream_version(rd):
         ru['datetime'] = datetime.now()
         return ru
 
-    # XXX: we suppose that the first entry points to the upstream sources
+    # If the upstream name has been specified, take that one.
+    # Otherwise, default to the first URI in the list
     src_uri = src_uris.split()[0]
-    uri_type, _, _, _, _, _ =  decodeurl(src_uri)
+    if str(rd.getVar('UPSTREAM_CHECK_SRCNAME')):
+        for s in src_uris.split():
+            ud = bb.fetch2.FetchData(s, rd)
+            if ud.parm.get('name') == str(rd.getVar('UPSTREAM_CHECK_SRCNAME')):
+                src_uri = s
+    uri_type, _, _, _, _, _ = decodeurl(src_uri)
 
     (pv, pfx, sfx) = get_recipe_pv_with_pfx_sfx(rd.getVar('PV'), uri_type)
     ru['current_version'] = pv
@@ -1127,6 +1133,7 @@ def get_recipe_upgrade_status(recipes=None):
                  'UPSTREAM_CHECK_COMMITS',
                  'UPSTREAM_CHECK_GITTAGREGEX',
                  'UPSTREAM_CHECK_REGEX',
+                 'UPSTREAM_CHECK_SRCNAME',
                  'UPSTREAM_CHECK_URI',
                  'UPSTREAM_VERSION_UNKNOWN',
                  'RECIPE_MAINTAINER',
-- 
2.30.2



             reply	other threads:[~2024-03-27 18:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 18:45 Jon Mason [this message]
2024-03-27 20:31 ` [OE-core] [RFC] recipeutils: check for SRC_URI name in get_recipe_upstream_version Alexander Kanavin
2024-03-28 15:13   ` Jon Mason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240327184532.226557-1-jdmason@kudzu.us \
    --to=jdmason@kudzu.us \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.