Fri, 01 Feb 2013 11:22:41 +0100
Merge
1 #!/bin/bash
2 #
3 # Copyright (c) 2012, 2013 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 # This script is processed by configure before it's usable. It is run from
26 # the root of the build directory.
29 ##########################################################################################
31 # Check that we are run via the wrapper generated by configure
32 if [ -z "$SRC_ROOT" ]; then
33 echo "Error: You must run this script using build/[conf]/compare.sh"
34 exit 1
35 fi
37 if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
38 FULLDUMP_CMD="$OTOOL -v -V -h -X -t -d"
39 LDD_CMD="$OTOOL -L"
40 DIS_CMD="$OTOOL -v -t"
41 STAT_PRINT_SIZE="-f %z"
42 elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then
43 FULLDUMP_CMD="$DUMPBIN -all"
44 LDD_CMD="$DUMPBIN -dependants | $GREP .dll"
45 DIS_CMD="$DUMPBIN -disasm:nobytes"
46 STAT_PRINT_SIZE="-c %s"
47 else
48 FULLDUMP_CMD="$READELF -a"
49 LDD_CMD="$LDD"
50 DIS_CMD="$OBJDUMP -d"
51 STAT_PRINT_SIZE="-c %s"
52 fi
54 UNARCHIVE="$UNZIP -q"
56 COMPARE_EXCEPTIONS_INCLUDE="$SRC_ROOT/common/bin/compare_exceptions.sh.incl"
57 if [ ! -e "$COMPARE_EXCEPTIONS_INCLUDE" ]; then
58 echo "Error: Cannot locate the exceptions file, it should have been here: $COMPARE_EXCEPTIONS_INCLUDE"
59 exit 1
60 fi
61 # Include exception definitions
62 . "$COMPARE_EXCEPTIONS_INCLUDE"
64 ##########################################################################################
65 # Compare text files and ignore specific differences:
66 #
67 # * Timestamps in Java sources generated by idl2java
68 # * Sorting order and cleanup style in .properties files
70 diff_text() {
71 OTHER_FILE=$1
72 THIS_FILE=$2
74 SUFFIX="${THIS_FILE##*.}"
76 TMP=1
78 if [[ "$THIS_FILE" = *"META-INF/MANIFEST.MF" ]]; then
79 TMP=$(LANG=C $DIFF $OTHER_FILE $THIS_FILE | \
80 $GREP '^[<>]' | \
81 $SED -e '/[<>] Ant-Version: Apache Ant .*/d' \
82 -e '/[<>] Created-By: .* (Oracle Corporation).*/d')
83 fi
84 if test "x$SUFFIX" = "xjava"; then
85 TMP=$(LANG=C $DIFF $OTHER_FILE $THIS_FILE | \
86 $GREP '^[<>]' | \
87 $SED -e '/[<>] \* from.*\.idl/d' \
88 -e '/[<>] \*.*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
89 -e '/[<>] \*.*[0-9]\{4\} [0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \
90 -e '/\/\/ Generated from input file.*/d' \
91 -e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \
92 -e '/\/\/ java GenerateCharacter.*/d')
93 fi
94 # Ignore date strings in class files.
95 # On Macosx the system sources for generated java classes produce different output on
96 # consequtive invokations seemingly randomly.
97 # For example a method parameter randomly named "thePoint" or "aPoint". Ignore this.
98 if test "x$SUFFIX" = "xclass"; then
99 # To improve performance when large diffs are found, do a rough filtering of classes
100 # elibeble for these exceptions
101 if $GREP -R -e '[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}' \
102 -e '[0-9]\{2\}/[0-9]\{2\}/[0-9]\{4\}' \
103 -e thePoint -e aPoint -e setItemsPtr ${THIS_FILE} > /dev/null; then
104 $JAVAP -c -constants -l -p ${OTHER_FILE} > ${OTHER_FILE}.javap
105 $JAVAP -c -constants -l -p ${THIS_FILE} > ${THIS_FILE}.javap
106 TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \
107 $GREP '^[<>]' | \
108 $SED -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
109 -e '/[0-9]\{2\}\/[0-9]\{2\}\/[0-9]\{4\}/d' \
110 -e '/[<>].*Point Lcom\/apple\/jobjc\/foundation\/NSPoint;/d' \
111 -e '/[<>].*public com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*itemsPtr();/d' \
112 -e '/[<>].*public void setItemsPtr(com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*);/d')
113 fi
114 fi
115 if test "x$SUFFIX" = "xproperties"; then
116 # Run through nawk to add possibly missing newline at end of file.
117 $CAT $OTHER_FILE | $NAWK '{ print }' > $OTHER_FILE.cleaned
118 # Disable this exception since we aren't changing the properties cleaning method yet.
119 # $CAT $OTHER_FILE | $SED -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \
120 # | $SED -f "$SRC_ROOT/common/makefiles/support/unicode2x.sed" \
121 # | $SED -e '/^#/d' -e '/^$/d' \
122 # -e :a -e '/\\$/N; s/\\\n//; ta' \
123 # -e 's/^[ \t]*//;s/[ \t]*$//' \
124 # -e 's/\\=/=/' | LANG=C $SORT > $OTHER_FILE.cleaned
125 TMP=$(LANG=C $DIFF $OTHER_FILE.cleaned $THIS_FILE)
126 fi
127 if test -n "$TMP"; then
128 echo Files $OTHER_FILE and $THIS_FILE differ
129 return 1
130 fi
132 return 0
133 }
135 ##########################################################################################
136 # Compare directory structure
138 compare_dirs() {
139 THIS_DIR=$1
140 OTHER_DIR=$2
141 WORK_DIR=$3
143 mkdir -p $WORK_DIR
145 (cd $OTHER_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_other)
146 (cd $THIS_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_this)
148 $DIFF $WORK_DIR/dirs_other $WORK_DIR/dirs_other > $WORK_DIR/dirs_diff
150 echo -n Directory structure...
151 if [ -s $WORK_DIR/dirs_diff ]; then
152 echo Differences found.
153 REGRESSIONS=true
154 # Differences in directories found.
155 ONLY_OTHER=$($GREP '<' $WORK_DIR/dirs_diff)
156 if [ "$ONLY_OTHER" ]; then
157 echo Only in $OTHER
158 $GREP '<' $WORK_DIR/dirs_diff | $SED 's|< ./| |g'
159 fi
160 ONLY_THIS=$($GREP '>' $WORK_DIR/dirs_diff)
161 if [ "$ONLY_THIS" ]; then
162 echo Only in $THIS
163 $GREP '>' $WORK_DIR/dirs_diff | $SED 's|> ./| |g'
164 fi
165 else
166 echo Identical!
167 fi
168 }
171 ##########################################################################################
172 # Compare file structure
174 compare_files() {
175 THIS_DIR=$1
176 OTHER_DIR=$2
177 WORK_DIR=$3
179 $MKDIR -p $WORK_DIR
181 (cd $OTHER_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_other)
182 (cd $THIS_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_this)
184 $DIFF $WORK_DIR/files_other $WORK_DIR/files_this > $WORK_DIR/files_diff
186 echo -n File names...
187 if [ -s $WORK_DIR/files_diff ]; then
188 echo Differences found.
189 REGRESSIONS=true
190 # Differences in files found.
191 ONLY_OTHER=$($GREP '<' $WORK_DIR/files_diff)
192 if [ "$ONLY_OTHER" ]; then
193 echo Only in $OTHER
194 $GREP '<' $WORK_DIR/files_diff | $SED 's|< ./| |g'
195 fi
196 ONLY_THIS=$($GREP '>' $WORK_DIR/files_diff)
197 if [ "$ONLY_THIS" ]; then
198 echo Only in $THIS
199 $GREP '>' $WORK_DIR/files_diff | $SED 's|> ./| |g'
200 fi
201 else
202 echo Identical!
203 fi
204 }
207 ##########################################################################################
208 # Compare permissions
210 compare_permissions() {
211 THIS_DIR=$1
212 OTHER_DIR=$2
213 WORK_DIR=$3
215 mkdir -p $WORK_DIR
217 echo -n Permissions...
218 found=""
219 for f in `cd $OTHER_DIR && $FIND . -type f`
220 do
221 if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
222 if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
223 OP=`ls -l ${OTHER_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
224 TP=`ls -l ${THIS_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
225 if [ "$OP" != "$TP" ]
226 then
227 if [ -z "$found" ]; then echo ; found="yes"; fi
228 $PRINTF "\told: ${OP} new: ${TP}\t$f\n"
229 fi
230 done
231 if [ -z "$found" ]; then
232 echo "Identical!"
233 else
234 REGRESSIONS=true
235 fi
236 }
238 ##########################################################################################
239 # Compare file command output
241 compare_file_types() {
242 THIS_DIR=$1
243 OTHER_DIR=$2
244 WORK_DIR=$3
246 $MKDIR -p $WORK_DIR
248 echo -n File types...
249 found=""
250 for f in `cd $OTHER_DIR && $FIND . ! -type d`
251 do
252 if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
253 if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
254 OF=`cd ${OTHER_DIR} && $FILE -h $f`
255 TF=`cd ${THIS_DIR} && $FILE -h $f`
256 if [ "$f" = "./src.zip" ] || [[ "$f" = *"/Home/src.zip" ]] || [[ "$f" = *"/lib/JObjC.jar" ]]
257 then
258 if [ "`echo $OF | $GREP -ic zip`" -gt 0 -a "`echo $TF | $GREP -ic zip`" -gt 0 ]
259 then
260 # the way we produces zip-files make it so that directories are stored in old file
261 # but not in new (only files with full-path)
262 # this makes file-5.09 report them as different
263 continue;
264 fi
265 fi
267 if [ "$OF" != "$TF" ]
268 then
269 if [ -z "$found" ]; then echo ; found="yes"; fi
270 $PRINTF "\tother: ${OF}\n\tthis : ${TF}\n"
271 fi
272 done
273 if [ -z "$found" ]; then
274 echo "Identical!"
275 else
276 REGRESSIONS=true
277 fi
278 }
280 ##########################################################################################
281 # Compare the rest of the files
283 compare_general_files() {
284 THIS_DIR=$1
285 OTHER_DIR=$2
286 WORK_DIR=$3
288 GENERAL_FILES=$(cd $THIS_DIR && $FIND . -type f ! -name "*.so" ! -name "*.jar" ! -name "*.zip" \
289 ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \
290 ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \
291 ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \
292 ! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" \
293 | $GREP -v "./bin/" | $SORT | $FILTER)
295 echo General files...
296 for f in $GENERAL_FILES
297 do
298 if [ -e $OTHER_DIR/$f ]; then
299 SUFFIX="${f##*.}"
300 if [ "$(basename $f)" = "release" ]; then
301 # Ignore differences in change numbers in release file.
302 OTHER_FILE=$WORK_DIR/$f.other
303 THIS_FILE=$WORK_DIR/$f.this
304 $MKDIR -p $(dirname $OTHER_FILE)
305 $MKDIR -p $(dirname $THIS_FILE)
306 $CAT $OTHER_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $OTHER_FILE
307 $CAT $THIS_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $THIS_FILE
308 elif [ "x$SUFFIX" = "xhtml" ]; then
309 # Ignore time stamps in docs files
310 OTHER_FILE=$WORK_DIR/$f.other
311 THIS_FILE=$WORK_DIR/$f.this
312 $MKDIR -p $(dirname $OTHER_FILE)
313 $MKDIR -p $(dirname $THIS_FILE)
314 #Note that | doesn't work on mac sed.
315 $CAT $OTHER_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
316 -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \
317 -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/(removed)/' \
318 -e 's/[A-Z][a-z]* [A-Z][a-z]* [0-9][0-9] [0-9][0-9:]* [A-Z][A-Z]* [12][0-9]*/(removed)/' \
319 -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \
320 > $OTHER_FILE
321 $CAT $THIS_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
322 -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \
323 -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/(removed)/' \
324 -e 's/[A-Z][a-z]* [A-Z][a-z]* [0-9][0-9] [0-9][0-9:]* [A-Z][A-Z]* [12][0-9]*/(removed)/' \
325 -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \
326 > $THIS_FILE
327 else
328 OTHER_FILE=$OTHER_DIR/$f
329 THIS_FILE=$THIS_DIR/$f
330 fi
331 DIFF_OUT=$($DIFF $OTHER_FILE $THIS_FILE 2>&1)
332 if [ -n "$DIFF_OUT" ]; then
333 echo $f
334 REGRESSIONS=true
335 if [ "$SHOW_DIFFS" = "true" ]; then
336 echo "$DIFF_OUT"
337 fi
338 fi
339 fi
340 done
343 }
345 ##########################################################################################
346 # Compare zip file
348 compare_zip_file() {
349 THIS_DIR=$1
350 OTHER_DIR=$2
351 WORK_DIR=$3
352 ZIP_FILE=$4
353 # Optionally provide different name for other zipfile
354 OTHER_ZIP_FILE=$5
356 THIS_ZIP=$THIS_DIR/$ZIP_FILE
357 if [ -n "$OTHER_ZIP_FILE" ]; then
358 OTHER_ZIP=$OTHER_DIR/$OTHER_ZIP_FILE
359 else
360 OTHER_ZIP=$OTHER_DIR/$ZIP_FILE
361 fi
363 THIS_SUFFIX="${THIS_ZIP##*.}"
364 OTHER_SUFFIX="${OTHER_ZIP##*.}"
365 if [ "$THIS_SUFFIX" != "$OTHER_SUFFIX" ]; then
366 echo The files do not have the same suffix type!
367 return 2
368 fi
370 TYPE="$THIS_SUFFIX"
372 if $CMP $OTHER_ZIP $THIS_ZIP > /dev/null
373 then
374 return 0
375 fi
376 # Not quite identical, the might still contain the same data.
377 # Unpack the jar/zip files in temp dirs
379 THIS_UNZIPDIR=$WORK_DIR/$ZIP_FILE.this
380 OTHER_UNZIPDIR=$WORK_DIR/$ZIP_FILE.other
381 $RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR
382 $MKDIR -p $THIS_UNZIPDIR
383 $MKDIR -p $OTHER_UNZIPDIR
384 (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)
385 (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)
387 # Find all archives inside and unzip them as well to compare the contents rather than
388 # the archives. pie.jar.pack.gz i app3.war is corrupt, skip it.
389 EXCEPTIONS="pie.jar.pack.gz"
390 for pack in $($FIND $THIS_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do
391 ($UNPACK200 $pack $pack.jar)
392 # Filter out the unzipped archives from the diff below.
393 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
394 done
395 for pack in $($FIND $OTHER_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do
396 ($UNPACK200 $pack $pack.jar)
397 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
398 done
399 for zip in $($FIND $THIS_UNZIPDIR -name "*.jar" -o -name "*.zip"); do
400 $MKDIR $zip.unzip
401 (cd $zip.unzip && $UNARCHIVE $zip)
402 EXCEPTIONS="$EXCEPTIONS $zip"
403 done
404 for zip in $($FIND $OTHER_UNZIPDIR -name "*.jar" -o -name "*.zip"); do
405 $MKDIR $zip.unzip
406 (cd $zip.unzip && $UNARCHIVE $zip)
407 EXCEPTIONS="$EXCEPTIONS $zip"
408 done
410 CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff
411 # On solaris, there is no -q option.
412 if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
413 LANG=C $DIFF -r $OTHER_UNZIPDIR $THIS_UNZIPDIR \
414 | $GREP -v -e "^<" -e "^>" -e "^Common subdirectories:" \
415 > $CONTENTS_DIFF_FILE
416 else
417 LANG=C $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE
418 fi
420 ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE)
421 ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE)
423 return_value=0
425 if [ -n "$ONLY_OTHER" ]; then
426 echo " Only OTHER $ZIP_FILE contains:"
427 echo "$ONLY_OTHER" | sed "s|Only in $OTHER_UNZIPDIR| |"g | sed 's|: |/|g'
428 return_value=1
429 fi
431 if [ -n "$ONLY_THIS" ]; then
432 echo " Only THIS $ZIP_FILE contains:"
433 echo "$ONLY_THIS" | sed "s|Only in $THIS_UNZIPDIR| |"g | sed 's|: |/|g'
434 return_value=1
435 fi
437 if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
438 DIFFING_FILES=$($GREP -e "differ$" -e "^diff " $CONTENTS_DIFF_FILE \
439 | $CUT -f 3 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
440 else
441 DIFFING_FILES=$($GREP -e "differ$" $CONTENTS_DIFF_FILE \
442 | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
443 fi
445 $RM -f $WORK_DIR/$ZIP_FILE.diffs
446 for file in $DIFFING_FILES; do
447 if [[ "$ACCEPTED_JARZIP_CONTENTS $EXCEPTIONS" != *"$file"* ]]; then
448 diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs
449 fi
450 done
452 if [ -s "$WORK_DIR/$ZIP_FILE.diffs" ]; then
453 return_value=1
454 echo " Differing files in $ZIP_FILE"
455 $CAT $WORK_DIR/$ZIP_FILE.diffs | $GREP differ | cut -f 2 -d ' ' | \
456 $SED "s|$OTHER_UNZIPDIR| |g" > $WORK_DIR/$ZIP_FILE.difflist
457 $CAT $WORK_DIR/$ZIP_FILE.difflist
459 if [ -n "$SHOW_DIFFS" ]; then
460 for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do
461 if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then
462 LANG=C $DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap
463 elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then
464 LANG=C $DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i
465 else
466 LANG=C $DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i
467 fi
468 done
469 fi
470 fi
472 return $return_value
473 }
476 ##########################################################################################
477 # Compare all zip files
479 compare_all_zip_files() {
480 THIS_DIR=$1
481 OTHER_DIR=$2
482 WORK_DIR=$3
484 ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER )
486 if [ -n "$ZIPS" ]; then
487 echo Zip files...
489 return_value=0
490 for f in $ZIPS; do
491 if [ -f "$OTHER_DIR/$f" ]; then
492 compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
493 if [ "$?" != "0" ]; then
494 return_value=1
495 REGRESSIONS=true
496 fi
497 fi
498 done
499 fi
501 return $return_value
502 }
504 ##########################################################################################
505 # Compare all jar files
507 compare_all_jar_files() {
508 THIS_DIR=$1
509 OTHER_DIR=$2
510 WORK_DIR=$3
512 # TODO filter?
513 ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" -o -name "*.war" | $SORT | $FILTER)
515 if [ -n "$ZIPS" ]; then
516 echo Jar files...
518 return_value=0
519 for f in $ZIPS; do
520 if [ -f "$OTHER_DIR/$f" ]; then
521 compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
522 if [ "$?" != "0" ]; then
523 return_value=1
524 REGRESSIONS=true
525 fi
526 fi
527 done
528 fi
530 return $return_value
531 }
533 ##########################################################################################
534 # Compare binary (executable/library) file
536 compare_bin_file() {
537 THIS_DIR=$1
538 OTHER_DIR=$2
539 WORK_DIR=$3
540 BIN_FILE=$4
542 THIS_FILE=$THIS_DIR/$BIN_FILE
543 OTHER_FILE=$OTHER_DIR/$BIN_FILE
544 NAME=$(basename $BIN_FILE)
545 WORK_FILE_BASE=$WORK_DIR/$BIN_FILE
546 FILE_WORK_DIR=$(dirname $WORK_FILE_BASE)
548 $MKDIR -p $FILE_WORK_DIR
550 ORIG_THIS_FILE="$THIS_FILE"
551 ORIG_OTHER_FILE="$OTHER_FILE"
553 if [[ "$STRIP_BEFORE_COMPARE" = *"$BIN_FILE"* ]]; then
554 THIS_STRIPPED_FILE=$FILE_WORK_DIR/this/$NAME
555 OTHER_STRIPPED_FILE=$FILE_WORK_DIR/other/$NAME
556 $MKDIR -p $FILE_WORK_DIR/this $FILE_WORK_DIR/other
557 $CP $THIS_FILE $THIS_STRIPPED_FILE
558 $CP $OTHER_FILE $OTHER_STRIPPED_FILE
559 $STRIP $THIS_STRIPPED_FILE
560 $STRIP $OTHER_STRIPPED_FILE
561 THIS_FILE="$THIS_STRIPPED_FILE"
562 OTHER_FILE="$OTHER_STRIPPED_FILE"
563 fi
565 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
566 unset _NT_SYMBOL_PATH
567 # On windows we need to unzip the debug symbols, if present
568 OTHER_FILE_BASE=${OTHER_FILE/.dll/}
569 OTHER_FILE_BASE=${OTHER_FILE_BASE/.exe/}
570 DIZ_NAME=$(basename $OTHER_FILE_BASE).diz
571 # java.exe and java.dll diz files will have the same name. Have to
572 # make sure java.exe gets the right one. This is only needed for
573 # OTHER since in the new build, all pdb files are left around.
574 if [ "$NAME" = "java.exe" ] && [ -f "$OTHER/tmp/java/java/obj64/java.diz" ]; then
575 OTHER_DIZ_FILE="$OTHER/tmp/java/java/obj64/java.diz"
576 elif [ -f "${OTHER_FILE_BASE}.diz" ]; then
577 OTHER_DIZ_FILE=${OTHER_FILE_BASE}.diz
578 else
579 # Some files, jli.dll, appears twice in the image but only one of
580 # thme has a diz file next to it.
581 OTHER_DIZ_FILE="$($FIND $OTHER_DIR -name $DIZ_NAME | $SED 1q)"
582 if [ ! -f "$OTHER_DIZ_FILE" ]; then
583 # As a last resort, look for diz file in the whole build output
584 # dir.
585 OTHER_DIZ_FILE="$($FIND $OTHER -name $DIZ_NAME | $SED 1q)"
586 fi
587 fi
588 if [ -n "$OTHER_DIZ_FILE" ]; then
589 $MKDIR -p $FILE_WORK_DIR/other
590 (cd $FILE_WORK_DIR/other ; $UNARCHIVE -o $OTHER_DIZ_FILE)
591 export _NT_SYMBOL_PATH="$FILE_WORK_DIR/other"
592 fi
593 THIS_FILE_BASE=${THIS_FILE/.dll/}
594 THIS_FILE_BASE=${THIS_FILE_BASE/.exe/}
595 if [ -f "${THIS_FILE/.dll/}.diz" ]; then
596 THIS_DIZ_FILE=${THIS_FILE/.dll/}.diz
597 else
598 THIS_DIZ_FILE="$($FIND $THIS_DIR -name $DIZ_NAME | $SED 1q)"
599 if [ ! -f "$THIS_DIZ_FILE" ]; then
600 # As a last resort, look for diz file in the whole build output
601 # dir.
602 THIS_DIZ_FILE="$($FIND $THIS -name $DIZ_NAME | $SED 1q)"
603 fi
604 fi
605 if [ -n "$THIS_DIZ_FILE" ]; then
606 $MKDIR -p $FILE_WORK_DIR/this
607 (cd $FILE_WORK_DIR/this ; $UNARCHIVE -o $THIS_DIZ_FILE)
608 export _NT_SYMBOL_PATH="$_NT_SYMBOL_PATH;$FILE_WORK_DIR/this"
609 fi
610 fi
612 if [ -z "$SKIP_BIN_DIFF" ]; then
613 if cmp $OTHER_FILE $THIS_FILE > /dev/null; then
614 # The files were bytewise identical.
615 if [ -n "$VERBOSE" ]; then
616 echo " : : : : : $BIN_FILE"
617 fi
618 return 0
619 fi
620 BIN_MSG=" diff "
621 if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then
622 DIFF_BIN=true
623 if [[ "$KNOWN_BIN_DIFF" != *"$BIN_FILE"* ]]; then
624 BIN_MSG="*$BIN_MSG*"
625 REGRESSIONS=true
626 else
627 BIN_MSG=" $BIN_MSG "
628 fi
629 else
630 BIN_MSG="($BIN_MSG)"
631 DIFF_BIN=
632 fi
633 fi
635 if [ -n "$STAT" ]; then
636 THIS_SIZE=$($STAT $STAT_PRINT_SIZE "$THIS_FILE")
637 OTHER_SIZE=$($STAT $STAT_PRINT_SIZE "$OTHER_FILE")
638 else
639 THIS_SIZE=$(ls -l "$THIS_FILE" | awk '{ print $5 }')
640 OTHER_SIZE=$(ls -l "$OTHER_FILE" | awk '{ print $5 }')
641 fi
642 if [ $THIS_SIZE -ne $OTHER_SIZE ]; then
643 DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE)
644 DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE)
645 SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM)
646 if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \
647 && [ "$DIFF_SIZE_REL" -lt 102 ]; then
648 SIZE_MSG="($SIZE_MSG)"
649 DIFF_SIZE=
650 elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
651 && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
652 && [ "$DIFF_SIZE_NUM" = 512 ]; then
653 # On windows, size of binaries increase in 512 increments.
654 SIZE_MSG="($SIZE_MSG)"
655 DIFF_SIZE=
656 elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
657 && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
658 && [ "$DIFF_SIZE_NUM" = -512 ]; then
659 # On windows, size of binaries increase in 512 increments.
660 SIZE_MSG="($SIZE_MSG)"
661 DIFF_SIZE=
662 else
663 if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
664 DIFF_SIZE=true
665 if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
666 SIZE_MSG="*$SIZE_MSG*"
667 REGRESSIONS=true
668 else
669 SIZE_MSG=" $SIZE_MSG "
670 fi
671 else
672 SIZE_MSG="($SIZE_MSG)"
673 DIFF_SIZE=
674 fi
675 fi
676 else
677 SIZE_MSG=" "
678 DIFF_SIZE=
679 if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then
680 SIZE_MSG=" ! "
681 fi
682 fi
684 if [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then
685 SYM_SORT_CMD="sort"
686 else
687 SYM_SORT_CMD="cat"
688 fi
690 # Check symbols
691 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
692 # The output from dumpbin on windows differs depending on if the debug symbol
693 # files are still around at the location the binary is pointing too. Need
694 # to filter out that extra information.
695 $DUMPBIN -exports $OTHER_FILE | $GREP -E '^ +[0-9A-F]+ +[0-9A-F]+ [0-9A-F]+' | sed 's/ = .*//g' | cut -c27- | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
696 $DUMPBIN -exports $THIS_FILE | $GREP -E '^ +[0-9A-F]+ +[0-9A-F]+ [0-9A-F]+' | sed 's/ = .*//g' | cut -c27- | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
697 elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
698 # Some symbols get seemingly random 15 character prefixes. Filter them out.
699 $NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SED 's/^\([a-zA-Z] [\.\$]\)[a-zA-Z0-9_\$]\{15,15\}\./\1./g' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
700 $NM -a $ORIG_THIS_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SED 's/^\([a-zA-Z] [\.\$]\)[a-zA-Z0-9_\$]\{15,15\}\./\1./g' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
701 else
702 $NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
703 $NM -a $ORIG_THIS_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
704 fi
706 LANG=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff
707 if [ -s $WORK_FILE_BASE.symbols.diff ]; then
708 SYM_MSG=" diff "
709 if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then
710 DIFF_SYM=true
711 if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then
712 SYM_MSG="*$SYM_MSG*"
713 REGRESSIONS=true
714 else
715 SYM_MSG=" $SYM_MSG "
716 fi
717 else
718 SYM_MSG="($SYM_MSG)"
719 DIFF_SYM=
720 fi
721 else
722 SYM_MSG=" "
723 DIFF_SYM=
724 if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then
725 SYM_MSG=" ! "
726 fi
727 fi
729 # Check dependencies
730 if [ -n "$LDD_CMD" ]; then
731 (cd $FILE_WORK_DIR && $CP $OTHER_FILE . && $LDD_CMD $NAME 2>/dev/null | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.other | $UNIQ > $WORK_FILE_BASE.deps.other.uniq)
732 (cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME 2</dev/null | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.this | $UNIQ > $WORK_FILE_BASE.deps.this.uniq)
733 (cd $FILE_WORK_DIR && $RM -f $NAME)
735 LANG=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this > $WORK_FILE_BASE.deps.diff
736 LANG=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq > $WORK_FILE_BASE.deps.diff.uniq
738 if [ -s $WORK_FILE_BASE.deps.diff ]; then
739 if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then
740 DEP_MSG=" diff "
741 else
742 DEP_MSG=" redun "
743 fi
744 if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then
745 DIFF_DEP=true
746 if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then
747 DEP_MSG="*$DEP_MSG*"
748 REGRESSIONS=true
749 else
750 DEP_MSG=" $DEP_MSG "
751 fi
752 else
753 DEP_MSG="($DEP_MSG)"
754 DIFF_DEP=
755 fi
756 else
757 DEP_MSG=" "
758 DIFF_DEP=
759 if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
760 DEP_MSG=" ! "
761 fi
762 fi
763 else
764 DEP_MSG=" - "
765 fi
767 # Compare fulldump output
768 if [ -n "$FULLDUMP_CMD" ] && [ -z "$SKIP_FULLDUMP_DIFF" ]; then
769 $FULLDUMP_CMD $OTHER_FILE > $WORK_FILE_BASE.fulldump.other 2>&1
770 $FULLDUMP_CMD $THIS_FILE > $WORK_FILE_BASE.fulldump.this 2>&1
771 LANG=C $DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this > $WORK_FILE_BASE.fulldump.diff
773 if [ -s $WORK_FILE_BASE.fulldump.diff ]; then
774 ELF_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.fulldump.diff | awk '{print $5}')
775 ELF_MSG=$($PRINTF "%8d" $ELF_DIFF_SIZE)
776 if [[ "$ACCEPTED_ELF_DIFF" != *"$BIN_FILE"* ]]; then
777 DIFF_ELF=true
778 if [[ "$KNOWN_ELF_DIFF" != *"$BIN_FILE"* ]]; then
779 ELF_MSG="*$ELF_MSG*"
780 REGRESSIONS=true
781 else
782 ELF_MSG=" $ELF_MSG "
783 fi
784 else
785 ELF_MSG="($ELF_MSG)"
786 DIFF_ELF=
787 fi
788 else
789 ELF_MSG=" "
790 DIFF_ELF=
791 if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
792 ELF_MSG=" ! "
793 fi
794 fi
795 fi
797 # Compare disassemble output
798 if [ -n "$DIS_CMD" ] && [ -z "$SKIP_DIS_DIFF" ]; then
799 if [ -z "$DIS_DIFF_FILTER" ]; then
800 DIS_DIFF_FILTER="$CAT"
801 fi
802 $DIS_CMD $OTHER_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.other 2>&1
803 $DIS_CMD $THIS_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.this 2>&1
805 LANG=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff
807 if [ -s $WORK_FILE_BASE.dis.diff ]; then
808 DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}')
809 DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE)
810 if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then
811 DIFF_DIS=true
812 if [[ "$KNOWN_DIS_DIFF" != *"$BIN_FILE"* ]]; then
813 DIS_MSG="*$DIS_MSG*"
814 REGRESSIONS=true
815 else
816 DIS_MSG=" $DIS_MSG "
817 fi
818 else
819 DIS_MSG="($DIS_MSG)"
820 DIFF_DIS=
821 fi
822 else
823 DIS_MSG=" "
824 DIFF_DIS=
825 if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
826 DIS_MSG=" ! "
827 fi
828 fi
829 fi
832 if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_ELF$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then
833 if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi
834 if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi
835 if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi
836 if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi
837 if [ -n "$ELF_MSG" ]; then echo -n "$ELF_MSG:"; fi
838 if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi
839 echo " $BIN_FILE"
840 if [ "$SHOW_DIFFS" = "true" ]; then
841 if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then
842 echo "Symbols diff:"
843 $CAT $WORK_FILE_BASE.symbols.diff
844 fi
845 if [ -s "$WORK_FILE_BASE.deps.diff" ]; then
846 echo "Deps diff:"
847 $CAT $WORK_FILE_BASE.deps.diff
848 fi
849 if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then
850 echo "Fulldump diff:"
851 $CAT $WORK_FILE_BASE.fulldump.diff
852 fi
853 if [ -s "$WORK_FILE_BASE.dis.diff" ]; then
854 echo "Disassembly diff:"
855 $CAT $WORK_FILE_BASE.dis.diff
856 fi
857 fi
858 return 1
859 fi
860 return 0
861 }
863 ##########################################################################################
864 # Print binary diff header
866 print_binary_diff_header() {
867 if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi
868 if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n " Size :"; fi
869 if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi
870 if [ -z "$SKIP_DEP_DIFF" ]; then echo -n " Deps :"; fi
871 if [ -z "$SKIP_FULLDUMP_DIFF" ]; then echo -n " Fulldump :"; fi
872 if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass :"; fi
873 echo
874 }
876 ##########################################################################################
877 # Compare all libraries
879 compare_all_libs() {
880 THIS_DIR=$1
881 OTHER_DIR=$2
882 WORK_DIR=$3
884 LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' -o -name 'JavaControlPanel' \) | $SORT | $FILTER)
886 if [ -n "$LIBS" ]; then
887 echo Libraries...
888 print_binary_diff_header
889 for l in $LIBS; do
890 if [ -f "$OTHER_DIR/$l" ]; then
891 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l
892 if [ "$?" != "0" ]; then
893 return_value=1
894 fi
895 fi
896 done
897 fi
899 return $return_value
900 }
902 ##########################################################################################
903 # Compare all executables
905 compare_all_execs() {
906 THIS_DIR=$1
907 OTHER_DIR=$2
908 WORK_DIR=$3
910 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
911 EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER)
912 else
913 EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \
914 \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \
915 -o -name '*.jar' -o -name '*.diz' -o -name 'jcontrol' -o -name '*.properties' \
916 -o -name '*.data' -o -name '*.bfc' -o -name '*.src' -o -name '*.txt' \
917 -o -name '*.cfg' -o -name 'meta-index' -o -name '*.properties.ja' \
918 -o -name 'classlist' \) | $SORT | $FILTER)
919 fi
921 if [ -n "$EXECS" ]; then
922 echo Executables...
923 print_binary_diff_header
924 for e in $EXECS; do
925 if [ -f "$OTHER_DIR/$e" ]; then
926 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e
927 if [ "$?" != "0" ]; then
928 return_value=1
929 fi
930 fi
931 done
932 fi
934 return $return_value
935 }
937 ##########################################################################################
938 # Initiate configuration
940 COMPARE_ROOT=/tmp/cimages.$USER
941 $MKDIR -p $COMPARE_ROOT
942 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
943 if [ "$(uname -o)" = "Cygwin" ]; then
944 COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT)
945 fi
946 fi
948 THIS="$( cd "$( dirname "$0" )" && pwd )"
949 echo "$THIS"
950 THIS_SCRIPT="$0"
952 if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
953 echo "bash ./compare.sh [OPTIONS] [FILTER]"
954 echo ""
955 echo "-all Compare all files in all known ways"
956 echo "-names Compare the file names and directory structure"
957 echo "-perms Compare the permission bits on all files and directories"
958 echo "-types Compare the output of the file command on all files"
959 echo "-general Compare the files not convered by the specialized comparisons"
960 echo "-zips Compare the contents of all zip files"
961 echo "-jars Compare the contents of all jar files"
962 echo "-libs Compare all native libraries"
963 echo "-execs Compare all executables"
964 echo "-v Verbose output, does not hide known differences"
965 echo "-vv More verbose output, shows diff output of all comparisons"
966 echo "-o [OTHER] Compare with build in other directory. Will default to the old build directory"
967 echo ""
968 echo "[FILTER] List filenames in the image to compare, works for jars, zips, libs and execs"
969 echo "Example:"
970 echo "bash ./common/bin/compareimages.sh CodePointIM.jar"
971 echo ""
972 echo "-2zips <file1> <file2> Compare two zip files only"
973 echo ""
974 exit 10
975 fi
977 CMP_NAMES=false
978 CMP_PERMS=false
979 CMP_TYPES=false
980 CMP_GENERAL=false
981 CMP_ZIPS=false
982 CMP_JARS=false
983 CMP_LIBS=false
984 CMP_EXECS=false
986 while [ -n "$1" ]; do
987 case "$1" in
988 -v)
989 VERBOSE=true
990 ;;
991 -vv)
992 VERBOSE=true
993 SHOW_DIFFS=true
994 ;;
995 -o)
996 OTHER="$2"
997 shift
998 ;;
999 -all)
1000 CMP_NAMES=true
1001 if [ "$OPENJDK_TARGET_OS" != "windows" ]; then
1002 CMP_PERMS=true
1003 fi
1004 CMP_TYPES=true
1005 CMP_GENERAL=true
1006 CMP_ZIPS=true
1007 CMP_JARS=true
1008 CMP_LIBS=true
1009 CMP_EXECS=true
1010 ;;
1011 -names)
1012 CMP_NAMES=true
1013 ;;
1014 -perms)
1015 CMP_PERMS=true
1016 ;;
1017 -types)
1018 CMP_TYPES=true
1019 ;;
1020 -general)
1021 CMP_GENERAL=true
1022 ;;
1023 -zips)
1024 CMP_ZIPS=true
1025 ;;
1026 -jars)
1027 CMP_JARS=true
1028 ;;
1029 -libs)
1030 CMP_LIBS=true
1031 ;;
1032 -execs)
1033 CMP_EXECS=true
1034 ;;
1035 -2zips)
1036 CMP_2_ZIPS=true
1037 THIS_FILE=$2
1038 OTHER_FILE=$3
1039 shift
1040 shift
1041 ;;
1042 *)
1043 CMP_NAMES=false
1044 CMP_PERMS=false
1045 CMP_TYPES=false
1046 CMP_ZIPS=true
1047 CMP_JARS=true
1048 CMP_LIBS=true
1049 CMP_EXECS=true
1051 if [ -z "$FILTER" ]; then
1052 FILTER="$GREP"
1053 fi
1054 FILTER="$FILTER -e $1"
1055 ;;
1056 esac
1057 shift
1058 done
1060 if [ "$CMP_2_ZIPS" = "true" ]; then
1061 THIS_DIR="$(dirname $THIS_FILE)"
1062 THIS_DIR="$(cd "$THIS_DIR" && pwd )"
1063 OTHER_DIR="$(dirname $OTHER_FILE)"
1064 OTHER_DIR="$(cd "$OTHER_DIR" && pwd )"
1065 THIS_FILE_NAME="$(basename $THIS_FILE)"
1066 OTHER_FILE_NAME="$(basename $OTHER_FILE)"
1067 echo Comparing $THIS_DIR/$THIS_FILE_NAME and $OTHER_DIR/$OTHER_FILE_NAME
1068 compare_zip_file $THIS_DIR $OTHER_DIR $COMPARE_ROOT/2zips $THIS_FILE_NAME $OTHER_FILE_NAME
1069 exit
1070 fi
1072 if [ "$CMP_NAMES" = "false" ] && [ "$CMP_TYPES" = "false" ] && [ "$CMP_PERMS" = "false" ] && [ "$CMP_GENERAL" = "false" ] && [ "$CMP_ZIPS" = "false" ] && [ "$CMP_JARS" = "false" ] && [ "$CMP_LIBS" = "false" ] && [ "$CMP_EXECS" = "false" ]; then
1073 CMP_NAMES=true
1074 CMP_PERMS=true
1075 CMP_TYPES=true
1076 CMP_GENERAL=true
1077 CMP_ZIPS=true
1078 CMP_JARS=true
1079 CMP_LIBS=true
1080 CMP_EXECS=true
1081 fi
1083 if [ -z "$FILTER" ]; then
1084 FILTER="$CAT"
1085 fi
1087 if [ -z "$OTHER" ]; then
1088 OTHER="$THIS/../$LEGACY_BUILD_DIR"
1089 if [ -d "$OTHER" ]; then
1090 OTHER="$( cd "$OTHER" && pwd )"
1091 else
1092 echo "Default old build directory does not exist:"
1093 echo "$OTHER"
1094 exit 1
1095 fi
1096 echo "Comparing to default old build:"
1097 echo "$OTHER"
1098 echo
1099 else
1100 if [ ! -d "$OTHER" ]; then
1101 echo "Other build directory does not exist:"
1102 echo "$OTHER"
1103 exit 1
1104 fi
1105 OTHER="$( cd "$OTHER" && pwd )"
1106 echo "Comparing to:"
1107 echo "$OTHER"
1108 echo
1109 fi
1112 # Figure out the layout of the this build. Which kinds of images have been produced
1113 if [ -d "$THIS/install/j2sdk-image" ]; then
1114 THIS_J2SDK="$THIS/install/j2sdk-image"
1115 THIS_J2RE="$THIS/install/j2re-image"
1116 echo "Comparing install images"
1117 elif [ -d "$THIS/deploy/j2sdk-image" ]; then
1118 THIS_J2SDK="$THIS/deploy/j2sdk-image"
1119 THIS_J2RE="$THIS/deploy/j2re-image"
1120 echo "Comparing deploy images"
1121 elif [ -d "$THIS/images/j2sdk-image" ]; then
1122 THIS_J2SDK="$THIS/images/j2sdk-image"
1123 THIS_J2RE="$THIS/images/j2re-image"
1124 fi
1126 if [ -d "$THIS/images/j2sdk-overlay-image" ]; then
1127 if [ -d "$THIS/install/j2sdk-image" ]; then
1128 # If there is an install image, prefer that, it's also overlay
1129 THIS_J2SDK_OVERLAY="$THIS/install/j2sdk-image"
1130 THIS_J2RE_OVERLAY="$THIS/install/j2re-image"
1131 else
1132 THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image"
1133 THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image"
1134 fi
1135 fi
1137 if [ -d "$THIS/images/j2sdk-bundle" ]; then
1138 THIS_J2SDK_BUNDLE="$THIS/images/j2sdk-bundle"
1139 THIS_J2RE_BUNDLE="$THIS/images/j2re-bundle"
1140 fi
1142 # Figure out the layout of the other build (old or new, normal or overlay image)
1143 if [ -d "$OTHER/j2sdk-image" ]; then
1144 if [ -f "$OTHER/j2sdk-image/LICENSE" ]; then
1145 OTHER_J2SDK="$OTHER/j2sdk-image"
1146 OTHER_J2RE="$OTHER/j2re-image"
1147 else
1148 OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image"
1149 OTHER_J2RE_OVERLAY="$OTHER/j2re-image"
1150 fi
1151 elif [ -d "$OTHER/images/j2sdk-image" ]; then
1152 OTHER_J2SDK="$OTHER/images/j2sdk-image"
1153 OTHER_J2RE="$OTHER/images/j2re-image"
1154 fi
1156 if [ -d "$OTHER/j2sdk-bundle" ]; then
1157 OTHER_J2SDK_BUNDLE="$OTHER/j2sdk-bundle"
1158 OTHER_J2RE_BUNDLE="$OTHER/j2re-bundle"
1159 elif [ -d "$OTHER/images/j2sdk-bundle" ]; then
1160 OTHER_J2SDK_BUNDLE="$OTHER/images/j2sdk-bundle"
1161 OTHER_J2RE_BUNDLE="$OTHER/images/j2re-bundle"
1162 fi
1164 if [ -z "$THIS_J2SDK" ] || [ -z "$THIS_J2RE" ]; then
1165 if [ -z "$THIS_J2SDK_OVERLAY" ]; then
1166 echo "Cannot locate images for this build. Are you sure you have run 'make images'?"
1167 exit 1
1168 fi
1169 fi
1171 if [ -z "$OTHER_J2SDK" ] && [ -n "$OTHER_J2SDK_OVERLAY" ] && [ -z "$THIS_J2SDK_OVERLAY" ]; then
1172 echo "OTHER build only has an overlay image while this build does not. Nothing to compare!"
1173 exit 1
1174 fi
1176 if [ -z "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
1177 echo "WARNING! OTHER build has bundles built while this build does not."
1178 echo "Skipping bundle compare!"
1179 fi
1181 if [ -d "$THIS/docs" ]; then
1182 THIS_DOCS="$THIS/docs"
1183 fi
1185 if [ -d "$OTHER/docs" ]; then
1186 OTHER_DOCS="$OTHER/docs"
1187 fi
1189 if [ -z "$THIS_DOCS" ]; then
1190 echo "WARNING! Docs haven't been built and won't be compared."
1191 fi
1193 if [ -z "$OTHER_DOCS" ]; then
1194 echo "WARNING! Other build doesn't contain docs, skipping doc compare."
1195 fi
1197 if [ -d "$OTHER/images" ]; then
1198 OTHER_SEC_DIR="$OTHER/images"
1199 else
1200 OTHER_SEC_DIR="$OTHER/tmp"
1201 fi
1202 OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip"
1203 THIS_SEC_DIR="$THIS/images"
1204 THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip"
1205 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
1206 if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
1207 JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip"
1208 else
1209 JGSS_WINDOWS_BIN="jgss-windows-i586-bin.zip"
1210 fi
1211 OTHER_SEC_WINDOWS_BIN="$OTHER_SEC_DIR/sec-windows-bin.zip"
1212 OTHER_JGSS_WINDOWS_BIN="$OTHER_SEC_DIR/$JGSS_WINDOWS_BIN"
1213 THIS_SEC_WINDOWS_BIN="$THIS_SEC_DIR/sec-windows-bin.zip"
1214 THIS_JGSS_WINDOWS_BIN="$THIS_SEC_DIR/$JGSS_WINDOWS_BIN"
1215 fi
1217 ##########################################################################################
1218 # Do the work
1220 if [ "$CMP_NAMES" = "true" ]; then
1221 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1222 echo -n "J2SDK "
1223 compare_dirs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1224 echo -n "J2RE "
1225 compare_dirs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
1227 echo -n "J2SDK "
1228 compare_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1229 echo -n "J2RE "
1230 compare_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
1231 fi
1232 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
1233 echo -n "J2SDK Overlay "
1234 compare_dirs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
1235 echo -n "J2RE Overlay "
1236 compare_dirs $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
1238 echo -n "J2SDK Overlay "
1239 compare_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
1240 echo -n "J2RE Overlay "
1241 compare_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
1242 fi
1243 if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
1244 echo -n "J2SDK Bundle "
1245 compare_dirs $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
1246 echo -n "J2RE Bundle "
1247 compare_dirs $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
1249 echo -n "J2SDK Bundle "
1250 compare_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
1251 echo -n "J2RE Bundle "
1252 compare_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
1253 fi
1254 if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then
1255 echo -n "Docs "
1256 compare_dirs $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
1257 echo -n "Docs "
1258 compare_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
1259 fi
1260 fi
1262 if [ "$CMP_PERMS" = "true" ]; then
1263 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1264 echo -n "J2SDK "
1265 compare_permissions $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1266 echo -n "J2RE "
1267 compare_permissions $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
1268 fi
1269 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
1270 echo -n "J2SDK Overlay "
1271 compare_permissions $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
1272 echo -n "J2RE Overlay "
1273 compare_permissions $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
1274 fi
1275 if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
1276 echo -n "J2SDK Bundle "
1277 compare_permissions $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
1278 echo -n "J2RE Bundle "
1279 compare_permissions $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
1280 fi
1281 fi
1283 if [ "$CMP_TYPES" = "true" ]; then
1284 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1285 echo -n "J2SDK "
1286 compare_file_types $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1287 echo -n "J2RE "
1288 compare_file_types $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
1289 fi
1290 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
1291 echo -n "J2SDK Overlay "
1292 compare_file_types $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
1293 echo -n "J2RE Overlay "
1294 compare_file_types $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
1295 fi
1296 if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
1297 echo -n "J2SDK Bundle "
1298 compare_file_types $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
1299 echo -n "J2RE Bundle "
1300 compare_file_types $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
1301 fi
1302 fi
1304 if [ "$CMP_GENERAL" = "true" ]; then
1305 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1306 echo -n "J2SDK "
1307 compare_general_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1308 echo -n "J2RE "
1309 compare_general_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
1310 fi
1311 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
1312 echo -n "J2SDK Overlay "
1313 compare_general_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
1314 echo -n "J2RE Overlay "
1315 compare_general_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
1316 fi
1317 if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
1318 echo -n "J2SDK Bundle "
1319 compare_general_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
1320 echo -n "J2RE Bundle "
1321 compare_general_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
1322 fi
1323 if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then
1324 echo -n "Docs "
1325 compare_general_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
1326 fi
1327 fi
1329 if [ "$CMP_ZIPS" = "true" ]; then
1330 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1331 compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1332 fi
1333 if [ -n "$THIS_SEC_BIN" ] && [ -n "$OTHER_SEC_BIN" ]; then
1334 if [ -n "$(echo $THIS_SEC_BIN | $FILTER)" ]; then
1335 echo "sec-bin.zip..."
1336 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-bin.zip
1337 fi
1338 fi
1339 if [ -n "$THIS_SEC_WINDOWS_BIN" ] && [ -n "$OTHER_SEC_WINDOWS_BIN" ]; then
1340 if [ -n "$(echo $THIS_SEC_WINDOWS_BIN | $FILTER)" ]; then
1341 echo "sec-windows-bin.zip..."
1342 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-windows-bin.zip
1343 fi
1344 fi
1345 if [ -n "$THIS_JGSS_WINDOWS_BIN" ] && [ -n "$OTHER_JGSS_WINDOWS_BIN" ]; then
1346 if [ -n "$(echo $THIS_JGSS_WINDOWS_BIN | $FILTER)" ]; then
1347 echo "$JGSS_WINDOWS_BIN..."
1348 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin $JGSS_WINDOWS_BIN
1349 fi
1350 fi
1351 fi
1353 if [ "$CMP_JARS" = "true" ]; then
1354 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1355 compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1356 fi
1357 fi
1359 if [ "$CMP_LIBS" = "true" ]; then
1360 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1361 echo -n "J2SDK "
1362 compare_all_libs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1363 if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
1364 echo -n "J2RE "
1365 compare_all_libs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
1366 fi
1367 fi
1368 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
1369 echo -n "Bundle "
1370 compare_all_libs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
1371 fi
1372 fi
1374 if [ "$CMP_EXECS" = "true" ]; then
1375 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1376 compare_all_execs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1377 fi
1378 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
1379 echo -n "Overlay "
1380 compare_all_execs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
1381 fi
1382 fi
1384 echo
1386 if [ -n "$REGRESSIONS" ]; then
1387 echo "REGRESSIONS FOUND!"
1388 echo
1389 exit 1
1390 else
1391 echo "No regressions found"
1392 echo
1393 exit 0
1394 fi