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