Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCHv2 1/2] oe-pkgdata-util: Make parse_pkgdatafile() support package suffixed vars
Date: Sat,  2 Jun 2018 21:30:32 +0200	[thread overview]
Message-ID: <20180602193033.14641-1-pkj@axis.com> (raw)

Support for variables suffixed with package names, e.g., PKGV_foo, was
removed in commit 3d2c87c4, which broke support for recipes that set
other versions on their packages than what is in ${PV}.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 scripts/oe-pkgdata-util | 46 ++++++++++++++++++----------------------------
 1 file changed, 18 insertions(+), 28 deletions(-)

diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index aea8a57516..965f473725 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -286,36 +286,26 @@ def lookup_recipe(args):
 
 def package_info(args):
     def parse_pkgdatafile(pkgdatafile):
+        vars = ['PKGV', 'PKGE', 'PKGR', 'PN', 'PV', 'PE', 'PR', 'PKGSIZE']
         with open(pkgdatafile, 'r') as f:
-            pkge = ''
-            pkgr = ''
-            pe = ''
-            pr = ''
+            vals = dict()
             for line in f:
-                if line.startswith('PKGV:'):
-                    pkg_version = line.split(':', 1)[1].strip()
-                elif line.startswith('PKGE:'):
-                    pkge = line.split(':', 1)[1].strip()
-                elif line.startswith('PKGR:'):
-                    pkgr = line.split(':', 1)[1].strip()
-                elif line.startswith('PN:'):
-                    recipe = line.split(':', 1)[1].strip()
-                elif line.startswith('PV:'):
-                    recipe_version = line.split(':', 1)[1].strip()
-                elif line.startswith('PE:'):
-                    pe = line.split(':', 1)[1].strip()
-                elif line.startswith('PR:'):
-                    pr = line.split(':', 1)[1].strip()
-                elif line.startswith('PKGSIZE'):
-                    pkg_size = line.split(':', 1)[1].strip()
-            if pkge:
-                pkg_version = pkge + ":" + pkg_version
-            if pkgr:
-                pkg_version = pkg_version + "-" + pkgr
-            if pe:
-                recipe_version = pe + ":" + recipe_version
-            if pr:
-                recipe_version = recipe_version + "-" + pr
+                for var in vars:
+                    m = re.match(var + '(?:_\S+)?:\s*(.+?)\s*$', line)
+                    if m:
+                        vals[var] = m.group(1)
+            pkg_version = vals['PKGV'] or ''
+            recipe = vals['PN'] or ''
+            recipe_version = vals['PV'] or ''
+            pkg_size = vals['PKGSIZE'] or ''
+            if 'PKGE' in vals:
+                pkg_version = vals['PKGE'] + ":" + pkg_version
+            if 'PKGR' in vals:
+                pkg_version = pkg_version + "-" + vals['PKGR']
+            if 'PE' in vals:
+                recipe_version = vals['PE'] + ":" + recipe_version
+            if 'PR' in vals:
+                recipe_version = recipe_version + "-" + vals['PR']
             print("%s %s %s %s %s" % (pkg, pkg_version, recipe, recipe_version, pkg_size))
 
     # Handle both multiple arguments and multiple values within an arg (old syntax)
-- 
2.12.0



             reply	other threads:[~2018-06-02 19:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-02 19:30 Peter Kjellerstedt [this message]
2018-06-02 19:30 ` [PATCHv2 2/2] oe-pkgdata-util: package-info: Re-add support for the --extra option Peter Kjellerstedt
2018-06-03 16:14 ` [PATCHv2 1/2] oe-pkgdata-util: Make parse_pkgdatafile() support package suffixed vars Richard Purdie
2018-06-04  7:37   ` Peter Kjellerstedt

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=20180602193033.14641-1-pkj@axis.com \
    --to=peter.kjellerstedt@axis.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox