aboutsummaryrefslogtreecommitdiff
path: root/common/bin/compare.sh
blob: 08c0d6bb2294c6e0a5c1a982491e58310fa7a92d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
#!/bin/bash
#
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

# This script is processed by configure before it's usable. It is run from 
# the root of the build directory.


##########################################################################################

# Check that we are run via the wrapper generated by configure
if [ -z "$SRC_ROOT" ]; then
    echo "Error: You must run this script using build/[conf]/compare.sh"
    exit 1
fi

if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
    FULLDUMP_CMD="$OTOOL -v -V -h -X -t -d"
    LDD_CMD="$OTOOL -L"
    DIS_CMD="$OTOOL -v -t"
    STAT_PRINT_SIZE="-f %z"
elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then
    FULLDUMP_CMD="$DUMPBIN -all"
    LDD_CMD="$DUMPBIN -dependants | $GREP .dll"
    DIS_CMD="$DUMPBIN -disasm:nobytes"
    STAT_PRINT_SIZE="-c %s"
else
    FULLDUMP_CMD="$READELF -a"
    LDD_CMD="$LDD"
    DIS_CMD="$OBJDUMP -d"
    STAT_PRINT_SIZE="-c %s"
fi

UNARCHIVE="$UNZIP -q"

COMPARE_EXCEPTIONS_INCLUDE="$SRC_ROOT/common/bin/compare_exceptions.sh.incl"
if [ ! -e "$COMPARE_EXCEPTIONS_INCLUDE" ]; then
    echo "Error: Cannot locate the exceptions file, it should have been here: $COMPARE_EXCEPTIONS_INCLUDE"
    exit 1
fi
# Include exception definitions
. "$COMPARE_EXCEPTIONS_INCLUDE"

##########################################################################################
# Compare text files and ignore specific differences:
#
#  * Timestamps in Java sources generated by idl2java
#  * Sorting order and cleanup style in .properties files

diff_text() {
    OTHER_FILE=$1
    THIS_FILE=$2

    SUFFIX="${THIS_FILE##*.}"

    TMP=1

    if [[ "$THIS_FILE" = *"META-INF/MANIFEST.MF" ]]; then
        TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \
            $GREP '^[<>]' | \
            $SED -e '/[<>] Ant-Version: Apache Ant .*/d' \
	         -e '/[<>] Created-By: .* (Oracle Corporation).*/d')
    fi
    if test "x$SUFFIX" = "xjava"; then
        TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \
            $GREP '^[<>]' | \
            $SED -e '/[<>] \* from.*\.idl/d' \
                 -e '/[<>] \*.*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
                 -e '/[<>] \*.*[0-9]\{4\} [0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \
                 -e '/\/\/ Generated from input file.*/d' \
                 -e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \
                 -e '/\/\/ java GenerateCharacter.*/d')
    fi
    # Ignore date strings in class files.
    # On Macosx the system sources for generated java classes produce different output on 
    # consequtive invokations seemingly randomly.
    # For example a method parameter randomly named "thePoint" or "aPoint". Ignore this.
    if test "x$SUFFIX" = "xclass"; then
        # To improve performance when large diffs are found, do a rough filtering of classes
        # elibeble for these exceptions
        if $GREP -R -e '[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}' \
	        -e '[0-9]\{2\}/[0-9]\{2\}/[0-9]\{4\}' \
	        -e thePoint -e aPoint -e setItemsPtr ${THIS_FILE} > /dev/null; then
            $JAVAP -c -constants -l -p ${OTHER_FILE} >  ${OTHER_FILE}.javap
            $JAVAP -c -constants -l -p ${THIS_FILE} > ${THIS_FILE}.javap
            TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \
                $GREP '^[<>]' | \
                $SED -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
		     -e '/[0-9]\{2\}\/[0-9]\{2\}\/[0-9]\{4\}/d' \
 	             -e '/[<>].*Point   Lcom\/apple\/jobjc\/foundation\/NSPoint;/d' \
	             -e '/[<>].*public com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*itemsPtr();/d' \
	             -e '/[<>].*public void setItemsPtr(com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*);/d')
        fi
    fi
    if test "x$SUFFIX" = "xproperties"; then
        # Run through nawk to add possibly missing newline at end of file.
        $CAT $OTHER_FILE | $NAWK '{ print }' > $OTHER_FILE.cleaned
# Disable this exception since we aren't changing the properties cleaning method yet.
#        $CAT $OTHER_FILE | $SED -e 's/\([^\\]\):/\1\\:/g' -e  's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \
#            | $SED -f "$SRC_ROOT/common/makefiles/support/unicode2x.sed" \
#  	    | $SED -e '/^#/d' -e '/^$/d' \
#            -e :a -e '/\\$/N; s/\\\n//; ta' \
#  	    -e 's/^[ \t]*//;s/[ \t]*$//' \
#	    -e 's/\\=/=/' | LC_ALL=C $SORT > $OTHER_FILE.cleaned
        TMP=$(LC_ALL=C $DIFF $OTHER_FILE.cleaned $THIS_FILE)
    fi
    if test -n "$TMP"; then
        echo Files $OTHER_FILE and $THIS_FILE differ
        return 1
    fi

    return 0
}

##########################################################################################
# Compare directory structure

compare_dirs() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3

    mkdir -p $WORK_DIR

    (cd $OTHER_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_other)
    (cd $THIS_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_this)

    $DIFF $WORK_DIR/dirs_other $WORK_DIR/dirs_other > $WORK_DIR/dirs_diff
    
    echo -n Directory structure...
    if [ -s $WORK_DIR/dirs_diff ]; then
        echo Differences found.
        REGRESSIONS=true
        # Differences in directories found.
        ONLY_OTHER=$($GREP '<' $WORK_DIR/dirs_diff)
        if [ "$ONLY_OTHER" ]; then
            echo Only in $OTHER
            $GREP '<' $WORK_DIR/dirs_diff | $SED 's|< ./|    |g'
        fi
        ONLY_THIS=$($GREP '>' $WORK_DIR/dirs_diff)
        if [ "$ONLY_THIS" ]; then
            echo Only in $THIS
            $GREP '>' $WORK_DIR/dirs_diff | $SED 's|> ./|    |g'
        fi
    else
        echo Identical!
    fi
}


##########################################################################################
# Compare file structure

compare_files() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3

    $MKDIR -p $WORK_DIR

    (cd $OTHER_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_other)
    (cd $THIS_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_this)
    
    $DIFF $WORK_DIR/files_other $WORK_DIR/files_this > $WORK_DIR/files_diff

    echo -n File names...
    if [ -s $WORK_DIR/files_diff ]; then
        echo Differences found.
        REGRESSIONS=true
        # Differences in files found.
        ONLY_OTHER=$($GREP '<' $WORK_DIR/files_diff)
        if [ "$ONLY_OTHER" ]; then
            echo Only in $OTHER
            $GREP '<' $WORK_DIR/files_diff | $SED 's|< ./|    |g'
        fi
        ONLY_THIS=$($GREP '>' $WORK_DIR/files_diff)
        if [ "$ONLY_THIS" ]; then
            echo Only in $THIS
            $GREP '>' $WORK_DIR/files_diff | $SED 's|> ./|    |g'
        fi
    else
        echo Identical!
    fi
}


##########################################################################################
# Compare permissions

compare_permissions() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3

    mkdir -p $WORK_DIR

    echo -n Permissions...
    found=""
    for f in `cd $OTHER_DIR && $FIND . -type f`
    do
        if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
        if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
        OP=`ls -l ${OTHER_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
        TP=`ls -l ${THIS_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
        if [ "$OP" != "$TP" ]
        then
	    if [ -z "$found" ]; then echo ; found="yes"; fi
	    $PRINTF "\told: ${OP} new: ${TP}\t$f\n"
        fi
    done
    if [ -z "$found" ]; then 
        echo "Identical!"
    else
        REGRESSIONS=true
    fi
}

##########################################################################################
# Compare file command output

compare_file_types() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3

    $MKDIR -p $WORK_DIR

    echo -n File types...
    found=""
    for f in `cd $OTHER_DIR && $FIND . ! -type d`
    do
        if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
        if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
        OF=`cd ${OTHER_DIR} && $FILE -h $f`
        TF=`cd ${THIS_DIR} && $FILE -h $f`
        if [ "$f" = "./src.zip" ] || [[ "$f" = *"/Home/src.zip" ]] || [[ "$f" = *"/lib/JObjC.jar" ]]
        then
	    if [ "`echo $OF | $GREP -ic zip`" -gt 0 -a "`echo $TF | $GREP -ic zip`" -gt 0 ]
	    then
	        # the way we produces zip-files make it so that directories are stored in old file
	        # but not in new (only files with full-path)
	        # this makes file-5.09 report them as different
	        continue;
	    fi
        fi
        
        if [ "$OF" != "$TF" ]
        then
	    if [ -z "$found" ]; then echo ; found="yes"; fi
	    $PRINTF "\tother: ${OF}\n\tthis : ${TF}\n"
        fi
    done
    if [ -z "$found" ]; then 
        echo "Identical!"
    else
        REGRESSIONS=true
    fi
}

##########################################################################################
# Compare the rest of the files

compare_general_files() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3
    
    GENERAL_FILES=$(cd $THIS_DIR && $FIND . -type f ! -name "*.so" ! -name "*.jar" ! -name "*.zip" \
        ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \
        ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \
        ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \
        ! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" \
        | $GREP -v "./bin/"  | $SORT | $FILTER)

    echo General files...
    for f in $GENERAL_FILES
    do
        if [ -e $OTHER_DIR/$f ]; then
            SUFFIX="${f##*.}"
            if [ "$(basename $f)" = "release" ]; then
                # Ignore differences in change numbers in release file.
                OTHER_FILE=$WORK_DIR/$f.other
                THIS_FILE=$WORK_DIR/$f.this
                $MKDIR -p $(dirname $OTHER_FILE)
                $MKDIR -p $(dirname $THIS_FILE)
                $CAT $OTHER_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $OTHER_FILE
                $CAT $THIS_DIR/$f  | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $THIS_FILE
            elif [ "x$SUFFIX" = "xhtml" ]; then
                # Ignore time stamps in docs files
                OTHER_FILE=$WORK_DIR/$f.other
                THIS_FILE=$WORK_DIR/$f.this
                $MKDIR -p $(dirname $OTHER_FILE)
                $MKDIR -p $(dirname $THIS_FILE)
                #Note that | doesn't work on mac sed.
                $CAT $OTHER_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
                                          -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \
                                          -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/(removed)/' \
                                          -e 's/[A-Z][a-z]* [A-Z][a-z]* [0-9][0-9] [0-9][0-9:]* [A-Z][A-Z]* [12][0-9]*/(removed)/' \
                                          -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \
                    > $OTHER_FILE
                $CAT $THIS_DIR/$f  | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
                                          -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \
                                          -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/(removed)/' \
                                          -e 's/[A-Z][a-z]* [A-Z][a-z]* [0-9][0-9] [0-9][0-9:]* [A-Z][A-Z]* [12][0-9]*/(removed)/' \
                                          -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \
                    > $THIS_FILE
            else
                OTHER_FILE=$OTHER_DIR/$f
                THIS_FILE=$THIS_DIR/$f
            fi
            DIFF_OUT=$($DIFF $OTHER_FILE $THIS_FILE 2>&1)
            if [ -n "$DIFF_OUT" ]; then
                echo $f
                REGRESSIONS=true
                if [ "$SHOW_DIFFS" = "true" ]; then
                    echo "$DIFF_OUT"
                fi
            fi
        fi
    done


}

##########################################################################################
# Compare zip file

compare_zip_file() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3
    ZIP_FILE=$4
    # Optionally provide different name for other zipfile
    OTHER_ZIP_FILE=$5

    THIS_ZIP=$THIS_DIR/$ZIP_FILE
    if [ -n "$OTHER_ZIP_FILE" ]; then
        OTHER_ZIP=$OTHER_DIR/$OTHER_ZIP_FILE
    else
        OTHER_ZIP=$OTHER_DIR/$ZIP_FILE
    fi

    THIS_SUFFIX="${THIS_ZIP##*.}"
    OTHER_SUFFIX="${OTHER_ZIP##*.}"
    if [ "$THIS_SUFFIX" != "$OTHER_SUFFIX" ]; then
        echo The files do not have the same suffix type!
        return 2
    fi

    TYPE="$THIS_SUFFIX"

    if $CMP $OTHER_ZIP $THIS_ZIP > /dev/null
    then
        return 0
    fi
    # Not quite identical, the might still contain the same data.
    # Unpack the jar/zip files in temp dirs
    
    THIS_UNZIPDIR=$WORK_DIR/$ZIP_FILE.this
    OTHER_UNZIPDIR=$WORK_DIR/$ZIP_FILE.other
    $RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR
    $MKDIR -p $THIS_UNZIPDIR
    $MKDIR -p $OTHER_UNZIPDIR
    (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)
    (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)

    # Find all archives inside and unzip them as well to compare the contents rather than
    # the archives. pie.jar.pack.gz i app3.war is corrupt, skip it.
    EXCEPTIONS="pie.jar.pack.gz"
    for pack in $($FIND $THIS_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do
        ($UNPACK200 $pack $pack.jar)
        # Filter out the unzipped archives from the diff below.
        EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
    done
    for pack in $($FIND $OTHER_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do
        ($UNPACK200 $pack $pack.jar)
        EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
    done
    for zip in $($FIND $THIS_UNZIPDIR -name "*.jar" -o -name "*.zip"); do
        $MKDIR $zip.unzip
        (cd $zip.unzip && $UNARCHIVE $zip)
        EXCEPTIONS="$EXCEPTIONS $zip"
    done
    for zip in $($FIND $OTHER_UNZIPDIR -name "*.jar" -o -name "*.zip"); do
        $MKDIR $zip.unzip
        (cd $zip.unzip && $UNARCHIVE $zip)
        EXCEPTIONS="$EXCEPTIONS $zip"
    done

    CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff
    # On solaris, there is no -q option.
    if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
        LC_ALL=C $DIFF -r $OTHER_UNZIPDIR $THIS_UNZIPDIR \
            | $GREP -v -e "^<" -e "^>" -e "^Common subdirectories:" \
            > $CONTENTS_DIFF_FILE
    else
        LC_ALL=C $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE
    fi

    ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE)
    ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE)

    return_value=0

    if [ -n "$ONLY_OTHER" ]; then
        echo "        Only OTHER $ZIP_FILE contains:"
        echo "$ONLY_OTHER" | sed "s|Only in $OTHER_UNZIPDIR|            |"g | sed 's|: |/|g'
        return_value=1
    fi

    if [ -n "$ONLY_THIS" ]; then
        echo "        Only THIS $ZIP_FILE contains:"
        echo "$ONLY_THIS" | sed "s|Only in $THIS_UNZIPDIR|            |"g | sed 's|: |/|g'
        return_value=1
    fi

    if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
        DIFFING_FILES=$($GREP -e "differ$" -e "^diff " $CONTENTS_DIFF_FILE \
            | $CUT -f 3 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
    else
        DIFFING_FILES=$($GREP -e "differ$" $CONTENTS_DIFF_FILE \
            | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
    fi

    $RM -f $WORK_DIR/$ZIP_FILE.diffs
    for file in $DIFFING_FILES; do
	if [[ "$ACCEPTED_JARZIP_CONTENTS $EXCEPTIONS" != *"$file"* ]]; then
            diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs
	fi
    done

    if [ -s "$WORK_DIR/$ZIP_FILE.diffs" ]; then
        return_value=1
        echo "        Differing files in $ZIP_FILE"
        $CAT $WORK_DIR/$ZIP_FILE.diffs | $GREP differ | cut -f 2 -d ' ' | \
            $SED "s|$OTHER_UNZIPDIR|            |g" > $WORK_DIR/$ZIP_FILE.difflist
        $CAT $WORK_DIR/$ZIP_FILE.difflist

        if [ -n "$SHOW_DIFFS" ]; then
            for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do
                if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then
                    LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap
                elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then
                    LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i
                else
                    LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i
                fi
            done
        fi
    fi

    return $return_value
}


##########################################################################################
# Compare all zip files

compare_all_zip_files() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3

    ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER )

    if [ -n "$ZIPS" ]; then
        echo Zip files...

        return_value=0
        for f in $ZIPS; do
            if [ -f "$OTHER_DIR/$f" ]; then
                compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
                if [ "$?" != "0" ]; then
                    return_value=1
                    REGRESSIONS=true
                fi
            fi
        done
    fi

    return $return_value
}

##########################################################################################
# Compare all jar files

compare_all_jar_files() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3

    # TODO filter?
    ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" -o -name "*.war" | $SORT | $FILTER)

    if [ -n "$ZIPS" ]; then
        echo Jar files...

        return_value=0
        for f in $ZIPS; do
            if [ -f "$OTHER_DIR/$f" ]; then
                compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
                if [ "$?" != "0" ]; then
                    return_value=1
                    REGRESSIONS=true
                fi
            fi
        done
    fi

    return $return_value
}

##########################################################################################
# Compare binary (executable/library) file

compare_bin_file() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3
    BIN_FILE=$4

    THIS_FILE=$THIS_DIR/$BIN_FILE
    OTHER_FILE=$OTHER_DIR/$BIN_FILE
    NAME=$(basename $BIN_FILE)
    WORK_FILE_BASE=$WORK_DIR/$BIN_FILE
    FILE_WORK_DIR=$(dirname $WORK_FILE_BASE)

    $MKDIR -p $FILE_WORK_DIR

    ORIG_THIS_FILE="$THIS_FILE"
    ORIG_OTHER_FILE="$OTHER_FILE"

    if [[ "$STRIP_BEFORE_COMPARE" = *"$BIN_FILE"* ]]; then
        THIS_STRIPPED_FILE=$FILE_WORK_DIR/this/$NAME
        OTHER_STRIPPED_FILE=$FILE_WORK_DIR/other/$NAME
        $MKDIR -p $FILE_WORK_DIR/this $FILE_WORK_DIR/other
        $CP $THIS_FILE $THIS_STRIPPED_FILE
        $CP $OTHER_FILE $OTHER_STRIPPED_FILE
        $STRIP $THIS_STRIPPED_FILE
        $STRIP $OTHER_STRIPPED_FILE
        THIS_FILE="$THIS_STRIPPED_FILE"
        OTHER_FILE="$OTHER_STRIPPED_FILE"
    fi

    if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
	unset _NT_SYMBOL_PATH
	# On windows we need to unzip the debug symbols, if present
	OTHER_FILE_BASE=${OTHER_FILE/.dll/}
	OTHER_FILE_BASE=${OTHER_FILE_BASE/.exe/}
	DIZ_NAME=$(basename $OTHER_FILE_BASE).diz
        # java.exe and java.dll diz files will have the same name. Have to
	# make sure java.exe gets the right one. This is only needed for 
	# OTHER since in the new build, all pdb files are left around.
	if [ "$NAME" = "java.exe" ] && [ -f "$OTHER/tmp/java/java/obj64/java.diz" ]; then
	    OTHER_DIZ_FILE="$OTHER/tmp/java/java/obj64/java.diz"
	elif [ -f "${OTHER_FILE_BASE}.diz" ]; then
	    OTHER_DIZ_FILE=${OTHER_FILE_BASE}.diz
	else
            # Some files, jli.dll, appears twice in the image but only one of
	    # thme has a diz file next to it.
	    OTHER_DIZ_FILE="$($FIND $OTHER_DIR -name $DIZ_NAME | $SED 1q)"
	    if [ ! -f "$OTHER_DIZ_FILE" ]; then
		# As a last resort, look for diz file in the whole build output
		# dir.
		OTHER_DIZ_FILE="$($FIND $OTHER -name $DIZ_NAME | $SED 1q)"
	    fi
	fi
	if [ -n "$OTHER_DIZ_FILE" ]; then
	    $MKDIR -p $FILE_WORK_DIR/other
	    (cd $FILE_WORK_DIR/other ; $UNARCHIVE -o $OTHER_DIZ_FILE)
	    export _NT_SYMBOL_PATH="$FILE_WORK_DIR/other"
	fi
	THIS_FILE_BASE=${THIS_FILE/.dll/}
	THIS_FILE_BASE=${THIS_FILE_BASE/.exe/}
	if [ -f "${THIS_FILE/.dll/}.diz" ]; then
	    THIS_DIZ_FILE=${THIS_FILE/.dll/}.diz
	else
	    THIS_DIZ_FILE="$($FIND $THIS_DIR -name $DIZ_NAME | $SED 1q)"
	    if [ ! -f "$THIS_DIZ_FILE" ]; then
		# As a last resort, look for diz file in the whole build output
		# dir.
		THIS_DIZ_FILE="$($FIND $THIS -name $DIZ_NAME | $SED 1q)"
	    fi
	fi
	if [ -n "$THIS_DIZ_FILE" ]; then
	    $MKDIR -p $FILE_WORK_DIR/this
	    (cd $FILE_WORK_DIR/this ; $UNARCHIVE -o $THIS_DIZ_FILE)
	    export _NT_SYMBOL_PATH="$_NT_SYMBOL_PATH;$FILE_WORK_DIR/this"
	fi
    fi

    if [ -z "$SKIP_BIN_DIFF" ]; then
        if cmp $OTHER_FILE $THIS_FILE > /dev/null; then
        # The files were bytewise identical.
            if [ -n "$VERBOSE" ]; then
                echo "        :           :         :         :          : $BIN_FILE"
            fi
            return 0
        fi
        BIN_MSG=" diff "
        if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then
            DIFF_BIN=true
            if [[ "$KNOWN_BIN_DIFF" != *"$BIN_FILE"* ]]; then
                BIN_MSG="*$BIN_MSG*"
                REGRESSIONS=true
            else
                BIN_MSG=" $BIN_MSG "
            fi
        else
            BIN_MSG="($BIN_MSG)"
            DIFF_BIN=
        fi
    fi

    if [ -n "$STAT" ]; then
        THIS_SIZE=$($STAT $STAT_PRINT_SIZE "$THIS_FILE")
        OTHER_SIZE=$($STAT $STAT_PRINT_SIZE "$OTHER_FILE")
    else
        THIS_SIZE=$(ls -l "$THIS_FILE" | awk '{ print $5 }')
        OTHER_SIZE=$(ls -l "$OTHER_FILE" | awk '{ print $5 }')
    fi
    if [ $THIS_SIZE -ne $OTHER_SIZE ]; then
        DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE)
        DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE)
        SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM)
        if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \
	    && [ "$DIFF_SIZE_REL" -lt 102 ]; then
            SIZE_MSG="($SIZE_MSG)"
            DIFF_SIZE=
        elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
	    && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
	    && [ "$DIFF_SIZE_NUM" = 512 ]; then
	    # On windows, size of binaries increase in 512 increments.
            SIZE_MSG="($SIZE_MSG)"
            DIFF_SIZE=
        elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
	    && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
	    && [ "$DIFF_SIZE_NUM" = -512 ]; then
	    # On windows, size of binaries increase in 512 increments.
            SIZE_MSG="($SIZE_MSG)"
            DIFF_SIZE=
        else
            if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
                DIFF_SIZE=true
                if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
                    SIZE_MSG="*$SIZE_MSG*"
                    REGRESSIONS=true
                else
                    SIZE_MSG=" $SIZE_MSG "
                fi
            else
                SIZE_MSG="($SIZE_MSG)"
                DIFF_SIZE=
            fi
        fi
    else
        SIZE_MSG="           "
        DIFF_SIZE=
        if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then
            SIZE_MSG="     !     "
        fi
    fi

    if [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then
        SYM_SORT_CMD="sort"
    else
        SYM_SORT_CMD="cat"
    fi

    # Check symbols
    if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
        # The output from dumpbin on windows differs depending on if the debug symbol
        # files are still around at the location the binary is pointing too. Need
	# to filter out that extra information.
	$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
	$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
    elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
        # Some symbols get seemingly random 15 character prefixes. Filter them out.
        $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
	$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
    else
	$NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
	$NM -a $ORIG_THIS_FILE  2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
    fi
    
    LC_ALL=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff
    if [ -s $WORK_FILE_BASE.symbols.diff ]; then
        SYM_MSG=" diff  "
        if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then
            DIFF_SYM=true
            if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then
                SYM_MSG="*$SYM_MSG*"
                REGRESSIONS=true
            else
                SYM_MSG=" $SYM_MSG "
            fi
        else
            SYM_MSG="($SYM_MSG)"            
            DIFF_SYM=
        fi
    else
        SYM_MSG="         "
        DIFF_SYM=
        if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then
            SYM_MSG="    !    "
        fi
    fi

    # Check dependencies
    if [ -n "$LDD_CMD" ]; then
	(cd $FILE_WORK_DIR && $CP $OTHER_FILE . && $LDD_CMD $NAME 2>/dev/null | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.other | $UNIQ > $WORK_FILE_BASE.deps.other.uniq)
	(cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME 2</dev/null | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.this | $UNIQ > $WORK_FILE_BASE.deps.this.uniq)
	(cd $FILE_WORK_DIR && $RM -f $NAME)
	
	LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this > $WORK_FILE_BASE.deps.diff
	LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq > $WORK_FILE_BASE.deps.diff.uniq
	
	if [ -s $WORK_FILE_BASE.deps.diff ]; then
            if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then
		DEP_MSG=" diff  "
            else
		DEP_MSG=" redun "
            fi
            if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then
		DIFF_DEP=true
		if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then
                    DEP_MSG="*$DEP_MSG*"
                    REGRESSIONS=true
		else
                    DEP_MSG=" $DEP_MSG "
		fi
            else
		DEP_MSG="($DEP_MSG)"
		DIFF_DEP=
            fi
	else
	    DEP_MSG="         "
	    DIFF_DEP=
            if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
                DEP_MSG="     !      "
            fi
	fi
    else
	DEP_MSG="    -    "
    fi
    
    # Compare fulldump output
    if [ -n "$FULLDUMP_CMD" ] && [ -z "$SKIP_FULLDUMP_DIFF" ]; then
        $FULLDUMP_CMD $OTHER_FILE > $WORK_FILE_BASE.fulldump.other 2>&1
        $FULLDUMP_CMD $THIS_FILE > $WORK_FILE_BASE.fulldump.this 2>&1
        LC_ALL=C $DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this > $WORK_FILE_BASE.fulldump.diff
        
        if [ -s $WORK_FILE_BASE.fulldump.diff ]; then
            ELF_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.fulldump.diff | awk '{print $5}')
            ELF_MSG=$($PRINTF "%8d" $ELF_DIFF_SIZE)
            if [[ "$ACCEPTED_ELF_DIFF" != *"$BIN_FILE"* ]]; then
                DIFF_ELF=true
                if [[ "$KNOWN_ELF_DIFF" != *"$BIN_FILE"* ]]; then
                    ELF_MSG="*$ELF_MSG*"
                    REGRESSIONS=true
                else
                    ELF_MSG=" $ELF_MSG "
                fi
            else
                ELF_MSG="($ELF_MSG)"
                DIFF_ELF=
            fi
        else
            ELF_MSG="          "
            DIFF_ELF=
            if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
                ELF_MSG="    !    "
            fi
        fi
    fi

    # Compare disassemble output
    if [ -n "$DIS_CMD" ] && [ -z "$SKIP_DIS_DIFF" ]; then
	if [ -z "$DIS_DIFF_FILTER" ]; then
	    DIS_DIFF_FILTER="$CAT"
	fi
        $DIS_CMD $OTHER_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.other 2>&1
        $DIS_CMD $THIS_FILE  | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.this  2>&1
        
        LC_ALL=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff
        
        if [ -s $WORK_FILE_BASE.dis.diff ]; then
            DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}')
            DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE)
            if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then
                DIFF_DIS=true
                if [[ "$KNOWN_DIS_DIFF" != *"$BIN_FILE"* ]]; then
                    DIS_MSG="*$DIS_MSG*"
                    REGRESSIONS=true
                else
                    DIS_MSG=" $DIS_MSG "
                fi
            else
                DIS_MSG="($DIS_MSG)"
                DIFF_DIS=
            fi
        else
            DIS_MSG="          "
            DIFF_DIS=
            if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
                DIS_MSG="    !    "
            fi
        fi
    fi


    if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_ELF$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then
        if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi
        if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi
        if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi
        if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi
        if [ -n "$ELF_MSG" ]; then echo -n "$ELF_MSG:"; fi
        if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi
        echo " $BIN_FILE"
        if [ "$SHOW_DIFFS" = "true" ]; then
            if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then
                echo "Symbols diff:"
                $CAT $WORK_FILE_BASE.symbols.diff
            fi
            if [ -s "$WORK_FILE_BASE.deps.diff" ]; then
                echo "Deps diff:"
                $CAT $WORK_FILE_BASE.deps.diff
            fi
            if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then
                echo "Fulldump diff:"
                $CAT $WORK_FILE_BASE.fulldump.diff
            fi
            if [ -s "$WORK_FILE_BASE.dis.diff" ]; then
                echo "Disassembly diff:"
                $CAT $WORK_FILE_BASE.dis.diff
            fi
        fi
        return 1
    fi
    return 0
}

##########################################################################################
# Print binary diff header

print_binary_diff_header() {
    if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi
    if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n "   Size    :"; fi
    if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi
    if [ -z "$SKIP_DEP_DIFF" ]; then echo -n "  Deps   :"; fi
    if [ -z "$SKIP_FULLDUMP_DIFF" ]; then echo -n " Fulldump :"; fi
    if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass   :"; fi
    echo
}

##########################################################################################
# Compare all libraries

compare_all_libs() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3

    LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' -o -name 'JavaControlPanel' \) | $SORT | $FILTER)

    if [ -n "$LIBS" ]; then
        echo Libraries...
        print_binary_diff_header
        for l in $LIBS; do
            if [ -f "$OTHER_DIR/$l" ]; then
                compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l
                if [ "$?" != "0" ]; then
                    return_value=1
                fi
            fi
        done
    fi

    return $return_value
}

##########################################################################################
# Compare all executables

compare_all_execs() {
    THIS_DIR=$1
    OTHER_DIR=$2
    WORK_DIR=$3

    if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
        EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER)
    else
        EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \
            \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \
            -o -name '*.jar' -o -name '*.diz' -o -name 'jcontrol' -o -name '*.properties' \
            -o -name '*.data' -o -name '*.bfc' -o -name '*.src' -o -name '*.txt' \
            -o -name '*.cfg' -o -name 'meta-index' -o -name '*.properties.ja' \
            -o -name 'classlist' \) | $SORT | $FILTER)
    fi

    if [ -n "$EXECS" ]; then
        echo Executables...
        print_binary_diff_header
        for e in $EXECS; do
            if [ -f "$OTHER_DIR/$e" ]; then
                compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e
                if [ "$?" != "0" ]; then
                    return_value=1
                fi
            fi
        done
    fi

    return $return_value
}

##########################################################################################
# Initiate configuration

COMPARE_ROOT=/tmp/cimages.$USER
$MKDIR -p $COMPARE_ROOT
if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
    if [ "$(uname -o)" = "Cygwin" ]; then
	COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT)
    fi
fi

THIS="$( cd "$( dirname "$0" )" && pwd )"
echo "$THIS"
THIS_SCRIPT="$0"

if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
    echo "bash ./compare.sh [OPTIONS] [FILTER]"
    echo ""
    echo "-all                Compare all files in all known ways"
    echo "-names              Compare the file names and directory structure"
    echo "-perms              Compare the permission bits on all files and directories"
    echo "-types              Compare the output of the file command on all files"
    echo "-general            Compare the files not convered by the specialized comparisons"
    echo "-zips               Compare the contents of all zip files"
    echo "-jars               Compare the contents of all jar files"
    echo "-libs               Compare all native libraries"
    echo "-execs              Compare all executables"
    echo "-v                  Verbose output, does not hide known differences"
    echo "-vv                 More verbose output, shows diff output of all comparisons"
    echo "-o [OTHER]          Compare with build in other directory. Will default to the old build directory"
    echo ""
    echo "[FILTER]            List filenames in the image to compare, works for jars, zips, libs and execs"
    echo "Example:"
    echo "bash ./common/bin/compareimages.sh CodePointIM.jar"
    echo ""
    echo "-2zips <file1> <file2> Compare two zip files only"
    echo ""
    exit 10
fi

CMP_NAMES=false
CMP_PERMS=false
CMP_TYPES=false
CMP_GENERAL=false
CMP_ZIPS=false
CMP_JARS=false
CMP_LIBS=false
CMP_EXECS=false

while [ -n "$1" ]; do
    case "$1" in
        -v)
            VERBOSE=true
            ;;
        -vv)
            VERBOSE=true
            SHOW_DIFFS=true
            ;;
        -o)
            OTHER="$2"
            shift
            ;;
        -all)
            CMP_NAMES=true
            if [ "$OPENJDK_TARGET_OS" != "windows" ]; then
                CMP_PERMS=true
            fi
            CMP_TYPES=true
            CMP_GENERAL=true
            CMP_ZIPS=true
            CMP_JARS=true
            CMP_LIBS=true
            CMP_EXECS=true
            ;;
        -names)
            CMP_NAMES=true
            ;;
        -perms)
            CMP_PERMS=true
            ;;
        -types)
            CMP_TYPES=true
            ;;
        -general)
            CMP_GENERAL=true
            ;;
        -zips)
            CMP_ZIPS=true
            ;;
        -jars)
            CMP_JARS=true
            ;;
        -libs)
            CMP_LIBS=true
            ;;
        -execs)
            CMP_EXECS=true
            ;;
        -2zips)
            CMP_2_ZIPS=true
            THIS_FILE=$2
            OTHER_FILE=$3
            shift
            shift
            ;;
        *)
            CMP_NAMES=false
            CMP_PERMS=false
            CMP_TYPES=false
            CMP_ZIPS=true
            CMP_JARS=true
            CMP_LIBS=true
            CMP_EXECS=true
            
            if [ -z "$FILTER" ]; then
                FILTER="$GREP"
            fi
            FILTER="$FILTER -e $1"
            ;;
    esac
    shift
done

if [ "$CMP_2_ZIPS" = "true" ]; then
    THIS_DIR="$(dirname $THIS_FILE)"
    THIS_DIR="$(cd "$THIS_DIR" && pwd )"
    OTHER_DIR="$(dirname $OTHER_FILE)"
    OTHER_DIR="$(cd "$OTHER_DIR" && pwd )"
    THIS_FILE_NAME="$(basename $THIS_FILE)"
    OTHER_FILE_NAME="$(basename $OTHER_FILE)"
    echo Comparing $THIS_DIR/$THIS_FILE_NAME and $OTHER_DIR/$OTHER_FILE_NAME
    compare_zip_file $THIS_DIR $OTHER_DIR $COMPARE_ROOT/2zips $THIS_FILE_NAME $OTHER_FILE_NAME
    exit
fi

if [ "$CMP_NAMES" = "false" ] && [ "$CMP_TYPES" = "false" ] && [ "$CMP_PERMS" = "false" ] && [ "$CMP_GENERAL" = "false" ] && [ "$CMP_ZIPS" = "false" ] && [ "$CMP_JARS" = "false" ] && [ "$CMP_LIBS" = "false" ] && [ "$CMP_EXECS" = "false" ]; then
    CMP_NAMES=true
    CMP_PERMS=true
    CMP_TYPES=true
    CMP_GENERAL=true
    CMP_ZIPS=true
    CMP_JARS=true
    CMP_LIBS=true
    CMP_EXECS=true
fi

if [ -z "$FILTER" ]; then
    FILTER="$CAT"
fi

if [ -z "$OTHER" ]; then
    OTHER="$THIS/../$LEGACY_BUILD_DIR"
    if [ -d "$OTHER" ]; then
        OTHER="$( cd "$OTHER" && pwd )"
    else
        echo "Default old build directory does not exist:"
        echo "$OTHER"
        exit 1
    fi
    echo "Comparing to default old build:"
    echo "$OTHER"
    echo
else
    if [ ! -d "$OTHER" ]; then
        echo "Other build directory does not exist:"
        echo "$OTHER"
        exit 1
    fi
    OTHER="$( cd "$OTHER" && pwd )"
    echo "Comparing to:"
    echo "$OTHER"
    echo
fi


# Figure out the layout of the this build. Which kinds of images have been produced
if [ -d "$THIS/install/j2sdk-image" ]; then
    THIS_J2SDK="$THIS/install/j2sdk-image"
    THIS_J2RE="$THIS/install/j2re-image"
    echo "Selecting install images in this build"
elif [ -d "$THIS/deploy/j2sdk-image" ]; then
    THIS_J2SDK="$THIS/deploy/j2sdk-image"
    THIS_J2RE="$THIS/deploy/j2re-image"
    echo "Selecting deploy images in this build"
elif [ -d "$THIS/images/j2sdk-image" ]; then
    THIS_J2SDK="$THIS/images/j2sdk-image"
    THIS_J2RE="$THIS/images/j2re-image"
    echo "Selecting jdk images in this build"
fi

if [ -d "$THIS/images/j2sdk-overlay-image" ]; then
    if [ -d "$THIS/install/j2sdk-image" ]; then
        # If there is an install image, prefer that, it's also overlay
        THIS_J2SDK_OVERLAY="$THIS/install/j2sdk-image"
        THIS_J2RE_OVERLAY="$THIS/install/j2re-image"
        echo "Selecting install overlay images in this build"
    else
        THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image"
        THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image"
        echo "Selecting jdk overlay images in this build"
    fi
fi

if [ -d "$THIS/images/j2sdk-bundle" ]; then
    THIS_J2SDK_BUNDLE="$THIS/images/j2sdk-bundle"
    THIS_J2RE_BUNDLE="$THIS/images/j2re-bundle"
    echo "Selecting bundles in this build"
fi

# Figure out the layout of the other build (old or new, normal or overlay image)
if [ -d "$OTHER/j2sdk-image" ]; then
    if [ -f "$OTHER/j2sdk-image/LICENSE" ]; then
        OTHER_J2SDK="$OTHER/j2sdk-image"
        OTHER_J2RE="$OTHER/j2re-image"
        echo "Selecting old-style images in other build"
    else
        OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image"
        OTHER_J2RE_OVERLAY="$OTHER/j2re-image"
        echo "Selecting overlay images in other build"
    fi
elif [ -d "$OTHER/install/j2sdk-image" ]; then
    OTHER_J2SDK="$OTHER/install/j2sdk-image"
    OTHER_J2RE="$OTHER/install/j2re-image"
    echo "Selecting install images in other build"
elif [ -d "$OTHER/deploy/j2sdk-image" ]; then
    OTHER_J2SDK="$OTHER/deploy/j2sdk-image"
    OTHER_J2RE="$OTHER/deploy/j2re-image"
    echo "Selecting deploy images in other build"
elif [ -d "$OTHER/images/j2sdk-image" ]; then
    OTHER_J2SDK="$OTHER/images/j2sdk-image"
    OTHER_J2RE="$OTHER/images/j2re-image"
    echo "Selecting jdk images in other build"
fi

if [ -d "$OTHER/j2sdk-bundle" ]; then
    OTHER_J2SDK_BUNDLE="$OTHER/j2sdk-bundle"
    OTHER_J2RE_BUNDLE="$OTHER/j2re-bundle"
    echo "Selecting bundles in other build"
elif [ -d "$OTHER/images/j2sdk-bundle" ]; then
    OTHER_J2SDK_BUNDLE="$OTHER/images/j2sdk-bundle"
    OTHER_J2RE_BUNDLE="$OTHER/images/j2re-bundle"
    echo "Selecting jdk bundles in other build"
fi

if [ -z "$THIS_J2SDK" ] || [ -z "$THIS_J2RE" ]; then
    if [ -z "$THIS_J2SDK_OVERLAY" ]; then
        echo "Cannot locate images for this build. Are you sure you have run 'make images'?"
        exit 1
    fi
fi

if [ -z "$OTHER_J2SDK" ] && [ -n "$OTHER_J2SDK_OVERLAY" ] && [ -z "$THIS_J2SDK_OVERLAY" ]; then
    echo "OTHER build only has an overlay image while this build does not. Nothing to compare!"
    exit 1
fi

if [ -z "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
    echo "WARNING! OTHER build has bundles built while this build does not."
    echo "Skipping bundle compare!"
fi

if [ -d "$THIS/docs" ]; then
    THIS_DOCS="$THIS/docs"
fi

if [ -d "$OTHER/docs" ]; then
    OTHER_DOCS="$OTHER/docs"
fi

if [ -z "$THIS_DOCS" ]; then
    echo "WARNING! Docs haven't been built and won't be compared."
fi

if [ -z "$OTHER_DOCS" ]; then
    echo "WARNING! Other build doesn't contain docs, skipping doc compare."
fi

if [ -d "$OTHER/images" ]; then
    OTHER_SEC_DIR="$OTHER/images"
else
    OTHER_SEC_DIR="$OTHER/tmp"
fi
OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip"
THIS_SEC_DIR="$THIS/images"
THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip"
if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
    if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
        JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip"
    else
        JGSS_WINDOWS_BIN="jgss-windows-i586-bin.zip"
    fi
    OTHER_SEC_WINDOWS_BIN="$OTHER_SEC_DIR/sec-windows-bin.zip"
    OTHER_JGSS_WINDOWS_BIN="$OTHER_SEC_DIR/$JGSS_WINDOWS_BIN"
    THIS_SEC_WINDOWS_BIN="$THIS_SEC_DIR/sec-windows-bin.zip"
    THIS_JGSS_WINDOWS_BIN="$THIS_SEC_DIR/$JGSS_WINDOWS_BIN"
fi

##########################################################################################
# Do the work

if [ "$CMP_NAMES" = "true" ]; then
    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
        echo -n "J2SDK "
        compare_dirs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
        echo -n "J2RE  "
        compare_dirs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
        
        echo -n "J2SDK "
        compare_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
        echo -n "J2RE  "
        compare_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
    fi
    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
        echo -n "J2SDK Overlay "
        compare_dirs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
        echo -n "J2RE  Overlay "
        compare_dirs $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
        
        echo -n "J2SDK Overlay "
        compare_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
        echo -n "J2RE  Overlay "
        compare_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
    fi
    if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
        echo -n "J2SDK Bundle "
        compare_dirs $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
        echo -n "J2RE  Bundle "
        compare_dirs $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
        
        echo -n "J2SDK Bundle "
        compare_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
        echo -n "J2RE  Bundle "
        compare_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
    fi
    if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then
        echo -n "Docs "
        compare_dirs $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
        echo -n "Docs "
        compare_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
    fi
fi

if [ "$CMP_PERMS" = "true" ]; then
    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
        echo -n "J2SDK "
        compare_permissions $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
        echo -n "J2RE  "
        compare_permissions $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
    fi
    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
        echo -n "J2SDK Overlay "
        compare_permissions $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
        echo -n "J2RE  Overlay "
        compare_permissions $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
    fi
    if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
        echo -n "J2SDK Bundle "
        compare_permissions $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
        echo -n "J2RE  Bundle "
        compare_permissions $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
    fi
fi

if [ "$CMP_TYPES" = "true" ]; then
    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
        echo -n "J2SDK "
        compare_file_types $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
        echo -n "J2RE  "
        compare_file_types $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
    fi
    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
        echo -n "J2SDK Overlay "
        compare_file_types $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
        echo -n "J2RE  Overlay "
        compare_file_types $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
    fi
    if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
        echo -n "J2SDK Bundle "
        compare_file_types $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
        echo -n "J2RE  Bundle "
        compare_file_types $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
    fi
fi

if [ "$CMP_GENERAL" = "true" ]; then
    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
        echo -n "J2SDK "
        compare_general_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
        echo -n "J2RE  "
        compare_general_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
    fi
    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
        echo -n "J2SDK Overlay "
        compare_general_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
        echo -n "J2RE  Overlay "
        compare_general_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
    fi
    if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
        echo -n "J2SDK Bundle "
        compare_general_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
        echo -n "J2RE  Bundle "
        compare_general_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
    fi
    if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then
        echo -n "Docs "
        compare_general_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
    fi
fi

if [ "$CMP_ZIPS" = "true" ]; then
    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
        compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
    fi
    if [ -n "$THIS_SEC_BIN" ] && [ -n "$OTHER_SEC_BIN" ]; then
        if [ -n "$(echo $THIS_SEC_BIN | $FILTER)" ]; then
            echo "sec-bin.zip..."
            compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-bin.zip
        fi
    fi
    if [ -n "$THIS_SEC_WINDOWS_BIN" ] && [ -n "$OTHER_SEC_WINDOWS_BIN" ]; then
        if [ -n "$(echo $THIS_SEC_WINDOWS_BIN | $FILTER)" ]; then
            echo "sec-windows-bin.zip..."
            compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-windows-bin.zip
        fi
    fi
    if [ -n "$THIS_JGSS_WINDOWS_BIN" ] && [ -n "$OTHER_JGSS_WINDOWS_BIN" ]; then
        if [ -n "$(echo $THIS_JGSS_WINDOWS_BIN | $FILTER)" ]; then
            echo "$JGSS_WINDOWS_BIN..."
            compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin $JGSS_WINDOWS_BIN
        fi
    fi
fi

if [ "$CMP_JARS" = "true" ]; then
    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
        compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
    fi
fi

if [ "$CMP_LIBS" = "true" ]; then
    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
        echo -n "J2SDK "
        compare_all_libs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
        if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
            echo -n "J2RE  "
            compare_all_libs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
        fi
    fi
    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
        echo -n "Bundle   "
        compare_all_libs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
    fi
fi

if [ "$CMP_EXECS" = "true" ]; then
    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
        compare_all_execs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
    fi
    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
        echo -n "Overlay "
        compare_all_execs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
    fi
fi

echo

if [ -n "$REGRESSIONS" ]; then
    echo "REGRESSIONS FOUND!"
    echo
    exit 1
else
    echo "No regressions found"
    echo
    exit 0
fi