Patchwork [1/5] buildhistory_analysis: use bb.utils.explode_dep_versions

login
register
mail settings
Submitter Paul Eggleton
Date March 20, 2012, 4:06 p.m.
Message ID <8c7e0bb53a02dae0bdde4ab6220684dce129363b.1332259383.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/23893/
State Accepted
Commit de21a483063d9803c4ce1d62b03913ccad2931bd
Headers show

Comments

Paul Eggleton - March 20, 2012, 4:06 p.m.
Previously this had its own implementation of splitting a list of
packages with optional version e.g. "libncurses-dev (>= 5.9)"; switch to
using the already existing bitbake function which does this as it is
much better tested.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 meta/lib/oe/buildhistory_analysis.py |   11 +++++++++--
 scripts/buildhistory-diff            |   21 ++++++++++++++++++---
 2 files changed, 27 insertions(+), 5 deletions(-)

Patch

diff --git a/meta/lib/oe/buildhistory_analysis.py b/meta/lib/oe/buildhistory_analysis.py
index d09911c..c0fa339 100644
--- a/meta/lib/oe/buildhistory_analysis.py
+++ b/meta/lib/oe/buildhistory_analysis.py
@@ -13,6 +13,7 @@  import os.path
 import difflib
 import git
 import re
+import bb.utils
 
 
 # How to display fields
@@ -55,8 +56,13 @@  class ChangeRecord:
             prefix = ''
 
         def pkglist_split(pkgs):
-            pkgit = re.finditer(r'[a-zA-Z0-9.+-]+( \([><=]+ [^ )]+\))?', pkgs, 0)
-            pkglist = [p.group(0) for p in pkgit]
+            depver = bb.utils.explode_dep_versions(pkgs)
+            pkglist = []
+            for k,v in depver.iteritems():
+                if v:
+                    pkglist.append("%s (%s)" % (k,v))
+                else:
+                    pkglist.append(k)
             return pkglist
 
         if self.fieldname in list_fields or self.fieldname in list_order_fields:
@@ -68,6 +74,7 @@  class ChangeRecord:
                 bitems = self.newvalue.split()
             removed = list(set(aitems) - set(bitems))
             added = list(set(bitems) - set(aitems))
+
             if removed or added:
                 out = '%s:%s%s' % (self.fieldname, ' removed "%s"' % ' '.join(removed) if removed else '', ' added "%s"' % ' '.join(added) if added else '')
             else:
diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff
index 6b344eb..9936a4b 100755
--- a/scripts/buildhistory-diff
+++ b/scripts/buildhistory-diff
@@ -6,7 +6,7 @@ 
 # Author: Paul Eggleton <paul.eggleton@linux.intel.com>
 
 import sys
-import os.path
+import os
 
 # Ensure PythonGit is installed (buildhistory_analysis needs it)
 try:
@@ -24,8 +24,23 @@  def main():
         sys.exit(1)
 
     # Set path to OE lib dir so we can import the buildhistory_analysis module
-    newpath = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../meta/lib')
-    sys.path = sys.path + [newpath]
+    basepath = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])) + '/..')
+    newpath = basepath + '/meta/lib'
+    # Set path to bitbake lib dir so the buildhistory_analysis module can load bb.utils
+    if os.path.exists(basepath + '/bitbake/lib/bb'):
+        bitbakepath = basepath + '/bitbake'
+    else:
+        # look for bitbake/bin dir in PATH
+        bitbakepath = None
+        for pth in os.environ['PATH'].split(':'):
+            if os.path.exists(os.path.join(pth, '../lib/bb')):
+                bitbakepath = os.path.abspath(os.path.join(pth, '..'))
+                break
+        if not bitbakepath:
+            print("Unable to find bitbake by searching parent directory of this script or PATH")
+            sys.exit(1)
+
+    sys.path.extend([newpath, bitbakepath + '/lib'])
     import oe.buildhistory_analysis
 
     if len(sys.argv) > 3: