aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-09-15 16:04:39 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-18 11:07:24 +0100
commit2f8942d6830258fcbe1925f12ba1516def32d132 (patch)
tree0aa54de331122a24e90e5110a05b222dd838aba8 /scripts
parentddd9443cb2432af2c15b358bfda708393fa3c417 (diff)
downloadopenembedded-core-2f8942d6830258fcbe1925f12ba1516def32d132.zip
openembedded-core-2f8942d6830258fcbe1925f12ba1516def32d132.tar.gz
openembedded-core-2f8942d6830258fcbe1925f12ba1516def32d132.tar.bz2
scripts/buildstats-diff: move more code to lib/buildstats.py
More refactoring of buildstats-diff script. Move recipe version comparison functionality to scripts/lib/buildstats.py. This patch also compasses some wording changes, i.e. changing 'package' to 'recipe'. [YOCTO #11382] Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/buildstats-diff86
-rw-r--r--scripts/lib/buildstats.py31
2 files changed, 61 insertions, 56 deletions
diff --git a/scripts/buildstats-diff b/scripts/buildstats-diff
index ce82dab..a128dd3 100755
--- a/scripts/buildstats-diff
+++ b/scripts/buildstats-diff
@@ -24,7 +24,7 @@ from operator import attrgetter
# Import oe libs
scripts_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(scripts_path, 'lib'))
-from buildstats import BuildStats, diff_buildstats, taskdiff_fields
+from buildstats import BuildStats, diff_buildstats, taskdiff_fields, BSVerDiff
# Setup logging
@@ -76,72 +76,48 @@ def read_buildstats(path, multi):
def print_ver_diff(bs1, bs2):
"""Print package version differences"""
- pkgs1 = set(bs1.keys())
- pkgs2 = set(bs2.keys())
- new_pkgs = pkgs2 - pkgs1
- deleted_pkgs = pkgs1 - pkgs2
-
- echanged = []
- vchanged = []
- rchanged = []
- unchanged = []
- common_pkgs = pkgs2.intersection(pkgs1)
- if common_pkgs:
- for pkg in common_pkgs:
- if bs1[pkg].epoch != bs2[pkg].epoch:
- echanged.append(pkg)
- elif bs1[pkg].version != bs2[pkg].version:
- vchanged.append(pkg)
- elif bs1[pkg].revision != bs2[pkg].revision:
- rchanged.append(pkg)
- else:
- unchanged.append(pkg)
- maxlen = max([len(pkg) for pkg in pkgs1.union(pkgs2)])
+ diff = BSVerDiff(bs1, bs2)
+
+ maxlen = max([len(r) for r in set(bs1.keys()).union(set(bs2.keys()))])
fmt_str = " {:{maxlen}} ({})"
-# if unchanged:
-# print("\nUNCHANGED PACKAGES:")
-# print("-------------------")
-# maxlen = max([len(pkg) for pkg in unchanged])
-# for pkg in sorted(unchanged):
-# print(fmt_str.format(pkg, bs2[pkg]['nevr'], maxlen=maxlen))
-
- if new_pkgs:
- print("\nNEW PACKAGES:")
- print("-------------")
- for pkg in sorted(new_pkgs):
- print(fmt_str.format(pkg, bs2[pkg].nevr, maxlen=maxlen))
-
- if deleted_pkgs:
- print("\nDELETED PACKAGES:")
- print("-----------------")
- for pkg in sorted(deleted_pkgs):
- print(fmt_str.format(pkg, bs1[pkg].nevr, maxlen=maxlen))
+
+ if diff.new:
+ print("\nNEW RECIPES:")
+ print("------------")
+ for name, val in sorted(diff.new.items()):
+ print(fmt_str.format(name, val.nevr, maxlen=maxlen))
+
+ if diff.dropped:
+ print("\nDROPPED RECIPES:")
+ print("----------------")
+ for name, val in sorted(diff.dropped.items()):
+ print(fmt_str.format(name, val.nevr, maxlen=maxlen))
fmt_str = " {0:{maxlen}} {1:<20} ({2})"
- if rchanged:
+ if diff.rchanged:
print("\nREVISION CHANGED:")
print("-----------------")
- for pkg in sorted(rchanged):
- field1 = "{} -> {}".format(pkg, bs1[pkg].revision, bs2[pkg].revision)
- field2 = "{} -> {}".format(bs1[pkg].nevr, bs2[pkg].nevr)
- print(fmt_str.format(pkg, field1, field2, maxlen=maxlen))
+ for name, val in sorted(diff.rchanged.items()):
+ field1 = "{} -> {}".format(val.left.revision, val.right.revision)
+ field2 = "{} -> {}".format(val.left.nevr, val.right.nevr)
+ print(fmt_str.format(name, field1, field2, maxlen=maxlen))
- if vchanged:
+ if diff.vchanged:
print("\nVERSION CHANGED:")
print("----------------")
- for pkg in sorted(vchanged):
- field1 = "{} -> {}".format(bs1[pkg].version, bs2[pkg].version)
- field2 = "{} -> {}".format(bs1[pkg].nevr, bs2[pkg].nevr)
- print(fmt_str.format(pkg, field1, field2, maxlen=maxlen))
+ for name, val in sorted(diff.vchanged.items()):
+ field1 = "{} -> {}".format(val.left.version, val.right.version)
+ field2 = "{} -> {}".format(val.left.nevr, val.right.nevr)
+ print(fmt_str.format(name, field1, field2, maxlen=maxlen))
- if echanged:
+ if diff.echanged:
print("\nEPOCH CHANGED:")
print("--------------")
- for pkg in sorted(echanged):
- field1 = "{} -> {}".format(bs1[pkg].epoch, bs2[pkg].epoch)
- field2 = "{} -> {}".format(bs1[pkg].nevr, bs2[pkg].nevr)
- print(fmt_str.format(pkg, field1, field2, maxlen=maxlen))
+ for name, val in sorted(diff.echanged.items()):
+ field1 = "{} -> {}".format(val.left.epoch, val.right.epoch)
+ field2 = "{} -> {}".format(val.left.nevr, val.right.nevr)
+ print(fmt_str.format(name, field1, field2, maxlen=maxlen))
def print_task_diff(bs1, bs2, val_type, min_val=0, min_absdiff=0, sort_by=('absdiff',)):
diff --git a/scripts/lib/buildstats.py b/scripts/lib/buildstats.py
index bd63321..b1c9e61 100644
--- a/scripts/lib/buildstats.py
+++ b/scripts/lib/buildstats.py
@@ -15,7 +15,7 @@ import json
import logging
import os
import re
-from collections import namedtuple
+from collections import namedtuple,OrderedDict
from statistics import mean
@@ -307,3 +307,32 @@ def diff_buildstats(bs1, bs2, stat_attr, min_val=None, min_absdiff=None):
tasks_diff.append(TaskDiff(pkg, pkg_op, task, task_op, val1, val2,
val2-val1, reldiff))
return tasks_diff
+
+
+class BSVerDiff(object):
+ """Class representing recipe version differences between two buildstats"""
+ def __init__(self, bs1, bs2):
+ RecipeVerDiff = namedtuple('RecipeVerDiff', 'left right')
+
+ recipes1 = set(bs1.keys())
+ recipes2 = set(bs2.keys())
+
+ self.new = dict([(r, bs2[r]) for r in sorted(recipes2 - recipes1)])
+ self.dropped = dict([(r, bs1[r]) for r in sorted(recipes1 - recipes2)])
+ self.echanged = {}
+ self.vchanged = {}
+ self.rchanged = {}
+ self.unchanged = {}
+
+ common = recipes2.intersection(recipes1)
+ if common:
+ for recipe in common:
+ rdiff = RecipeVerDiff(bs1[recipe], bs2[recipe])
+ if bs1[recipe].epoch != bs2[recipe].epoch:
+ self.echanged[recipe] = rdiff
+ elif bs1[recipe].version != bs2[recipe].version:
+ self.vchanged[recipe] = rdiff
+ elif bs1[recipe].revision != bs2[recipe].revision:
+ self.rchanged[recipe] = rdiff
+ else:
+ self.unchanged[recipe] = rdiff