]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/blame - scripts/buildhistory-diff
conf/licenses: Add FreeType SPDX mapping
[thirdparty/openembedded/openembedded-core.git] / scripts / buildhistory-diff
CommitLineData
dad96178 1#!/usr/bin/env python3
5e5cbb9b
PE
2
3# Report significant differences in the buildhistory repository since a specific revision
4#
329edb52 5# Copyright (C) 2013 Intel Corporation
5e5cbb9b 6# Author: Paul Eggleton <paul.eggleton@linux.intel.com>
f8c9c511
RP
7#
8# SPDX-License-Identifier: GPL-2.0-only
9#
5e5cbb9b
PE
10
11import sys
de21a483 12import os
e67b40c0 13import argparse
2f0f5a89 14from distutils.version import LooseVersion
5e5cbb9b
PE
15
16# Ensure PythonGit is installed (buildhistory_analysis needs it)
17try:
18 import git
19except ImportError:
0632c3e6 20 print("Please install GitPython (python3-git) 0.3.4 or later in order to use this script")
5e5cbb9b
PE
21 sys.exit(1)
22
e67b40c0
DP
23def get_args_parser():
24 description = "Reports significant differences in the buildhistory repository."
25
26 parser = argparse.ArgumentParser(description=description,
27 usage="""
28 %(prog)s [options] [from-revision [to-revision]]
29 (if not specified, from-revision defaults to build-minus-1, and to-revision defaults to HEAD)""")
30
18ca377d
RB
31 default_dir = os.path.join(os.environ.get('BUILDDIR', '.'), 'buildhistory')
32
e67b40c0
DP
33 parser.add_argument('-p', '--buildhistory-dir',
34 action='store',
35 dest='buildhistory_dir',
18ca377d 36 default=default_dir,
e67b40c0
DP
37 help="Specify path to buildhistory directory (defaults to buildhistory/ under cwd)")
38 parser.add_argument('-v', '--report-version',
39 action='store_true',
40 dest='report_ver',
41 default=False,
42 help="Report changes in PKGE/PKGV/PKGR even when the values are still the default (PE/PV/PR)")
43 parser.add_argument('-a', '--report-all',
44 action='store_true',
45 dest='report_all',
b30153a1 46 default=False,
e67b40c0
DP
47 help="Report all changes, not just the default significant ones")
48 parser.add_argument('-s', '---signatures',
49 action='store_true',
50 dest='sigs',
51 default=False,
52 help="Report list of signatures differing instead of output")
53 parser.add_argument('-S', '--signatures-with-diff',
54 action='store_true',
55 dest='sigsdiff',
56 default=False,
57 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)")
58 parser.add_argument('-e', '--exclude-path',
59 action='append',
60 help="Exclude path from the output")
4208f154
RB
61 parser.add_argument('-c', '--colour',
62 choices=('yes', 'no', 'auto'),
63 default="auto",
64 help="Whether to colourise (defaults to auto)")
e67b40c0
DP
65 parser.add_argument('revisions',
66 default = ['build-minus-1', 'HEAD'],
67 nargs='*',
68 help=argparse.SUPPRESS)
69 return parser
70
5e5cbb9b 71def main():
e67b40c0
DP
72
73 parser = get_args_parser()
74 args = parser.parse_args()
5e2be70e 75
2f0f5a89 76 if LooseVersion(git.__version__) < '0.3.1':
329edb52 77 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")
2f0f5a89
PE
78 sys.exit(1)
79
e67b40c0
DP
80 if len(args.revisions) > 2:
81 sys.stderr.write('Invalid argument(s) specified: %s\n\n' % ' '.join(args.revisions[2:]))
82 parser.print_help()
83
84 sys.exit(1)
e67b40c0
DP
85
86 if not os.path.exists(args.buildhistory_dir):
87 sys.stderr.write('Buildhistory directory "%s" does not exist\n\n' % args.buildhistory_dir)
5e2be70e 88 parser.print_help()
5e5cbb9b
PE
89 sys.exit(1)
90
0b5e94e1
PE
91 scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
92 lib_path = scripts_path + '/lib'
93 sys.path = sys.path + [lib_path]
94
95 import scriptpath
96
5e5cbb9b 97 # Set path to OE lib dir so we can import the buildhistory_analysis module
0b5e94e1 98 scriptpath.add_oe_lib_path()
de21a483 99 # Set path to bitbake lib dir so the buildhistory_analysis module can load bb.utils
0b5e94e1 100 bitbakepath = scriptpath.add_bitbake_lib_path()
e67b40c0 101
0b5e94e1
PE
102 if not bitbakepath:
103 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
104 sys.exit(1)
105
e67b40c0
DP
106 if len(args.revisions) == 1:
107 if '..' in args.revisions[0]:
108 fromrev, torev = args.revisions[0].split('..')
5e2be70e 109 else:
e67b40c0
DP
110 fromrev, torev = args.revisions[0], 'HEAD'
111 elif len(args.revisions) == 2:
112 fromrev, torev = args.revisions
113
4208f154 114 from oe.buildhistory_analysis import init_colours, process_changes
329edb52 115 import gitdb
e67b40c0 116
4208f154
RB
117 init_colours({"yes": True, "no": False, "auto": sys.stdout.isatty()}[args.colour])
118
329edb52 119 try:
e67b40c0
DP
120 changes = process_changes(args.buildhistory_dir, fromrev, torev,
121 args.report_all, args.report_ver, args.sigs,
122 args.sigsdiff, args.exclude_path)
329edb52 123 except gitdb.exc.BadObject as e:
e67b40c0 124 if not args.revisions:
5e2be70e
PE
125 sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
126 parser.print_help()
127 else:
128 sys.stderr.write('Specified git revision "%s" is not valid\n' % e.args[0])
329edb52
PE
129 sys.exit(1)
130
5e5cbb9b 131 for chg in changes:
86393230
EB
132 out = str(chg)
133 if out:
134 print(out)
5e5cbb9b
PE
135
136 sys.exit(0)
137
5e5cbb9b
PE
138if __name__ == "__main__":
139 main()