common/bin/compare.sh

Wed, 14 Nov 2012 10:05:49 -0800

author
tbell
date
Wed, 14 Nov 2012 10:05:49 -0800
changeset 510
a2df4ee40ecb
parent 502
ed9e5635fc80
child 518
6ff2e1280dc3
permissions
-rw-r--r--

8002026: build-infra: deploy repository building
Summary: Change the compare script to handle deploy build artifacts.
Reviewed-by: ohair, tbell
Contributed-by: erik.joelsson@oracle.com

     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" ! -name "JavaControlPanel" \
   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 ] \
   615 	    && [ "$DIFF_SIZE_REL" -lt 102 ]; then
   616             SIZE_MSG="($SIZE_MSG)"
   617             DIFF_SIZE=
   618         elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
   619 	    && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
   620 	    && [ "$DIFF_SIZE_NUM" = 512 ]; then
   621 	    # On windows, size of binaries increase in 512 increments.
   622             SIZE_MSG="($SIZE_MSG)"
   623             DIFF_SIZE=
   624         elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
   625 	    && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
   626 	    && [ "$DIFF_SIZE_NUM" = -512 ]; then
   627 	    # On windows, size of binaries increase in 512 increments.
   628             SIZE_MSG="($SIZE_MSG)"
   629             DIFF_SIZE=
   630         else
   631             if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
   632                 DIFF_SIZE=true
   633                 if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
   634                     SIZE_MSG="*$SIZE_MSG*"
   635                     REGRESSIONS=true
   636                 else
   637                     SIZE_MSG=" $SIZE_MSG "
   638                 fi
   639             else
   640                 SIZE_MSG="($SIZE_MSG)"
   641                 DIFF_SIZE=
   642             fi
   643         fi
   644     else
   645         SIZE_MSG="           "
   646         DIFF_SIZE=
   647         if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then
   648             SIZE_MSG="     !     "
   649         fi
   650     fi
   652     if [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then
   653         SYM_SORT_CMD="sort"
   654     else
   655         SYM_SORT_CMD="cat"
   656     fi
   658     # Check symbols
   659     if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
   660         # The output from dumpbin on windows differs depending on if the debug symbol
   661         # files are still around at the location the binary is pointing too. Need
   662 	# to filter out that extra information.
   663 	$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
   664 	$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
   665     elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
   666         # Some symbols get seemingly random 15 character prefixes. Filter them out.
   667         $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
   668 	$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
   669     else
   670 	$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
   671 	$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
   672     fi
   674     LANG=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff
   675     if [ -s $WORK_FILE_BASE.symbols.diff ]; then
   676         SYM_MSG=" diff  "
   677         if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then
   678             DIFF_SYM=true
   679             if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then
   680                 SYM_MSG="*$SYM_MSG*"
   681                 REGRESSIONS=true
   682             else
   683                 SYM_MSG=" $SYM_MSG "
   684             fi
   685         else
   686             SYM_MSG="($SYM_MSG)"            
   687             DIFF_SYM=
   688         fi
   689     else
   690         SYM_MSG="         "
   691         DIFF_SYM=
   692         if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then
   693             SYM_MSG="    !    "
   694         fi
   695     fi
   697     # Check dependencies
   698     if [ -n "$LDD_CMD" ]; then
   699 	(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)
   700 	(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)
   701 	(cd $FILE_WORK_DIR && $RM -f $NAME)
   703 	LANG=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this > $WORK_FILE_BASE.deps.diff
   704 	LANG=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq > $WORK_FILE_BASE.deps.diff.uniq
   706 	if [ -s $WORK_FILE_BASE.deps.diff ]; then
   707             if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then
   708 		DEP_MSG=" diff  "
   709             else
   710 		DEP_MSG=" redun "
   711             fi
   712             if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then
   713 		DIFF_DEP=true
   714 		if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then
   715                     DEP_MSG="*$DEP_MSG*"
   716                     REGRESSIONS=true
   717 		else
   718                     DEP_MSG=" $DEP_MSG "
   719 		fi
   720             else
   721 		DEP_MSG="($DEP_MSG)"
   722 		DIFF_DEP=
   723             fi
   724 	else
   725 	    DEP_MSG="         "
   726 	    DIFF_DEP=
   727             if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
   728                 DEP_MSG="     !      "
   729             fi
   730 	fi
   731     else
   732 	DEP_MSG="    -    "
   733     fi
   735     # Compare fulldump output
   736     if [ -n "$FULLDUMP_CMD" ] && [ -z "$SKIP_FULLDUMP_DIFF" ]; then
   737         $FULLDUMP_CMD $OTHER_FILE > $WORK_FILE_BASE.fulldump.other 2>&1
   738         $FULLDUMP_CMD $THIS_FILE > $WORK_FILE_BASE.fulldump.this 2>&1
   739         LANG=C $DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this > $WORK_FILE_BASE.fulldump.diff
   741         if [ -s $WORK_FILE_BASE.fulldump.diff ]; then
   742             ELF_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.fulldump.diff | awk '{print $5}')
   743             ELF_MSG=$($PRINTF "%8d" $ELF_DIFF_SIZE)
   744             if [[ "$ACCEPTED_ELF_DIFF" != *"$BIN_FILE"* ]]; then
   745                 DIFF_ELF=true
   746                 if [[ "$KNOWN_ELF_DIFF" != *"$BIN_FILE"* ]]; then
   747                     ELF_MSG="*$ELF_MSG*"
   748                     REGRESSIONS=true
   749                 else
   750                     ELF_MSG=" $ELF_MSG "
   751                 fi
   752             else
   753                 ELF_MSG="($ELF_MSG)"
   754                 DIFF_ELF=
   755             fi
   756         else
   757             ELF_MSG="          "
   758             DIFF_ELF=
   759             if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
   760                 ELF_MSG="    !    "
   761             fi
   762         fi
   763     fi
   765     # Compare disassemble output
   766     if [ -n "$DIS_CMD" ] && [ -z "$SKIP_DIS_DIFF" ]; then
   767 	if [ -z "$DIS_DIFF_FILTER" ]; then
   768 	    DIS_DIFF_FILTER="$CAT"
   769 	fi
   770         $DIS_CMD $OTHER_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.other 2>&1
   771         $DIS_CMD $THIS_FILE  | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.this  2>&1
   773         LANG=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff
   775         if [ -s $WORK_FILE_BASE.dis.diff ]; then
   776             DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}')
   777             DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE)
   778             if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then
   779                 DIFF_DIS=true
   780                 if [[ "$KNOWN_DIS_DIFF" != *"$BIN_FILE"* ]]; then
   781                     DIS_MSG="*$DIS_MSG*"
   782                     REGRESSIONS=true
   783                 else
   784                     DIS_MSG=" $DIS_MSG "
   785                 fi
   786             else
   787                 DIS_MSG="($DIS_MSG)"
   788                 DIFF_DIS=
   789             fi
   790         else
   791             DIS_MSG="          "
   792             DIFF_DIS=
   793             if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
   794                 DIS_MSG="    !    "
   795             fi
   796         fi
   797     fi
   800     if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_ELF$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then
   801         if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi
   802         if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi
   803         if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi
   804         if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi
   805         if [ -n "$ELF_MSG" ]; then echo -n "$ELF_MSG:"; fi
   806         if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi
   807         echo " $BIN_FILE"
   808         if [ "$SHOW_DIFFS" = "true" ]; then
   809             if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then
   810                 echo "Symbols diff:"
   811                 $CAT $WORK_FILE_BASE.symbols.diff
   812             fi
   813             if [ -s "$WORK_FILE_BASE.deps.diff" ]; then
   814                 echo "Deps diff:"
   815                 $CAT $WORK_FILE_BASE.deps.diff
   816             fi
   817             if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then
   818                 echo "Fulldump diff:"
   819                 $CAT $WORK_FILE_BASE.fulldump.diff
   820             fi
   821             if [ -s "$WORK_FILE_BASE.dis.diff" ]; then
   822                 echo "Disassembly diff:"
   823                 $CAT $WORK_FILE_BASE.dis.diff
   824             fi
   825         fi
   826         return 1
   827     fi
   828     return 0
   829 }
   831 ##########################################################################################
   832 # Print binary diff header
   834 print_binary_diff_header() {
   835     if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi
   836     if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n "   Size    :"; fi
   837     if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi
   838     if [ -z "$SKIP_DEP_DIFF" ]; then echo -n "  Deps   :"; fi
   839     if [ -z "$SKIP_FULLDUMP_DIFF" ]; then echo -n " Fulldump :"; fi
   840     if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass   :"; fi
   841     echo
   842 }
   844 ##########################################################################################
   845 # Compare all libraries
   847 compare_all_libs() {
   848     THIS_DIR=$1
   849     OTHER_DIR=$2
   850     WORK_DIR=$3
   852     LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' -o -name 'JavaControlPanel' \) | $SORT | $FILTER)
   854     if [ -n "$LIBS" ]; then
   855         echo Libraries...
   856         print_binary_diff_header
   857         for l in $LIBS; do
   858             if [ -f "$OTHER_DIR/$l" ]; then
   859                 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l
   860                 if [ "$?" != "0" ]; then
   861                     return_value=1
   862                 fi
   863             fi
   864         done
   865     fi
   867     return $return_value
   868 }
   870 ##########################################################################################
   871 # Compare all executables
   873 compare_all_execs() {
   874     THIS_DIR=$1
   875     OTHER_DIR=$2
   876     WORK_DIR=$3
   878     if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
   879         EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER)
   880     else
   881         EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \
   882             \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \
   883             -o -name '*.jar' -o -name '*.diz' -o -name 'jcontrol' -o -name '*.properties' \
   884             -o -name '*.data' -o -name '*.bfc' -o -name '*.src' -o -name '*.txt' \
   885             -o -name '*.cfg' -o -name 'meta-index' -o -name '*.properties.ja' \
   886             -o -name 'classlist' \) | $SORT | $FILTER)
   887     fi
   889     if [ -n "$EXECS" ]; then
   890         echo Executables...
   891         print_binary_diff_header
   892         for e in $EXECS; do
   893             if [ -f "$OTHER_DIR/$e" ]; then
   894                 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e
   895                 if [ "$?" != "0" ]; then
   896                     return_value=1
   897                 fi
   898             fi
   899         done
   900     fi
   902     return $return_value
   903 }
   905 ##########################################################################################
   906 # Initiate configuration
   908 COMPARE_ROOT=/tmp/cimages.$USER
   909 $MKDIR -p $COMPARE_ROOT
   910 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
   911     if [ "$(uname -o)" = "Cygwin" ]; then
   912 	COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT)
   913     fi
   914 fi
   916 THIS="$( cd "$( dirname "$0" )" && pwd )"
   917 echo "$THIS"
   918 THIS_SCRIPT="$0"
   920 if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
   921     echo "bash ./compare.sh [OPTIONS] [FILTER]"
   922     echo ""
   923     echo "-all                Compare all files in all known ways"
   924     echo "-names              Compare the file names and directory structure"
   925     echo "-perms              Compare the permission bits on all files and directories"
   926     echo "-types              Compare the output of the file command on all files"
   927     echo "-general            Compare the files not convered by the specialized comparisons"
   928     echo "-zips               Compare the contents of all zip files"
   929     echo "-jars               Compare the contents of all jar files"
   930     echo "-libs               Compare all native libraries"
   931     echo "-execs              Compare all executables"
   932     echo "-v                  Verbose output, does not hide known differences"
   933     echo "-vv                 More verbose output, shows diff output of all comparisons"
   934     echo "-o [OTHER]          Compare with build in other directory. Will default to the old build directory"
   935     echo ""
   936     echo "[FILTER]            List filenames in the image to compare, works for jars, zips, libs and execs"
   937     echo "Example:"
   938     echo "bash ./common/bin/compareimages.sh CodePointIM.jar"
   939     exit 10
   940 fi
   942 CMP_NAMES=false
   943 CMP_PERMS=false
   944 CMP_TYPES=false
   945 CMP_GENERAL=false
   946 CMP_ZIPS=false
   947 CMP_JARS=false
   948 CMP_LIBS=false
   949 CMP_EXECS=false
   951 while [ -n "$1" ]; do
   952     case "$1" in
   953         -v)
   954             VERBOSE=true
   955             ;;
   956         -vv)
   957             VERBOSE=true
   958             SHOW_DIFFS=true
   959             ;;
   960         -o)
   961             OTHER="$2"
   962             shift
   963             ;;
   964         -all)
   965             CMP_NAMES=true
   966             if [ "$OPENJDK_TARGET_OS" != "windows" ]; then
   967                 CMP_PERMS=true
   968             fi
   969             CMP_TYPES=true
   970             CMP_GENERAL=true
   971             CMP_ZIPS=true
   972             CMP_JARS=true
   973             CMP_LIBS=true
   974             CMP_EXECS=true
   975             ;;
   976         -names)
   977             CMP_NAMES=true
   978             ;;
   979         -perms)
   980             CMP_PERMS=true
   981             ;;
   982         -types)
   983             CMP_TYPES=true
   984             ;;
   985         -general)
   986             CMP_GENERAL=true
   987             ;;
   988         -zips)
   989             CMP_ZIPS=true
   990             ;;
   991         -jars)
   992             CMP_JARS=true
   993             ;;
   994         -libs)
   995             CMP_LIBS=true
   996             ;;
   997         -execs)
   998             CMP_EXECS=true
   999             ;;
  1000         *)
  1001             CMP_NAMES=false
  1002             CMP_PERMS=false
  1003             CMP_TYPES=false
  1004             CMP_ZIPS=true
  1005             CMP_JARS=true
  1006             CMP_LIBS=true
  1007             CMP_EXECS=true
  1009             if [ -z "$FILTER" ]; then
  1010                 FILTER="$GREP"
  1011             fi
  1012             FILTER="$FILTER -e $1"
  1013             ;;
  1014     esac
  1015     shift
  1016 done
  1018 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
  1019     CMP_NAMES=true
  1020     CMP_PERMS=true
  1021     CMP_TYPES=true
  1022     CMP_GENERAL=true
  1023     CMP_ZIPS=true
  1024     CMP_JARS=true
  1025     CMP_LIBS=true
  1026     CMP_EXECS=true
  1027 fi
  1029 if [ -z "$FILTER" ]; then
  1030     FILTER="$CAT"
  1031 fi
  1033 if [ -z "$OTHER" ]; then
  1034     OTHER="$THIS/../$LEGACY_BUILD_DIR"
  1035     if [ -d "$OTHER" ]; then
  1036         OTHER="$( cd "$OTHER" && pwd )"
  1037     else
  1038         echo "Default old build directory does not exist:"
  1039         echo "$OTHER"
  1040         exit 1
  1041     fi
  1042     echo "Comparing to default old build:"
  1043     echo "$OTHER"
  1044     echo
  1045 else
  1046     if [ ! -d "$OTHER" ]; then
  1047         echo "Other build directory does not exist:"
  1048         echo "$OTHER"
  1049         exit 1
  1050     fi
  1051     OTHER="$( cd "$OTHER" && pwd )"
  1052     echo "Comparing to:"
  1053     echo "$OTHER"
  1054     echo
  1055 fi
  1058 # Figure out the layout of the this build. Which kinds of images have been produced
  1059 if [ -d "$THIS/deploy/j2sdk-image" ]; then
  1060     THIS_J2SDK="$THIS/deploy/j2sdk-image"
  1061     THIS_J2RE="$THIS/deploy/j2re-image"
  1062     echo "Comparing deploy images"
  1063 elif [ -d "$THIS/images/j2sdk-image" ]; then
  1064     THIS_J2SDK="$THIS/images/j2sdk-image"
  1065     THIS_J2RE="$THIS/images/j2re-image"
  1066 fi
  1067 if [ -d "$THIS/images/j2sdk-overlay-image" ]; then
  1068     THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image"
  1069     THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image"
  1070 fi
  1072 if [ -d "$THIS/images/j2sdk-bundle" ]; then
  1073     THIS_J2SDK_BUNDLE="$THIS/images/j2sdk-bundle"
  1074     THIS_J2RE_BUNDLE="$THIS/images/j2re-bundle"
  1075 fi
  1077 # Figure out the layout of the other build (old or new, normal or overlay image)
  1078 if [ -d "$OTHER/j2sdk-image" ]; then
  1079     if [ -f "$OTHER/j2sdk-image/LICENSE" ]; then
  1080         OTHER_J2SDK="$OTHER/j2sdk-image"
  1081         OTHER_J2RE="$OTHER/j2re-image"
  1082     else
  1083         OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image"
  1084         OTHER_J2RE_OVERLAY="$OTHER/j2re-image"
  1085     fi
  1087 fi
  1089 if [ -d "$OTHER/j2sdk-bundle" ]; then
  1090     OTHER_J2SDK_BUNDLE="$OTHER/j2sdk-bundle"
  1091     OTHER_J2RE_BUNDLE="$OTHER/j2re-bundle"
  1092 elif [ -d "$OTHER/images/j2sdk-bundle" ]; then
  1093     OTHER_J2SDK_BUNDLE="$OTHER/images/j2sdk-bundle"
  1094     OTHER_J2RE_BUNDLE="$OTHER/images/j2re-bundle"
  1095 fi
  1097 if [ -z "$THIS_J2SDK" ] || [ -z "$THIS_J2RE" ]; then
  1098     if [ -z "$THIS_J2SDK_OVERLAY" ]; then
  1099         echo "Cannot locate images for this build. Are you sure you have run 'make images'?"
  1100         exit 1
  1101     fi
  1102 fi
  1104 if [ -z "$OTHER_J2SDK" ] && [ -n "$OTHER_J2SDK_OVERLAY" ] && [ -z "$THIS_J2SDK_OVERLAY" ]; then
  1105     echo "OTHER build only has an overlay image while this build does not. Nothing to compare!"
  1106     exit 1
  1107 fi
  1109 if [ -z "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
  1110     echo "WARNING! OTHER build has bundles built while this build does not."
  1111     echo "Skipping bundle compare!"
  1112 fi
  1114 ##########################################################################################
  1115 # Do the work
  1117 if [ "$CMP_NAMES" = "true" ]; then
  1118     if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
  1119         echo -n "J2SDK "
  1120         compare_dirs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
  1121         echo -n "J2RE  "
  1122         compare_dirs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
  1124         echo -n "J2SDK "
  1125         compare_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
  1126         echo -n "J2RE  "
  1127         compare_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
  1128     fi
  1129     if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
  1130         echo -n "J2SDK Overlay "
  1131         compare_dirs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
  1132         echo -n "J2RE  Overlay "
  1133         compare_dirs $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
  1135         echo -n "J2SDK Overlay "
  1136         compare_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
  1137         echo -n "J2RE  Overlay "
  1138         compare_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
  1139     fi
  1140     if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
  1141         echo -n "J2SDK Bundle "
  1142         compare_dirs $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
  1143         echo -n "J2RE  Bundle "
  1144         compare_dirs $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
  1146         echo -n "J2SDK Bundle "
  1147         compare_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
  1148         echo -n "J2RE  Bundle "
  1149         compare_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
  1150     fi
  1151 fi
  1153 if [ "$CMP_PERMS" = "true" ]; then
  1154     if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
  1155         echo -n "J2SDK "
  1156         compare_permissions $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
  1157         echo -n "J2RE  "
  1158         compare_permissions $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
  1159     fi
  1160     if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
  1161         echo -n "J2SDK Overlay "
  1162         compare_permissions $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
  1163         echo -n "J2RE  Overlay "
  1164         compare_permissions $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
  1165     fi
  1166     if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
  1167         echo -n "J2SDK Bundle "
  1168         compare_permissions $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
  1169         echo -n "J2RE  Bundle "
  1170         compare_permissions $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
  1171     fi
  1172 fi
  1174 if [ "$CMP_TYPES" = "true" ]; then
  1175     if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
  1176         echo -n "J2SDK "
  1177         compare_file_types $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
  1178         echo -n "J2RE  "
  1179         compare_file_types $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
  1180     fi
  1181     if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
  1182         echo -n "J2SDK Overlay "
  1183         compare_file_types $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
  1184         echo -n "J2RE  Overlay "
  1185         compare_file_types $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
  1186     fi
  1187     if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
  1188         echo -n "J2SDK Bundle "
  1189         compare_file_types $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
  1190         echo -n "J2RE  Bundle "
  1191         compare_file_types $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
  1192     fi
  1193 fi
  1195 if [ "$CMP_GENERAL" = "true" ]; then
  1196     if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
  1197         echo -n "J2SDK "
  1198         compare_general_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
  1199         echo -n "J2RE  "
  1200         compare_general_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
  1201     fi
  1202     if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
  1203         echo -n "J2SDK Overlay "
  1204         compare_general_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
  1205         echo -n "J2RE  Overlay "
  1206         compare_general_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
  1207     fi
  1208     if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
  1209         echo -n "J2SDK Bundle "
  1210         compare_general_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
  1211         echo -n "J2RE  Bundle "
  1212         compare_general_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
  1213     fi
  1214 fi
  1216 if [ "$CMP_ZIPS" = "true" ]; then
  1217     if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
  1218         compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
  1219     fi
  1220 fi
  1222 if [ "$CMP_JARS" = "true" ]; then
  1223     if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
  1224         compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
  1225     fi
  1226 fi
  1228 if [ "$CMP_LIBS" = "true" ]; then
  1229     if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
  1230         echo -n "J2SDK "
  1231         compare_all_libs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
  1232         if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
  1233             echo -n "J2RE  "
  1234             compare_all_libs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
  1235         fi
  1236     fi
  1237     if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
  1238         echo -n "Bundle   "
  1239         compare_all_libs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
  1240     fi
  1241 fi
  1243 if [ "$CMP_EXECS" = "true" ]; then
  1244     if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
  1245         compare_all_execs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
  1246     fi
  1247     if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
  1248         echo -n "Overlay "
  1249         compare_all_execs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
  1250     fi
  1251 fi
  1253 echo
  1255 if [ -n "$REGRESSIONS" ]; then
  1256     echo "REGRESSIONS FOUND!"
  1257     echo
  1258     exit 1
  1259 else
  1260     echo "No regressions found"
  1261     echo
  1262     exit 0
  1263 fi

mercurial