~ubuntu-security/ubuntu-security-tools/trunk

1 by Kees Cook
initial re-check-in
1
#!/usr/bin/python
548 by Marc Deslauriers
umt: properly escape + in package names when trying to find log file
2
# Copyright (C) 2007-2014 Canonical, Ltd.
1 by Kees Cook
initial re-check-in
3
# Author: Kees Cook <kees@ubuntu.com>
347 by Jamie Strandboge
build-tools/buildlog-compare: normalize even harder the chatty apt
4
#         Jamie Strandboge <jamie@canonical.com>
548 by Marc Deslauriers
umt: properly escape + in package names when trying to find log file
5
#         Marc Deslauriers <marc.deslauriers@canonical.com>
1 by Kees Cook
initial re-check-in
6
# License: GPLv3
451 by Jamie Strandboge
build-tools/buildlog-compare: fix traceback when calling with no args
7
import sys, subprocess, tempfile, re, os
367 by Jamie Strandboge
build-tools/buildlog-compare:
8
import optparse
1 by Kees Cook
initial re-check-in
9
10
def pull_build_log(filename):
11
    sep = '\nChecking correctness of source dependencies...\n'
12
    log = file(filename).read()
13
    if sep in log:
14
        log = log.split(sep,1)[1]
15
#        log = sep.join(log.split(sep)[:-1])+"\n"
16
    return log
17
377 by Jamie Strandboge
build-tools/buildlog-compare:
18
def sort_build(log, pkg=None):
368 by Jamie Strandboge
build-tools/buildlog-compare:
19
    out = []
20
21
    pat = re.compile(r'^\s+')
377 by Jamie Strandboge
build-tools/buildlog-compare:
22
    pat_beg = None # used for matching at the beginning of a line to ensure
23
                   # the next line gets added to it
452 by Jamie Strandboge
build-tools/buildlog-compare: make openjdk comparisons slightly less painful
24
    pat_force_line = None # used to match at beginning of line to ensure it
25
                          # is on its own line
377 by Jamie Strandboge
build-tools/buildlog-compare:
26
    if pkg.startswith("python2") or pkg.startswith("python3"):
27
        pat = re.compile(r"^(\s+|Expecting.+|ok$|FAIL|ERROR)")
28
        pat_beg = re.compile(r'^Trying:')
452 by Jamie Strandboge
build-tools/buildlog-compare: make openjdk comparisons slightly less painful
29
    elif pkg.startswith("openjdk"):
30
        pat_force_line = re.compile(r"^\s+(created|inflated|inflating): ")
373 by Jamie Strandboge
build-tools/buildlog-compare: fix typo in relevancy pattern
31
    pat_w = re.compile(r'[a-zA-Z0-9]')
368 by Jamie Strandboge
build-tools/buildlog-compare:
32
    s = ""
33
    for line in log.split('\n'):
377 by Jamie Strandboge
build-tools/buildlog-compare:
34
        if pat_beg and pat_beg.search(line):
35
            s = line
452 by Jamie Strandboge
build-tools/buildlog-compare: make openjdk comparisons slightly less painful
36
        elif pat.search(line) and \
37
             not (pat_force_line and pat_force_line.search(line)):
377 by Jamie Strandboge
build-tools/buildlog-compare:
38
            if s == "": # avoids adding extra newline
39
                s = line
40
            else:
41
                s += 'BLSNEWLINE' + line
368 by Jamie Strandboge
build-tools/buildlog-compare:
42
        else:
377 by Jamie Strandboge
build-tools/buildlog-compare:
43
            if s == "": # avoids adding extra newline
44
                s = line
45
            else:
46
                s = "%s\n%s" % (s, line)
47
368 by Jamie Strandboge
build-tools/buildlog-compare:
48
            if pat_w.search(s):
49
                # Don't include anything that isn't worth sorting
377 by Jamie Strandboge
build-tools/buildlog-compare:
50
                out.append(s)
368 by Jamie Strandboge
build-tools/buildlog-compare:
51
            s = ""
52
53
    out.sort()
54
    out_s = "\n".join(out)
55
56
    # Now that we are sorted, replace BLSNEWLINE placeholders
57
    pat = re.compile(r'BLSNEWLINE')
58
    return pat.sub('\n', out_s)
59
377 by Jamie Strandboge
build-tools/buildlog-compare:
60
def write_log(fd, log, deparallel, pkg):
367 by Jamie Strandboge
build-tools/buildlog-compare:
61
    if deparallel:
368 by Jamie Strandboge
build-tools/buildlog-compare:
62
        split_str = '\n debian/rules build\n'
63
        (pre, rest) = log.split(split_str, 1)
64
        pre += split_str
65
415 by Jamie Strandboge
build-tools/buildlog-compare: buildd logs might use 'binary-arch' instead of
66
        split_str = 'fakeroot debian/rules binary-arch\n'
67
        if split_str not in rest:
68
            split_str = 'fakeroot debian/rules binary\n'
376 by Jamie Strandboge
build-tools/buildlog-compare: don't compare 'pre' twice
69
        (build, post) = rest.split(split_str, 1)
368 by Jamie Strandboge
build-tools/buildlog-compare:
70
        post = split_str + post
71
72
        # Don't try to sort non-build targets
73
        fd.write(pre)
74
75
        # Sort the build target
377 by Jamie Strandboge
build-tools/buildlog-compare:
76
        fd.write(sort_build(build, pkg))
368 by Jamie Strandboge
build-tools/buildlog-compare:
77
78
        # Don't try to sort non-build targets
79
        fd.write(post)
80
81
        fd.write("Specified --deparallel with '%s' (experimental)\n" % fd.name)
367 by Jamie Strandboge
build-tools/buildlog-compare:
82
    else:
83
        fd.write(log)
84
368 by Jamie Strandboge
build-tools/buildlog-compare:
85
    fd.flush()
86
367 by Jamie Strandboge
build-tools/buildlog-compare:
87
parser = optparse.OptionParser()
88
parser.add_option("--deparallel", help="Attempt to deparallelize the build logs", action='store_true', default=False)
89
(opt, args) = parser.parse_args()
90
91
if len(args)<4:
451 by Jamie Strandboge
build-tools/buildlog-compare: fix traceback when calling with no args
92
    sys.stderr.write("Usage: %s [--deparallel] PKG OLDVER OLDLOG NEWVER NEWLOG\n" % (os.path.basename(sys.argv[0])))
1 by Kees Cook
initial re-check-in
93
    sys.exit(1)
94
367 by Jamie Strandboge
build-tools/buildlog-compare:
95
pkg = args[0]
1 by Kees Cook
initial re-check-in
96
367 by Jamie Strandboge
build-tools/buildlog-compare:
97
oldver = args[1]
1 by Kees Cook
initial re-check-in
98
oldver_escaped = oldver.replace('.','\.')
367 by Jamie Strandboge
build-tools/buildlog-compare:
99
oldlog = pull_build_log(args[2]).replace(oldver,"VERSION").replace(oldver_escaped,"VERSION")
1 by Kees Cook
initial re-check-in
100
if '-' in oldver:
27 by Kees Cook
handle logs with "-" in the upstream version
101
    oldverup = pkg + "-" + '-'.join(oldver.split('-')[:-1])
1 by Kees Cook
initial re-check-in
102
    oldlog = oldlog.replace(oldverup,"%s-VERSION"%(pkg))
103
367 by Jamie Strandboge
build-tools/buildlog-compare:
104
newver = args[3]
1 by Kees Cook
initial re-check-in
105
newver_escaped = newver.replace('.','\.')
367 by Jamie Strandboge
build-tools/buildlog-compare:
106
newlog = pull_build_log(args[4]).replace(newver,"VERSION").replace(newver_escaped,"VERSION")
1 by Kees Cook
initial re-check-in
107
if '-' in newver:
27 by Kees Cook
handle logs with "-" in the upstream version
108
    newverup = pkg + "-" + '-'.join(newver.split('-')[:-1])
1 by Kees Cook
initial re-check-in
109
    newlog = newlog.replace(newverup,"%s-VERSION"%(pkg))
110
200 by Jamie Strandboge
buildlog-compare: normalize things liek this too:
111
buildpath_regex = r'\/build\/([^\/]+)\/%s-VERSION[\/\'\" ]' % (pkg)
12 by Kees Cook
catch more build directory locations
112
368 by Jamie Strandboge
build-tools/buildlog-compare:
113
# Normalize Ubuntu buildd build host (must happen before USER normalization)
114
oldlog = re.sub(r'<buildd@.*\.buildd>', '<buildd@BUILDHOST.buildd>', oldlog)
115
newlog = re.sub(r'<buildd@.*\.buildd>', '<buildd@BUILDHOST.buildd>', newlog)
116
1 by Kees Cook
initial re-check-in
117
# Normalize user
78 by Jamie Strandboge
buildlog-compare: handle when re.search(buildpath_regex, oldlog) is None
118
userold = "USER"
119
if re.search(buildpath_regex, oldlog) != None:
120
    try:
121
        userold = re.search(buildpath_regex, oldlog).group(1)
122
    except:
367 by Jamie Strandboge
build-tools/buildlog-compare:
123
        sys.stderr.write("Problem processing '%s' (perhaps an aborted build?)\n" % (args[2]))
78 by Jamie Strandboge
buildlog-compare: handle when re.search(buildpath_regex, oldlog) is None
124
        sys.exit(1)
125
126
usernew = "USER"
127
if re.search(buildpath_regex, newlog) != None:
128
    try:
129
        usernew = re.search(buildpath_regex, newlog).group(1)
130
    except:
367 by Jamie Strandboge
build-tools/buildlog-compare:
131
        sys.stderr.write("Problem processing '%s' (perhaps an aborted build?)\n" % (args[4]))
78 by Jamie Strandboge
buildlog-compare: handle when re.search(buildpath_regex, oldlog) is None
132
        sys.exit(1)
23 by Jamie Strandboge
build-tools/buildlog-compare: handle abourted builds better
133
1 by Kees Cook
initial re-check-in
134
if '-' in userold:
135
    userold = userold.split('-')[0]
136
if '-' in usernew:
137
    usernew = usernew.split('-')[0]
138
oldlog = re.sub(r'\b%s\b' % (userold), 'USER', oldlog)
139
newlog = re.sub(r'\b%s\b' % (usernew), 'USER', newlog)
140
141
# Normalize build paths
142
#/build/buildd/                                                 gdb-6.8.90.20090918/...
143
#/build/kees-gdb_6.8.90.20090918-0ubuntu1~ppa2-amd64-WX65oZ     gdb-6.8.90.20090918/...
144
#-make[1]: Leaving directory `/build/buildd/gdb-VERSION'
145
#+make[1]: Leaving directory `/build/kees-gdb_VERSION-amd64-WX65oZ/gdb-VERSION'
200 by Jamie Strandboge
buildlog-compare: normalize things liek this too:
146
#- ... -I"/build/jamie-libvpx_VERSION-amd64-xVTtDS/libvpx-VERSION" ...
147
#+ ... -I"/build/jamie-libvpx_VERSION-amd64-O1LsQi/libvpx-VERSION" ...
12 by Kees Cook
catch more build directory locations
148
oldlog = re.sub(buildpath_regex, '/BUILDPATH/', oldlog)
149
newlog = re.sub(buildpath_regex, '/BUILDPATH/', newlog)
150
oldlog = re.sub(r'\/home\/USER\/build-[-0-9]+\/', '/HOMEBUILDPATH/', oldlog)
151
newlog = re.sub(r'\/home\/USER\/build-[-0-9]+\/', '/HOMEBUILDPATH/', newlog)
1 by Kees Cook
initial re-check-in
152
367 by Jamie Strandboge
build-tools/buildlog-compare:
153
# Normalize Ubuntu buildd SUDO_COMMAND
154
oldlog = re.sub(r'\/home\/buildd\/build-[a-f0-9]+\/chroot-autobuild', '/BUILDPATH/chroot-autobuild', oldlog)
155
newlog = re.sub(r'\/home\/buildd\/build-[a-f0-9]+\/chroot-autobuild', '/BUILDPATH/chroot-autobuild', newlog)
156
342 by Jamie Strandboge
build-tools/buildlog-compare: normalize a lot more output:
157
# Normalize sbuild resolver paths
158
oldlog = re.sub(r'\/resolver-[a-zA-Z0-9_]+\/(apt_archive\/sbuild-build-depends-)', '/resolver-RESOLVERPATH/\\1', oldlog)
159
newlog = re.sub(r'\/resolver-[a-zA-Z0-9_]+\/(apt_archive\/sbuild-build-depends-)', '/resolver-RESOLVERPATH/\\1', newlog)
160
161
# Normalize umt tmp paths
162
oldlog = re.sub(r'\/tmp\/umt-[a-zA-Z0-9_]+', '/tmp/umt-TMPPATH', oldlog)
163
newlog = re.sub(r'\/tmp\/umt-[a-zA-Z0-9_]+', '/tmp/umt-TMPPATH', newlog)
164
1 by Kees Cook
initial re-check-in
165
# Normalize schroot mount points
166
oldlog = re.sub(r'/var/lib/schroot/mount/([^/]+)/', '/SCHROOTMOUNT/', oldlog)
167
newlog = re.sub(r'/var/lib/schroot/mount/([^/]+)/', '/SCHROOTMOUNT/', newlog)
168
342 by Jamie Strandboge
build-tools/buildlog-compare: normalize a lot more output:
169
# Normalize SCHROOT_SESSION_ID
170
oldlog = re.sub(r'SCHROOT_SESSION_ID=([a-z]+-[a-z0-9]+)-[0-9a-f\-]+', 'SCHROOT_SESSION_ID=\\1-SCHROOTSESSIONID', oldlog)
171
newlog = re.sub(r'SCHROOT_SESSION_ID=([a-z]+-[a-z0-9]+)-[0-9a-f\-]+', 'SCHROOT_SESSION_ID=\\1-SCHROOTSESSIONID', newlog)
172
173
# Normalize schroot NOTICEs
174
oldlog = re.sub(r"(I: NOTICE: Log filtering will replace ').*(' with ').*('.*)", '\\1VAR1\\2VAR2\\3', oldlog)
175
newlog = re.sub(r"(I: NOTICE: Log filtering will replace ').*(' with ').*('.*)", '\\1VAR1\\2VAR2\\3', newlog)
176
177
# Normalize build finished
178
oldlog = re.sub(r'((Build finished at|Finished at)) [0-9\-]+', '\\1 FINISHTIME', oldlog)
179
newlog = re.sub(r'((Build finished at|Finished at)) [0-9\-]+', '\\1 FINISHTIME', newlog)
180
181
# Normalize redundant summary line
182
oldlog = re.sub(r'(Build needed) [0-9]{2}:[0-9]{2}:[0-9]{2}, [0-9]+[kmg] (disc space)', '\\1 BUILDTIME, BUILDSPACE \\2', oldlog)
183
newlog = re.sub(r'(Build needed) [0-9]{2}:[0-9]{2}:[0-9]{2}, [0-9]+[kmg] (disc space)', '\\1 BUILDTIME, BUILDSPACE \\2', newlog)
184
1 by Kees Cook
initial re-check-in
185
# Normalize file times
186
oldlog = re.sub('(\d+ )[12][09]\d\d-\d\d-\d\d [0-2]\d:[0-5]\d(?::[0-5]\d)?( \./)', '\g<1>0000-00-00 00:00\g<2>', oldlog)
187
newlog = re.sub('(\d+ )[12][09]\d\d-\d\d-\d\d [0-2]\d:[0-5]\d(?::[0-5]\d)?( \./)', '\g<1>0000-00-00 00:00\g<2>', newlog)
188
189
# Normalize timestamps (e.g. Mon Aug 24 16:58:26 UTC 2009)
190
oldlog = re.sub('(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),? )?(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [ \d]?\d [0-2]\d:[0-5]\d(?::[0-5]\d)?(?:(?: [^ ]+)? [12][09]\d\d|[-+]\d+)?', 'DAY MON DD HH:MM:SS TZ YEAR', oldlog)
191
newlog = re.sub('(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),? )?(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [ \d]?\d [0-2]\d:[0-5]\d(?::[0-5]\d)?(?:(?: [^ ]+)? [12][09]\d\d|[-+]\d+)?', 'DAY MON DD HH:MM:SS TZ YEAR', newlog)
192
374 by Jamie Strandboge
build-tools/buildlog-compare: normalize lines of the form:
193
# Normalize ' size 2121828 bytes: control archive= 607 bytes.'
194
oldlog = re.sub(' size \d+ bytes: control archive= \d+ bytes', ' size NN bytes: control archive= NN bytes', oldlog)
195
newlog = re.sub(' size \d+ bytes: control archive= \d+ bytes', ' size NN bytes: control archive= NN bytes', newlog)
196
368 by Jamie Strandboge
build-tools/buildlog-compare:
197
# progress dots (less than 4 catches too much)
198
oldlog = re.sub('\.\.\.\.\.*', '.4+DOTS.', oldlog)
199
newlog = re.sub('\.\.\.\.\.*', '.4+DOTS.', newlog)
200
452 by Jamie Strandboge
build-tools/buildlog-compare: make openjdk comparisons slightly less painful
201
# Normalize 'Ubuntu [a-z]+ \(development branch\)' and 'Ubuntu [\d]?\d\.(04|10)'
202
oldlog = re.sub('Ubuntu ([a-z]+ \(development branch\)|[\d]?\d\.(04|10))', 'Ubuntu YY.MM', oldlog)
203
newlog = re.sub('Ubuntu ([a-z]+ \(development branch\)|[\d]?\d\.(04|10))', 'Ubuntu YY.MM', newlog)
204
342 by Jamie Strandboge
build-tools/buildlog-compare: normalize a lot more output:
205
# Normalize chatty apt output
206
# Filter out 'Reading package lists...' bits
207
oldlog = re.sub(r'(Reading package lists...) [0-9]{1,2}%.*(Reading package lists... Done)', '\\1 PROGRESS... \\2', oldlog)
208
newlog = re.sub(r'(Reading package lists...) [0-9]{1,2}%.*(Reading package lists... Done)', '\\1 PROGRESS... \\2', newlog)
209
# Normalize 'Fetched ... in ...
375 by Jamie Strandboge
build-tools/buildlog-compare:
210
oldlog = re.sub(r'Fetched [0-9\.]+ ?[kmMgGB]+ in( [0-9]+min)? [0-9]+s \([0-9\.]+ ?[kmMgGB]+/s\)', 'Fetched SIZE in TIME (RATE)', oldlog)
211
newlog = re.sub(r'Fetched [0-9\.]+ ?[kmMgGB]+ in( [0-9]+min)? [0-9]+s \([0-9\.]+ ?[kmMgGB]+/s\)', 'Fetched SIZE in TIME (RATE)', newlog)
342 by Jamie Strandboge
build-tools/buildlog-compare: normalize a lot more output:
212
# Normalize 'Need to get ...'
343 by Jamie Strandboge
build-tools/buildlog-compare: normalize harder the chatty apt
213
oldlog = re.sub(r'Need to get [0-9\.]+ ?[kmMgGB]+(/[0-9\.]+ ?[kmMgGB]+)? of archives', 'Need to get SIZE of archives', oldlog)
214
newlog = re.sub(r'Need to get [0-9\.]+ ?[kmMgGB]+(/[0-9\.]+ ?[kmMgGB]+)? of archives', 'Need to get SIZE of archives', newlog)
347 by Jamie Strandboge
build-tools/buildlog-compare: normalize even harder the chatty apt
215
# Normalize 'Get:... vs Hit... for binaries'
216
oldlog = re.sub(r'(Get:[0-9]+|Hit) (\S+://\S+ \S+ \S+ \S+ \S+) \[[0-9\.]+ ?[kmMgGB]+\]', 'GETHITIGN \\2 SIZEOMITTED', oldlog)
217
newlog = re.sub(r'(Get:[0-9]+|Hit) (\S+://\S+ \S+ \S+ \S+ \S+) \[[0-9\.]+ ?[kmMgGB]+\]', 'GETHITIGN \\2 SIZEOMITTED', newlog)
218
# Normalize 'Get:... vs Hit... vs Ign... for Packages'
219
oldlog = re.sub(r'(Get:[0-9]+|Hit|Ign) (\S+://\S+ \S+ \S+ Packages\S*)( \[[0-9\.]+ ?[kmMgGB]+\])?', 'GETHITIGN \\2 SIZEOMITTED', oldlog)
220
newlog = re.sub(r'(Get:[0-9]+|Hit|Ign) (\S+://\S+ \S+ \S+ Packages\S*)( \[[0-9\.]+ ?[kmMgGB]+\])?', 'GETHITIGN \\2 SIZEOMITTED', newlog)
221
# Normalize 'Get:... vs Hit... vs Ign... for Sources, Release, etc'
222
oldlog = re.sub(r'(Get:[0-9]+|Hit|Ign) (\S+://\S+ \S+ \S+)( \[[0-9\.]+ ?[kmMgGB]+\])?', 'GETHITIGN \\2 SIZEOMITTED', oldlog)
223
newlog = re.sub(r'(Get:[0-9]+|Hit|Ign) (\S+://\S+ \S+ \S+)( \[[0-9\.]+ ?[kmMgGB]+\])?', 'GETHITIGN \\2 SIZEOMITTED', newlog)
343 by Jamie Strandboge
build-tools/buildlog-compare: normalize harder the chatty apt
224
# Normalize 'After this operation, ...
225
oldlog = re.sub(r'After this operation, [0-9]+ ?[kmMgGB]+ of additional disk space will be used', 'After this operation, SIZE of additional disk space will be used', oldlog)
226
newlog = re.sub(r'After this operation, [0-9]+ ?[kmMgGB]+ of additional disk space will be used', 'After this operation, SIZE of additional disk space will be used', newlog)
342 by Jamie Strandboge
build-tools/buildlog-compare: normalize a lot more output:
227
368 by Jamie Strandboge
build-tools/buildlog-compare:
228
# /tmp files
229
oldlog = re.sub('/tmp/.*', '/tmp/TMPFILE', oldlog)
230
newlog = re.sub('/tmp/.*', '/tmp/TMPFILE', newlog)
231
371 by Jamie Strandboge
build-tools/buildlog-compare: normalize dpkg-gensymbols lines
232
# dpkg-gensymbols
233
oldlog = re.sub('dpkg-gensymbols[a-zA-Z0-9_]+\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [+-]\d{4}', 'dpkg-gensymbolsXXXX      DATETIME', oldlog)
234
newlog = re.sub('dpkg-gensymbols[a-zA-Z0-9_]+\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [+-]\d{4}', 'dpkg-gensymbolsXXXX      DATETIME', newlog)
235
1 by Kees Cook
initial re-check-in
236
# Normalize special stuff
452 by Jamie Strandboge
build-tools/buildlog-compare: make openjdk comparisons slightly less painful
237
# openjdk...
1 by Kees Cook
initial re-check-in
238
oldlog = re.sub('Timing: \d+ seconds or (?:\d+m)?\d+s for', 'Timing: NNNNN seconds or NmNs for', oldlog)
239
newlog = re.sub('Timing: \d+ seconds or (?:\d+m)?\d+s for', 'Timing: NNNNN seconds or NmNs for', newlog)
452 by Jamie Strandboge
build-tools/buildlog-compare: make openjdk comparisons slightly less painful
240
oldlog = re.sub('-D(FULL_VERSION|RELEASE)=\'"([a-z0-9_\.\-]+)"\'', '-D\\1=\'"N.N.N_NN"\'', oldlog)
241
newlog = re.sub('-D(FULL_VERSION|RELEASE)=\'"([a-z0-9_\.\-]+)"\'', '-D\\1=\'"N.N.N_NN"\'', newlog)
242
oldlog = re.sub('(BUILD_NUMBER|JDK_BUILD_NUMBER|JDK_MKTG_VERSION|JDK_VERSION|COOKED_JDK_UPDATE_VERSION|COOKED_BUILD_NUMBER|JRE_RELEASE_VERSION|HOTSPOT_RELEASE_VERSION|FULL_VERSION)=(\\")?([a-zA-Z0-9_\.\-]+)(\\")?', '\\1=N.N.N_NN', oldlog)
243
newlog = re.sub('(BUILD_NUMBER|JDK_BUILD_NUMBER|JDK_MKTG_VERSION|JDK_VERSION|COOKED_JDK_UPDATE_VERSION|COOKED_BUILD_NUMBER|JRE_RELEASE_VERSION|HOTSPOT_RELEASE_VERSION|FULL_VERSION)=(\\")?([a-z0-9_\.\-]+)(\\")?', '\\1=N.N.N_NN', newlog)
244
oldlog = re.sub('(lib.*.so(\.[0-9]+)? => .*lib.*.so(\.[0-9])?) \(0x[0-9a-f]+\)', '\\1 (0xDEADBEEF)', oldlog) 
245
newlog = re.sub('(lib.*.so(\.[0-9]+)? => .*lib.*.so(\.[0-9])?) \(0x[0-9a-f]+\)', '\\1 (0xDEADBEEF)', newlog) 
246
oldlog = re.sub('#@@RELEASE@@#[a-z0-9_\.\-]+#', '#@@RELEASE@@#N.N.N_NN#', oldlog)
247
newlog = re.sub('#@@RELEASE@@#[a-z0-9_\.\-]+#', '#@@RELEASE@@#N.N.N_NN#', newlog)
248
oldlog = re.sub('DERIVATIVE_ID="(\\")?IcedTea[0-9]+ ([0-9\.]+)(\\")?"', 'DERIVATIVE_ID="\\"IcedTeaN N.N.N\\""', oldlog)
249
newlog = re.sub('DERIVATIVE_ID="(\\")?IcedTea[0-9]+ ([0-9\.]+)(\\")?"', 'DERIVATIVE_ID="\\"IcedTeaN N.N.N\\""', newlog)
250
oldlog = re.sub('-DDERIVATIVE_ID="(\\")?IcedTea[0-9]+ ([0-9\.]+)(\\")?"', '-DDERIVATIVE_ID="\\"IcedTeaN N.N.N\\""', oldlog)
251
newlog = re.sub('-DDERIVATIVE_ID="(\\")?IcedTea[0-9]+ ([0-9\.]+)(\\")?"', '-DDERIVATIVE_ID="\\"IcedTeaN N.N.N\\""', newlog)
1 by Kees Cook
initial re-check-in
252
548 by Marc Deslauriers
umt: properly escape + in package names when trying to find log file
253
# gtk+3.0
552 by Marc Deslauriers
buildlog-compare: added regex for openssh
254
oldlog = re.sub('/build/gtk\+3.0-[^/]+/', '/build/gtk+3.0-TEMP/', oldlog)
255
newlog = re.sub('/build/gtk\+3.0-[^/]+/', '/build/gtk+3.0-TEMP/', newlog)
256
257
# openssh
258
oldlog = re.sub('SSH_EXTRAVERSION=\\\\\"[a-zA-Z0-9_\.\-]+\\\\\"', 'SSH_EXTRAVERSION=\\\\"XXXX\\\\\"', oldlog)
259
newlog = re.sub('SSH_EXTRAVERSION=\\\\\"[a-zA-Z0-9_\.\-]+\\\\\"', 'SSH_EXTRAVERSION=\\\\"XXXX\\\\\"', newlog)
553 by Marc Deslauriers
buildlog-compare: more regex
260
oldlog = re.sub('SSH_EXTRAVERSION=\\\"[a-zA-Z0-9_\.\-]+\\\"', 'SSH_EXTRAVERSION=\\"XXXX\\\"', oldlog)
261
newlog = re.sub('SSH_EXTRAVERSION=\\\"[a-zA-Z0-9_\.\-]+\\\"', 'SSH_EXTRAVERSION=\\"XXXX\\\"', newlog)
548 by Marc Deslauriers
umt: properly escape + in package names when trying to find log file
262
368 by Jamie Strandboge
build-tools/buildlog-compare:
263
# libreoffice (adding: com/sun/... (deflated 60%))
264
oldlog = re.sub(' \(deflated [0-9]{1,2}%\)', ' (deflated N%)', oldlog)
265
newlog = re.sub(' \(deflated [0-9]{1,2}%\)', ' (deflated N%)', newlog)
266
585 by Marc Deslauriers
buildlog-compare: added regex for samba build logs
267
# samba (09:33:21 runner /usr/bin/gcc -g -O2 -fstack-protector)
268
oldlog = re.sub('[0-9:]{8} runner', '00:00:00 runner', oldlog)
269
newlog = re.sub('[0-9:]{8} runner', '00:00:00 runner', newlog)
270
342 by Jamie Strandboge
build-tools/buildlog-compare: normalize a lot more output:
271
# PNG optimization
272
oldlog = re.sub('(pkgstripfiles: PNG optimization for package \S+ took) .*', '\\1 TIME', oldlog)
273
newlog = re.sub('(pkgstripfiles: PNG optimization for package \S+ took) .*', '\\1 TIME', newlog)
274
375 by Jamie Strandboge
build-tools/buildlog-compare:
275
# gi introspection (as seen in rhythmbox)
276
oldlog = re.sub('/tmp-introspect[a-zA-Z0-9_]+/', '/tmp-XXXX/', oldlog)
277
newlog = re.sub('/tmp-introspect[a-zA-Z0-9_]+/', '/tmp-XXXX/', newlog)
278
436 by Jamie Strandboge
build-tools/buildlog-compare: add a few more python filters
279
# python (flags=re.MULTILINE is 2.7 only, otherwise use re.compile(... flags=))
280
oldlog = re.sub(r'^Ran ([0-9]+) tests in [0-9]+\.[0-9]+s$', 'Ran \\1 tests in N.NNNs', oldlog, flags=re.MULTILINE)
281
newlog = re.sub(r'^Ran ([0-9]+) tests in [0-9]+\.[0-9]+s$', 'Ran \\1 tests in N.NNNs', newlog, flags=re.MULTILINE)
282
oldlog = re.sub(r'(<.* object at) 0x[0-9a-f]+>$', '\\1 0xHHHHHHHH>', oldlog, flags=re.MULTILINE)
283
newlog = re.sub(r'(<.* object at) 0x[0-9a-f]+>$', '\\1 0xHHHHHHHH>', newlog, flags=re.MULTILINE)
284
oldlog = re.sub(r"^( (|a )server:  new connection from \('127.0.0.1',) [0-9]+\)$", '\\1 PORT)', oldlog, flags=re.MULTILINE)
285
newlog = re.sub(r"^( (|a )server:  new connection from \('127.0.0.1',) [0-9]+\)$", '\\1 PORT)', newlog, flags=re.MULTILINE)
286
oldlog = re.sub(r"( server:  new connection from 127.0.0.1:)[0-9]+$", '\\1PORT)', oldlog, flags=re.MULTILINE)
287
newlog = re.sub(r"( server:  new connection from 127.0.0.1:)[0-9]+$", '\\1PORT)', newlog, flags=re.MULTILINE)
377 by Jamie Strandboge
build-tools/buildlog-compare:
288
562 by Steve Beattie
buildlog-compare: replace pids and other spurious sizes and addresses in
289
# gcc AddressSanitzer Failures; remove pid
610 by Marc Deslauriers
buildlog-compare: normalize openldap test suite
290
oldlog = re.sub('(FAIL: .*, is )====(ERROR: AddressSanitizer failed to allocate 0x)[0-9a-f]+ \(\d+\) (bytes at address 0x)[0-9a-f]+ (.*)', '\\1 ==PID==\\2HEXSIZEOMITTED (SIZEOMITTED) \\3ADDROMITTED \\4)', oldlog)
562 by Steve Beattie
buildlog-compare: replace pids and other spurious sizes and addresses in
291
newlog = re.sub('(FAIL: .*, is )==\d+==(ERROR: AddressSanitizer failed to allocate 0x)[0-9a-f]+ \(\d+\) (bytes at address 0x)[0-9a-f]+ (.*)', '\\1 ==PID==\\2HEXSIZEOMITTED (SIZEOMITTED) \\3ADDROMITTED \\4)', newlog)
292
571 by Marc Deslauriers
buildlog-compare: added a couple of tomcat7 regexes
293
# Normalize tomcat7 junit timestamps (e.g. Jul 24, 2014 2:02:12 PM)
294
oldlog = re.sub('\[junit\] (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [ \d]?\d, [12][09]\d\d 1?\d:[0-5]\d:[0-5]\d (?:AM|PM)', 'MON DD, YEAR HH:MM:SS XM', oldlog)
295
newlog = re.sub('\[junit\] (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [ \d]?\d, [12][09]\d\d 1?\d:[0-5]\d:[0-5]\d (?:AM|PM)', 'MON DD, YEAR HH:MM:SS XM', newlog)
296
297
# Normalize tomcat7 pids
298
oldlog = re.sub('http-bio-127.0.0.1-auto-[0-9]+-[0-9]+', 'http-bio-127.0.0.1-auto-X-XXX', oldlog)
299
newlog = re.sub('http-bio-127.0.0.1-auto-[0-9]+-[0-9]+', 'http-bio-127.0.0.1-auto-X-XXX', newlog)
300
301
# Normalize tomcat7 time elapsed
302
oldlog = re.sub('Time elapsed: [0-9]+.[0-9]+ sec', 'Time elapsed: X.XXX sec', oldlog)
303
newlog = re.sub('Time elapsed: [0-9]+.[0-9]+ sec', 'Time elapsed: X.XXX sec', newlog)
304
609 by Marc Deslauriers
buildlog-compare: normalize icu test suite
305
# Normalize icu test suite time
306
oldlog = re.sub(' \(?\( ?[0-9.]+m?s ?\)\)?', '', oldlog)
307
newlog = re.sub(' \(?\( ?[0-9.]+m?s ?\)\)?', '', newlog)
308
oldlog = re.sub('Elapsed Time: [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}', 'Elapsed Time: XX:XX:XX.XXX', oldlog)
309
newlog = re.sub('Elapsed Time: [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}', 'Elapsed Time: XX:XX:XX.XXX', newlog)
310
610 by Marc Deslauriers
buildlog-compare: normalize openldap test suite
311
# Normalize openldap test suite
312
oldlog = re.sub('PID=\d+([ :])', 'PID=PID\\1', oldlog)
313
newlog = re.sub('PID=\d+([ :])', 'PID=PID\\1', newlog)
314
oldlog = re.sub('\(pid=\d+\)', '(pid=PID)', oldlog)
315
newlog = re.sub('\(pid=\d+\)', '(pid=PID)', newlog)
316
oldlog = re.sub('in [0-9]+.[0-9]+ seconds', 'in X.XXX seconds', oldlog)
317
newlog = re.sub('in [0-9]+.[0-9]+ seconds', 'in X.XXX seconds', newlog)
318
621 by Marc Deslauriers
added openssl regexes to buildlog-compare
319
# Normalize openssl test suite
320
oldlog = re.sub('[0-9]{15}:error', '000000000000000:error', oldlog)
321
newlog = re.sub('[0-9]{15}:error', '000000000000000:error', newlog)
322
oldlog = re.sub('s3_clnt.c:[0-9]{4}', 's3_clnt.c:0000', oldlog)
323
newlog = re.sub('s3_clnt.c:[0-9]{4}', 's3_clnt.c:0000', newlog)
324
oldlog = re.sub('rsa_sign.c:[0-9]{3}', 'rsa_sign.c:000', oldlog)
325
newlog = re.sub('rsa_sign.c:[0-9]{3}', 'rsa_sign.c:000', newlog)
326
oldlog = re.sub('context\? 0x0x[0-9a-f]+ a cert\? 0x0x[0-9a-f]+', 'context\? 0x0xHHHHHH a cert\? 0x0xHHHHHH', oldlog)
327
newlog = re.sub('context\? 0x0x[0-9a-f]+ a cert\? 0x0x[0-9a-f]+', 'context\? 0x0xHHHHHH a cert\? 0x0xHHHHHH', newlog)
328
oldlog = re.sub('Nonce: 0x[0-9A-F]{16}', 'Nonce: 0xHHHHHHHHHHHHHHHH', oldlog)
329
newlog = re.sub('Nonce: 0x[0-9A-F]{16}', 'Nonce: 0xHHHHHHHHHHHHHHHH', newlog)
330
639 by Marc Deslauriers
buildlog-compare: filter perl build directory
331
# perl build directory
332
oldlog = re.sub('/build/perl\\\-.*/', '/build/perl\-XXXXXX/', oldlog)
333
newlog = re.sub('/build/perl\\\-.*/', '/build/perl\-XXXXXX/', newlog)
334
641 by Marc Deslauriers
buildlog-compare: add samba filtering
335
# samba progress
336
oldlog = re.sub('\[[ 0-9]{4}/[ 0-9]{4}\] Compiling', '[XXXX/XXXX] Compiling', oldlog)
337
newlog = re.sub('\[[ 0-9]{4}/[ 0-9]{4}\] Compiling', '[XXXX/XXXX] Compiling', newlog)
338
oldlog = re.sub('\[[ 0-9]{4}/[ 0-9]{4}\] Generating', '[XXXX/XXXX] Generating', oldlog)
339
newlog = re.sub('\[[ 0-9]{4}/[ 0-9]{4}\] Generating', '[XXXX/XXXX] Generating', newlog)
696 by Marc Deslauriers
buildlog-compare: add another samba regex
340
oldlog = re.sub('\[[ 0-9]{4}/[ 0-9]{4}\] Linking', '[XXXX/XXXX] Linking', oldlog)
341
newlog = re.sub('\[[ 0-9]{4}/[ 0-9]{4}\] Linking', '[XXXX/XXXX] Linking', newlog)
641 by Marc Deslauriers
buildlog-compare: add samba filtering
342
342 by Jamie Strandboge
build-tools/buildlog-compare: normalize a lot more output:
343
# Write out the files for diffing
1 by Kees Cook
initial re-check-in
344
oldfile = tempfile.NamedTemporaryFile(prefix='buildlog-')
377 by Jamie Strandboge
build-tools/buildlog-compare:
345
write_log(oldfile, oldlog, opt.deparallel, pkg)
1 by Kees Cook
initial re-check-in
346
347
newfile = tempfile.NamedTemporaryFile(prefix='buildlog-')
377 by Jamie Strandboge
build-tools/buildlog-compare:
348
write_log(newfile, newlog, opt.deparallel, pkg)
367 by Jamie Strandboge
build-tools/buildlog-compare:
349
452 by Jamie Strandboge
build-tools/buildlog-compare: make openjdk comparisons slightly less painful
350
# To debug, useful to do:
351
#shutil.copy(oldfile.name, "/tmp/old")
352
#shutil.copy(newfile.name, "/tmp/new")
353
561 by Steve Beattie
make umt compare-log ignore some whitespace changes when diffing
354
subprocess.call(['diff', '-ub', oldfile.name, newfile.name])