diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /scripts/buildhistory-diff | |
download | poky-c527fd1f14c27855a37f2e8ac5346ce8d940ced2.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'scripts/buildhistory-diff')
-rwxr-xr-x | scripts/buildhistory-diff | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff new file mode 100755 index 0000000000..ad50414bce --- /dev/null +++ b/scripts/buildhistory-diff | |||
@@ -0,0 +1,104 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | # Report significant differences in the buildhistory repository since a specific revision | ||
4 | # | ||
5 | # Copyright (C) 2013 Intel Corporation | ||
6 | # Author: Paul Eggleton <paul.eggleton@linux.intel.com> | ||
7 | |||
8 | import sys | ||
9 | import os | ||
10 | import optparse | ||
11 | from distutils.version import LooseVersion | ||
12 | |||
13 | # Ensure PythonGit is installed (buildhistory_analysis needs it) | ||
14 | try: | ||
15 | import git | ||
16 | except ImportError: | ||
17 | print("Please install GitPython (python-git) 0.3.1 or later in order to use this script") | ||
18 | sys.exit(1) | ||
19 | |||
20 | def main(): | ||
21 | parser = optparse.OptionParser( | ||
22 | description = "Reports significant differences in the buildhistory repository.", | ||
23 | usage = """ | ||
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 | |||
37 | options, args = parser.parse_args(sys.argv) | ||
38 | |||
39 | if len(args) > 3: | ||
40 | sys.stderr.write('Invalid argument(s) specified: %s\n\n' % ' '.join(args[3:])) | ||
41 | parser.print_help() | ||
42 | sys.exit(1) | ||
43 | |||
44 | if LooseVersion(git.__version__) < '0.3.1': | ||
45 | 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") | ||
46 | sys.exit(1) | ||
47 | |||
48 | if not os.path.exists(options.buildhistory_dir): | ||
49 | sys.stderr.write('Buildhistory directory "%s" does not exist\n\n' % options.buildhistory_dir) | ||
50 | parser.print_help() | ||
51 | sys.exit(1) | ||
52 | |||
53 | # Set path to OE lib dir so we can import the buildhistory_analysis module | ||
54 | basepath = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])) + '/..') | ||
55 | newpath = basepath + '/meta/lib' | ||
56 | # Set path to bitbake lib dir so the buildhistory_analysis module can load bb.utils | ||
57 | if os.path.exists(basepath + '/bitbake/lib/bb'): | ||
58 | bitbakepath = basepath + '/bitbake' | ||
59 | else: | ||
60 | # look for bitbake/bin dir in PATH | ||
61 | bitbakepath = None | ||
62 | for pth in os.environ['PATH'].split(':'): | ||
63 | if os.path.exists(os.path.join(pth, '../lib/bb')): | ||
64 | bitbakepath = os.path.abspath(os.path.join(pth, '..')) | ||
65 | break | ||
66 | if not bitbakepath: | ||
67 | sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") | ||
68 | sys.exit(1) | ||
69 | |||
70 | sys.path[0:0] = [newpath, bitbakepath + '/lib'] | ||
71 | import oe.buildhistory_analysis | ||
72 | |||
73 | fromrev = 'build-minus-1' | ||
74 | torev = 'HEAD' | ||
75 | if len(args) > 1: | ||
76 | if len(args) == 2 and '..' in args[1]: | ||
77 | revs = args[1].split('..') | ||
78 | fromrev = revs[0] | ||
79 | if revs[1]: | ||
80 | torev = revs[1] | ||
81 | else: | ||
82 | fromrev = args[1] | ||
83 | if len(args) > 2: | ||
84 | torev = args[2] | ||
85 | |||
86 | import gitdb | ||
87 | try: | ||
88 | changes = oe.buildhistory_analysis.process_changes(options.buildhistory_dir, fromrev, torev, options.report_all, options.report_ver) | ||
89 | except gitdb.exc.BadObject as e: | ||
90 | if len(args) == 1: | ||
91 | sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n") | ||
92 | parser.print_help() | ||
93 | else: | ||
94 | sys.stderr.write('Specified git revision "%s" is not valid\n' % e.args[0]) | ||
95 | sys.exit(1) | ||
96 | |||
97 | for chg in changes: | ||
98 | print('%s' % chg) | ||
99 | |||
100 | sys.exit(0) | ||
101 | |||
102 | |||
103 | if __name__ == "__main__": | ||
104 | main() | ||