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