summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/buildhistory-diff125
1 files changed, 71 insertions, 54 deletions
diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff
index 1b2e0d1f4e..e79cb7ac8d 100755
--- a/scripts/buildhistory-diff
+++ b/scripts/buildhistory-diff
@@ -7,7 +7,7 @@
7 7
8import sys 8import sys
9import os 9import os
10import optparse 10import argparse
11from distutils.version import LooseVersion 11from distutils.version import LooseVersion
12 12
13# Ensure PythonGit is installed (buildhistory_analysis needs it) 13# Ensure PythonGit is installed (buildhistory_analysis needs it)
@@ -17,49 +17,70 @@ except ImportError:
17 print("Please install GitPython (python3-git) 0.3.4 or later in order to use this script") 17 print("Please install GitPython (python3-git) 0.3.4 or later in order to use this script")
18 sys.exit(1) 18 sys.exit(1)
19 19
20def get_args_parser():
21 description = "Reports significant differences in the buildhistory repository."
22
23 parser = argparse.ArgumentParser(description=description,
24 usage="""
25 %(prog)s [options] [from-revision [to-revision]]
26 (if not specified, from-revision defaults to build-minus-1, and to-revision defaults to HEAD)""")
27
28 parser.add_argument('-p', '--buildhistory-dir',
29 action='store',
30 dest='buildhistory_dir',
31 default='buildhistory/',
32 help="Specify path to buildhistory directory (defaults to buildhistory/ under cwd)")
33 parser.add_argument('-v', '--report-version',
34 action='store_true',
35 dest='report_ver',
36 default=False,
37 help="Report changes in PKGE/PKGV/PKGR even when the values are still the default (PE/PV/PR)")
38 parser.add_argument('-a', '--report-all',
39 action='store_true',
40 dest='report_all',
41 default='False',
42 help="Report all changes, not just the default significant ones")
43 parser.add_argument('-s', '---signatures',
44 action='store_true',
45 dest='sigs',
46 default=False,
47 help="Report list of signatures differing instead of output")
48 parser.add_argument('-S', '--signatures-with-diff',
49 action='store_true',
50 dest='sigsdiff',
51 default=False,
52 help="Report on actual signature differences instead of output (requires signature data to have been generated, either by running the actual tasks or using bitbake -S)")
53 parser.add_argument('-e', '--exclude-path',
54 action='append',
55 help="Exclude path from the output")
56 parser.add_argument('revisions',
57 default = ['build-minus-1', 'HEAD'],
58 nargs='*',
59 help=argparse.SUPPRESS)
60 return parser
61
20def main(): 62def main():
21 parser = optparse.OptionParser( 63
22 description = "Reports significant differences in the buildhistory repository.", 64 parser = get_args_parser()
23 usage = """ 65 args = parser.parse_args()
24 %prog [options] [from-revision [to-revision]]
25(if not specified, from-revision defaults to build-minus-1, and to-revision defaults to HEAD)""")
26
27 parser.add_option("-p", "--buildhistory-dir",
28 help = "Specify path to buildhistory directory (defaults to buildhistory/ under cwd)",
29 action="store", dest="buildhistory_dir", default='buildhistory/')
30 parser.add_option("-v", "--report-version",
31 help = "Report changes in PKGE/PKGV/PKGR even when the values are still the default (PE/PV/PR)",
32 action="store_true", dest="report_ver", default=False)
33 parser.add_option("-a", "--report-all",
34 help = "Report all changes, not just the default significant ones",
35 action="store_true", dest="report_all", default=False)
36 parser.add_option("-s", "--signatures",
37 help = "Report list of signatures differing instead of output",
38 action="store_true", dest="sigs", default=False)
39 parser.add_option("-S", "--signatures-with-diff",
40 help = "Report on actual signature differences instead of output (requires signature data to have been generated, either by running the actual tasks or using bitbake -S)",
41 action="store_true", dest="sigsdiff", default=False)
42 parser.add_option("-e", "--exclude-path", action="append",
43 help = "exclude path from the output")
44
45 options, args = parser.parse_args(sys.argv)
46
47 if len(args) > 3:
48 sys.stderr.write('Invalid argument(s) specified: %s\n\n' % ' '.join(args[3:]))
49 parser.print_help()
50 sys.exit(1)
51 66
52 if LooseVersion(git.__version__) < '0.3.1': 67 if LooseVersion(git.__version__) < '0.3.1':
53 sys.stderr.write("Version of GitPython is too old, please install GitPython (python-git) 0.3.1 or later in order to use this script\n") 68 sys.stderr.write("Version of GitPython is too old, please install GitPython (python-git) 0.3.1 or later in order to use this script\n")
54 sys.exit(1) 69 sys.exit(1)
55 70
56 if not os.path.exists(options.buildhistory_dir): 71 if len(args.revisions) > 2:
57 if options.buildhistory_dir == 'buildhistory/': 72 sys.stderr.write('Invalid argument(s) specified: %s\n\n' % ' '.join(args.revisions[2:]))
73 parser.print_help()
74
75 sys.exit(1)
76 if not os.path.exists(args.buildhistory_dir):
77 if args.buildhistory_dir == 'buildhistory/':
58 cwd = os.getcwd() 78 cwd = os.getcwd()
59 if os.path.basename(cwd) == 'buildhistory': 79 if os.path.basename(cwd) == 'buildhistory':
60 options.buildhistory_dir = cwd 80 args.buildhistory_dir = cwd
61 if not os.path.exists(options.buildhistory_dir): 81
62 sys.stderr.write('Buildhistory directory "%s" does not exist\n\n' % options.buildhistory_dir) 82 if not os.path.exists(args.buildhistory_dir):
83 sys.stderr.write('Buildhistory directory "%s" does not exist\n\n' % args.buildhistory_dir)
63 parser.print_help() 84 parser.print_help()
64 sys.exit(1) 85 sys.exit(1)
65 86
@@ -73,32 +94,29 @@ def main():
73 scriptpath.add_oe_lib_path() 94 scriptpath.add_oe_lib_path()
74 # Set path to bitbake lib dir so the buildhistory_analysis module can load bb.utils 95 # Set path to bitbake lib dir so the buildhistory_analysis module can load bb.utils
75 bitbakepath = scriptpath.add_bitbake_lib_path() 96 bitbakepath = scriptpath.add_bitbake_lib_path()
97
76 if not bitbakepath: 98 if not bitbakepath:
77 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") 99 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
78 sys.exit(1) 100 sys.exit(1)
79 101
80 from oe.buildhistory_analysis import process_changes 102 if len(args.revisions) == 1:
81 103 if '..' in args.revisions[0]:
82 fromrev = 'build-minus-1' 104 fromrev, torev = args.revisions[0].split('..')
83 torev = 'HEAD'
84 if len(args) > 1:
85 if len(args) == 2 and '..' in args[1]:
86 revs = args[1].split('..')
87 fromrev = revs[0]
88 if revs[1]:
89 torev = revs[1]
90 else: 105 else:
91 fromrev = args[1] 106 fromrev, torev = args.revisions[0], 'HEAD'
92 if len(args) > 2: 107 elif len(args.revisions) == 2:
93 torev = args[2] 108 fromrev, torev = args.revisions
109
110 from oe.buildhistory_analysis import process_changes
94 111
95 import gitdb 112 import gitdb
113
96 try: 114 try:
97 changes = process_changes(options.buildhistory_dir, fromrev, torev, 115 changes = process_changes(args.buildhistory_dir, fromrev, torev,
98 options.report_all, options.report_ver, options.sigs, 116 args.report_all, args.report_ver, args.sigs,
99 options.sigsdiff, options.exclude_path) 117 args.sigsdiff, args.exclude_path)
100 except gitdb.exc.BadObject as e: 118 except gitdb.exc.BadObject as e:
101 if len(args) == 1: 119 if not args.revisions:
102 sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n") 120 sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
103 parser.print_help() 121 parser.print_help()
104 else: 122 else:
@@ -112,6 +130,5 @@ def main():
112 130
113 sys.exit(0) 131 sys.exit(0)
114 132
115
116if __name__ == "__main__": 133if __name__ == "__main__":
117 main() 134 main()