diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 14:36:22 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 15:32:53 +0200 |
commit | f4cf9fe05bb3f32fabea4e54dd92d368967a80da (patch) | |
tree | 487180fa9866985ea7b28e625651765d86f515c3 /scripts/buildhistory-collect-srcrevs | |
download | poky-f4cf9fe05bb3f32fabea4e54dd92d368967a80da.tar.gz |
initial commit for Enea Linux 4.0
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'scripts/buildhistory-collect-srcrevs')
-rwxr-xr-x | scripts/buildhistory-collect-srcrevs | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/scripts/buildhistory-collect-srcrevs b/scripts/buildhistory-collect-srcrevs new file mode 100755 index 0000000000..58a2708032 --- /dev/null +++ b/scripts/buildhistory-collect-srcrevs | |||
@@ -0,0 +1,109 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # | ||
3 | # Collects the recorded SRCREV values from buildhistory and reports on them | ||
4 | # | ||
5 | # Copyright 2013 Intel Corporation | ||
6 | # Authored-by: Paul Eggleton <paul.eggleton@intel.com> | ||
7 | # | ||
8 | # This program is free software; you can redistribute it and/or modify | ||
9 | # it under the terms of the GNU General Public License version 2 as | ||
10 | # published by the Free Software Foundation. | ||
11 | # | ||
12 | # This program is distributed in the hope that it will be useful, | ||
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | # GNU General Public License for more details. | ||
16 | # | ||
17 | # You should have received a copy of the GNU General Public License along | ||
18 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
20 | |||
21 | import os, sys | ||
22 | import optparse | ||
23 | import logging | ||
24 | |||
25 | def logger_create(): | ||
26 | logger = logging.getLogger("buildhistory") | ||
27 | loggerhandler = logging.StreamHandler() | ||
28 | loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) | ||
29 | logger.addHandler(loggerhandler) | ||
30 | logger.setLevel(logging.INFO) | ||
31 | return logger | ||
32 | |||
33 | logger = logger_create() | ||
34 | |||
35 | def main(): | ||
36 | parser = optparse.OptionParser( | ||
37 | description = "Collects the recorded SRCREV values from buildhistory and reports on them.", | ||
38 | usage = """ | ||
39 | %prog [options]""") | ||
40 | |||
41 | parser.add_option("-a", "--report-all", | ||
42 | help = "Report all SRCREV values, not just ones where AUTOREV has been used", | ||
43 | action="store_true", dest="reportall") | ||
44 | parser.add_option("-f", "--forcevariable", | ||
45 | help = "Use forcevariable override for all output lines", | ||
46 | action="store_true", dest="forcevariable") | ||
47 | parser.add_option("-p", "--buildhistory-dir", | ||
48 | help = "Specify path to buildhistory directory (defaults to buildhistory/ under cwd)", | ||
49 | action="store", dest="buildhistory_dir", default='buildhistory/') | ||
50 | |||
51 | options, args = parser.parse_args(sys.argv) | ||
52 | |||
53 | if len(args) > 1: | ||
54 | sys.stderr.write('Invalid argument(s) specified: %s\n\n' % ' '.join(args[1:])) | ||
55 | parser.print_help() | ||
56 | sys.exit(1) | ||
57 | |||
58 | if not os.path.exists(options.buildhistory_dir): | ||
59 | sys.stderr.write('Buildhistory directory "%s" does not exist\n\n' % options.buildhistory_dir) | ||
60 | parser.print_help() | ||
61 | sys.exit(1) | ||
62 | |||
63 | if options.forcevariable: | ||
64 | forcevariable = '_forcevariable' | ||
65 | else: | ||
66 | forcevariable = '' | ||
67 | |||
68 | lastdir = '' | ||
69 | for root, dirs, files in os.walk(options.buildhistory_dir): | ||
70 | if '.git' in dirs: | ||
71 | dirs.remove('.git') | ||
72 | for fn in files: | ||
73 | if fn == 'latest_srcrev': | ||
74 | curdir = os.path.basename(os.path.dirname(root)) | ||
75 | if lastdir != curdir: | ||
76 | print('# %s' % curdir) | ||
77 | lastdir = curdir | ||
78 | fullpath = os.path.join(root, fn) | ||
79 | pn = os.path.basename(root) | ||
80 | srcrev = None | ||
81 | orig_srcrev = None | ||
82 | orig_srcrevs = {} | ||
83 | srcrevs = {} | ||
84 | with open(fullpath) as f: | ||
85 | for line in f: | ||
86 | if '=' in line: | ||
87 | splitval = line.split('=') | ||
88 | value = splitval[1].strip('" \t\n\r') | ||
89 | if line.startswith('# SRCREV = '): | ||
90 | orig_srcrev = value | ||
91 | elif line.startswith('# SRCREV_'): | ||
92 | splitval = line.split('=') | ||
93 | name = splitval[0].split('_')[1].strip() | ||
94 | orig_srcrevs[name] = value | ||
95 | elif line.startswith('SRCREV ='): | ||
96 | srcrev = value | ||
97 | elif line.startswith('SRCREV_'): | ||
98 | name = splitval[0].split('_')[1].strip() | ||
99 | srcrevs[name] = value | ||
100 | if srcrev and (options.reportall or srcrev != orig_srcrev): | ||
101 | print('SRCREV_pn-%s%s = "%s"' % (pn, forcevariable, srcrev)) | ||
102 | for name, value in srcrevs.items(): | ||
103 | orig = orig_srcrevs.get(name, orig_srcrev) | ||
104 | if options.reportall or value != orig: | ||
105 | print('SRCREV_%s_pn-%s%s = "%s"' % (name, pn, forcevariable, value)) | ||
106 | |||
107 | |||
108 | if __name__ == "__main__": | ||
109 | main() | ||