summaryrefslogtreecommitdiffstats
path: root/scripts/buildhistory-diff
diff options
context:
space:
mode:
authorAdrian Dudau <adrian.dudau@enea.com>2013-12-12 13:38:32 +0100
committerAdrian Dudau <adrian.dudau@enea.com>2013-12-12 13:50:20 +0100
commite2e6f6fe07049f33cb6348780fa975162752e421 (patch)
treeb1813295411235d1297a0ed642b1346b24fdfb12 /scripts/buildhistory-diff
downloadpoky-e2e6f6fe07049f33cb6348780fa975162752e421.tar.gz
initial commit of Enea Linux 3.1
Migrated from the internal git server on the dora-enea branch Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'scripts/buildhistory-diff')
-rwxr-xr-xscripts/buildhistory-diff98
1 files changed, 98 insertions, 0 deletions
diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff
new file mode 100755
index 0000000000..b82240d763
--- /dev/null
+++ b/scripts/buildhistory-diff
@@ -0,0 +1,98 @@
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
8import sys
9import os
10import optparse
11from distutils.version import LooseVersion
12
13# Ensure PythonGit is installed (buildhistory_analysis needs it)
14try:
15 import git
16except ImportError:
17 print("Please install GitPython (python-git) 0.3.1 or later in order to use this script")
18 sys.exit(1)
19
20def 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
31 options, args = parser.parse_args(sys.argv)
32
33 if len(args) > 3:
34 sys.stderr.write('Invalid argument(s) specified: %s\n\n' % ' '.join(args[3:]))
35 parser.print_help()
36 sys.exit(1)
37
38 if LooseVersion(git.__version__) < '0.3.1':
39 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")
40 sys.exit(1)
41
42 if not os.path.exists(options.buildhistory_dir):
43 sys.stderr.write('Buildhistory directory "%s" does not exist\n\n' % options.buildhistory_dir)
44 parser.print_help()
45 sys.exit(1)
46
47 # Set path to OE lib dir so we can import the buildhistory_analysis module
48 basepath = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])) + '/..')
49 newpath = basepath + '/meta/lib'
50 # Set path to bitbake lib dir so the buildhistory_analysis module can load bb.utils
51 if os.path.exists(basepath + '/bitbake/lib/bb'):
52 bitbakepath = basepath + '/bitbake'
53 else:
54 # look for bitbake/bin dir in PATH
55 bitbakepath = None
56 for pth in os.environ['PATH'].split(':'):
57 if os.path.exists(os.path.join(pth, '../lib/bb')):
58 bitbakepath = os.path.abspath(os.path.join(pth, '..'))
59 break
60 if not bitbakepath:
61 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
62 sys.exit(1)
63
64 sys.path[0:0] = [newpath, bitbakepath + '/lib']
65 import oe.buildhistory_analysis
66
67 fromrev = 'build-minus-1'
68 torev = 'HEAD'
69 if len(args) > 1:
70 if len(args) == 2 and '..' in args[1]:
71 revs = args[1].split('..')
72 fromrev = revs[0]
73 if revs[1]:
74 torev = revs[1]
75 else:
76 fromrev = args[1]
77 if len(args) > 2:
78 torev = args[2]
79
80 import gitdb
81 try:
82 changes = oe.buildhistory_analysis.process_changes(options.buildhistory_dir, fromrev, torev)
83 except gitdb.exc.BadObject as e:
84 if len(args) == 1:
85 sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
86 parser.print_help()
87 else:
88 sys.stderr.write('Specified git revision "%s" is not valid\n' % e.args[0])
89 sys.exit(1)
90
91 for chg in changes:
92 print('%s' % chg)
93
94 sys.exit(0)
95
96
97if __name__ == "__main__":
98 main()