1 #!/bin/bash
   2 #
   3 # Copyright (c) 2012, 2018, 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 "$TOPDIR" ]; 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 -d"
  39     LDD_CMD="$OTOOL -L"
  40     DIS_CMD="$OTOOL -v -V -t"
  41     STAT_PRINT_SIZE="-f %z"
  42 elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then
  43     FULLDUMP_CMD="$DUMPBIN -all"
  44     LDD_CMD="$DUMPBIN -dependents"
  45     DIS_CMD="$DUMPBIN -disasm:nobytes"
  46     STAT_PRINT_SIZE="-c %s"
  47 elif [ "$OPENJDK_TARGET_OS" = "aix" ]; then
  48     FULLDUMP_CMD="dump -h -r -t -n -X64"
  49     LDD_CMD="$LDD"
  50     DIS_CMD="$OBJDUMP -d"
  51     STAT_PRINT_SIZE="-c %s"
  52 else
  53     FULLDUMP_CMD="$READELF -a"
  54     LDD_CMD="$LDD"
  55     DIS_CMD="$OBJDUMP -d"
  56     STAT_PRINT_SIZE="-c %s"
  57 fi
  58 
  59 COMPARE_EXCEPTIONS_INCLUDE="$TOPDIR/make/scripts/compare_exceptions.sh.incl"
  60 if [ ! -e "$COMPARE_EXCEPTIONS_INCLUDE" ]; then
  61     echo "Error: Cannot locate the exceptions file, it should have been here: $COMPARE_EXCEPTIONS_INCLUDE"
  62     exit 1
  63 fi
  64 # Include exception definitions
  65 . "$COMPARE_EXCEPTIONS_INCLUDE"
  66 
  67 ################################################################################
  68 # Compare text files and ignore specific differences:
  69 #
  70 #  * Timestamps in Java sources generated by idl2java
  71 #  * Sorting order and cleanup style in .properties files
  72 
  73 diff_text() {
  74     OTHER_FILE=$1
  75     THIS_FILE=$2
  76 
  77     SUFFIX="${THIS_FILE##*.}"
  78     NAME="${THIS_FILE##*/}"
  79 
  80     TMP=1
  81 
  82     if [[ "$THIS_FILE" = *"META-INF/MANIFEST.MF" ]]; then
  83         # Filter out date string, ant version and java version differences.
  84         TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \
  85             $GREP '^[<>]' | \
  86             $SED -e '/[<>] Ant-Version: Apache Ant .*/d' \
  87                  -e '/[<>] Created-By: .* (Oracle [Corpatin)]*/d' \
  88                  -e '/[<>]  [Corpatin]*)/d' \
  89                  -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d')
  90     fi
  91     if test "x$SUFFIX" = "xjava"; then
  92         TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \
  93             $GREP '^[<>]' | \
  94             $SED -e '/[<>] \* from.*\.idl/d' \
  95                  -e '/[<>] .*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
  96                  -e '/[<>] .*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d' \
  97                  -e '/[<>] \*.*[0-9]\{4\} \(at \)*[0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \
  98                  -e '/\/\/ Generated from input file.*/d' \
  99                  -e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \
 100                  -e '/\/\/ java GenerateCharacter.*/d')
 101     fi
 102     # Ignore date strings in class files.
 103     # Anonymous lambda classes get randomly assigned counters in their names.
 104     if test "x$SUFFIX" = "xclass"; then
 105         if [ "$NAME" = "SystemModules\$all.class" ] \
 106            || [ "$NAME" = "SystemModules\$default.class" ]; then
 107             # The SystemModules\$*.classes are not comparable as they contain the
 108             # module hashes which would require a whole other level of
 109             # reproducible builds to get reproducible. There is also random
 110             # order of map initialization.
 111             TMP=""
 112         elif [ "$NAME" = "module-info.class" ]; then
 113             # The module-info.class have several issues with random ordering of
 114             # elements in HashSets.
 115             MODULES_CLASS_FILTER="$SED \
 116                 -e 's/,$//' \
 117                 -e 's/;$//' \
 118                 -e 's/^ *[0-9]*://' \
 119                 -e 's/#[0-9]* */#/' \
 120                 -e 's/ *\/\// \/\//' \
 121                 -e 's/aload *[0-9]*/aload X/' \
 122                 -e 's/ldc_w/ldc  /' \
 123                 | $SORT \
 124                 "
 125             $JAVAP -c -constants -l -p "${OTHER_FILE}" \
 126                 | eval "$MODULES_CLASS_FILTER" >  ${OTHER_FILE}.javap &
 127             $JAVAP -c -constants -l -p "${THIS_FILE}" \
 128                 | eval "$MODULES_CLASS_FILTER" > ${THIS_FILE}.javap &
 129             wait
 130             TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap)
 131         # To improve performance when large diffs are found, do a rough filtering of classes
 132         # elibeble for these exceptions
 133         elif $GREP -R -e '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}' \
 134                 -e 'lambda\$[a-zA-Z0-9]*\$[0-9]' ${THIS_FILE} > /dev/null
 135         then
 136             $JAVAP -c -constants -l -p "${OTHER_FILE}" >  ${OTHER_FILE}.javap &
 137             $JAVAP -c -constants -l -p "${THIS_FILE}" > ${THIS_FILE}.javap &
 138             wait
 139             TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \
 140                 $GREP '^[<>]' | \
 141                 $SED -e '/[<>].*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d' \
 142                      -e '/[<>].*lambda\$[a-zA-Z0-9]*\$[0-9]*/d')
 143         fi
 144     fi
 145     if test "x$SUFFIX" = "xproperties"; then
 146         # Filter out date string differences.
 147         TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \
 148             $GREP '^[<>]' | \
 149             $SED -e '/[<>].*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d')
 150     fi
 151     if test "x$SUFFIX" = "xhtml"; then
 152         # Some javadoc versions do not put quotes around font size
 153         HTML_FILTER="$SED \
 154             -e 's/<font size=-1>/<font size=\"-1\">/g'"
 155         $CAT $THIS_FILE | eval "$HTML_FILTER" > $THIS_FILE.filtered
 156         $CAT $OTHER_FILE | eval "$HTML_FILTER" > $OTHER_FILE.filtered
 157         TMP=$(LC_ALL=C $DIFF $OTHER_FILE.filtered $THIS_FILE.filtered | \
 158             $GREP '^[<>]' | \
 159             $SED -e '/[<>] <!-- Generated by javadoc .* on .* -->/d' \
 160                  -e '/[<>] <meta name="date" content=".*">/d' )
 161     fi
 162     if test -n "$TMP"; then
 163         echo Files $OTHER_FILE and $THIS_FILE differ
 164         return 1
 165     fi
 166 
 167     return 0
 168 }
 169 
 170 ################################################################################
 171 # Compare directory structure
 172 
 173 compare_dirs() {
 174     THIS_DIR=$1
 175     OTHER_DIR=$2
 176     WORK_DIR=$3
 177 
 178     mkdir -p $WORK_DIR
 179 
 180     (cd $OTHER_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_other)
 181     (cd $THIS_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_this)
 182 
 183     $DIFF $WORK_DIR/dirs_other $WORK_DIR/dirs_this > $WORK_DIR/dirs_diff
 184 
 185     echo -n Directory structure...
 186     if [ -s $WORK_DIR/dirs_diff ]; then
 187         echo Differences found.
 188         REGRESSIONS=true
 189         # Differences in directories found.
 190         ONLY_OTHER=$($GREP '<' $WORK_DIR/dirs_diff)
 191         if [ "$ONLY_OTHER" ]; then
 192             echo Only in $OTHER
 193             $GREP '<' $WORK_DIR/dirs_diff | $SED 's|< ./|    |g'
 194         fi
 195         ONLY_THIS=$($GREP '>' $WORK_DIR/dirs_diff)
 196         if [ "$ONLY_THIS" ]; then
 197             echo Only in $THIS
 198             $GREP '>' $WORK_DIR/dirs_diff | $SED 's|> ./|    |g'
 199         fi
 200     else
 201         echo Identical!
 202     fi
 203 }
 204 
 205 
 206 ################################################################################
 207 # Compare file structure
 208 
 209 compare_files() {
 210     THIS_DIR=$1
 211     OTHER_DIR=$2
 212     WORK_DIR=$3
 213 
 214     $MKDIR -p $WORK_DIR
 215 
 216     (cd $OTHER_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_other)
 217     (cd $THIS_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_this)
 218 
 219     $DIFF $WORK_DIR/files_other $WORK_DIR/files_this > $WORK_DIR/files_diff
 220 
 221     echo -n File names...
 222     if [ -s $WORK_DIR/files_diff ]; then
 223         echo Differences found.
 224         REGRESSIONS=true
 225         # Differences in files found.
 226         ONLY_OTHER=$($GREP '<' $WORK_DIR/files_diff)
 227         if [ "$ONLY_OTHER" ]; then
 228             echo Only in $OTHER
 229             $GREP '<' $WORK_DIR/files_diff | $SED 's|< ./|    |g'
 230         fi
 231         ONLY_THIS=$($GREP '>' $WORK_DIR/files_diff)
 232         if [ "$ONLY_THIS" ]; then
 233             echo Only in $THIS
 234             $GREP '>' $WORK_DIR/files_diff | $SED 's|> ./|    |g'
 235         fi
 236     else
 237         echo Identical!
 238     fi
 239 }
 240 
 241 
 242 ################################################################################
 243 # Compare permissions
 244 
 245 compare_permissions() {
 246     THIS_DIR=$1
 247     OTHER_DIR=$2
 248     WORK_DIR=$3
 249 
 250     mkdir -p $WORK_DIR
 251 
 252     echo -n Permissions...
 253     found=""
 254     for f in `cd $OTHER_DIR && $FIND . -type f`
 255     do
 256         if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
 257         if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
 258         OP=`ls -l ${OTHER_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
 259         TP=`ls -l ${THIS_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
 260         if [ "$OP" != "$TP" ]
 261         then
 262             if [ -z "$found" ]; then echo ; found="yes"; fi
 263             $PRINTF "\tother: ${OP} this: ${TP}\t$f\n"
 264         fi
 265     done
 266     if [ -z "$found" ]; then
 267         echo "Identical!"
 268     else
 269         REGRESSIONS=true
 270     fi
 271 }
 272 
 273 ################################################################################
 274 # Compare file command output
 275 
 276 compare_file_types() {
 277     THIS_DIR=$1
 278     OTHER_DIR=$2
 279     WORK_DIR=$3
 280 
 281     $MKDIR -p $WORK_DIR
 282 
 283     FILE_TYPES_FILTER="$SED \
 284         -e 's/BuildID[^,]*//' \
 285         -e 's/last modified: .*//' \
 286         "
 287 
 288     echo -n File types...
 289     found=""
 290     for f in `cd $OTHER_DIR && $FIND . ! -type d`
 291     do
 292         if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
 293         if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
 294         OF=$(cd ${OTHER_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER)
 295         TF=$(cd ${THIS_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER)
 296         if [ "$OF" != "$TF" ]
 297         then
 298             if [ "`echo $OF | $GREP -c 'Zip archive data'`" -gt 0 ] \
 299                 && [ "`echo $TF | $GREP -c 'Zip archive data'`" -gt 0 ]
 300             then
 301                 # the way we produce zip-files make it so that directories are stored in
 302                 # old file but not in new (only files with full-path) this makes file
 303                 # report them as different
 304                 continue
 305             else
 306                 if [ -z "$found" ]; then echo ; found="yes"; fi
 307                 $PRINTF "\tother: ${OF}\n\tthis : ${TF}\n"
 308             fi
 309         fi
 310     done
 311     if [ -z "$found" ]; then
 312         echo "Identical!"
 313     else
 314         REGRESSIONS=true
 315     fi
 316 }
 317 
 318 ################################################################################
 319 # Compare the rest of the files
 320 
 321 compare_general_files() {
 322     THIS_DIR=$1
 323     OTHER_DIR=$2
 324     WORK_DIR=$3
 325 
 326     GENERAL_FILES=$(cd $THIS_DIR && $FIND . -type f ! -name "*.so" ! -name "*.jar" \
 327         ! -name "*.zip" ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \
 328         ! -name "modules" ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \
 329         ! -name "*.cpl" ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \
 330         ! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" ! -name "*.jmod" \
 331         ! -name "*.obj" ! -name "*.o" ! -name "JavaControlPanelHelper" \
 332         ! -name "JavaUpdater" ! -name "JavaWSApplicationStub" \
 333         ! -name "jspawnhelper" ! -name "JavawsLauncher" ! -name "*.a" \
 334         ! -name "finish_installation" ! -name "Sparkle" ! -name "*.tar.gz" \
 335         ! -name "classes.jsa" \
 336         | $GREP -v "./bin/"  | $SORT | $FILTER)
 337 
 338     echo Other files with binary differences...
 339     for f in $GENERAL_FILES
 340     do
 341         if [ -e $OTHER_DIR/$f ]; then
 342             SUFFIX="${f##*.}"
 343             if [ "$(basename $f)" = "release" ]; then
 344                 # In release file, ignore differences in change numbers and order
 345                 # of modules in list.
 346                 OTHER_FILE=$WORK_DIR/$f.other
 347                 THIS_FILE=$WORK_DIR/$f.this
 348                 $MKDIR -p $(dirname $OTHER_FILE)
 349                 $MKDIR -p $(dirname $THIS_FILE)
 350                 RELEASE_FILTER="$SED \
 351                     -e 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' \
 352                     -e 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}/<DATE>/g' \
 353                     -e 's/^#.*/#COMMENT/g' \
 354                     -e 's/MODULES=/MODULES=\'$'\n/' \
 355                     -e 's/,/\'$'\n/g' \
 356                     | $SORT
 357                     "
 358                 $CAT $OTHER_DIR/$f | eval "$RELEASE_FILTER" > $OTHER_FILE
 359                 $CAT $THIS_DIR/$f  | eval "$RELEASE_FILTER" > $THIS_FILE
 360             elif [ "x$SUFFIX" = "xhtml" ]; then
 361                 # Ignore time stamps in docs files
 362                 OTHER_FILE=$WORK_DIR/$f.other
 363                 THIS_FILE=$WORK_DIR/$f.this
 364                 $MKDIR -p $(dirname $OTHER_FILE) $(dirname $THIS_FILE)
 365                 # Older versions of compare might have left soft links with
 366                 # these names.
 367                 $RM $OTHER_FILE $THIS_FILE
 368                 #Note that | doesn't work on mac sed.
 369                 HTML_FILTER="$SED \
 370                     -e 's/20[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6,7\}/<DATE>/g' \
 371                     -e 's/20[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}/<DATE>/g' \
 372                     -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
 373                     -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [0-9]\{4\} [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/<DATE>/' \
 374                     -e 's/from .*\.idl/\.idl/' \
 375                     "
 376                 $CAT $OTHER_DIR/$f | eval "$HTML_FILTER" > $OTHER_FILE &
 377                 $CAT $THIS_DIR/$f  | eval "$HTML_FILTER" > $THIS_FILE &
 378                 wait
 379             elif [[ "$f" = *"/lib/classlist" ]]; then
 380                 # The classlist files may have some lines in random order
 381                 OTHER_FILE=$WORK_DIR/$f.other
 382                 THIS_FILE=$WORK_DIR/$f.this
 383                 $MKDIR -p $(dirname $OTHER_FILE) $(dirname $THIS_FILE)
 384                 $RM $OTHER_FILE $THIS_FILE
 385                 $CAT $OTHER_DIR/$f | $SORT > $OTHER_FILE
 386                 $CAT $THIS_DIR/$f  | $SORT > $THIS_FILE
 387             else
 388                 OTHER_FILE=$OTHER_DIR/$f
 389                 THIS_FILE=$THIS_DIR/$f
 390             fi
 391             DIFF_OUT=$($DIFF $OTHER_FILE $THIS_FILE 2>&1)
 392             if [ -n "$DIFF_OUT" ]; then
 393                 echo $f
 394                 REGRESSIONS=true
 395                 if [ "$SHOW_DIFFS" = "true" ]; then
 396                     echo "$DIFF_OUT"
 397                 fi
 398             fi
 399         fi
 400     done
 401 
 402 
 403 }
 404 
 405 ################################################################################
 406 # Compare zip file
 407 
 408 compare_zip_file() {
 409     THIS_DIR=$1
 410     OTHER_DIR=$2
 411     WORK_DIR=$3
 412     ZIP_FILE=$4
 413     # Optionally provide different name for other zipfile
 414     OTHER_ZIP_FILE=$5
 415 
 416     THIS_ZIP=$THIS_DIR/$ZIP_FILE
 417     if [ -n "$OTHER_ZIP_FILE" ]; then
 418         OTHER_ZIP=$OTHER_DIR/$OTHER_ZIP_FILE
 419     else
 420         OTHER_ZIP=$OTHER_DIR/$ZIP_FILE
 421     fi
 422 
 423     THIS_SUFFIX="${THIS_ZIP##*.}"
 424     OTHER_SUFFIX="${OTHER_ZIP##*.}"
 425     if [ "$THIS_SUFFIX" != "$OTHER_SUFFIX" ]; then
 426         echo "The files do not have the same suffix type! ($THIS_SUFFIX != $OTHER_SUFFIX)"
 427         return 2
 428     fi
 429 
 430     TYPE="$THIS_SUFFIX"
 431 
 432     if $CMP $OTHER_ZIP $THIS_ZIP > /dev/null
 433     then
 434         return 0
 435     fi
 436     # Not quite identical, the might still contain the same data.
 437     # Unpack the jar/zip files in temp dirs
 438 
 439     THIS_UNZIPDIR=$WORK_DIR/$ZIP_FILE.this
 440     OTHER_UNZIPDIR=$WORK_DIR/$ZIP_FILE.other
 441     $RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR
 442     $MKDIR -p $THIS_UNZIPDIR
 443     $MKDIR -p $OTHER_UNZIPDIR
 444     if [ "$TYPE" = "jar" -o "$TYPE" = "war" -o "$TYPE" = "zip" -o "$TYPE" = "jmod" ]
 445     then
 446         (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)
 447         (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)
 448     elif [ "$TYPE" = "gz" ]
 449     then
 450         (cd $THIS_UNZIPDIR && $GUNZIP -c $THIS_ZIP | $TAR xf -)
 451         (cd $OTHER_UNZIPDIR && $GUNZIP -c $OTHER_ZIP | $TAR xf -)
 452     else
 453         (cd $THIS_UNZIPDIR && $JIMAGE extract $THIS_ZIP)
 454         (cd $OTHER_UNZIPDIR && $JIMAGE extract $OTHER_ZIP)
 455     fi
 456 
 457     # Find all archives inside and unzip them as well to compare the contents rather than
 458     # the archives. pie.jar.pack.gz i app3.war is corrupt, skip it.
 459     EXCEPTIONS="pie.jar.pack.gz jdk.pack"
 460     for pack in $($FIND $THIS_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a \
 461                         ! -name pie.jar.pack.gz -a ! -name jdk.pack); do
 462         ($UNPACK200 $pack $pack.jar)
 463         # Filter out the unzipped archives from the diff below.
 464         EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
 465     done
 466     for pack in $($FIND $OTHER_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a \
 467                         ! -name pie.jar.pack.gz -a ! -name jdk.pack); do
 468         ($UNPACK200 $pack $pack.jar)
 469         EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
 470     done
 471     for zip in $($FIND $THIS_UNZIPDIR -name "*.jar" -o -name "*.zip"); do
 472         $MKDIR $zip.unzip
 473         (cd $zip.unzip && $UNARCHIVE $zip)
 474         EXCEPTIONS="$EXCEPTIONS $zip"
 475     done
 476     for zip in $($FIND $OTHER_UNZIPDIR -name "*.jar" -o -name "*.zip"); do
 477         $MKDIR $zip.unzip
 478         (cd $zip.unzip && $UNARCHIVE $zip)
 479         EXCEPTIONS="$EXCEPTIONS $zip"
 480     done
 481 
 482     CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff
 483     # On solaris, there is no -q option.
 484     if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
 485         LC_ALL=C $DIFF -r $OTHER_UNZIPDIR $THIS_UNZIPDIR \
 486             | $GREP -v -e "^<" -e "^>" -e "^Common subdirectories:" \
 487             > $CONTENTS_DIFF_FILE
 488     else
 489         LC_ALL=C $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE
 490     fi
 491 
 492     ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE)
 493     ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE)
 494 
 495     return_value=0
 496 
 497     if [ -n "$ONLY_OTHER" ]; then
 498         echo "        Only OTHER $ZIP_FILE contains:"
 499         echo "$ONLY_OTHER" | sed "s|Only in $OTHER_UNZIPDIR|            |"g | sed 's|: |/|g'
 500         return_value=1
 501     fi
 502 
 503     if [ -n "$ONLY_THIS" ]; then
 504         echo "        Only THIS $ZIP_FILE contains:"
 505         echo "$ONLY_THIS" | sed "s|Only in $THIS_UNZIPDIR|            |"g | sed 's|: |/|g'
 506         return_value=1
 507     fi
 508 
 509     if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
 510         DIFFING_FILES=$($GREP -e 'differ$' -e '^diff ' $CONTENTS_DIFF_FILE \
 511             | $SED -e 's/^Files //g' -e 's/diff -r //g' | $CUT -f 1 -d ' ' \
 512             | $SED "s|$OTHER_UNZIPDIR/||g")
 513     else
 514         DIFFING_FILES=$($GREP -e "differ$" $CONTENTS_DIFF_FILE \
 515             | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
 516     fi
 517 
 518     if [ "$CMP_ZIPS_CONTENTS" = "true" ]; then
 519         $RM -f $WORK_DIR/$ZIP_FILE.diffs
 520         for file in $DIFFING_FILES; do
 521             if [[ "$ACCEPTED_JARZIP_CONTENTS $EXCEPTIONS" != *"$file"* ]]; then
 522                 diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs
 523             fi
 524         done
 525 
 526         if [ -s "$WORK_DIR/$ZIP_FILE.diffs" ]; then
 527             return_value=1
 528             echo "        Differing files in $ZIP_FILE"
 529             $CAT $WORK_DIR/$ZIP_FILE.diffs | $GREP 'differ$' | cut -f 2 -d ' ' | \
 530                 $SED "s|$OTHER_UNZIPDIR|            |g" > $WORK_DIR/$ZIP_FILE.difflist
 531             $CAT $WORK_DIR/$ZIP_FILE.difflist
 532 
 533             if [ -n "$SHOW_DIFFS" ]; then
 534                 for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do
 535                     if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then
 536                         LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap
 537                     elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then
 538                         LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i
 539                     else
 540                         LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i
 541                     fi
 542                 done
 543             fi
 544         fi
 545     fi
 546 
 547     return $return_value
 548 }
 549 
 550 
 551 ################################################################################
 552 # Compare all zip files
 553 
 554 compare_all_zip_files() {
 555     THIS_DIR=$1
 556     OTHER_DIR=$2
 557     WORK_DIR=$3
 558 
 559     ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" -o -name "*.tar.gz" \
 560         | $SORT | $FILTER )
 561 
 562     if [ -n "$ZIPS" ]; then
 563         echo Zip/tar.gz files...
 564 
 565         return_value=0
 566         for f in $ZIPS; do
 567             if [ -f "$OTHER_DIR/$f" ]; then
 568                 compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
 569                 if [ "$?" != "0" ]; then
 570                     return_value=1
 571                     REGRESSIONS=true
 572                 fi
 573             fi
 574         done
 575     fi
 576 
 577     return $return_value
 578 }
 579 
 580 ################################################################################
 581 # Compare all jar files
 582 
 583 compare_all_jar_files() {
 584     THIS_DIR=$1
 585     OTHER_DIR=$2
 586     WORK_DIR=$3
 587 
 588     # TODO filter?
 589     ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" -o -name "*.war" \
 590         -o -name "modules" | $SORT | $FILTER)
 591 
 592     if [ -n "$ZIPS" ]; then
 593         echo Jar files...
 594 
 595         return_value=0
 596         for f in $ZIPS; do
 597             if [ -f "$OTHER_DIR/$f" ]; then
 598                 compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
 599                 if [ "$?" != "0" ]; then
 600                     return_value=1
 601                     REGRESSIONS=true
 602                 fi
 603             fi
 604         done
 605     fi
 606 
 607     return $return_value
 608 }
 609 
 610 ################################################################################
 611 # Compare binary (executable/library) file
 612 
 613 compare_bin_file() {
 614     THIS_DIR=$1
 615     OTHER_DIR=$2
 616     WORK_DIR=$3
 617     BIN_FILE=$4
 618     OTHER_BIN_FILE=$5
 619 
 620     THIS_FILE=$THIS_DIR/$BIN_FILE
 621     if [ -n "$OTHER_BIN_FILE" ]; then
 622         OTHER_FILE=$OTHER_DIR/$OTHER_BIN_FILE
 623     else
 624         OTHER_FILE=$OTHER_DIR/$BIN_FILE
 625     fi
 626     NAME=$(basename $BIN_FILE)
 627     WORK_FILE_BASE=$WORK_DIR/$BIN_FILE
 628     FILE_WORK_DIR=$(dirname $WORK_FILE_BASE)
 629 
 630     $MKDIR -p $FILE_WORK_DIR
 631 
 632     # Make soft links to original files from work dir to facilitate debugging
 633     $LN -f -s $THIS_FILE $WORK_FILE_BASE.this
 634     $LN -f -s $OTHER_FILE $WORK_FILE_BASE.other
 635 
 636     ORIG_THIS_FILE="$THIS_FILE"
 637     ORIG_OTHER_FILE="$OTHER_FILE"
 638 
 639     if [ "$STRIP_ALL" = "true" ] || [[ "$STRIP_BEFORE_COMPARE" = *"$BIN_FILE"* ]]; then
 640         THIS_STRIPPED_FILE=$FILE_WORK_DIR/this/$NAME
 641         OTHER_STRIPPED_FILE=$FILE_WORK_DIR/other/$NAME
 642         $MKDIR -p $FILE_WORK_DIR/this $FILE_WORK_DIR/other
 643         $CP $THIS_FILE $THIS_STRIPPED_FILE
 644         $CP $OTHER_FILE $OTHER_STRIPPED_FILE
 645         $STRIP $THIS_STRIPPED_FILE
 646         $STRIP $OTHER_STRIPPED_FILE
 647         THIS_FILE="$THIS_STRIPPED_FILE"
 648         OTHER_FILE="$OTHER_STRIPPED_FILE"
 649     fi
 650 
 651     if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
 652         unset _NT_SYMBOL_PATH
 653         if [ "$(uname -o)" = "Cygwin" ]; then
 654             THIS=$(cygpath -msa $THIS)
 655             OTHER=$(cygpath -msa $OTHER)
 656         fi
 657         # Build an _NT_SYMBOL_PATH that contains all known locations for
 658         # pdb files.
 659         PDB_DIRS="$(ls -d \
 660             {$OTHER,$THIS}/support/modules_{cmds,libs}/{*,*/*} \
 661             {$OTHER,$THIS}/support/native/java.base/java_objs \
 662             )"
 663         export _NT_SYMBOL_PATH="$(echo $PDB_DIRS | tr ' ' ';')"
 664     fi
 665 
 666     if [ -z "$SKIP_BIN_DIFF" ]; then
 667         if cmp $OTHER_FILE $THIS_FILE > /dev/null; then
 668         # The files were bytewise identical.
 669             if [ -n "$VERBOSE" ]; then
 670                 echo "        :           :         :         :          :          : $BIN_FILE"
 671             fi
 672             return 0
 673         fi
 674         BIN_MSG=" diff "
 675         if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then
 676             DIFF_BIN=true
 677             if [[ "$KNOWN_BIN_DIFF" != *"$BIN_FILE"* ]]; then
 678                 BIN_MSG="*$BIN_MSG*"
 679                 REGRESSIONS=true
 680             else
 681                 BIN_MSG=" $BIN_MSG "
 682             fi
 683         else
 684             BIN_MSG="($BIN_MSG)"
 685             DIFF_BIN=
 686         fi
 687     fi
 688 
 689     if [ -n "$STAT" ]; then
 690         THIS_SIZE=$($STAT $STAT_PRINT_SIZE "$THIS_FILE")
 691         OTHER_SIZE=$($STAT $STAT_PRINT_SIZE "$OTHER_FILE")
 692     else
 693         THIS_SIZE=$(ls -l "$THIS_FILE" | awk '{ print $5 }')
 694         OTHER_SIZE=$(ls -l "$OTHER_FILE" | awk '{ print $5 }')
 695     fi
 696     if [ $THIS_SIZE -ne $OTHER_SIZE ]; then
 697         DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE)
 698         DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE)
 699         SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM)
 700         if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \
 701             && [ "$DIFF_SIZE_REL" -lt 102 ]; then
 702             SIZE_MSG="($SIZE_MSG)"
 703             DIFF_SIZE=
 704         elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
 705             && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
 706             && [ "$DIFF_SIZE_NUM" = 512 ]; then
 707             # On windows, size of binaries increase in 512 increments.
 708             SIZE_MSG="($SIZE_MSG)"
 709             DIFF_SIZE=
 710         elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
 711             && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
 712             && [ "$DIFF_SIZE_NUM" = -512 ]; then
 713             # On windows, size of binaries increase in 512 increments.
 714             SIZE_MSG="($SIZE_MSG)"
 715             DIFF_SIZE=
 716         else
 717             if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
 718                 DIFF_SIZE=true
 719                 if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
 720                     SIZE_MSG="*$SIZE_MSG*"
 721                     REGRESSIONS=true
 722                 else
 723                     SIZE_MSG=" $SIZE_MSG "
 724                 fi
 725             else
 726                 SIZE_MSG="($SIZE_MSG)"
 727                 DIFF_SIZE=
 728             fi
 729         fi
 730     else
 731         SIZE_MSG="           "
 732         DIFF_SIZE=
 733         if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then
 734             SIZE_MSG="     !     "
 735         fi
 736     fi
 737 
 738     if [ "$SORT_ALL_SYMBOLS" = "true" ] || [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then
 739         SYM_SORT_CMD="sort"
 740     else
 741         SYM_SORT_CMD="cat"
 742     fi
 743 
 744     if [ -n "$SYMBOLS_DIFF_FILTER" ] && [ -z "$NEED_SYMBOLS_DIFF_FILTER" ] \
 745             || [[ "$NEED_SYMBOLS_DIFF_FILTER" = *"$BIN_FILE"* ]]; then
 746         this_SYMBOLS_DIFF_FILTER="$SYMBOLS_DIFF_FILTER"
 747     else
 748         this_SYMBOLS_DIFF_FILTER="$CAT"
 749     fi
 750 
 751     # Check symbols
 752     if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
 753         # The output from dumpbin on windows differs depending on if the debug symbol
 754         # files are still around at the location the binary is pointing too. Need
 755         # to filter out that extra information.
 756         $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
 757         $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
 758     elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
 759         # Some symbols get seemingly random 15 character prefixes. Filter them out.
 760         $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
 761         $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
 762     elif [ "$OPENJDK_TARGET_OS" = "aix" ]; then
 763         $OBJDUMP -T $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
 764         $OBJDUMP -T $ORIG_THIS_FILE  2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
 765     elif [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
 766         $NM -j $ORIG_OTHER_FILE 2> /dev/null | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
 767         $NM -j $ORIG_THIS_FILE  2> /dev/null | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
 768     else
 769         $NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME \
 770             | $AWK '{print $2, $3, $4, $5}' \
 771             | eval "$this_SYMBOLS_DIFF_FILTER" \
 772             | $SYM_SORT_CMD \
 773             > $WORK_FILE_BASE.symbols.other
 774         $NM -a $ORIG_THIS_FILE  2> /dev/null | $GREP -v $NAME \
 775             | $AWK '{print $2, $3, $4, $5}' \
 776             | eval "$this_SYMBOLS_DIFF_FILTER" \
 777             | $SYM_SORT_CMD \
 778             > $WORK_FILE_BASE.symbols.this
 779     fi
 780 
 781     LC_ALL=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff
 782     if [ -s $WORK_FILE_BASE.symbols.diff ]; then
 783         SYM_MSG=" diff  "
 784         if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then
 785             DIFF_SYM=true
 786             if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then
 787                 SYM_MSG="*$SYM_MSG*"
 788                 REGRESSIONS=true
 789             else
 790                 SYM_MSG=" $SYM_MSG "
 791             fi
 792         else
 793             SYM_MSG="($SYM_MSG)"
 794             DIFF_SYM=
 795         fi
 796     else
 797         SYM_MSG="         "
 798         DIFF_SYM=
 799         if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then
 800             SYM_MSG="    !    "
 801         fi
 802     fi
 803 
 804     # Check dependencies
 805     if [ -n "$LDD_CMD" ]; then
 806         if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
 807             LDD_FILTER="$GREP \.dll"
 808         else
 809             LDD_FILTER="$CAT"
 810         fi
 811         (cd $FILE_WORK_DIR && $CP $OTHER_FILE . && $LDD_CMD $NAME 2>/dev/null \
 812                     | $LDD_FILTER | $AWK '{ print $1;}' | $SORT \
 813                     | $TEE $WORK_FILE_BASE.deps.other \
 814                     | $UNIQ > $WORK_FILE_BASE.deps.other.uniq)
 815         (cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME 2</dev/null \
 816                     | $LDD_FILTER | $AWK '{ print $1;}' | $SORT \
 817                     | $TEE $WORK_FILE_BASE.deps.this \
 818                     | $UNIQ > $WORK_FILE_BASE.deps.this.uniq)
 819         (cd $FILE_WORK_DIR && $RM -f $NAME)
 820 
 821         LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this \
 822               > $WORK_FILE_BASE.deps.diff
 823         LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq \
 824               > $WORK_FILE_BASE.deps.diff.uniq
 825 
 826         if [ -s $WORK_FILE_BASE.deps.diff ]; then
 827             if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then
 828                 DEP_MSG=" diff  "
 829             else
 830                 DEP_MSG=" redun "
 831             fi
 832             if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then
 833                 DIFF_DEP=true
 834                 if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then
 835                     DEP_MSG="*$DEP_MSG*"
 836                     REGRESSIONS=true
 837                 else
 838                     DEP_MSG=" $DEP_MSG "
 839                 fi
 840             else
 841                 DEP_MSG="($DEP_MSG)"
 842                 DIFF_DEP=
 843             fi
 844         else
 845             DEP_MSG="         "
 846             DIFF_DEP=
 847             if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
 848                 DEP_MSG="     !      "
 849             fi
 850         fi
 851     else
 852         DEP_MSG="    -    "
 853     fi
 854 
 855     # Some linux compilers add a unique Build ID
 856     if [ "$OPENJDK_TARGET_OS" = "linux" ]; then
 857       BUILD_ID_FILTER="$SED -r 's/(Build ID:) [0-9a-f]{40}/\1/'"
 858     else
 859       BUILD_ID_FILTER="$CAT"
 860     fi
 861 
 862     # Compare fulldump output
 863     if [ -n "$FULLDUMP_CMD" ] && [ -z "$SKIP_FULLDUMP_DIFF" ]; then
 864         if [ -z "$FULLDUMP_DIFF_FILTER" ]; then
 865             FULLDUMP_DIFF_FILTER="$CAT"
 866         fi
 867         $FULLDUMP_CMD $OTHER_FILE | eval "$BUILD_ID_FILTER" | eval "$FULLDUMP_DIFF_FILTER" \
 868             > $WORK_FILE_BASE.fulldump.other 2>&1 &
 869         $FULLDUMP_CMD $THIS_FILE  | eval "$BUILD_ID_FILTER" | eval "$FULLDUMP_DIFF_FILTER" \
 870             > $WORK_FILE_BASE.fulldump.this  2>&1 &
 871         wait
 872 
 873         LC_ALL=C $DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this \
 874             > $WORK_FILE_BASE.fulldump.diff
 875 
 876         if [ -s $WORK_FILE_BASE.fulldump.diff ]; then
 877             FULLDUMP_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.fulldump.diff | awk '{print $5}')
 878             FULLDUMP_MSG=$($PRINTF "%8d" $FULLDUMP_DIFF_SIZE)
 879             if [[ "$ACCEPTED_FULLDUMP_DIFF" != *"$BIN_FILE"* ]]; then
 880                 DIFF_FULLDUMP=true
 881                 if [[ "$KNOWN_FULLDUMP_DIFF" != *"$BIN_FILE"* ]]; then
 882                     FULLDUMP_MSG="*$FULLDUMP_MSG*"
 883                     REGRESSIONS=true
 884                 else
 885                     FULLDUMP_MSG=" $FULLDUMP_MSG "
 886                 fi
 887             else
 888                 FULLDUMP_MSG="($FULLDUMP_MSG)"
 889                 DIFF_FULLDUMP=
 890             fi
 891         else
 892             FULLDUMP_MSG="          "
 893             DIFF_FULLDUMP=
 894             if [[ "$KNOWN_FULLDUMP_DIFF $ACCEPTED_FULLDUMP_DIFF" = *"$BIN_FILE"* ]]; then
 895                 FULLDUMP_MSG="    !    "
 896             fi
 897         fi
 898     fi
 899 
 900     # Compare disassemble output
 901     if [ -n "$DIS_CMD" ] && [ -z "$SKIP_DIS_DIFF" ]; then
 902         this_DIS_DIFF_FILTER="$CAT"
 903         if [ -n "$DIS_DIFF_FILTER" ]; then
 904             if [ -z "$NEED_DIS_DIFF_FILTER" ] \
 905                 || [[ "$NEED_DIS_DIFF_FILTER" = *"$BIN_FILE"* ]]; then
 906                 this_DIS_DIFF_FILTER="$DIS_DIFF_FILTER"
 907             fi
 908         fi
 909         if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
 910             DIS_GREP_ARG=-a
 911         else
 912             DIS_GREP_ARG=
 913         fi
 914         $DIS_CMD $OTHER_FILE | $GREP $DIS_GREP_ARG -v $NAME \
 915             | eval "$this_DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.other 2>&1 &
 916         $DIS_CMD $THIS_FILE  | $GREP $DIS_GREP_ARG -v $NAME \
 917             | eval "$this_DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.this  2>&1 &
 918         wait
 919 
 920         LC_ALL=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff
 921 
 922         if [ -s $WORK_FILE_BASE.dis.diff ]; then
 923             DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}')
 924             DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE)
 925             if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then
 926                 DIFF_DIS=true
 927                 if [ "$MAX_KNOWN_DIS_DIFF_SIZE" = "" ]; then
 928                     MAX_KNOWN_DIS_DIFF_SIZE="0"
 929                 fi
 930                 if [[ "$KNOWN_DIS_DIFF" = *"$BIN_FILE"* ]] \
 931                     && [ "$DIS_DIFF_SIZE" -lt "$MAX_KNOWN_DIS_DIFF_SIZE" ]; then
 932                     DIS_MSG=" $DIS_MSG "
 933                 else
 934                     DIS_MSG="*$DIS_MSG*"
 935                     REGRESSIONS=true
 936                 fi
 937             else
 938                 DIS_MSG="($DIS_MSG)"
 939                 DIFF_DIS=
 940             fi
 941         else
 942             DIS_MSG="          "
 943             DIFF_DIS=
 944             if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
 945                 DIS_MSG="    !    "
 946             fi
 947         fi
 948     fi
 949 
 950 
 951     if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_FULLDUMP$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then
 952         if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi
 953         if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi
 954         if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi
 955         if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi
 956         if [ -n "$FULLDUMP_MSG" ]; then echo -n "$FULLDUMP_MSG:"; fi
 957         if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi
 958         echo " $BIN_FILE"
 959         if [ "$SHOW_DIFFS" = "true" ]; then
 960             if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then
 961                 echo "Symbols diff:"
 962                 $CAT $WORK_FILE_BASE.symbols.diff
 963             fi
 964             if [ -s "$WORK_FILE_BASE.deps.diff" ]; then
 965                 echo "Deps diff:"
 966                 $CAT $WORK_FILE_BASE.deps.diff
 967             fi
 968             if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then
 969                 echo "Fulldump diff:"
 970                 $CAT $WORK_FILE_BASE.fulldump.diff
 971             fi
 972             if [ -s "$WORK_FILE_BASE.dis.diff" ]; then
 973                 echo "Disassembly diff:"
 974                 $CAT $WORK_FILE_BASE.dis.diff
 975             fi
 976         fi
 977         return 1
 978     fi
 979     return 0
 980 }
 981 
 982 ################################################################################
 983 # Print binary diff header
 984 
 985 print_binary_diff_header() {
 986     if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi
 987     if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n "   Size    :"; fi
 988     if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi
 989     if [ -z "$SKIP_DEP_DIFF" ]; then echo -n "  Deps   :"; fi
 990     if [ -z "$SKIP_FULLDUMP_DIFF" ]; then echo -n " Fulldump :"; fi
 991     if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass   :"; fi
 992     echo
 993 }
 994 
 995 ################################################################################
 996 # Compare all libraries
 997 
 998 compare_all_libs() {
 999     THIS_DIR=$1
1000     OTHER_DIR=$2
1001     WORK_DIR=$3
1002 
1003     LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' \
1004         -o -name '*.dll' -o -name '*.obj' -o -name '*.o' -o -name '*.a' \
1005         -o -name '*.cpl' \) | $SORT | $FILTER)
1006 
1007     # On macos, filter out the dSYM debug symbols files as they are also
1008     # named *.dylib.
1009     if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
1010         LIBS=$(echo "$LIBS" | $GREP -v '\.dSYM/')
1011     fi
1012 
1013     if [ -n "$LIBS" ]; then
1014         echo Libraries...
1015         print_binary_diff_header
1016         for l in $LIBS; do
1017             if [ -f "$OTHER_DIR/$l" ]; then
1018                 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l
1019                 if [ "$?" != "0" ]; then
1020                     return_value=1
1021                 fi
1022             fi
1023         done
1024     fi
1025 
1026     return $return_value
1027 }
1028 
1029 ################################################################################
1030 # Compare all executables
1031 
1032 compare_all_execs() {
1033     THIS_DIR=$1
1034     OTHER_DIR=$2
1035     WORK_DIR=$3
1036 
1037     if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
1038         EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER)
1039     else
1040         EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \
1041             \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \
1042             -o -name '*.jar' -o -name '*.diz' -o -name 'jcontrol' -o -name '*.properties' \
1043             -o -name '*.data' -o -name '*.bfc' -o -name '*.src' -o -name '*.txt' \
1044             -o -name '*.cfg' -o -name 'meta-index' -o -name '*.properties.ja' \
1045             -o -name '*.xml' -o -name '*.html' -o -name '*.png' -o -name 'README' \
1046             -o -name '*.zip' -o -name '*.jimage' -o -name '*.java' -o -name '*.mf' \
1047             -o -name '*.jpg' -o -name '*.wsdl' -o -name '*.js' -o -name '*.sh' \
1048             -o -name '*.bat' -o -name '*LICENSE' -o -name '*.d' -o -name '*store' \
1049             -o -name 'blacklist' -o -name '*certs' -o -name '*.ttf' \
1050             -o -name '*.jfc' -o -name '*.dat'  -o -name 'release' -o -name '*.dir'\
1051             -o -name '*.sym' -o -name '*.idl' -o -name '*.h' -o -name '*.access' \
1052             -o -name '*.template' -o -name '*.policy' -o -name '*.security' \
1053             -o -name 'COPYRIGHT' -o -name '*.1' -o -name '*.debuginfo' \
1054             -o -name 'classlist' \) | $SORT | $FILTER)
1055     fi
1056 
1057     if [ -n "$EXECS" ]; then
1058         echo Executables...
1059         print_binary_diff_header
1060         for e in $EXECS; do
1061             if [ -f "$OTHER_DIR/$e" ]; then
1062                 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e
1063                 if [ "$?" != "0" ]; then
1064                     return_value=1
1065                 fi
1066             fi
1067         done
1068     fi
1069 
1070     return $return_value
1071 }
1072 
1073 ################################################################################
1074 # Initiate configuration
1075 
1076 THIS="$SCRIPT_DIR"
1077 echo "$THIS"
1078 THIS_SCRIPT="$0"
1079 
1080 if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
1081     echo "bash ./compare.sh [OPTIONS] [FILTER]"
1082     echo ""
1083     echo "-all                Compare all files in all known ways"
1084     echo "-names              Compare the file names and directory structure"
1085     echo "-perms              Compare the permission bits on all files and directories"
1086     echo "-types              Compare the output of the file command on all files"
1087     echo "-general            Compare the files not convered by the specialized comparisons"
1088     echo "-zips               Compare the contents of all zip files and files in them"
1089     echo "-zips-names         Compare the file names inside all zip files"
1090     echo "-jars               Compare the contents of all jar files"
1091     echo "-libs               Compare all native libraries"
1092     echo "-execs              Compare all executables"
1093     echo "-v                  Verbose output, does not hide known differences"
1094     echo "-vv                 More verbose output, shows diff output of all comparisons"
1095     echo "-o [OTHER]          Compare with build in other directory. Will default to the old build directory"
1096     echo ""
1097     echo "--sort-symbols      Sort all symbols before comparing"
1098     echo "--strip             Strip all binaries before comparing"
1099     echo "--clean             Clean all previous comparison results first"
1100     echo ""
1101     echo "[FILTER]            List filenames in the image to compare, works for jars, zips, libs and execs"
1102     echo "Example:"
1103     echo "bash ./make/scripts/compareimages.sh CodePointIM.jar"
1104     echo ""
1105     echo "-2zips <file1> <file2> Compare two zip files only"
1106     echo "-2bins <file1> <file2> Compare two binary files only"
1107     echo "-2dirs <dir1> <dir2> Compare two directories as if they were images"
1108     echo ""
1109     exit 10
1110 fi
1111 
1112 CMP_NAMES=false
1113 CMP_PERMS=false
1114 CMP_TYPES=false
1115 CMP_GENERAL=false
1116 CMP_ZIPS=false
1117 CMP_ZIPS_CONTENTS=true
1118 CMP_JARS=false
1119 CMP_LIBS=false
1120 CMP_EXECS=false
1121 
1122 while [ -n "$1" ]; do
1123     case "$1" in
1124         -v)
1125             VERBOSE=true
1126             ;;
1127         -vv)
1128             VERBOSE=true
1129             SHOW_DIFFS=true
1130             ;;
1131         -o)
1132             OTHER="$2"
1133             shift
1134             ;;
1135         -all)
1136             CMP_NAMES=true
1137             if [ "$OPENJDK_TARGET_OS" != "windows" ]; then
1138                 CMP_PERMS=true
1139             fi
1140             CMP_TYPES=true
1141             CMP_GENERAL=true
1142             CMP_ZIPS=true
1143             CMP_JARS=true
1144             CMP_LIBS=true
1145             CMP_EXECS=true
1146             ;;
1147         -names)
1148             CMP_NAMES=true
1149             ;;
1150         -perms)
1151             CMP_PERMS=true
1152             ;;
1153         -types)
1154             CMP_TYPES=true
1155             ;;
1156         -general)
1157             CMP_GENERAL=true
1158             ;;
1159         -zips)
1160             CMP_ZIPS=true
1161             CMP_ZIPS_CONTENTS=true
1162             ;;
1163         -zips-names)
1164             CMP_ZIPS=true
1165             CMP_ZIPS_CONTENTS=false
1166             ;;
1167         -jars)
1168             CMP_JARS=true
1169             ;;
1170         -libs)
1171             CMP_LIBS=true
1172             ;;
1173         -execs)
1174             CMP_EXECS=true
1175             ;;
1176         -2dirs)
1177             THIS="$(cd "$2" > /dev/null && pwd )"
1178             OTHER="$(cd "$3" > /dev/null && pwd )"
1179             THIS_BASE_DIR="$THIS"
1180             OTHER_BASE_DIR="$OTHER"
1181             SKIP_DEFAULT=true
1182             shift
1183             shift
1184             ;;
1185         -2zips)
1186             CMP_2_ZIPS=true
1187             THIS_FILE=$2
1188             OTHER_FILE=$3
1189             shift
1190             shift
1191             ;;
1192         -2bins)
1193             CMP_2_BINS=true
1194             THIS_FILE=$2
1195             OTHER_FILE=$3
1196             shift
1197             shift
1198             ;;
1199         --sort-symbols)
1200             SORT_ALL_SYMBOLS=true
1201             ;;
1202         --strip)
1203             STRIP_ALL=true
1204             ;;
1205         --clean)
1206             CLEAN_OUTPUT=true
1207             ;;
1208         *)
1209             CMP_NAMES=false
1210             CMP_PERMS=false
1211             CMP_TYPES=false
1212             CMP_ZIPS=true
1213             CMP_JARS=true
1214             CMP_LIBS=true
1215             CMP_EXECS=true
1216 
1217             if [ -z "$FILTER" ]; then
1218                 FILTER="$GREP"
1219             fi
1220             FILTER="$FILTER -e $1"
1221             ;;
1222     esac
1223     shift
1224 done
1225 
1226 if [ "$STRIP_ALL" = "true" ] && [ -z "$STRIP" ]; then
1227   echo Warning: Not stripping even with --strip, since strip is missing on this platform
1228   STRIP_ALL=false
1229 fi
1230 
1231 COMPARE_ROOT=$OUTPUTDIR/compare-support
1232 if [ "$CLEAN_OUTPUT" = "true" ]; then
1233     echo Cleaning old output in $COMPARE_ROOT.
1234     $RM -rf $COMPARE_ROOT
1235 fi
1236 $MKDIR -p $COMPARE_ROOT
1237 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
1238     if [ "$(uname -o)" = "Cygwin" ]; then
1239         COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT)
1240     fi
1241 fi
1242 
1243 if [ "$CMP_2_ZIPS" = "true" ]; then
1244     THIS_DIR="$(dirname $THIS_FILE)"
1245     THIS_DIR="$(cd "$THIS_DIR" > /dev/null && pwd )"
1246     OTHER_DIR="$(dirname $OTHER_FILE)"
1247     OTHER_DIR="$(cd "$OTHER_DIR" > /dev/null && pwd )"
1248     THIS_FILE_NAME="$(basename $THIS_FILE)"
1249     OTHER_FILE_NAME="$(basename $OTHER_FILE)"
1250     echo Comparing $THIS_DIR/$THIS_FILE_NAME and $OTHER_DIR/$OTHER_FILE_NAME
1251     compare_zip_file $THIS_DIR $OTHER_DIR $COMPARE_ROOT/2zips $THIS_FILE_NAME $OTHER_FILE_NAME
1252     exit
1253 fi
1254 
1255 if [ "$CMP_2_BINS" = "true" ]; then
1256     THIS_DIR="$(dirname $THIS_FILE)"
1257     THIS_DIR="$(cd "$THIS_DIR" > /dev/null && pwd )"
1258     OTHER_DIR="$(dirname $OTHER_FILE)"
1259     OTHER_DIR="$(cd "$OTHER_DIR" > /dev/null && pwd )"
1260     THIS_FILE_NAME="$(basename $THIS_FILE)"
1261     OTHER_FILE_NAME="$(basename $OTHER_FILE)"
1262     echo Comparing $THIS_DIR/$THIS_FILE_NAME and $OTHER_DIR/$OTHER_FILE_NAME
1263     compare_bin_file $THIS_DIR $OTHER_DIR $COMPARE_ROOT/2bins $THIS_FILE_NAME $OTHER_FILE_NAME
1264     exit
1265 fi
1266 
1267 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
1268     CMP_NAMES=true
1269     CMP_PERMS=true
1270     CMP_TYPES=true
1271     CMP_GENERAL=true
1272     CMP_ZIPS=true
1273     CMP_JARS=true
1274     CMP_LIBS=true
1275     CMP_EXECS=true
1276 fi
1277 
1278 if [ -z "$FILTER" ]; then
1279     FILTER="$CAT"
1280 fi
1281 
1282 if [ "$SKIP_DEFAULT" != "true" ]; then
1283     if [ -z "$OTHER" ]; then
1284         echo "Nothing to compare to, set with -o"
1285         exit 1
1286     else
1287         if [ ! -d "$OTHER" ]; then
1288             echo "Other build directory does not exist:"
1289             echo "$OTHER"
1290             exit 1
1291         fi
1292         OTHER="$( cd "$OTHER" > /dev/null && pwd )"
1293         echo "Comparing to:"
1294         echo "$OTHER"
1295         echo
1296     fi
1297 
1298 
1299     # Find the common images to compare, prioritizing later build stages
1300     if [ -d "$THIS/install/jdk" ] && [ -d "$OTHER/install/jdk" ]; then
1301         THIS_JDK="$THIS/install/jdk"
1302         OTHER_JDK="$OTHER/install/jdk"
1303         echo "Selecting install images for JDK compare"
1304     elif [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/images/jdk" ]; then
1305         THIS_JDK="$THIS/images/jdk"
1306         OTHER_JDK="$OTHER/images/jdk"
1307         echo "Selecting normal images for JDK compare"
1308     elif [ -d "$(ls -d $THIS/licensee-src/build/*/images/jdk 2> /dev/null)" ] \
1309         && [ -d "$(ls -d $OTHER/licensee-src/build/*/images/jdk 2> /dev/null)" ]
1310     then
1311         echo "Selecting licensee images for compare"
1312         # Simply override the THIS and OTHER dir with the build dir from
1313         # the nested licensee source build for the rest of the script
1314         # execution.
1315         OLD_THIS="$THIS"
1316         OLD_OTHER="$OTHER"
1317         THIS="$(ls -d $THIS/licensee-src/build/*)"
1318         OTHER="$(ls -d $OTHER/licensee-src/build/*)"
1319         THIS_JDK="$THIS/images/jdk"
1320         OTHER_JDK="$OTHER/images/jdk"
1321         # Rewrite the path to tools that are used from the build
1322         JIMAGE="$(echo "$JIMAGE" | $SED "s|$OLD_THIS|$THIS|g")"
1323         JAVAP="$(echo "$JAVAP" | $SED "s|$OLD_THIS|$THIS|g")"
1324     else
1325         echo "No common images found."
1326         exit 1
1327     fi
1328     echo "  $THIS_JDK"
1329     echo "  $OTHER_JDK"
1330 
1331     if [ -d "$THIS/images/jdk-bundle" -o -d "$THIS/deploy/images/jdk-bundle" ] \
1332              && [ -d "$OTHER/images/jdk-bundle" -o -d "$OTHER/deploy/images/jdk-bundle" ]; then
1333         if [ -d "$THIS/deploy/images/jdk-bundle" ]; then
1334             THIS_JDK_BUNDLE="$THIS/deploy/images/jdk-bundle"
1335         else
1336             THIS_JDK_BUNDLE="$THIS/images/jdk-bundle"
1337         fi
1338         if [ -d "$OTHER/deploy/images/jdk-bundle" ]; then
1339             OTHER_JDK_BUNDLE="$OTHER/deploy/images/jdk-bundle"
1340         else
1341             OTHER_JDK_BUNDLE="$OTHER/images/jdk-bundle"
1342         fi
1343         echo "Also comparing jdk macosx bundles"
1344         echo "  $THIS_JDK_BUNDLE"
1345         echo "  $OTHER_JDK_BUNDLE"
1346     fi
1347 
1348     if [ -d "$THIS/deploy/bundles" -o -d "$THIS/deploy/images/bundles" ] \
1349              && [ -d "$OTHER/deploy/bundles" -o -d "$OTHER/deploy/images/bundles" ]; then
1350         if [ -d "$THIS/deploy/images/bundles" ]; then
1351             THIS_DEPLOY_BUNDLE_DIR="$THIS/deploy/images/bundles"
1352         else
1353             THIS_DEPLOY_BUNDLE_DIR="$THIS/deploy/bundles"
1354         fi
1355         if [ -d "$OTHER/deploy/images/bundles" ]; then
1356             OTHER_DEPLOY_BUNDLE_DIR="$OTHER/deploy/images/bundles"
1357         else
1358             OTHER_DEPLOY_BUNDLE_DIR="$OTHER/deploy/bundles"
1359         fi
1360         echo "Also comparing deploy javadoc bundles"
1361     fi
1362 
1363     if [ -d "$THIS/images/JavaAppletPlugin.plugin" ] \
1364              && [ -d "$OTHER/images/JavaAppletPlugin.plugin" -o -d "$OTHER/deploy/images/JavaAppletPlugin.plugin" ]; then
1365         if [ -d "$THIS/images/JavaAppletPlugin.plugin" ]; then
1366             THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/images/JavaAppletPlugin.plugin"
1367         else
1368             THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/deploy/images/JavaAppletPlugin.plugin"
1369         fi
1370         if [ -d "$OTHER/images/JavaAppletPlugin.plugin" ]; then
1371             OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/images/JavaAppletPlugin.plugin"
1372         else
1373             OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/deploy/images/JavaAppletPlugin.plugin"
1374         fi
1375         echo "Also comparing deploy applet image"
1376         echo "  $THIS_DEPLOY_APPLET_PLUGIN_DIR"
1377         echo "  $OTHER_DEPLOY_APPLET_PLUGIN_DIR"
1378     fi
1379 
1380     if [ -d "$THIS/install/sparkle/Sparkle.framework" ] \
1381            && [ -d "$OTHER/install/sparkle/Sparkle.framework" ]; then
1382         THIS_SPARKLE_DIR="$THIS/install/sparkle/Sparkle.framework"
1383         OTHER_SPARKLE_DIR="$OTHER/install/sparkle/Sparkle.framework"
1384         echo "Also comparing install sparkle framework"
1385         echo "  $THIS_SPARKLE_DIR"
1386         echo "  $OTHER_SPARKLE_DIR"
1387     fi
1388 
1389     THIS_SEC_DIR="$THIS/images"
1390     OTHER_SEC_DIR="$OTHER/images"
1391     if [ -f "$THIS_SEC_DIR/sec-bin.zip" ] && [ -f "$OTHER_SEC_DIR/sec-bin.zip" ]; then
1392         OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip"
1393         THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip"
1394         if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
1395             if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
1396                 JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip"
1397             else
1398                 JGSS_WINDOWS_BIN="jgss-windows-i586-bin.zip"
1399             fi
1400             OTHER_SEC_WINDOWS_BIN="$OTHER_SEC_DIR/sec-windows-bin.zip"
1401             OTHER_JGSS_WINDOWS_BIN="$OTHER_SEC_DIR/$JGSS_WINDOWS_BIN"
1402             THIS_SEC_WINDOWS_BIN="$THIS_SEC_DIR/sec-windows-bin.zip"
1403             THIS_JGSS_WINDOWS_BIN="$THIS_SEC_DIR/$JGSS_WINDOWS_BIN"
1404         fi
1405     fi
1406 
1407     if [ -d "$THIS/images/docs" ] && [ -d "$OTHER/images/docs" ]; then
1408         THIS_DOCS="$THIS/images/docs"
1409         OTHER_DOCS="$OTHER/images/docs"
1410         echo "Also comparing docs"
1411     else
1412         echo "WARNING! Docs haven't been built and won't be compared."
1413     fi
1414 fi
1415 
1416 ################################################################################
1417 # Do the work
1418 
1419 if [ "$CMP_NAMES" = "true" ]; then
1420     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
1421         echo -n "JDK "
1422         compare_dirs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
1423         echo -n "JDK "
1424         compare_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
1425     fi
1426     if [ -n "$THIS_JDK_BUNDLE" ] && [ -n "$OTHER_JDK_BUNDLE" ]; then
1427         echo -n "JDK Bundle "
1428         compare_dirs $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle
1429 
1430         echo -n "JDK Bundle "
1431         compare_files $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle
1432     fi
1433     if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then
1434         echo -n "Docs "
1435         compare_dirs $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
1436         echo -n "Docs "
1437         compare_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
1438     fi
1439     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
1440         compare_dirs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
1441         compare_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
1442     fi
1443     if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
1444         echo -n "JavaAppletPlugin "
1445         compare_dirs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
1446         echo -n "JavaAppletPlugin "
1447         compare_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
1448     fi
1449     if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
1450         echo -n "Sparkle.framework "
1451         compare_dirs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
1452         echo -n "Sparkle.framework "
1453         compare_files $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
1454     fi
1455 fi
1456 
1457 if [ "$CMP_LIBS" = "true" ]; then
1458     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
1459         echo -n "JDK "
1460         compare_all_libs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
1461     fi
1462     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
1463         compare_all_libs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
1464     fi
1465     if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
1466         echo -n "JavaAppletPlugin "
1467         compare_all_libs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
1468     fi
1469     if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
1470         echo -n "Sparkle.framework "
1471         compare_all_libs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
1472     fi
1473 fi
1474 
1475 if [ "$CMP_EXECS" = "true" ]; then
1476     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
1477         compare_all_execs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
1478     fi
1479     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
1480         compare_all_execs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
1481     fi
1482     if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
1483         echo -n "JavaAppletPlugin "
1484         compare_all_execs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
1485     fi
1486     if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
1487         echo -n "Sparkle.framework "
1488         compare_all_execs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
1489     fi
1490 fi
1491 
1492 if [ "$CMP_GENERAL" = "true" ]; then
1493     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
1494         echo -n "JDK "
1495         compare_general_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
1496     fi
1497     if [ -n "$THIS_JDK_BUNDLE" ] && [ -n "$OTHER_JDK_BUNDLE" ]; then
1498         echo -n "JDK Bundle "
1499         compare_general_files $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle
1500     fi
1501     if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then
1502         echo -n "Docs "
1503         compare_general_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
1504     fi
1505     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
1506         compare_general_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
1507     fi
1508     if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
1509         echo -n "JavaAppletPlugin "
1510         compare_general_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
1511     fi
1512     if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
1513         echo -n "Sparkle.framework "
1514         compare_general_files $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
1515     fi
1516 fi
1517 
1518 if [ "$CMP_ZIPS" = "true" ]; then
1519     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
1520         compare_all_zip_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
1521     fi
1522     if [ -n "$THIS_SEC_BIN" ] && [ -n "$OTHER_SEC_BIN" ]; then
1523         if [ -n "$(echo $THIS_SEC_BIN | $FILTER)" ]; then
1524             echo "sec-bin.zip..."
1525             compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-bin.zip
1526         fi
1527     fi
1528     if [ -n "$THIS_SEC_WINDOWS_BIN" ] && [ -n "$OTHER_SEC_WINDOWS_BIN" ]; then
1529         if [ -n "$(echo $THIS_SEC_WINDOWS_BIN | $FILTER)" ]; then
1530             echo "sec-windows-bin.zip..."
1531             compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-windows-bin.zip
1532         fi
1533     fi
1534     if [ -n "$THIS_JGSS_WINDOWS_BIN" ] && [ -n "$OTHER_JGSS_WINDOWS_BIN" ]; then
1535         if [ -n "$(echo $THIS_JGSS_WINDOWS_BIN | $FILTER)" ]; then
1536             echo "$JGSS_WINDOWS_BIN..."
1537             compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin $JGSS_WINDOWS_BIN
1538         fi
1539     fi
1540     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
1541         compare_all_zip_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
1542     fi
1543     if [ -n "$THIS_DEPLOY_BUNDLE_DIR" ] && [ -n "$OTHER_DEPLOY_BUNDLE_DIR" ]; then
1544         compare_all_zip_files $THIS_DEPLOY_BUNDLE_DIR $OTHER_DEPLOY_BUNDLE_DIR $COMPARE_ROOT/deploy-bundle
1545     fi
1546     if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
1547         compare_all_zip_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
1548     fi
1549 fi
1550 
1551 if [ "$CMP_JARS" = "true" ]; then
1552     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
1553         compare_all_jar_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
1554     fi
1555     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
1556         compare_all_jar_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
1557     fi
1558     if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
1559         compare_all_jar_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
1560     fi
1561 fi
1562 
1563 if [ "$CMP_PERMS" = "true" ]; then
1564     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
1565         echo -n "JDK "
1566         compare_permissions $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
1567     fi
1568     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
1569         compare_permissions $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
1570     fi
1571     if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
1572         echo -n "JavaAppletPlugin "
1573         compare_permissions $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
1574     fi
1575     if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
1576         echo -n "Sparkle.framework "
1577         compare_permissions $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
1578     fi
1579 fi
1580 
1581 if [ "$CMP_TYPES" = "true" ]; then
1582     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
1583         echo -n "JDK "
1584         compare_file_types $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
1585     fi
1586     if [ -n "$THIS_JDK_BUNDLE" ] && [ -n "$OTHER_JDK_BUNDLE" ]; then
1587         echo -n "JDK Bundle "
1588         compare_file_types $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle
1589     fi
1590     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
1591         compare_file_types $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
1592     fi
1593     if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
1594         echo -n "JavaAppletPlugin "
1595         compare_file_types $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
1596     fi
1597     if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
1598         echo -n "Sparkle.framework "
1599         compare_file_types $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
1600     fi
1601 fi
1602 
1603 echo
1604 
1605 if [ -n "$REGRESSIONS" ]; then
1606     echo "REGRESSIONS FOUND!"
1607     echo
1608     exit 1
1609 else
1610     echo "No regressions found"
1611     echo
1612     exit 0
1613 fi