common/bin/compare.sh

Sat, 03 Nov 2012 16:28:14 -0700

author
erikj
date
Sat, 03 Nov 2012 16:28:14 -0700
changeset 502
ed9e5635fc80
parent 494
e64f2cb57d05
child 510
a2df4ee40ecb
permissions
-rw-r--r--

8002220: build-infra: update for mac, solaris 11 issues
8002184: Fixed exclude and includes for jarsigner in new build
Reviewed-by: ohair

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

mercurial