author | esaxe |
Fri, 11 Aug 2006 18:11:49 -0700 | |
changeset 2538 | b5894d78c55a |
child 3002 | 44325328cb8d |
permissions | -rwxr-xr-x |
2538
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1 |
#!/usr/sfw/bin/python |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
2 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
4 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
8 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
12 |
# and limitations under the License. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
13 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
19 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
21 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
22 |
# Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
23 |
# Use is subject to license terms. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
24 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
25 |
#ident "%Z%%M% %I% %E% SMI" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
26 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
27 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
28 |
# wsdiff(1) is a tool that can be used to determine which compiled objects |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
29 |
# have changed as a result of a given source change. Developers backporting |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
30 |
# new features, RFEs and bug fixes need to be able to identify the set of |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
31 |
# patch deliverables necessary for feature/fix realization on a patched system. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
32 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
33 |
# The tool works by comparing objects in two trees/proto areas (one build with, |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
34 |
# and without the source changes. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
35 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
36 |
# Using wsdiff(1) is fairly simple: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
37 |
# - Bringover to a fresh workspace |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
38 |
# - Perform a full non-debug build (clobber if workspace isn't fresh) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
39 |
# - Move the proto area aside, call it proto.old, or something. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
40 |
# - Integrate your changes to the workspace |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
41 |
# - Perform another full non-debug clobber build. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
42 |
# - Use wsdiff(1) to see what changed: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
43 |
# $ wsdiff proto.old proto |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
44 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
45 |
# By default, wsdiff will print the list of changed objects / deliverables to |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
46 |
# stdout. If a results file is specified via -r, the list of differing objects, |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
47 |
# and details about why wsdiff(1) thinks they are different will be logged to |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
48 |
# the results file. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
49 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
50 |
# By invoking nightly(1) with the -w option to NIGHTLY_FLAGS, nightly(1) will use |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
51 |
# wsdiff(1) to report on what objects changed since the last build. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
52 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
53 |
# For patch deliverable purposes, it's advised to have nightly do a clobber, |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
54 |
# non-debug build. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
55 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
56 |
# Think about the results. Was something flagged that you don't expect? Go look |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
57 |
# at the results file to see details about the differences. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
58 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
59 |
# Use the -i option in conjunction with -v and -V to dive deeper and have wsdiff(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
60 |
# report with more verbosity. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
61 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
62 |
# Usage: wsdiff [-vVt] [-r results ] [-i filelist ] old new |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
63 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
64 |
# Where "old" is the path to the proto area build without the changes, and |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
65 |
# "new" is the path to the proto area built with the changes. The following |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
66 |
# options are supported: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
67 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
68 |
# -v Do not truncate observed diffs in results |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
69 |
# -V Log *all* ELF sect diffs vs. logging the first diff found |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
70 |
# -t Use onbld tools in $SRC/tools |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
71 |
# -r Log results and observed differences |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
72 |
# -i Tell wsdiff which objects to compare via an input file list |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
73 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
74 |
import datetime, fnmatch, getopt, profile, os, popen2, commands |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
75 |
import re, select, string, struct, sys, tempfile, time |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
76 |
from stat import * |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
77 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
78 |
# Human readable diffs truncated by default if longer than this |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
79 |
# Specifying -v on the command line will override |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
80 |
diffs_sz_thresh = 4096 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
81 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
82 |
# Default search path for wsdiff |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
83 |
wsdiff_path = [ "/usr/bin", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
84 |
"/usr/ccs/bin", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
85 |
"/lib/svc/bin", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
86 |
"/opt/onbld/bin" ] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
87 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
88 |
# These are objects that wsdiff will notice look different, but will not report. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
89 |
# Existence of an exceptions list, and adding things here is *dangerous*, |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
90 |
# and therefore the *only* reasons why anything would be listed here is because |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
91 |
# the objects do not build deterministically, yet we *cannot* fix this. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
92 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
93 |
# These perl libraries use __DATE__ and therefore always look different. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
94 |
# Ideally, we would purge use the use of __DATE__ from the source, but because |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
95 |
# this is source we wish to distribute with Solaris "unchanged", we cannot modify. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
96 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
97 |
wsdiff_exceptions = [ "usr/perl5/5.8.4/lib/sun4-solaris-64int/CORE/libperl.so.1", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
98 |
"usr/perl5/5.6.1/lib/sun4-solaris-64int/CORE/libperl.so.1", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
99 |
"usr/perl5/5.8.4/lib/i86pc-solaris-64int/CORE/libperl.so.1", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
100 |
"usr/perl5/5.6.1/lib/i86pc-solaris-64int/CORE/libperl.so.1" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
101 |
] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
102 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
103 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
104 |
# Logging routines |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
105 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
106 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
107 |
# Informational message to be printed to the screen, and the log file |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
108 |
def info(msg) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
109 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
110 |
print >> sys.stdout, msg |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
111 |
if logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
112 |
print >> log, msg |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
113 |
sys.stdout.flush() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
114 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
115 |
# Error message to be printed to the screen, and the log file |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
116 |
def error(msg) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
117 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
118 |
print >> sys.stderr, "ERROR:", msg |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
119 |
sys.stderr.flush() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
120 |
if logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
121 |
print >> log, "ERROR:", msg |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
122 |
log.flush() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
123 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
124 |
# Informational message to be printed only to the log, if there is one. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
125 |
def v_info(msg) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
126 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
127 |
if logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
128 |
print >> log, msg |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
129 |
log.flush() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
130 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
131 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
132 |
# Flag a detected file difference |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
133 |
# Display the fileName to stdout, and log the difference |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
134 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
135 |
def difference(f, dtype, diffs) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
136 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
137 |
if f in wsdiff_exceptions : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
138 |
return |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
139 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
140 |
print >> sys.stdout, f |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
141 |
sys.stdout.flush() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
142 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
143 |
log_difference(f, dtype, diffs) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
144 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
145 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
146 |
# Do the actual logging of the difference to the results file |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
147 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
148 |
def log_difference(f, dtype, diffs) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
149 |
if logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
150 |
print >> log, f |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
151 |
print >> log, "NOTE:", dtype, "difference detected." |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
152 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
153 |
difflen = len(diffs) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
154 |
if difflen > 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
155 |
print >> log |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
156 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
157 |
if not vdiffs and difflen > diffs_sz_thresh : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
158 |
print >> log, diffs[:diffs_sz_thresh] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
159 |
print >> log, \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
160 |
"... truncated due to length: " \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
161 |
"use -v to override ..." |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
162 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
163 |
print >> log, diffs |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
164 |
print >> log, "\n" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
165 |
log.flush() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
166 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
167 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
168 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
169 |
# diff generating routines |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
170 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
171 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
172 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
173 |
# Return human readable diffs from two temporary files |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
174 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
175 |
def diffFileData(tmpf1, tmpf2) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
176 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
177 |
# Filter the data through od(1) if the data is detected |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
178 |
# as being binary |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
179 |
if isBinary(tmpf1) or isBinary(tmpf2) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
180 |
tmp_od1 = tmpf1 + ".od" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
181 |
tmp_od2 = tmpf2 + ".od" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
182 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
183 |
cmd = od_cmd + " -c -t x4" + " " + tmpf1 + " > " + tmp_od1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
184 |
os.system(cmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
185 |
cmd = od_cmd + " -c -t x4" + " " + tmpf2 + " > " + tmp_od2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
186 |
os.system(cmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
187 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
188 |
tmpf1 = tmp_od1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
189 |
tmpf2 = tmp_od2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
190 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
191 |
data = commands.getoutput(diff_cmd + " " + tmpf1 + " " + tmpf2) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
192 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
193 |
return data |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
194 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
195 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
196 |
# Return human readable diffs betweeen two datasets |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
197 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
198 |
def diffData(d1, d2) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
199 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
200 |
global tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
201 |
global tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
202 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
203 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
204 |
fd1 = open(tmpFile1, "w") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
205 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
206 |
error("failed to open: " + tmpFile1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
207 |
cleanup(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
208 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
209 |
fd2 = open(tmpFile2, "w") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
210 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
211 |
error("failed to open: " + tmpFile2) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
212 |
cleanup(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
213 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
214 |
fd1.write(d1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
215 |
fd2.write(d2) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
216 |
fd1.close() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
217 |
fd2.close() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
218 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
219 |
return diffFileData(tmpFile1, tmpFile2) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
220 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
221 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
222 |
# Misc utility functions |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
223 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
224 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
225 |
# Prune off the leading prefix from string s |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
226 |
def str_prefix_trunc(s, prefix) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
227 |
snipLen = len(prefix) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
228 |
return s[snipLen:] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
229 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
230 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
231 |
# Prune off leading proto path goo (if there is one) to yield |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
232 |
# the deliverable's eventual path relative to root |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
233 |
# e.g. proto.base/root_sparc/usr/src/cmd/prstat => usr/src/cmd/prstat |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
234 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
235 |
def fnFormat(fn) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
236 |
root_arch_str = "root_" + arch |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
237 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
238 |
pos = fn.find(root_arch_str) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
239 |
if pos == -1 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
240 |
return fn |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
241 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
242 |
pos = fn.find("/", pos) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
243 |
if pos == -1 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
244 |
return fn |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
245 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
246 |
return fn[pos + 1:] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
247 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
248 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
249 |
# Usage / argument processing |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
250 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
251 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
252 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
253 |
# Display usage message |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
254 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
255 |
def usage() : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
256 |
sys.stdout.flush() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
257 |
print >> sys.stderr, """Usage: wsdiff [-vVt] [-r results ] [-i filelist ] old new |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
258 |
-v Do not truncate observed diffs in results |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
259 |
-V Log *all* ELF sect diffs vs. logging the first diff found |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
260 |
-t Use onbld tools in $SRC/tools |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
261 |
-r Log results and observed differences |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
262 |
-i Tell wsdiff which objects to compare via an input file list""" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
263 |
sys.exit(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
264 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
265 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
266 |
# Process command line options |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
267 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
268 |
def args() : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
269 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
270 |
global logging |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
271 |
global vdiffs |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
272 |
global reportAllSects |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
273 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
274 |
validOpts = 'i:r:vVt?' |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
275 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
276 |
baseRoot = "" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
277 |
ptchRoot = "" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
278 |
fileNamesFile = "" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
279 |
results = "" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
280 |
localTools = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
281 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
282 |
# getopt.getopt() returns: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
283 |
# an option/value tuple |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
284 |
# a list of remaining non-option arguments |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
285 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
286 |
# A correct wsdiff invocation will have exactly two non option |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
287 |
# arguments, the paths to the base (old), ptch (new) proto areas |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
288 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
289 |
optlist, args = getopt.getopt(sys.argv[1:], validOpts) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
290 |
except getopt.error, val: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
291 |
usage() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
292 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
293 |
if len(args) != 2 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
294 |
usage(); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
295 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
296 |
for opt,val in optlist : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
297 |
if opt == '-i' : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
298 |
fileNamesFile = val |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
299 |
elif opt == '-r' : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
300 |
results = val |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
301 |
logging = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
302 |
elif opt == '-v' : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
303 |
vdiffs = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
304 |
elif opt == '-V' : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
305 |
reportAllSects = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
306 |
elif opt == '-t': |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
307 |
localTools = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
308 |
else: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
309 |
usage() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
310 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
311 |
baseRoot = args[0] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
312 |
ptchRoot = args[1] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
313 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
314 |
if len(baseRoot) == 0 or len(ptchRoot) == 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
315 |
usage() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
316 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
317 |
if logging and len(results) == 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
318 |
usage() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
319 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
320 |
if vdiffs and not logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
321 |
error("The -v option requires a results file (-r)") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
322 |
sys.exit(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
323 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
324 |
if reportAllSects and not logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
325 |
error("The -V option requires a results file (-r)") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
326 |
sys.exit(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
327 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
328 |
# alphabetical order |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
329 |
return baseRoot, fileNamesFile, localTools, ptchRoot, results |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
330 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
331 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
332 |
# File identification |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
333 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
334 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
335 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
336 |
# Identify the file type. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
337 |
# If it's not ELF, use the file extension to identify |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
338 |
# certain file types that require special handling to |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
339 |
# compare. Otherwise just return a basic "ASCII" type. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
340 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
341 |
def getTheFileType(f) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
342 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
343 |
extensions = { 'a' : 'ELF Object Archive', |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
344 |
'jar' : 'Java Archive', |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
345 |
'html' : 'HTML', |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
346 |
'ln' : 'Lint Library', |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
347 |
'db' : 'Sqlite Database' } |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
348 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
349 |
if os.stat(f)[ST_SIZE] == 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
350 |
return 'ASCII' |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
351 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
352 |
if isELF(f) == 1 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
353 |
return 'ELF' |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
354 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
355 |
fnamelist = f.split('.') |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
356 |
if len(fnamelist) > 1 : # Test the file extension |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
357 |
extension = fnamelist[-1] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
358 |
if extension in extensions.keys(): |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
359 |
return extensions[extension] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
360 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
361 |
return 'ASCII' |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
362 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
363 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
364 |
# Return non-zero if "f" is an ELF file |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
365 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
366 |
elfmagic = '\177ELF' |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
367 |
def isELF(f) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
368 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
369 |
fd = open(f) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
370 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
371 |
error("failed to open: " + f) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
372 |
return 0 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
373 |
magic = fd.read(len(elfmagic)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
374 |
fd.close() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
375 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
376 |
if magic == elfmagic : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
377 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
378 |
return 0 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
379 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
380 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
381 |
# Return non-zero is "f" is binary. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
382 |
# Consider the file to be binary if it contains any null characters |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
383 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
384 |
def isBinary(f) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
385 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
386 |
fd = open(f) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
387 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
388 |
error("failed to open: " + f) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
389 |
return 0 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
390 |
s = fd.read() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
391 |
fd.close() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
392 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
393 |
if s.find('\0') == -1 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
394 |
return 0 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
395 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
396 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
397 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
398 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
399 |
# Directory traversal and file finding |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
400 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
401 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
402 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
403 |
# Return a sorted list of files found under the specified directory |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
404 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
405 |
def findFiles(d) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
406 |
for path, subdirs, files in os.walk(d) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
407 |
files.sort() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
408 |
for name in files : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
409 |
yield os.path.join(path, name) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
410 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
411 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
412 |
# Examine all files in base, ptch |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
413 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
414 |
# Return a list of files appearing in both proto areas, |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
415 |
# a list of new files (files found only in ptch) and |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
416 |
# a list of deleted files (files found only in base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
417 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
418 |
def protoCatalog(base, ptch) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
419 |
compFiles = [] # List of files in both proto areas |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
420 |
ptchList = [] # List of file in patch proto area |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
421 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
422 |
newFiles = [] # New files detected |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
423 |
deletedFiles = [] # Deleted files |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
424 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
425 |
baseFilesList = list(findFiles(base)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
426 |
baseStringLength = len(base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
427 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
428 |
ptchFilesList = list(findFiles(ptch)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
429 |
ptchStringLength = len(ptch) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
430 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
431 |
# Inventory files in the base proto area |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
432 |
for fn in baseFilesList : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
433 |
if os.path.islink(fn) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
434 |
continue |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
435 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
436 |
fileName = fn[baseStringLength:] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
437 |
compFiles.append(fileName) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
438 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
439 |
# Inventory files in the patch proto area |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
440 |
for fn in ptchFilesList : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
441 |
if os.path.islink(fn) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
442 |
continue |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
443 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
444 |
fileName = fn[ptchStringLength:] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
445 |
ptchList.append(fileName) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
446 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
447 |
# Deleted files appear in the base area, but not the patch area |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
448 |
for fileName in compFiles : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
449 |
if not fileName in ptchList : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
450 |
deletedFiles.append(fileName) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
451 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
452 |
# Eliminate "deleted" files from the list of objects appearing |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
453 |
# in both the base and patch proto areas |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
454 |
for fileName in deletedFiles : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
455 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
456 |
compFiles.remove(fileName) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
457 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
458 |
error("filelist.remove() failed") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
459 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
460 |
# New files appear in the patch area, but not the base |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
461 |
for fileName in ptchList : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
462 |
if not fileName in compFiles : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
463 |
newFiles.append(fileName) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
464 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
465 |
return compFiles, newFiles, deletedFiles |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
466 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
467 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
468 |
# Examine the files listed in the input file list |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
469 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
470 |
# Return a list of files appearing in both proto areas, |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
471 |
# a list of new files (files found only in ptch) and |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
472 |
# a list of deleted files (files found only in base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
473 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
474 |
def flistCatalog(base, ptch, flist) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
475 |
compFiles = [] # List of files in both proto areas |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
476 |
newFiles = [] # New files detected |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
477 |
deletedFiles = [] # Deleted files |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
478 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
479 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
480 |
fd = open(flist, "r") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
481 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
482 |
error("could not open: " + flist) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
483 |
cleanup(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
484 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
485 |
files = [] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
486 |
files = fd.readlines() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
487 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
488 |
for f in files : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
489 |
ptch_present = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
490 |
base_present = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
491 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
492 |
if f == '\n' : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
493 |
continue |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
494 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
495 |
# the fileNames have a trailing '\n' |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
496 |
f = f.rstrip() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
497 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
498 |
# The objects in the file list have paths relative |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
499 |
# to $ROOT or to the base/ptch directory specified on |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
500 |
# the command line. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
501 |
# If it's relative to $ROOT, we'll need to add back the |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
502 |
# root_`uname -p` goo we stripped off in fnFormat() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
503 |
if os.path.exists(base + f) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
504 |
fn = f; |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
505 |
elif os.path.exists(base + "root_" + arch + "/" + f) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
506 |
fn = "root_" + arch + "/" + f |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
507 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
508 |
base_present = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
509 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
510 |
if base_present : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
511 |
if not os.path.exists(ptch + fn) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
512 |
ptch_present = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
513 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
514 |
if os.path.exists(ptch + f) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
515 |
fn = f |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
516 |
elif os.path.exists(ptch + "root_" + arch + "/" + f) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
517 |
fn = "root_" + arch + "/" + f |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
518 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
519 |
ptch_present = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
520 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
521 |
if os.path.islink(base + fn) : # ignore links |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
522 |
base_present = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
523 |
if os.path.islink(ptch + fn) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
524 |
ptch_present = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
525 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
526 |
if base_present and ptch_present : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
527 |
compFiles.append(fn) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
528 |
elif base_present : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
529 |
deletedFiles.append(fn) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
530 |
elif ptch_present : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
531 |
newFiles.append(fn) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
532 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
533 |
if os.path.islink(base + fn) and os.path.islink(ptch + fn) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
534 |
continue |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
535 |
error(f + " in file list, but not in either tree. Skipping...") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
536 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
537 |
return compFiles, newFiles, deletedFiles |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
538 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
539 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
540 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
541 |
# Build a fully qualified path to an external tool/utility. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
542 |
# Consider the default system locations. For onbld tools, if |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
543 |
# the -t option was specified, we'll try to use built tools in $SRC tools, |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
544 |
# and otherwise, we'll fall back on /opt/onbld/ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
545 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
546 |
def find_tool(tool) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
547 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
548 |
# First, check what was passed |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
549 |
if os.path.exists(tool) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
550 |
return tool |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
551 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
552 |
# Next try in wsdiff path |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
553 |
for pdir in wsdiff_path : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
554 |
location = pdir + "/" + tool |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
555 |
if os.path.exists(location) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
556 |
return location + " " |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
557 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
558 |
location = pdir + "/" + arch + "/" + tool |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
559 |
if os.path.exists(location) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
560 |
return location + " " |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
561 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
562 |
error("Could not find path to: " + tool); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
563 |
sys.exit(1); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
564 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
565 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
566 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
567 |
# ELF file comparison helper routines |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
568 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
569 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
570 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
571 |
# Return a dictionary of ELF section types keyed by section name |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
572 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
573 |
def get_elfheader(f) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
574 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
575 |
header = {} |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
576 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
577 |
hstring = commands.getoutput(elfdump_cmd + " -c " + f) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
578 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
579 |
if len(hstring) == 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
580 |
error("Failed to dump ELF header for " + f) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
581 |
return |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
582 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
583 |
# elfdump(1) dumps the section headers with the section name |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
584 |
# following "sh_name:", and the section type following "sh_type:" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
585 |
sections = hstring.split("Section Header") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
586 |
for sect in sections : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
587 |
datap = sect.find("sh_name:"); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
588 |
if datap == -1 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
589 |
continue |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
590 |
section = sect[datap:].split()[1] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
591 |
datap = sect.find("sh_type:"); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
592 |
if datap == -1 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
593 |
error("Could not get type for sect: " + section + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
594 |
" in " + f) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
595 |
sh_type = sect[datap:].split()[2] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
596 |
header[section] = sh_type |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
597 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
598 |
return header |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
599 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
600 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
601 |
# Extract data in the specified ELF section from the given file |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
602 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
603 |
def extract_elf_section(f, section) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
604 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
605 |
data = commands.getoutput(dump_cmd + " -sn " + section + " " + f) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
606 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
607 |
if len(data) == 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
608 |
error(cmd + " yielded no data") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
609 |
return |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
610 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
611 |
# dump(1) displays the file name to start... |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
612 |
# get past it to the data itself |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
613 |
dbegin = data.find(":") + 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
614 |
data = data[dbegin:]; |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
615 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
616 |
return (data) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
617 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
618 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
619 |
# Return a (hopefully meaningful) human readable set of diffs |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
620 |
# for the specified ELF section between f1 and f2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
621 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
622 |
# Depending on the section, various means for dumping and diffing |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
623 |
# the data may be employed. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
624 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
625 |
text_sections = [ '.text', '.init', '.fini' ] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
626 |
def diff_elf_section(f1, f2, section, sh_type) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
627 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
628 |
if (sh_type == "SHT_RELA") : # sh_type == SHT_RELA |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
629 |
cmd1 = elfdump_cmd + " -r " + f1 + " > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
630 |
cmd2 = elfdump_cmd + " -r " + f2 + " > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
631 |
elif (section == ".group") : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
632 |
cmd1 = elfdump_cmd + " -g " + f1 + " > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
633 |
cmd2 = elfdump_cmd + " -g " + f2 + " > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
634 |
elif (section == ".hash") : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
635 |
cmd1 = elfdump_cmd + " -h " + f1 + " > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
636 |
cmd2 = elfdump_cmd + " -h " + f2 + " > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
637 |
elif (section == ".dynamic") : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
638 |
cmd1 = elfdump_cmd + " -d " + f1 + " > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
639 |
cmd2 = elfdump_cmd + " -d " + f2 + " > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
640 |
elif (section == ".got") : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
641 |
cmd1 = elfdump_cmd + " -G " + f1 + " > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
642 |
cmd2 = elfdump_cmd + " -G " + f2 + " > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
643 |
elif (section == ".SUNW_cap") : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
644 |
cmd1 = elfdump_cmd + " -H " + f1 + " > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
645 |
cmd2 = elfdump_cmd + " -H " + f2 + " > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
646 |
elif (section == ".interp") : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
647 |
cmd1 = elfdump_cmd + " -i " + f1 + " > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
648 |
cmd2 = elfdump_cmd + " -i " + f2 + " > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
649 |
elif (section == ".symtab" or section == ".dynsym") : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
650 |
cmd1 = elfdump_cmd + " -s -N " + section + " " + f1 + " > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
651 |
cmd2 = elfdump_cmd + " -s -N " + section + " " + f2 + " > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
652 |
elif (section in text_sections) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
653 |
# dis sometimes complains when it hits something it doesn't |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
654 |
# know how to disassemble. Just ignore it, as the output |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
655 |
# being generated here is human readable, and we've already |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
656 |
# correctly flagged the difference. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
657 |
cmd1 = dis_cmd + " -t " + section + " " + f1 + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
658 |
" 2>/dev/null | grep -v disassembly > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
659 |
cmd2 = dis_cmd + " -t " + section + " " + f2 + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
660 |
" 2>/dev/null | grep -v disassembly > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
661 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
662 |
cmd1 = elfdump_cmd + " -w " + tmpFile1 + " -N " + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
663 |
section + " " + f1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
664 |
cmd2 = elfdump_cmd + " -w " + tmpFile2 + " -N " + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
665 |
section + " " + f2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
666 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
667 |
os.system(cmd1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
668 |
os.system(cmd2) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
669 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
670 |
data = diffFileData(tmpFile1, tmpFile2) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
671 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
672 |
return (data) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
673 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
674 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
675 |
# compare the relevant sections of two ELF binaries |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
676 |
# and report any differences |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
677 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
678 |
# Returns: 1 if any differenes found |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
679 |
# 0 if no differences found |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
680 |
# -1 on error |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
681 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
682 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
683 |
# Sections deliberately not considered when comparing two ELF |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
684 |
# binaries. Differences observed in these sections are not considered |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
685 |
# significant where patch deliverable identification is concerned. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
686 |
sections_to_skip = [ ".SUNW_signature", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
687 |
".comment", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
688 |
".SUNW_ctf", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
689 |
".debug", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
690 |
".plt", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
691 |
".rela.bss", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
692 |
".rela.plt", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
693 |
".line", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
694 |
".note", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
695 |
] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
696 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
697 |
sections_preferred = [ ".rodata.str1.8", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
698 |
".rodata.str1.1", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
699 |
".rodata", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
700 |
".data1", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
701 |
".data", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
702 |
".text", |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
703 |
] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
704 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
705 |
def compareElfs(base, ptch, quiet) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
706 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
707 |
global logging |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
708 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
709 |
base_header = get_elfheader(base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
710 |
sections = base_header.keys() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
711 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
712 |
ptch_header = get_elfheader(ptch) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
713 |
e2_only_sections = ptch_header.keys() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
714 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
715 |
e1_only_sections = [] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
716 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
717 |
fileName = fnFormat(base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
718 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
719 |
# Derive the list of ELF sections found only in |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
720 |
# either e1 or e2. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
721 |
for sect in sections : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
722 |
if not sect in e2_only_sections : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
723 |
e1_only_sections.append(sect) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
724 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
725 |
e2_only_sections.remove(sect) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
726 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
727 |
if len(e1_only_sections) > 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
728 |
if quiet : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
729 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
730 |
info(fileName); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
731 |
if not logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
732 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
733 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
734 |
slist = "" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
735 |
for sect in e1_only_sections : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
736 |
slist = slist + sect + "\t" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
737 |
v_info("\nELF sections found in " + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
738 |
base + " but not in " + ptch) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
739 |
v_info("\n" + slist) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
740 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
741 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
742 |
if len(e2_only_sections) > 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
743 |
if quiet : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
744 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
745 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
746 |
info(fileName); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
747 |
if not logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
748 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
749 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
750 |
slist = "" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
751 |
for sect in e2_only_sections : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
752 |
slist = slist + sect + "\t" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
753 |
v_info("\nELF sections found in " + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
754 |
ptch + " but not in " + base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
755 |
v_info("\n" + slist) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
756 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
757 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
758 |
# Look for preferred sections, and put those at the |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
759 |
# top of the list of sections to compare |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
760 |
for psect in sections_preferred : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
761 |
if psect in sections : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
762 |
sections.remove(psect) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
763 |
sections.insert(0, psect) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
764 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
765 |
# Compare ELF sections |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
766 |
first_section = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
767 |
for sect in sections : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
768 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
769 |
if sect in sections_to_skip : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
770 |
continue |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
771 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
772 |
s1 = extract_elf_section(base, sect); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
773 |
s2 = extract_elf_section(ptch, sect); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
774 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
775 |
if len(s1) != len (s2) or s1 != s2: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
776 |
if not quiet: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
777 |
sh_type = base_header[sect] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
778 |
data = diff_elf_section(base, ptch, sect, \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
779 |
sh_type) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
780 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
781 |
# If all ELF sections are being reported, then |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
782 |
# invoke difference() to flag the file name to |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
783 |
# stdout only once. Any other section differences |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
784 |
# should be logged to the results file directly |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
785 |
if not first_section : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
786 |
log_difference(fileName, "ELF " + sect, data) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
787 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
788 |
difference(fileName, "ELF " + sect, data) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
789 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
790 |
if not reportAllSects : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
791 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
792 |
first_section = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
793 |
return 0 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
794 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
795 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
796 |
# Archive object comparison |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
797 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
798 |
# Returns 1 if difference detected |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
799 |
# 0 if no difference detected |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
800 |
# -1 on error |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
801 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
802 |
def compareArchives(base, ptch, fileType) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
803 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
804 |
fileName = fnFormat(base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
805 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
806 |
# clear the temp directories |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
807 |
baseCmd = "rm -rf " + tmpDir1 + "*" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
808 |
status, output = commands.getstatusoutput(baseCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
809 |
if status != 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
810 |
error(baseCmd + " failed: " + output) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
811 |
return -1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
812 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
813 |
ptchCmd = "rm -rf " + tmpDir2 + "*" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
814 |
status, output = commands.getstatusoutput(ptchCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
815 |
if status != 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
816 |
error(ptchCmd + " failed: " + output) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
817 |
return -1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
818 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
819 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
820 |
# Be optimistic and first try a straight file compare |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
821 |
# as it will allow us to finish up quickly. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
822 |
if compareBasic(base, ptch, True, fileType) == 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
823 |
return 0 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
824 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
825 |
# copy over the objects to the temp areas, and |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
826 |
# unpack them |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
827 |
baseCmd = "cp -fp " + base + " " + tmpDir1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
828 |
status, output = commands.getstatusoutput(baseCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
829 |
if status != 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
830 |
error(baseCmd + " failed: " + output) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
831 |
return -1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
832 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
833 |
ptchCmd = "cp -fp " + ptch + " " + tmpDir2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
834 |
status, output = commands.getstatusoutput(ptchCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
835 |
if status != 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
836 |
error(ptchCmd + " failed: " + output) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
837 |
return -1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
838 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
839 |
bname = string.split(fileName, '/')[-1] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
840 |
if fileType == "Java Archive" : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
841 |
baseCmd = "cd " + tmpDir1 + "; " + "jar xf " + bname + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
842 |
"; rm -f " + bname + " META-INF/MANIFEST.MF" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
843 |
ptchCmd = "cd " + tmpDir2 + "; " + "jar xf " + bname + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
844 |
"; rm -f " + bname + " META-INF/MANIFEST.MF" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
845 |
elif fileType == "ELF Object Archive" : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
846 |
baseCmd = "cd " + tmpDir1 + "; " + "/usr/ccs/bin/ar x " + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
847 |
bname + "; rm -f " + bname |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
848 |
ptchCmd = "cd " + tmpDir2 + "; " + "/usr/ccs/bin/ar x " + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
849 |
bname + "; rm -f " + bname |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
850 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
851 |
error("unexpected file type: " + fileType) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
852 |
return -1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
853 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
854 |
os.system(baseCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
855 |
os.system(ptchCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
856 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
857 |
baseFlist = list(findFiles(tmpDir1)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
858 |
ptchFlist = list(findFiles(tmpDir2)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
859 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
860 |
# Trim leading path off base/ptch file lists |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
861 |
flist = [] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
862 |
for fn in baseFlist : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
863 |
flist.append(str_prefix_trunc(fn, tmpDir1)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
864 |
baseFlist = flist |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
865 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
866 |
flist = [] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
867 |
for fn in ptchFlist : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
868 |
flist.append(str_prefix_trunc(fn, tmpDir2)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
869 |
ptchFlist = flist |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
870 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
871 |
for fn in ptchFlist : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
872 |
if not fn in baseFlist : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
873 |
difference(fileName, fileType, \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
874 |
fn + " added to " + fileName) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
875 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
876 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
877 |
for fn in baseFlist : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
878 |
if not fn in ptchFlist : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
879 |
difference(fileName, fileType, \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
880 |
fn + " removed from " + fileName) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
881 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
882 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
883 |
differs = compareOneFile((tmpDir1 + fn), (tmpDir2 + fn), True) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
884 |
if differs : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
885 |
difference(fileName, fileType, \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
886 |
fn + " in " + fileName + " differs") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
887 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
888 |
return 0 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
889 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
890 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
891 |
# (Basic) file comparison |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
892 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
893 |
# There's some special case code here for Javadoc HTML files |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
894 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
895 |
# Returns 1 if difference detected |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
896 |
# 0 if no difference detected |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
897 |
# -1 on error |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
898 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
899 |
def compareBasic(base, ptch, quiet, fileType) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
900 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
901 |
fileName = fnFormat(base); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
902 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
903 |
if quiet and os.stat(base)[ST_SIZE] != os.stat(ptch)[ST_SIZE] : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
904 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
905 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
906 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
907 |
baseFile = open(base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
908 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
909 |
error("could not open " + base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
910 |
return -1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
911 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
912 |
ptchFile = open(ptch) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
913 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
914 |
error("could not open " + ptch) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
915 |
return -1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
916 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
917 |
baseData = baseFile.read() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
918 |
ptchData = ptchFile.read() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
919 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
920 |
baseFile.close() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
921 |
ptchFile.close() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
922 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
923 |
needToSnip = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
924 |
if fileType == "HTML" : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
925 |
needToSnip = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
926 |
toSnipBeginStr = "<!-- Generated by javadoc" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
927 |
toSnipEndStr = "-->\n" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
928 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
929 |
if needToSnip : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
930 |
toSnipBegin = string.find(baseData, toSnipBeginStr) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
931 |
if toSnipBegin != -1 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
932 |
toSnipEnd = string.find(baseData[toSnipBegin:], \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
933 |
toSnipEndStr) + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
934 |
len(toSnipEndStr) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
935 |
baseData = baseData[:toSnipBegin] + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
936 |
baseData[toSnipBegin + toSnipEnd:] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
937 |
ptchData = ptchData[:toSnipBegin] + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
938 |
ptchData[toSnipBegin + toSnipEnd:] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
939 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
940 |
if quiet : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
941 |
if baseData != ptchData : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
942 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
943 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
944 |
if len(baseData) != len(ptchData) or baseData != ptchData : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
945 |
diffs = diffData(baseData, ptchData) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
946 |
difference(fileName, fileType, diffs) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
947 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
948 |
return 0 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
949 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
950 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
951 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
952 |
# Compare two objects by producing a data dump from |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
953 |
# each object, and then comparing the dump data |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
954 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
955 |
# Returns: 1 if a difference is detected |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
956 |
# 0 if no difference detected |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
957 |
# -1 upon error |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
958 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
959 |
def compareByDumping(base, ptch, quiet, fileType) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
960 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
961 |
fileName = fnFormat(base); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
962 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
963 |
if fileType == "Lint Library" : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
964 |
baseCmd = lintdump_cmd + " -ir " + base + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
965 |
" | grep -v LINTLIB:" + " > " + tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
966 |
ptchCmd = lintdump_cmd + " -ir " + ptch + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
967 |
" | grep -v LINTLIB:" + " > " + tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
968 |
elif fileType == "Sqlite Database" : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
969 |
baseCmd = "echo .dump | " + sqlite_cmd + base + " > " + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
970 |
tmpFile1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
971 |
ptchCmd = "echo .dump | " + sqlite_cmd + ptch + " > " + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
972 |
tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
973 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
974 |
os.system(baseCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
975 |
os.system(ptchCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
976 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
977 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
978 |
baseFile = open(tmpFile1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
979 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
980 |
error("could not open: " + tmpFile1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
981 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
982 |
ptchFile = open(tmpFile2) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
983 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
984 |
error("could not open: " + tmpFile2) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
985 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
986 |
baseData = baseFile.read() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
987 |
ptchData = ptchFile.read() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
988 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
989 |
baseFile.close() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
990 |
ptchFile.close() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
991 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
992 |
if len(baseData) != len(ptchData) or baseData != ptchData : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
993 |
if not quiet : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
994 |
data = diffFileData(tmpFile1, tmpFile2); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
995 |
difference(fileName, fileType, data) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
996 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
997 |
return 0 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
998 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
999 |
##### |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1000 |
# Compare two objects. Detect type changes. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1001 |
# Vector off to the appropriate type specific |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1002 |
# compare routine based on the type. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1003 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1004 |
def compareOneFile(base, ptch, quiet) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1005 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1006 |
# Verify the file types. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1007 |
# If they are different, indicate this and move on |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1008 |
btype = getTheFileType(base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1009 |
ptype = getTheFileType(ptch) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1010 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1011 |
fileName = fnFormat(base) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1012 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1013 |
if (btype != ptype) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1014 |
difference(fileName, "file type", btype + " to " + ptype) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1015 |
return 1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1016 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1017 |
fileType = btype |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1018 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1019 |
if (fileType == 'ELF') : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1020 |
return compareElfs(base, ptch, quiet) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1021 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1022 |
elif (fileType == 'Java Archive' or fileType == 'ELF Object Archive') : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1023 |
return compareArchives(base, ptch, fileType) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1024 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1025 |
elif (fileType == 'HTML') : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1026 |
return compareBasic(base, ptch, quiet, fileType) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1027 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1028 |
elif ( fileType == 'Lint Library' ) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1029 |
return compareByDumping(base, ptch, quiet, fileType) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1030 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1031 |
elif ( fileType == 'Sqlite Database' ) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1032 |
return compareByDumping(base, ptch, quiet, fileType) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1033 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1034 |
# it has to be some variety of text file |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1035 |
return compareBasic(base, ptch, quiet, fileType) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1036 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1037 |
# Cleanup and self-terminate |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1038 |
def cleanup(ret) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1039 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1040 |
if len(tmpDir1) > 0 and len(tmpDir2) > 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1041 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1042 |
baseCmd = "rm -rf " + tmpDir1 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1043 |
ptchCmd = "rm -rf " + tmpDir2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1044 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1045 |
os.system(baseCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1046 |
os.system(ptchCmd) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1047 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1048 |
if logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1049 |
log.close() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1050 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1051 |
sys.exit(ret) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1052 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1053 |
def main() : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1054 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1055 |
# Log file handle |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1056 |
global log |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1057 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1058 |
# Globals relating to command line options |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1059 |
global logging, vdiffs, reportAllSects |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1060 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1061 |
# Named temporary files / directories |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1062 |
global tmpDir1, tmpDir2, tmpFile1, tmpFile2 |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1063 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1064 |
# Command paths |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1065 |
global lintdump_cmd, elfdump_cmd, dump_cmd, dis_cmd, od_cmd, diff_cmd, sqlite_cmd |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1066 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1067 |
# Default search path |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1068 |
global wsdiff_path |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1069 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1070 |
# Essentially "uname -p" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1071 |
global arch |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1072 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1073 |
# Some globals need to be initialized |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1074 |
logging = vdiffs = reportAllSects = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1075 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1076 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1077 |
# Process command line arguments |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1078 |
# Return values are returned from args() in alpha order |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1079 |
# (Yes, python functions can return multiple values (ewww)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1080 |
# Note that args() also set the globals: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1081 |
# logging to True if verbose logging (to a file) was enabled |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1082 |
# vdiffs to True if logged differences aren't to be truncated |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1083 |
# reportAllSects to True if all ELF section differences are to be reported |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1084 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1085 |
baseRoot, fileNamesFile, localTools, ptchRoot, results = args() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1086 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1087 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1088 |
# Set up the results/log file |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1089 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1090 |
if logging : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1091 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1092 |
log = open(results, "w") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1093 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1094 |
logging = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1095 |
error("failed to open log file: " + log) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1096 |
sys.exit(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1097 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1098 |
dateTimeStr= "# %d/%d/%d at %d:%d:%d" % time.localtime()[:6] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1099 |
v_info("# This file was produced by wsdiff") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1100 |
v_info(dateTimeStr) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1101 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1102 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1103 |
# Build paths to the tools required tools |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1104 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1105 |
# Try to look for tools in $SRC/tools if the "-t" option |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1106 |
# was specified |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1107 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1108 |
arch = commands.getoutput("uname -p") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1109 |
if localTools : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1110 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1111 |
src = os.environ['SRC'] |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1112 |
except: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1113 |
error("-t specified, but $SRC not set. Cannot find $SRC/tools") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1114 |
src = "" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1115 |
if len(src) > 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1116 |
wsdiff_path.insert(0, src + "/tools/proto/opt/onbld/bin") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1117 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1118 |
lintdump_cmd = find_tool("lintdump") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1119 |
elfdump_cmd = find_tool("elfdump") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1120 |
dump_cmd = find_tool("dump") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1121 |
od_cmd = find_tool("od") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1122 |
dis_cmd = find_tool("dis") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1123 |
diff_cmd = find_tool("diff") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1124 |
sqlite_cmd = find_tool("sqlite") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1125 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1126 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1127 |
# validate the base and patch paths |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1128 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1129 |
if baseRoot[-1] != '/' : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1130 |
baseRoot += '/' |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1131 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1132 |
if ptchRoot[-1] != '/' : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1133 |
ptchRoot += '/' |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1134 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1135 |
if not os.path.exists(baseRoot) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1136 |
error("old proto area: " + baseRoot + " does not exist") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1137 |
sys.exit(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1138 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1139 |
if not os.path.exists(ptchRoot) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1140 |
error("new proto area: " + ptchRoot + \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1141 |
" does not exist") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1142 |
sys.exit(1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1143 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1144 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1145 |
# log some information identifying the run |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1146 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1147 |
v_info("Old proto area: " + baseRoot) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1148 |
v_info("New proto area: " + ptchRoot) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1149 |
v_info("Results file: " + results + "\n") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1150 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1151 |
# |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1152 |
# Set up the temporary directories / files |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1153 |
# Could use python's tmpdir routines, but these should |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1154 |
# be easier to identify / keep around for debugging |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1155 |
pid = os.getpid() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1156 |
tmpDir1 = "/tmp/wsdiff_tmp1_" + str(pid) + "/" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1157 |
tmpDir2 = "/tmp/wsdiff_tmp2_" + str(pid) + "/" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1158 |
if not os.path.exists(tmpDir1) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1159 |
os.makedirs(tmpDir1) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1160 |
if not os.path.exists(tmpDir2) : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1161 |
os.makedirs(tmpDir2) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1162 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1163 |
tmpFile1 = tmpDir1 + "f1" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1164 |
tmpFile2 = tmpDir2 + "f2" |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1165 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1166 |
# Derive a catalog of new, deleted, and to-be-compared objects |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1167 |
# either from the specified base and patch proto areas, or from |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1168 |
# from an input file list |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1169 |
newOrDeleted = False |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1170 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1171 |
if fileNamesFile != "" : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1172 |
changedFiles, newFiles, deletedFiles = \ |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1173 |
flistCatalog(baseRoot, ptchRoot, fileNamesFile) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1174 |
else : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1175 |
changedFiles, newFiles, deletedFiles = protoCatalog(baseRoot, ptchRoot) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1176 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1177 |
if len(newFiles) > 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1178 |
newOrDeleted = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1179 |
info("\nNew objects found: ") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1180 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1181 |
for fn in newFiles : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1182 |
info(fnFormat(fn)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1183 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1184 |
if len(deletedFiles) > 0 : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1185 |
newOrDeleted = True |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1186 |
info("\nObjects removed: ") |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1187 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1188 |
for fn in deletedFiles : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1189 |
info(fnFormat(fn)) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1190 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1191 |
if newOrDeleted : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1192 |
info("\nChanged objects: "); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1193 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1194 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1195 |
# Here's where all the heavy lifting happens |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1196 |
# Perform a comparison on each object appearing in |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1197 |
# both proto areas. compareOneFile will examine the |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1198 |
# file types of each object, and will vector off to |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1199 |
# the appropriate comparison routine, where the compare |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1200 |
# will happen, and any differences will be reported / logged |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1201 |
for fn in changedFiles : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1202 |
base = baseRoot + fn |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1203 |
ptch = ptchRoot + fn |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1204 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1205 |
compareOneFile(base, ptch, False) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1206 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1207 |
# We're done, cleanup. |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1208 |
cleanup(0) |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1209 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1210 |
if __name__ == '__main__' : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1211 |
try: |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1212 |
main() |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1213 |
except KeyboardInterrupt : |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1214 |
cleanup(1); |
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1215 |
|
b5894d78c55a
5016095 nightly should help determine what really changes from build to build
esaxe
parents:
diff
changeset
|
1216 |