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