Tue, 10 Apr 2012 08:18:28 -0700
7074397: Build infrastructure changes (makefile re-write)
Summary: New makefiles transition, old and new living side by side for now.
Reviewed-by: ohair, jjg, dholmes, ohrstrom, erikj, ihse, tgranat, ykantser
Contributed-by: ohrstrom <fredrik.ohrstrom@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>
1 #!/bin/bash
2 #
3 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 #
6 # This code is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License version 2 only, as
8 # published by the Free Software Foundation.
9 #
10 # This code is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # version 2 for more details (a copy is included in the LICENSE file that
14 # accompanied this code).
15 #
16 # You should have received a copy of the GNU General Public License version
17 # 2 along with this work; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 #
20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 # or visit www.oracle.com if you need additional information or have any
22 # questions.
23 #
25 # MANUAL
26 #
27 # ./common/bin/compareimages.sh old_jdk_image new_jdk_image
28 #
29 # Compare the directory structure.
30 # Compare the filenames in the directories.
31 # Compare the contents of the zip archives
32 # Compare the contents of the jar archives
33 # Compare the native libraries
34 # Compare the native executables
35 # Compare the remaining files
36 #
37 # ./common/bin/compareimages.sh old_jdk_image new_jdk_image [zips jars libs execs other]
38 #
39 # Compare only the selected subset of the images.
40 #
41 # ./common/bin/compareimages.sh old_jdk_image new_jdk_image CodePointIM.jar
42 #
43 # Compare only the CodePointIM.jar file
44 # Can be used to compare zips, libraries and executables.
45 #
47 if [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ] || [ "x$1" == "x" ]; then
48 echo "./common/bin/compareimages.sh old_jdk_image new_jdk_image"
49 echo ""
50 echo "Compare the directory structure."
51 echo "Compare the filenames in the directories."
52 echo "Compare the contents of the zip archives"
53 echo "Compare the contents of the jar archives"
54 echo "Compare the native libraries"
55 echo "Compare the native executables"
56 echo "Compare the remaining files"
57 echo ""
58 echo "./common/bin/compareimages.sh old_jdk_image new_jdk_image [zips jars libs execs other]"
59 echo ""
60 echo "Compare only the selected subset of the images."
61 echo ""
62 echo "./common/bin/compareimages.sh old_jdk_image new_jdk_image CodePointIM.jar"
63 echo ""
64 echo "Compare only the CodePointIM.jar file"
65 echo "Can be used to compare zips, libraries and executables."
66 exit 10
67 fi
69 OLD="$1"
70 NEW="$2"
71 CMD="$3"
73 DIFF_RESULT=0
75 CMP_ZIPS=false
76 CMP_JARS=false
77 CMP_LIBS=false
78 CMP_EXECS=false
79 CMP_OTHER=false
81 FILTER="cat"
83 if [ -n "$CMD" ]; then
84 case "$CMD" in
85 zips)
86 CMP_ZIPS=true
87 ;;
88 jars)
89 CMP_JARS=true
90 ;;
91 libs)
92 CMP_LIBS=true
93 ;;
94 execs)
95 CMP_EXECS=true
96 ;;
97 other)
98 CMP_OTHER=true
99 ;;
100 *)
101 CMP_ZIPS=true
102 CMP_JARS=true
103 CMP_LIBS=true
104 CMP_EXECS=true
105 CMP_OTHER=true
106 FILTER="grep $3"
107 ;;
108 esac
109 else
110 CMP_ZIPS=true
111 CMP_JARS=true
112 CMP_LIBS=true
113 CMP_EXECS=true
114 CMP_OTHER=true
115 fi
117 DIFFJARZIP=`dirname $0`/diffjarzip.sh
118 DIFFLIB=`dirname $0`/difflib.sh
119 DIFFEXEC=`dirname $0`/diffexec.sh
120 export COMPARE_ROOT=/tmp/cimages
121 mkdir -p $COMPARE_ROOT
123 # Load the correct exception list.
124 case "`uname -s`" in
125 Linux)
126 . `dirname $0`/exception_list_linux
127 ;;
128 esac
130 echo
131 echo Comparing $OLD to $NEW
132 echo
134 (cd $OLD && find . -type d | sort > $COMPARE_ROOT/from_dirs)
135 (cd $NEW && find . -type d | sort > $COMPARE_ROOT/to_dirs)
137 echo -n Directory structure...
138 if diff $COMPARE_ROOT/from_dirs $COMPARE_ROOT/to_dirs > /dev/null; then
139 echo Identical!
140 else
141 echo Differences found.
142 DIFF_RESULT=1
143 # Differences in directories found.
144 ONLY_OLD=$(diff $COMPARE_ROOT/from_dirs $COMPARE_ROOT/to_dirs | grep '<')
145 if [ "$ONLY_OLD" ]; then
146 echo Only in $OLD
147 echo $ONLY_OLD | sed 's|< ./|\t|g' | sed 's/ /\n/g'
148 fi
149 # Differences in directories found.
150 ONLY_NEW=$(diff $COMPARE_ROOT/from_dirs $COMPARE_ROOT/to_dirs | grep '>')
151 if [ "$ONLY_NEW" ]; then
152 echo Only in $NEW
153 echo $ONLY_NEW | sed 's|> ./|\t|g' | sed 's/ /\n/g'
154 fi
155 fi
157 (cd $OLD && find . -type f | sort > $COMPARE_ROOT/from_files)
158 (cd $NEW && find . -type f | sort > $COMPARE_ROOT/to_files)
160 echo -n File names...
161 if diff $COMPARE_ROOT/from_files $COMPARE_ROOT/to_files > /dev/null; then
162 echo Identical!
163 else
164 echo Differences found.
165 DIFF_RESULT=1
166 # Differences in directories found.
167 ONLY_OLD=$(diff $COMPARE_ROOT/from_files $COMPARE_ROOT/to_files | grep '<')
168 if [ "$ONLY_OLD" ]; then
169 echo Only in $OLD
170 echo $ONLY_OLD | sed 's|< ./|\t|g' | sed 's/ /\n/g'
171 fi
172 # Differences in directories found.
173 ONLY_NEW=$(diff $COMPARE_ROOT/from_files $COMPARE_ROOT/to_files | grep '>')
174 if [ "$ONLY_NEW" ]; then
175 echo Only in $NEW
176 echo $ONLY_NEW | sed 's|> ./|\t|g' | sed 's/ /\n/g'
177 fi
178 fi
180 if [ "x$CMP_ZIPS" == "xtrue" ]; then
181 ZIPS=$(cd $OLD && find . -type f -name "*.zip" | sort | $FILTER)
183 if [ -n "$ZIPS" ]; then
184 echo Zip files...
186 for f in $ZIPS
187 do
188 $DIFFJARZIP $OLD/$f $NEW/$f $OLD $NEW
189 if [ "$?" != "0" ]; then
190 DIFF_RESULT=1
191 fi
192 done
193 fi
194 fi
196 if [ "x$CMP_JARS" == "xtrue" ]; then
197 JARS=$(cd $OLD && find . -type f -name "*.jar" | sort | $FILTER)
199 if [ -n "$JARS" ]; then
200 echo Jar files...
202 for f in $JARS
203 do
204 DIFFJAR_OUTPUT=`$DIFFJARZIP $OLD/$f $NEW/$f $OLD $NEW`
205 DIFFJAR_RESULT=$?
206 if [ "$DIFFJAR_RESULT" != "0" ]; then
207 for diff in $LIST_DIFF_JAR; do
208 DIFFJAR_OUTPUT=`echo "$DIFFJAR_OUTPUT" | grep -v "$diff"`
209 done
210 if [ "`echo "$DIFFJAR_OUTPUT" | grep -v "Differing files in"`" != "" ]; then
211 DIFF_RESULT=1
212 echo "$DIFFJAR_OUTPUT"
213 fi
214 fi
215 done
216 fi
217 fi
219 if [ "x$FILTER" != "xcat" ]; then
220 VIEW=view
221 else
222 VIEW=
223 fi
225 if [ "x$CMP_LIBS" == "xtrue" ]; then
226 LIBS=$(cd $OLD && find . -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' | sort | $FILTER)
228 if [ -n "$LIBS" ]; then
229 echo Libraries...
230 for f in $LIBS
231 do
232 DIFFLIB_OUTPUT=`$DIFFLIB $OLD/$f $NEW/$f $OLD $NEW $VIEW`
233 DIFFLIB_RESULT=$?
234 if [ "$DIFFLIB_RESULT" = "0" ]; then
235 :
236 #echo "OK: $DIFFLIB_OUTPUT"
237 elif [ "$DIFFLIB_RESULT" = "2" ] && [[ "$LIST_DIFF_SIZE $LIST_DIFF_BYTE" == *"${f:2}"* ]]; then
238 :
239 #echo "OK: $DIFFLIB_OUTPUT"
240 elif [ "$DIFFLIB_RESULT" = "1" ] && [[ "$LIST_DIFF_BYTE" == *"${f:2}"* ]]; then
241 :
242 #echo "OK: $DIFFLIB_OUTPUT"
243 else
244 echo "$DIFFLIB_OUTPUT"
245 DIFF_RESULT=1
246 fi
247 done
248 fi
249 fi
251 if [ "x$CMP_EXECS" == "xtrue" ]; then
252 if [ $OSTYPE == "cygwin" ]; then
253 EXECS=$(cd $OLD && find . -type f -name '*.exe' | sort | $FILTER)
254 else
255 EXECS=$(cd $OLD && find . -type f -perm -100 \! \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' \) | sort | $FILTER)
256 fi
259 if [ -n "$EXECS" ]; then
260 echo Executables...
262 for f in $EXECS
263 do
264 DIFFEXEC_OUTPUT=`$DIFFEXEC $OLD/$f $NEW/$f $OLD $NEW $VIEW`
265 DIFFEXEC_RESULT=$?
266 if [ "$DIFFEXEC_RESULT" = "0" ]; then
267 :
268 #echo "OK: $DIFFEXEC_OUTPUT"
269 elif [ "$DIFFEXEC_RESULT" = "2" ] && [[ "$LIST_DIFF_SIZE $LIST_DIFF_BYTE" == *"${f:2}"* ]]; then
270 :
271 #echo "OK: $DIFFEXEC_OUTPUT"
272 elif [ "$DIFFEXEC_RESULT" = "1" ] && [[ "$LIST_DIFF_BYTE" == *"${f:2}"* ]]; then
273 :
274 #echo "OK: $DIFFEXEC_OUTPUT"
275 else
276 echo "$DIFFEXEC_OUTPUT"
277 DIFF_RESULT=1
278 fi
279 done
280 fi
281 fi
283 exit $DIFF_RESULT