buildhistory-diff: add ability to report version changes
Add a -v/--report-ver option to report changes in PKGE/PKGV/PKGR even if the value is the same as the default from PE/PV/PR. Also add a -a/--report-all option to report all changes instead of just the default significant ones. Addresses [YOCTO #5263]. (From OE-Core rev: b7de1eaac9eed559b2d68058f5de67de74a6cb58) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
bc77ea96ad
commit
f995febd2e
|
@ -19,10 +19,11 @@ import bb.utils
|
||||||
# How to display fields
|
# How to display fields
|
||||||
list_fields = ['DEPENDS', 'RPROVIDES', 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RREPLACES', 'RCONFLICTS', 'FILES', 'FILELIST', 'USER_CLASSES', 'IMAGE_CLASSES', 'IMAGE_FEATURES', 'IMAGE_LINGUAS', 'IMAGE_INSTALL', 'BAD_RECOMMENDATIONS']
|
list_fields = ['DEPENDS', 'RPROVIDES', 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RREPLACES', 'RCONFLICTS', 'FILES', 'FILELIST', 'USER_CLASSES', 'IMAGE_CLASSES', 'IMAGE_FEATURES', 'IMAGE_LINGUAS', 'IMAGE_INSTALL', 'BAD_RECOMMENDATIONS']
|
||||||
list_order_fields = ['PACKAGES']
|
list_order_fields = ['PACKAGES']
|
||||||
defaultval_fields = ['PKG', 'PKGE', 'PKGV', 'PKGR']
|
defaultval_map = {'PKG': 'PKG', 'PKGE': 'PE', 'PKGV': 'PV', 'PKGR': 'PR'}
|
||||||
numeric_fields = ['PKGSIZE', 'IMAGESIZE']
|
numeric_fields = ['PKGSIZE', 'IMAGESIZE']
|
||||||
# Fields to monitor
|
# Fields to monitor
|
||||||
monitor_fields = ['RPROVIDES', 'RDEPENDS', 'RRECOMMENDS', 'RREPLACES', 'RCONFLICTS', 'PACKAGES', 'FILELIST', 'PKGSIZE', 'IMAGESIZE', 'PKG', 'PKGE', 'PKGV', 'PKGR']
|
monitor_fields = ['RPROVIDES', 'RDEPENDS', 'RRECOMMENDS', 'RREPLACES', 'RCONFLICTS', 'PACKAGES', 'FILELIST', 'PKGSIZE', 'IMAGESIZE', 'PKG']
|
||||||
|
ver_monitor_fields = ['PKGE', 'PKGV', 'PKGR']
|
||||||
# Percentage change to alert for numeric fields
|
# Percentage change to alert for numeric fields
|
||||||
monitor_numeric_threshold = 10
|
monitor_numeric_threshold = 10
|
||||||
# Image files to monitor (note that image-info.txt is handled separately)
|
# Image files to monitor (note that image-info.txt is handled separately)
|
||||||
|
@ -94,7 +95,7 @@ class ChangeRecord:
|
||||||
else:
|
else:
|
||||||
percentchg = 100
|
percentchg = 100
|
||||||
out = '%s changed from %s to %s (%s%d%%)' % (self.fieldname, self.oldvalue or "''", self.newvalue or "''", '+' if percentchg > 0 else '', percentchg)
|
out = '%s changed from %s to %s (%s%d%%)' % (self.fieldname, self.oldvalue or "''", self.newvalue or "''", '+' if percentchg > 0 else '', percentchg)
|
||||||
elif self.fieldname in defaultval_fields:
|
elif self.fieldname in defaultval_map:
|
||||||
out = '%s changed from %s to %s' % (self.fieldname, self.oldvalue, self.newvalue)
|
out = '%s changed from %s to %s' % (self.fieldname, self.oldvalue, self.newvalue)
|
||||||
if self.fieldname == 'PKG' and '[default]' in self.newvalue:
|
if self.fieldname == 'PKG' and '[default]' in self.newvalue:
|
||||||
out += ' - may indicate debian renaming failure'
|
out += ' - may indicate debian renaming failure'
|
||||||
|
@ -305,24 +306,32 @@ def compare_pkg_lists(astr, bstr):
|
||||||
return (depvera, depverb)
|
return (depvera, depverb)
|
||||||
|
|
||||||
|
|
||||||
def compare_dict_blobs(path, ablob, bblob, report_all):
|
def compare_dict_blobs(path, ablob, bblob, report_all, report_ver):
|
||||||
adict = blob_to_dict(ablob)
|
adict = blob_to_dict(ablob)
|
||||||
bdict = blob_to_dict(bblob)
|
bdict = blob_to_dict(bblob)
|
||||||
|
|
||||||
pkgname = os.path.basename(path)
|
pkgname = os.path.basename(path)
|
||||||
|
|
||||||
defaultvals = {}
|
defaultvals = {}
|
||||||
defaultvals['PKG'] = pkgname
|
defaultvals['PKG'] = pkgname
|
||||||
defaultvals['PKGE'] = adict.get('PE', '0')
|
defaultvals['PKGE'] = '0'
|
||||||
defaultvals['PKGV'] = adict.get('PV', '')
|
|
||||||
defaultvals['PKGR'] = adict.get('PR', '')
|
|
||||||
for key in defaultvals:
|
|
||||||
defaultvals[key] = '%s [default]' % defaultvals[key]
|
|
||||||
|
|
||||||
changes = []
|
changes = []
|
||||||
keys = list(set(adict.keys()) | set(bdict.keys()))
|
keys = list(set(adict.keys()) | set(bdict.keys()) | set(defaultval_map.keys()))
|
||||||
for key in keys:
|
for key in keys:
|
||||||
astr = adict.get(key, '')
|
astr = adict.get(key, '')
|
||||||
bstr = bdict.get(key, '')
|
bstr = bdict.get(key, '')
|
||||||
|
if key in ver_monitor_fields:
|
||||||
|
monitored = report_ver or astr or bstr
|
||||||
|
else:
|
||||||
|
monitored = key in monitor_fields
|
||||||
|
mapped_key = defaultval_map.get(key, '')
|
||||||
|
if mapped_key:
|
||||||
|
if not astr:
|
||||||
|
astr = '%s [default]' % adict.get(mapped_key, defaultvals.get(key, ''))
|
||||||
|
if not bstr:
|
||||||
|
bstr = '%s [default]' % bdict.get(mapped_key, defaultvals.get(key, ''))
|
||||||
|
|
||||||
if astr != bstr:
|
if astr != bstr:
|
||||||
if (not report_all) and key in numeric_fields:
|
if (not report_all) and key in numeric_fields:
|
||||||
aval = int(astr or 0)
|
aval = int(astr or 0)
|
||||||
|
@ -350,18 +359,12 @@ def compare_dict_blobs(path, ablob, bblob, report_all):
|
||||||
if ' '.join(alist) == ' '.join(blist):
|
if ' '.join(alist) == ' '.join(blist):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if key in defaultval_fields:
|
chg = ChangeRecord(path, key, astr, bstr, monitored)
|
||||||
if not astr:
|
|
||||||
astr = defaultvals[key]
|
|
||||||
elif not bstr:
|
|
||||||
bstr = defaultvals[key]
|
|
||||||
|
|
||||||
chg = ChangeRecord(path, key, astr, bstr, key in monitor_fields)
|
|
||||||
changes.append(chg)
|
changes.append(chg)
|
||||||
return changes
|
return changes
|
||||||
|
|
||||||
|
|
||||||
def process_changes(repopath, revision1, revision2 = 'HEAD', report_all = False):
|
def process_changes(repopath, revision1, revision2='HEAD', report_all=False, report_ver=False):
|
||||||
repo = git.Repo(repopath)
|
repo = git.Repo(repopath)
|
||||||
assert repo.bare == False
|
assert repo.bare == False
|
||||||
commit = repo.commit(revision1)
|
commit = repo.commit(revision1)
|
||||||
|
@ -373,7 +376,7 @@ def process_changes(repopath, revision1, revision2 = 'HEAD', report_all = False)
|
||||||
if path.startswith('packages/'):
|
if path.startswith('packages/'):
|
||||||
filename = os.path.basename(d.a_blob.path)
|
filename = os.path.basename(d.a_blob.path)
|
||||||
if filename == 'latest':
|
if filename == 'latest':
|
||||||
changes.extend(compare_dict_blobs(path, d.a_blob, d.b_blob, report_all))
|
changes.extend(compare_dict_blobs(path, d.a_blob, d.b_blob, report_all, report_ver))
|
||||||
elif filename.startswith('latest.'):
|
elif filename.startswith('latest.'):
|
||||||
chg = ChangeRecord(path, filename, d.a_blob.data_stream.read(), d.b_blob.data_stream.read(), True)
|
chg = ChangeRecord(path, filename, d.a_blob.data_stream.read(), d.b_blob.data_stream.read(), True)
|
||||||
changes.append(chg)
|
changes.append(chg)
|
||||||
|
|
|
@ -27,6 +27,12 @@ def main():
|
||||||
parser.add_option("-p", "--buildhistory-dir",
|
parser.add_option("-p", "--buildhistory-dir",
|
||||||
help = "Specify path to buildhistory directory (defaults to buildhistory/ under cwd)",
|
help = "Specify path to buildhistory directory (defaults to buildhistory/ under cwd)",
|
||||||
action="store", dest="buildhistory_dir", default='buildhistory/')
|
action="store", dest="buildhistory_dir", default='buildhistory/')
|
||||||
|
parser.add_option("-v", "--report-version",
|
||||||
|
help = "Report changes in PKGE/PKGV/PKGR even when the values are still the default (PE/PV/PR)",
|
||||||
|
action="store_true", dest="report_ver", default=False)
|
||||||
|
parser.add_option("-a", "--report-all",
|
||||||
|
help = "Report all changes, not just the default significant ones",
|
||||||
|
action="store_true", dest="report_all", default=False)
|
||||||
|
|
||||||
options, args = parser.parse_args(sys.argv)
|
options, args = parser.parse_args(sys.argv)
|
||||||
|
|
||||||
|
@ -79,7 +85,7 @@ def main():
|
||||||
|
|
||||||
import gitdb
|
import gitdb
|
||||||
try:
|
try:
|
||||||
changes = oe.buildhistory_analysis.process_changes(options.buildhistory_dir, fromrev, torev)
|
changes = oe.buildhistory_analysis.process_changes(options.buildhistory_dir, fromrev, torev, options.report_all, options.report_ver)
|
||||||
except gitdb.exc.BadObject as e:
|
except gitdb.exc.BadObject as e:
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
|
sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
|
||||||
|
|
Loading…
Reference in New Issue