ohair@494: #!/bin/bash ohair@494: # ohair@494: # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. ohair@494: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@494: # ohair@494: # This code is free software; you can redistribute it and/or modify it ohair@494: # under the terms of the GNU General Public License version 2 only, as ohair@494: # published by the Free Software Foundation. ohair@494: # ohair@494: # This code is distributed in the hope that it will be useful, but WITHOUT ohair@494: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@494: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@494: # version 2 for more details (a copy is included in the LICENSE file that ohair@494: # accompanied this code). ohair@494: # ohair@494: # You should have received a copy of the GNU General Public License version ohair@494: # 2 along with this work; if not, write to the Free Software Foundation, ohair@494: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@494: # ohair@494: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@494: # or visit www.oracle.com if you need additional information or have any ohair@494: # questions. ohair@494: # ohair@494: ohair@494: # This script is processed by configure before it's usable. It is run from ohair@494: # the root of the build directory. ohair@494: ohair@494: ohair@494: ########################################################################################## ohair@494: ohair@494: # Check that we are run via the wrapper generated by configure ohair@494: if [ -z "$SRC_ROOT" ]; then ohair@494: echo "Error: You must run this script using build/[conf]/compare.sh" ohair@494: exit 1 ohair@494: fi ohair@494: ohair@494: if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then ohair@494: FULLDUMP_CMD="$OTOOL -v -V -h -X -t -d" ohair@494: LDD_CMD="$OTOOL -L" ohair@494: DIS_CMD="$OTOOL -v -t" ohair@494: STAT_PRINT_SIZE="-f %z" ohair@494: elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then ohair@494: FULLDUMP_CMD="$DUMPBIN -all" ohair@494: LDD_CMD="$DUMPBIN -dependants | $GREP .dll" ohair@494: DIS_CMD="$DUMPBIN -disasm:nobytes" ohair@494: STAT_PRINT_SIZE="-c %s" ohair@494: else ohair@494: FULLDUMP_CMD="$READELF -a" ohair@494: LDD_CMD="$LDD" ohair@494: DIS_CMD="$OBJDUMP -d" ohair@494: STAT_PRINT_SIZE="-c %s" ohair@494: fi ohair@494: ohair@494: UNARCHIVE="$UNZIP -q" ohair@494: ohair@494: COMPARE_EXCEPTIONS_INCLUDE="$SRC_ROOT/common/bin/compare_exceptions.sh.incl" ohair@494: if [ ! -e "$COMPARE_EXCEPTIONS_INCLUDE" ]; then ohair@494: echo "Error: Cannot locate the exceptions file, it should have been here: $COMPARE_EXCEPTIONS_INCLUDE" ohair@494: exit 1 ohair@494: fi ohair@494: # Include exception definitions ohair@494: . "$COMPARE_EXCEPTIONS_INCLUDE" ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare text files and ignore specific differences: ohair@494: # ohair@494: # * Timestamps in Java sources generated by idl2java ohair@494: # * Sorting order and cleanup style in .properties files ohair@494: ohair@494: diff_text() { ohair@494: OTHER_FILE=$1 ohair@494: THIS_FILE=$2 ohair@494: ohair@494: SUFFIX="${THIS_FILE##*.}" ohair@494: ohair@494: TMP=1 ohair@494: ohair@494: if [[ "$THIS_FILE" = *"META-INF/MANIFEST.MF" ]]; then ohair@494: TMP=$(LANG=C $DIFF $OTHER_FILE $THIS_FILE | \ ohair@494: $GREP '^[<>]' | \ ohair@494: $SED -e '/[<>] Ant-Version: Apache Ant .*/d' \ ohair@494: -e '/[<>] Created-By: .* (Oracle Corporation).*/d') ohair@494: fi ohair@494: if test "x$SUFFIX" = "xjava"; then ohair@494: TMP=$(LANG=C $DIFF $OTHER_FILE $THIS_FILE | \ ohair@494: $GREP '^[<>]' | \ ohair@494: $SED -e '/[<>] \* from.*\.idl/d' \ ohair@494: -e '/[<>] \*.*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \ ohair@494: -e '/[<>] \*.*[0-9]\{4\} [0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \ ohair@494: -e '/\/\/ Generated from input file.*/d' \ ohair@494: -e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \ ohair@494: -e '/\/\/ java GenerateCharacter.*/d') ohair@494: fi ohair@494: # Ignore date strings in class files. ohair@494: # On Macosx the system sources for generated java classes produce different output on ohair@494: # consequtive invokations seemingly randomly. ohair@494: # For example a method parameter randomly named "thePoint" or "aPoint". Ignore this. ohair@494: if test "x$SUFFIX" = "xclass"; then ohair@494: # To improve performance when large diffs are found, do a rough filtering of classes ohair@494: # elibeble for these exceptions ohair@494: 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 ohair@494: $JAVAP -c -constants -l -p ${OTHER_FILE} > ${OTHER_FILE}.javap ohair@494: $JAVAP -c -constants -l -p ${THIS_FILE} > ${THIS_FILE}.javap ohair@494: TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \ ohair@494: $GREP '^[<>]' | \ ohair@494: $SED -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \ ohair@494: -e '/[<>].*Point Lcom\/apple\/jobjc\/foundation\/NSPoint;/d' \ ohair@494: -e '/[<>].*public com\.apple\.jobjc\.Pointer].*public void setItemsPtr(com\.apple\.jobjc\.Pointer $OTHER_FILE.cleaned ohair@494: TMP=$(LANG=C $DIFF $OTHER_FILE.cleaned $THIS_FILE) ohair@494: fi ohair@494: if test -n "$TMP"; then ohair@494: echo Files $OTHER_FILE and $THIS_FILE differ ohair@494: return 1 ohair@494: fi ohair@494: ohair@494: return 0 ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare directory structure ohair@494: ohair@494: compare_dirs() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: ohair@494: mkdir -p $WORK_DIR ohair@494: ohair@494: (cd $OTHER_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_other) ohair@494: (cd $THIS_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_this) ohair@494: ohair@494: $DIFF $WORK_DIR/dirs_other $WORK_DIR/dirs_other > $WORK_DIR/dirs_diff ohair@494: ohair@494: echo -n Directory structure... ohair@494: if [ -s $WORK_DIR/dirs_diff ]; then ohair@494: echo Differences found. ohair@494: REGRESSIONS=true ohair@494: # Differences in directories found. ohair@494: ONLY_OTHER=$($GREP '<' $WORK_DIR/dirs_diff) ohair@494: if [ "$ONLY_OTHER" ]; then ohair@494: echo Only in $OTHER ohair@494: $GREP '<' $WORK_DIR/dirs_diff | $SED 's|< ./| |g' ohair@494: fi ohair@494: ONLY_THIS=$($GREP '>' $WORK_DIR/dirs_diff) ohair@494: if [ "$ONLY_THIS" ]; then ohair@494: echo Only in $THIS ohair@494: $GREP '>' $WORK_DIR/dirs_diff | $SED 's|> ./| |g' ohair@494: fi ohair@494: else ohair@494: echo Identical! ohair@494: fi ohair@494: } ohair@494: ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare file structure ohair@494: ohair@494: compare_files() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: ohair@494: $MKDIR -p $WORK_DIR ohair@494: ohair@494: (cd $OTHER_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_other) ohair@494: (cd $THIS_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_this) ohair@494: ohair@494: $DIFF $WORK_DIR/files_other $WORK_DIR/files_this > $WORK_DIR/files_diff ohair@494: ohair@494: echo -n File names... ohair@494: if [ -s $WORK_DIR/files_diff ]; then ohair@494: echo Differences found. ohair@494: REGRESSIONS=true ohair@494: # Differences in files found. ohair@494: ONLY_OTHER=$($GREP '<' $WORK_DIR/files_diff) ohair@494: if [ "$ONLY_OTHER" ]; then ohair@494: echo Only in $OTHER ohair@494: $GREP '<' $WORK_DIR/files_diff | $SED 's|< ./| |g' ohair@494: fi ohair@494: ONLY_THIS=$($GREP '>' $WORK_DIR/files_diff) ohair@494: if [ "$ONLY_THIS" ]; then ohair@494: echo Only in $THIS ohair@494: $GREP '>' $WORK_DIR/files_diff | $SED 's|> ./| |g' ohair@494: fi ohair@494: else ohair@494: echo Identical! ohair@494: fi ohair@494: } ohair@494: ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare permissions ohair@494: ohair@494: compare_permissions() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: ohair@494: mkdir -p $WORK_DIR ohair@494: ohair@494: echo -n Permissions... ohair@494: found="" ohair@494: for f in `cd $OTHER_DIR && $FIND . -type f` ohair@494: do ohair@494: if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi ohair@494: if [ ! -f ${THIS_DIR}/$f ]; then continue; fi ohair@494: OP=`ls -l ${OTHER_DIR}/$f | awk '{printf("%.10s\n", $1);}'` ohair@494: TP=`ls -l ${THIS_DIR}/$f | awk '{printf("%.10s\n", $1);}'` ohair@494: if [ "$OP" != "$TP" ] ohair@494: then ohair@494: if [ -z "$found" ]; then echo ; found="yes"; fi ohair@494: $PRINTF "\told: ${OP} new: ${TP}\t$f\n" ohair@494: fi ohair@494: done ohair@494: if [ -z "$found" ]; then ohair@494: echo "Identical!" ohair@494: else ohair@494: REGRESSIONS=true ohair@494: fi ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare file command output ohair@494: ohair@494: compare_file_types() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: ohair@494: $MKDIR -p $WORK_DIR ohair@494: ohair@494: echo -n File types... ohair@494: found="" ohair@494: for f in `cd $OTHER_DIR && $FIND . ! -type d` ohair@494: do ohair@494: if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi ohair@494: if [ ! -f ${THIS_DIR}/$f ]; then continue; fi ohair@494: OF=`cd ${OTHER_DIR} && $FILE -h $f` ohair@494: TF=`cd ${THIS_DIR} && $FILE -h $f` ohair@494: if [ "$f" = "./src.zip" ] || [[ "$f" = *"/Home/src.zip" ]] || [[ "$f" = *"/lib/JObjC.jar" ]] ohair@494: then ohair@494: if [ "`echo $OF | $GREP -ic zip`" -gt 0 -a "`echo $TF | $GREP -ic zip`" -gt 0 ] ohair@494: then ohair@494: # the way we produces zip-files make it so that directories are stored in old file ohair@494: # but not in new (only files with full-path) ohair@494: # this makes file-5.09 report them as different ohair@494: continue; ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ "$OF" != "$TF" ] ohair@494: then ohair@494: if [ -z "$found" ]; then echo ; found="yes"; fi ohair@494: $PRINTF "\tother: ${OF}\n\tthis : ${TF}\n" ohair@494: fi ohair@494: done ohair@494: if [ -z "$found" ]; then ohair@494: echo "Identical!" ohair@494: else ohair@494: REGRESSIONS=true ohair@494: fi ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare the rest of the files ohair@494: ohair@494: compare_general_files() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: ohair@494: GENERAL_FILES=$(cd $THIS_DIR && $FIND . -type f ! -name "*.so" ! -name "*.jar" ! -name "*.zip" \ ohair@494: ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \ ohair@494: ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \ ohair@494: ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \ tbell@510: ! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" \ ohair@494: | $GREP -v "./bin/" | $SORT | $FILTER) ohair@494: ohair@494: echo General files... ohair@494: for f in $GENERAL_FILES ohair@494: do ohair@494: if [ -e $OTHER_DIR/$f ]; then ohair@494: if [ "$(basename $f)" = "release" ]; then ohair@494: # Ignore differences in change numbers in release file. ohair@494: OTHER_FILE=$WORK_DIR/$f.other ohair@494: THIS_FILE=$WORK_DIR/$f.this ohair@494: $MKDIR -p $(dirname $OTHER_FILE) ohair@494: $MKDIR -p $(dirname $THIS_FILE) ohair@494: $CAT $OTHER_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $OTHER_FILE ohair@494: $CAT $THIS_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $THIS_FILE ohair@494: else ohair@494: OTHER_FILE=$OTHER_DIR/$f ohair@494: THIS_FILE=$THIS_DIR/$f ohair@494: fi ohair@494: DIFF_OUT=$($DIFF $OTHER_FILE $THIS_FILE 2>&1) ohair@494: if [ -n "$DIFF_OUT" ]; then ohair@494: echo $f ohair@494: REGRESSIONS=true ohair@494: if [ "$SHOW_DIFFS" = "true" ]; then ohair@494: echo "$DIFF_OUT" ohair@494: fi ohair@494: fi ohair@494: fi ohair@494: done ohair@494: ohair@494: ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare zip file ohair@494: ohair@494: compare_zip_file() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: ZIP_FILE=$4 ohair@494: ohair@494: THIS_ZIP=$THIS_DIR/$ZIP_FILE ohair@494: OTHER_ZIP=$OTHER_DIR/$ZIP_FILE ohair@494: ohair@494: THIS_SUFFIX="${THIS_ZIP##*.}" ohair@494: OTHER_SUFFIX="${OTHER_ZIP##*.}" ohair@494: if [ "$THIS_SUFFIX" != "$OTHER_SUFFIX" ]; then ohair@494: echo The files do not have the same suffix type! ohair@494: return 2 ohair@494: fi ohair@494: ohair@494: TYPE="$THIS_SUFFIX" ohair@494: ohair@494: if $CMP $OTHER_ZIP $THIS_ZIP > /dev/null ohair@494: then ohair@494: return 0 ohair@494: fi ohair@494: # Not quite identical, the might still contain the same data. ohair@494: # Unpack the jar/zip files in temp dirs ohair@494: ohair@494: THIS_UNZIPDIR=$WORK_DIR/$ZIP_FILE.this ohair@494: OTHER_UNZIPDIR=$WORK_DIR/$ZIP_FILE.other ohair@494: $RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR ohair@494: $MKDIR -p $THIS_UNZIPDIR ohair@494: $MKDIR -p $OTHER_UNZIPDIR ohair@494: (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP) ohair@494: (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP) ohair@494: erikj@502: # Find all archives inside and unzip them as well to compare the contents rather than erikj@502: # the archives. erikj@502: EXCEPTIONS="" erikj@502: for pack in $($FIND $THIS_UNZIPDIR -name "*.pack" -o -name "*.pack.gz"); do erikj@502: ($UNPACK200 $pack $pack.jar) erikj@502: # Filter out the unzipped archives from the diff below. erikj@502: EXCEPTIONS="$EXCEPTIONS $pack $pack.jar" erikj@502: done erikj@502: for pack in $($FIND $OTHER_UNZIPDIR -name "*.pack" -o -name "*.pack.gz"); do erikj@502: ($UNPACK200 $pack $pack.jar) erikj@502: EXCEPTIONS="$EXCEPTIONS $pack $pack.jar" erikj@502: done erikj@502: for zip in $($FIND $THIS_UNZIPDIR -name "*.jar" -o -name "*.zip"); do erikj@502: $MKDIR $zip.unzip erikj@502: (cd $zip.unzip && $UNARCHIVE $zip) erikj@502: EXCEPTIONS="$EXCEPTIONS $zip" erikj@502: done erikj@502: for zip in $($FIND $OTHER_UNZIPDIR -name "*.jar" -o -name "*.zip"); do erikj@502: $MKDIR $zip.unzip erikj@502: (cd $zip.unzip && $UNARCHIVE $zip) erikj@502: EXCEPTIONS="$EXCEPTIONS $zip" erikj@502: done erikj@502: ohair@494: CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff ohair@494: # On solaris, there is no -q option. ohair@494: if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then ohair@494: LANG=C $DIFF -r $OTHER_UNZIPDIR $THIS_UNZIPDIR \ ohair@494: | $GREP -v -e "^<" -e "^>" -e "^Common subdirectories:" \ ohair@494: > $CONTENTS_DIFF_FILE ohair@494: else ohair@494: LANG=C $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE ohair@494: fi ohair@494: ohair@494: ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE) ohair@494: ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE) ohair@494: ohair@494: return_value=0 ohair@494: ohair@494: if [ -n "$ONLY_OTHER" ]; then ohair@494: echo " Only OTHER $ZIP_FILE contains:" ohair@494: echo "$ONLY_OTHER" | sed "s|Only in $OTHER_UNZIPDIR| |"g | sed 's|: |/|g' ohair@494: return_value=1 ohair@494: fi ohair@494: ohair@494: if [ -n "$ONLY_THIS" ]; then ohair@494: echo " Only THIS $ZIP_FILE contains:" ohair@494: echo "$ONLY_THIS" | sed "s|Only in $THIS_UNZIPDIR| |"g | sed 's|: |/|g' ohair@494: return_value=1 ohair@494: fi ohair@494: ohair@494: if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then ohair@494: DIFFING_FILES=$($GREP -e "differ$" -e "^diff " $CONTENTS_DIFF_FILE \ ohair@494: | $CUT -f 3 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g") ohair@494: else ohair@494: DIFFING_FILES=$($GREP -e "differ$" $CONTENTS_DIFF_FILE \ ohair@494: | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g") ohair@494: fi ohair@494: ohair@494: $RM -f $WORK_DIR/$ZIP_FILE.diffs ohair@494: for file in $DIFFING_FILES; do erikj@502: if [[ "$ACCEPTED_JARZIP_CONTENTS $EXCEPTIONS" != *"$file"* ]]; then ohair@494: diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs ohair@494: fi ohair@494: done ohair@494: ohair@494: if [ -s "$WORK_DIR/$ZIP_FILE.diffs" ]; then ohair@494: return_value=1 ohair@494: echo " Differing files in $ZIP_FILE" ohair@494: $CAT $WORK_DIR/$ZIP_FILE.diffs | $GREP differ | cut -f 2 -d ' ' | \ ohair@494: $SED "s|$OTHER_UNZIPDIR| |g" > $WORK_DIR/$ZIP_FILE.difflist ohair@494: $CAT $WORK_DIR/$ZIP_FILE.difflist ohair@494: ohair@494: if [ -n "$SHOW_DIFFS" ]; then ohair@494: for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do ohair@494: if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then ohair@494: LANG=C $DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap ohair@494: elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then ohair@494: LANG=C $DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i ohair@494: else ohair@494: LANG=C $DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i ohair@494: fi ohair@494: done ohair@494: fi ohair@494: fi ohair@494: ohair@494: return $return_value ohair@494: } ohair@494: ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare all zip files ohair@494: ohair@494: compare_all_zip_files() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: ohair@494: ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER ) ohair@494: ohair@494: if [ -n "$ZIPS" ]; then ohair@494: echo Zip files... ohair@494: ohair@494: return_value=0 ohair@494: for f in $ZIPS; do ohair@494: if [ -f "$OTHER_DIR/$f" ]; then ohair@494: compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f ohair@494: if [ "$?" != "0" ]; then ohair@494: return_value=1 ohair@494: REGRESSIONS=true ohair@494: fi ohair@494: fi ohair@494: done ohair@494: fi ohair@494: ohair@494: return $return_value ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare all jar files ohair@494: ohair@494: compare_all_jar_files() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: ohair@494: # TODO filter? ohair@494: ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" -o -name "*.war" | $SORT | $FILTER) ohair@494: ohair@494: if [ -n "$ZIPS" ]; then ohair@494: echo Jar files... ohair@494: ohair@494: return_value=0 ohair@494: for f in $ZIPS; do ohair@494: if [ -f "$OTHER_DIR/$f" ]; then ohair@494: compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f ohair@494: if [ "$?" != "0" ]; then ohair@494: return_value=1 ohair@494: REGRESSIONS=true ohair@494: fi ohair@494: fi ohair@494: done ohair@494: fi ohair@494: ohair@494: return $return_value ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare binary (executable/library) file ohair@494: ohair@494: compare_bin_file() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: BIN_FILE=$4 ohair@494: ohair@494: THIS_FILE=$THIS_DIR/$BIN_FILE ohair@494: OTHER_FILE=$OTHER_DIR/$BIN_FILE ohair@494: NAME=$(basename $BIN_FILE) ohair@494: WORK_FILE_BASE=$WORK_DIR/$BIN_FILE ohair@494: FILE_WORK_DIR=$(dirname $WORK_FILE_BASE) ohair@494: ohair@494: $MKDIR -p $FILE_WORK_DIR ohair@494: ohair@494: ORIG_THIS_FILE="$THIS_FILE" ohair@494: ORIG_OTHER_FILE="$OTHER_FILE" ohair@494: ohair@494: if [[ "$STRIP_BEFORE_COMPARE" = *"$BIN_FILE"* ]]; then ohair@494: THIS_STRIPPED_FILE=$FILE_WORK_DIR/this/$NAME ohair@494: OTHER_STRIPPED_FILE=$FILE_WORK_DIR/other/$NAME ohair@494: $MKDIR -p $FILE_WORK_DIR/this $FILE_WORK_DIR/other ohair@494: $CP $THIS_FILE $THIS_STRIPPED_FILE ohair@494: $CP $OTHER_FILE $OTHER_STRIPPED_FILE ohair@494: $STRIP $THIS_STRIPPED_FILE ohair@494: $STRIP $OTHER_STRIPPED_FILE ohair@494: THIS_FILE="$THIS_STRIPPED_FILE" ohair@494: OTHER_FILE="$OTHER_STRIPPED_FILE" ohair@494: fi ohair@494: ohair@494: if [ "$OPENJDK_TARGET_OS" = "windows" ]; then ohair@494: unset _NT_SYMBOL_PATH ohair@494: # On windows we need to unzip the debug symbols, if present ohair@494: OTHER_FILE_BASE=${OTHER_FILE/.dll/} ohair@494: OTHER_FILE_BASE=${OTHER_FILE_BASE/.exe/} ohair@494: DIZ_NAME=$(basename $OTHER_FILE_BASE).diz ohair@494: # java.exe and java.dll diz files will have the same name. Have to ohair@494: # make sure java.exe gets the right one. This is only needed for ohair@494: # OTHER since in the new build, all pdb files are left around. ohair@494: if [ "$NAME" = "java.exe" ] && [ -f "$OTHER/tmp/java/java/obj64/java.diz" ]; then ohair@494: OTHER_DIZ_FILE="$OTHER/tmp/java/java/obj64/java.diz" ohair@494: elif [ -f "${OTHER_FILE_BASE}.diz" ]; then ohair@494: OTHER_DIZ_FILE=${OTHER_FILE_BASE}.diz ohair@494: else ohair@494: # Some files, jli.dll, appears twice in the image but only one of ohair@494: # thme has a diz file next to it. ohair@494: OTHER_DIZ_FILE="$($FIND $OTHER_DIR -name $DIZ_NAME | $SED 1q)" ohair@494: if [ ! -f "$OTHER_DIZ_FILE" ]; then ohair@494: # As a last resort, look for diz file in the whole build output ohair@494: # dir. ohair@494: OTHER_DIZ_FILE="$($FIND $OTHER -name $DIZ_NAME | $SED 1q)" ohair@494: fi ohair@494: fi ohair@494: if [ -n "$OTHER_DIZ_FILE" ]; then ohair@494: $MKDIR -p $FILE_WORK_DIR/other ohair@494: (cd $FILE_WORK_DIR/other ; $UNARCHIVE -o $OTHER_DIZ_FILE) ohair@494: export _NT_SYMBOL_PATH="$FILE_WORK_DIR/other" ohair@494: fi ohair@494: THIS_FILE_BASE=${THIS_FILE/.dll/} ohair@494: THIS_FILE_BASE=${THIS_FILE_BASE/.exe/} ohair@494: if [ -f "${THIS_FILE/.dll/}.diz" ]; then ohair@494: THIS_DIZ_FILE=${THIS_FILE/.dll/}.diz ohair@494: else ohair@494: THIS_DIZ_FILE="$($FIND $THIS_DIR -name $DIZ_NAME | $SED 1q)" ohair@494: if [ ! -f "$THIS_DIZ_FILE" ]; then ohair@494: # As a last resort, look for diz file in the whole build output ohair@494: # dir. ohair@494: THIS_DIZ_FILE="$($FIND $THIS -name $DIZ_NAME | $SED 1q)" ohair@494: fi ohair@494: fi ohair@494: if [ -n "$THIS_DIZ_FILE" ]; then ohair@494: $MKDIR -p $FILE_WORK_DIR/this ohair@494: (cd $FILE_WORK_DIR/this ; $UNARCHIVE -o $THIS_DIZ_FILE) ohair@494: export _NT_SYMBOL_PATH="$_NT_SYMBOL_PATH;$FILE_WORK_DIR/this" ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ -z "$SKIP_BIN_DIFF" ]; then ohair@494: if cmp $OTHER_FILE $THIS_FILE > /dev/null; then ohair@494: # The files were bytewise identical. ohair@494: if [ -n "$VERBOSE" ]; then ohair@494: echo " : : : : : $BIN_FILE" ohair@494: fi ohair@494: return 0 ohair@494: fi ohair@494: BIN_MSG=" diff " ohair@494: if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: DIFF_BIN=true ohair@494: if [[ "$KNOWN_BIN_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: BIN_MSG="*$BIN_MSG*" ohair@494: REGRESSIONS=true ohair@494: else ohair@494: BIN_MSG=" $BIN_MSG " ohair@494: fi ohair@494: else ohair@494: BIN_MSG="($BIN_MSG)" ohair@494: DIFF_BIN= ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ -n "$STAT" ]; then ohair@494: THIS_SIZE=$($STAT $STAT_PRINT_SIZE "$THIS_FILE") ohair@494: OTHER_SIZE=$($STAT $STAT_PRINT_SIZE "$OTHER_FILE") ohair@494: else ohair@494: THIS_SIZE=$(ls -l "$THIS_FILE" | awk '{ print $5 }') ohair@494: OTHER_SIZE=$(ls -l "$OTHER_FILE" | awk '{ print $5 }') ohair@494: fi ohair@494: if [ $THIS_SIZE -ne $OTHER_SIZE ]; then ohair@494: DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE) ohair@494: DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE) ohair@494: SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM) tbell@510: if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \ tbell@510: && [ "$DIFF_SIZE_REL" -lt 102 ]; then ohair@494: SIZE_MSG="($SIZE_MSG)" ohair@494: DIFF_SIZE= tbell@510: elif [ "$OPENJDK_TARGET_OS" = "windows" ] \ tbell@510: && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \ tbell@510: && [ "$DIFF_SIZE_NUM" = 512 ]; then tbell@510: # On windows, size of binaries increase in 512 increments. tbell@510: SIZE_MSG="($SIZE_MSG)" tbell@510: DIFF_SIZE= tbell@510: elif [ "$OPENJDK_TARGET_OS" = "windows" ] \ tbell@510: && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \ tbell@510: && [ "$DIFF_SIZE_NUM" = -512 ]; then ohair@494: # On windows, size of binaries increase in 512 increments. ohair@494: SIZE_MSG="($SIZE_MSG)" ohair@494: DIFF_SIZE= ohair@494: else ohair@494: if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: DIFF_SIZE=true ohair@494: if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: SIZE_MSG="*$SIZE_MSG*" ohair@494: REGRESSIONS=true ohair@494: else ohair@494: SIZE_MSG=" $SIZE_MSG " ohair@494: fi ohair@494: else ohair@494: SIZE_MSG="($SIZE_MSG)" ohair@494: DIFF_SIZE= ohair@494: fi ohair@494: fi ohair@494: else ohair@494: SIZE_MSG=" " ohair@494: DIFF_SIZE= ohair@494: if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then ohair@494: SIZE_MSG=" ! " ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then ohair@494: SYM_SORT_CMD="sort" ohair@494: else ohair@494: SYM_SORT_CMD="cat" ohair@494: fi ohair@494: ohair@494: # Check symbols ohair@494: if [ "$OPENJDK_TARGET_OS" = "windows" ]; then ohair@494: # The output from dumpbin on windows differs depending on if the debug symbol ohair@494: # files are still around at the location the binary is pointing too. Need ohair@494: # to filter out that extra information. ohair@494: $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 ohair@494: $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 ohair@494: elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then ohair@494: # Some symbols get seemingly random 15 character prefixes. Filter them out. ohair@494: $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 ohair@494: $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 ohair@494: else ohair@494: $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 ohair@494: $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 ohair@494: fi ohair@494: ohair@494: LANG=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff ohair@494: if [ -s $WORK_FILE_BASE.symbols.diff ]; then ohair@494: SYM_MSG=" diff " ohair@494: if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: DIFF_SYM=true ohair@494: if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: SYM_MSG="*$SYM_MSG*" ohair@494: REGRESSIONS=true ohair@494: else ohair@494: SYM_MSG=" $SYM_MSG " ohair@494: fi ohair@494: else ohair@494: SYM_MSG="($SYM_MSG)" ohair@494: DIFF_SYM= ohair@494: fi ohair@494: else ohair@494: SYM_MSG=" " ohair@494: DIFF_SYM= ohair@494: if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then ohair@494: SYM_MSG=" ! " ohair@494: fi ohair@494: fi ohair@494: ohair@494: # Check dependencies ohair@494: if [ -n "$LDD_CMD" ]; then erikj@502: (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) erikj@502: (cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME 2 $WORK_FILE_BASE.deps.this.uniq) ohair@494: (cd $FILE_WORK_DIR && $RM -f $NAME) ohair@494: ohair@494: LANG=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this > $WORK_FILE_BASE.deps.diff ohair@494: LANG=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq > $WORK_FILE_BASE.deps.diff.uniq ohair@494: ohair@494: if [ -s $WORK_FILE_BASE.deps.diff ]; then ohair@494: if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then ohair@494: DEP_MSG=" diff " ohair@494: else ohair@494: DEP_MSG=" redun " ohair@494: fi ohair@494: if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: DIFF_DEP=true ohair@494: if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: DEP_MSG="*$DEP_MSG*" ohair@494: REGRESSIONS=true ohair@494: else ohair@494: DEP_MSG=" $DEP_MSG " ohair@494: fi ohair@494: else ohair@494: DEP_MSG="($DEP_MSG)" ohair@494: DIFF_DEP= ohair@494: fi ohair@494: else ohair@494: DEP_MSG=" " ohair@494: DIFF_DEP= ohair@494: if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then ohair@494: DEP_MSG=" ! " ohair@494: fi ohair@494: fi ohair@494: else ohair@494: DEP_MSG=" - " ohair@494: fi ohair@494: ohair@494: # Compare fulldump output ohair@494: if [ -n "$FULLDUMP_CMD" ] && [ -z "$SKIP_FULLDUMP_DIFF" ]; then ohair@494: $FULLDUMP_CMD $OTHER_FILE > $WORK_FILE_BASE.fulldump.other 2>&1 ohair@494: $FULLDUMP_CMD $THIS_FILE > $WORK_FILE_BASE.fulldump.this 2>&1 ohair@494: LANG=C $DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this > $WORK_FILE_BASE.fulldump.diff ohair@494: ohair@494: if [ -s $WORK_FILE_BASE.fulldump.diff ]; then ohair@494: ELF_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.fulldump.diff | awk '{print $5}') ohair@494: ELF_MSG=$($PRINTF "%8d" $ELF_DIFF_SIZE) ohair@494: if [[ "$ACCEPTED_ELF_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: DIFF_ELF=true ohair@494: if [[ "$KNOWN_ELF_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: ELF_MSG="*$ELF_MSG*" ohair@494: REGRESSIONS=true ohair@494: else ohair@494: ELF_MSG=" $ELF_MSG " ohair@494: fi ohair@494: else ohair@494: ELF_MSG="($ELF_MSG)" ohair@494: DIFF_ELF= ohair@494: fi ohair@494: else ohair@494: ELF_MSG=" " ohair@494: DIFF_ELF= ohair@494: if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then ohair@494: ELF_MSG=" ! " ohair@494: fi ohair@494: fi ohair@494: fi ohair@494: ohair@494: # Compare disassemble output ohair@494: if [ -n "$DIS_CMD" ] && [ -z "$SKIP_DIS_DIFF" ]; then ohair@494: if [ -z "$DIS_DIFF_FILTER" ]; then ohair@494: DIS_DIFF_FILTER="$CAT" ohair@494: fi ohair@494: $DIS_CMD $OTHER_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.other 2>&1 ohair@494: $DIS_CMD $THIS_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.this 2>&1 ohair@494: ohair@494: LANG=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff ohair@494: ohair@494: if [ -s $WORK_FILE_BASE.dis.diff ]; then ohair@494: DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}') ohair@494: DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE) ohair@494: if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: DIFF_DIS=true ohair@494: if [[ "$KNOWN_DIS_DIFF" != *"$BIN_FILE"* ]]; then ohair@494: DIS_MSG="*$DIS_MSG*" ohair@494: REGRESSIONS=true ohair@494: else ohair@494: DIS_MSG=" $DIS_MSG " ohair@494: fi ohair@494: else ohair@494: DIS_MSG="($DIS_MSG)" ohair@494: DIFF_DIS= ohair@494: fi ohair@494: else ohair@494: DIS_MSG=" " ohair@494: DIFF_DIS= ohair@494: if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then ohair@494: DIS_MSG=" ! " ohair@494: fi ohair@494: fi ohair@494: fi ohair@494: ohair@494: ohair@494: if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_ELF$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then ohair@494: if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi ohair@494: if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi ohair@494: if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi ohair@494: if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi ohair@494: if [ -n "$ELF_MSG" ]; then echo -n "$ELF_MSG:"; fi ohair@494: if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi ohair@494: echo " $BIN_FILE" ohair@494: if [ "$SHOW_DIFFS" = "true" ]; then ohair@494: if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then ohair@494: echo "Symbols diff:" ohair@494: $CAT $WORK_FILE_BASE.symbols.diff ohair@494: fi ohair@494: if [ -s "$WORK_FILE_BASE.deps.diff" ]; then ohair@494: echo "Deps diff:" ohair@494: $CAT $WORK_FILE_BASE.deps.diff ohair@494: fi ohair@494: if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then ohair@494: echo "Fulldump diff:" ohair@494: $CAT $WORK_FILE_BASE.fulldump.diff ohair@494: fi ohair@494: if [ -s "$WORK_FILE_BASE.dis.diff" ]; then ohair@494: echo "Disassembly diff:" ohair@494: $CAT $WORK_FILE_BASE.dis.diff ohair@494: fi ohair@494: fi ohair@494: return 1 ohair@494: fi ohair@494: return 0 ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Print binary diff header ohair@494: ohair@494: print_binary_diff_header() { ohair@494: if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi ohair@494: if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n " Size :"; fi ohair@494: if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi ohair@494: if [ -z "$SKIP_DEP_DIFF" ]; then echo -n " Deps :"; fi ohair@494: if [ -z "$SKIP_FULLDUMP_DIFF" ]; then echo -n " Fulldump :"; fi ohair@494: if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass :"; fi ohair@494: echo ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare all libraries ohair@494: ohair@494: compare_all_libs() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: tbell@510: LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' -o -name 'JavaControlPanel' \) | $SORT | $FILTER) ohair@494: ohair@494: if [ -n "$LIBS" ]; then ohair@494: echo Libraries... ohair@494: print_binary_diff_header ohair@494: for l in $LIBS; do ohair@494: if [ -f "$OTHER_DIR/$l" ]; then ohair@494: compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l ohair@494: if [ "$?" != "0" ]; then ohair@494: return_value=1 ohair@494: fi ohair@494: fi ohair@494: done ohair@494: fi ohair@494: ohair@494: return $return_value ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Compare all executables ohair@494: ohair@494: compare_all_execs() { ohair@494: THIS_DIR=$1 ohair@494: OTHER_DIR=$2 ohair@494: WORK_DIR=$3 ohair@494: ohair@494: if [ "$OPENJDK_TARGET_OS" = "windows" ]; then ohair@494: EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER) ohair@494: else erikj@502: EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \ erikj@502: \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \ erikj@502: -o -name '*.jar' -o -name '*.diz' -o -name 'jcontrol' -o -name '*.properties' \ erikj@502: -o -name '*.data' -o -name '*.bfc' -o -name '*.src' -o -name '*.txt' \ erikj@502: -o -name '*.cfg' -o -name 'meta-index' -o -name '*.properties.ja' \ erikj@502: -o -name 'classlist' \) | $SORT | $FILTER) ohair@494: fi ohair@494: ohair@494: if [ -n "$EXECS" ]; then ohair@494: echo Executables... ohair@494: print_binary_diff_header ohair@494: for e in $EXECS; do ohair@494: if [ -f "$OTHER_DIR/$e" ]; then ohair@494: compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e ohair@494: if [ "$?" != "0" ]; then ohair@494: return_value=1 ohair@494: fi ohair@494: fi ohair@494: done ohair@494: fi ohair@494: ohair@494: return $return_value ohair@494: } ohair@494: ohair@494: ########################################################################################## ohair@494: # Initiate configuration ohair@494: ohair@494: COMPARE_ROOT=/tmp/cimages.$USER ohair@494: $MKDIR -p $COMPARE_ROOT ohair@494: if [ "$OPENJDK_TARGET_OS" = "windows" ]; then ohair@494: if [ "$(uname -o)" = "Cygwin" ]; then ohair@494: COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT) ohair@494: fi ohair@494: fi ohair@494: ohair@494: THIS="$( cd "$( dirname "$0" )" && pwd )" ohair@494: echo "$THIS" ohair@494: THIS_SCRIPT="$0" ohair@494: ohair@494: if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then ohair@494: echo "bash ./compare.sh [OPTIONS] [FILTER]" ohair@494: echo "" ohair@494: echo "-all Compare all files in all known ways" ohair@494: echo "-names Compare the file names and directory structure" ohair@494: echo "-perms Compare the permission bits on all files and directories" ohair@494: echo "-types Compare the output of the file command on all files" ohair@494: echo "-general Compare the files not convered by the specialized comparisons" ohair@494: echo "-zips Compare the contents of all zip files" ohair@494: echo "-jars Compare the contents of all jar files" ohair@494: echo "-libs Compare all native libraries" ohair@494: echo "-execs Compare all executables" ohair@494: echo "-v Verbose output, does not hide known differences" ohair@494: echo "-vv More verbose output, shows diff output of all comparisons" ohair@494: echo "-o [OTHER] Compare with build in other directory. Will default to the old build directory" ohair@494: echo "" ohair@494: echo "[FILTER] List filenames in the image to compare, works for jars, zips, libs and execs" ohair@494: echo "Example:" ohair@494: echo "bash ./common/bin/compareimages.sh CodePointIM.jar" ohair@494: exit 10 ohair@494: fi ohair@494: ohair@494: CMP_NAMES=false ohair@494: CMP_PERMS=false ohair@494: CMP_TYPES=false ohair@494: CMP_GENERAL=false ohair@494: CMP_ZIPS=false ohair@494: CMP_JARS=false ohair@494: CMP_LIBS=false ohair@494: CMP_EXECS=false ohair@494: ohair@494: while [ -n "$1" ]; do ohair@494: case "$1" in ohair@494: -v) ohair@494: VERBOSE=true ohair@494: ;; ohair@494: -vv) ohair@494: VERBOSE=true ohair@494: SHOW_DIFFS=true ohair@494: ;; ohair@494: -o) ohair@494: OTHER="$2" ohair@494: shift ohair@494: ;; ohair@494: -all) ohair@494: CMP_NAMES=true ohair@494: if [ "$OPENJDK_TARGET_OS" != "windows" ]; then ohair@494: CMP_PERMS=true ohair@494: fi ohair@494: CMP_TYPES=true ohair@494: CMP_GENERAL=true ohair@494: CMP_ZIPS=true ohair@494: CMP_JARS=true ohair@494: CMP_LIBS=true ohair@494: CMP_EXECS=true ohair@494: ;; ohair@494: -names) ohair@494: CMP_NAMES=true ohair@494: ;; ohair@494: -perms) ohair@494: CMP_PERMS=true ohair@494: ;; ohair@494: -types) ohair@494: CMP_TYPES=true ohair@494: ;; ohair@494: -general) ohair@494: CMP_GENERAL=true ohair@494: ;; ohair@494: -zips) ohair@494: CMP_ZIPS=true ohair@494: ;; ohair@494: -jars) ohair@494: CMP_JARS=true ohair@494: ;; ohair@494: -libs) ohair@494: CMP_LIBS=true ohair@494: ;; ohair@494: -execs) ohair@494: CMP_EXECS=true ohair@494: ;; ohair@494: *) ohair@494: CMP_NAMES=false ohair@494: CMP_PERMS=false ohair@494: CMP_TYPES=false ohair@494: CMP_ZIPS=true ohair@494: CMP_JARS=true ohair@494: CMP_LIBS=true ohair@494: CMP_EXECS=true ohair@494: ohair@494: if [ -z "$FILTER" ]; then ohair@494: FILTER="$GREP" ohair@494: fi ohair@494: FILTER="$FILTER -e $1" ohair@494: ;; ohair@494: esac ohair@494: shift ohair@494: done ohair@494: ohair@494: 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 ohair@494: CMP_NAMES=true ohair@494: CMP_PERMS=true ohair@494: CMP_TYPES=true ohair@494: CMP_GENERAL=true ohair@494: CMP_ZIPS=true ohair@494: CMP_JARS=true ohair@494: CMP_LIBS=true ohair@494: CMP_EXECS=true ohair@494: fi ohair@494: ohair@494: if [ -z "$FILTER" ]; then ohair@494: FILTER="$CAT" ohair@494: fi ohair@494: ohair@494: if [ -z "$OTHER" ]; then ohair@494: OTHER="$THIS/../$LEGACY_BUILD_DIR" ohair@494: if [ -d "$OTHER" ]; then ohair@494: OTHER="$( cd "$OTHER" && pwd )" ohair@494: else ohair@494: echo "Default old build directory does not exist:" ohair@494: echo "$OTHER" ohair@494: exit 1 ohair@494: fi ohair@494: echo "Comparing to default old build:" ohair@494: echo "$OTHER" ohair@494: echo ohair@494: else ohair@494: if [ ! -d "$OTHER" ]; then ohair@494: echo "Other build directory does not exist:" ohair@494: echo "$OTHER" ohair@494: exit 1 ohair@494: fi ohair@494: OTHER="$( cd "$OTHER" && pwd )" ohair@494: echo "Comparing to:" ohair@494: echo "$OTHER" ohair@494: echo ohair@494: fi ohair@494: ohair@494: ohair@494: # Figure out the layout of the this build. Which kinds of images have been produced ohair@494: if [ -d "$THIS/deploy/j2sdk-image" ]; then ohair@494: THIS_J2SDK="$THIS/deploy/j2sdk-image" ohair@494: THIS_J2RE="$THIS/deploy/j2re-image" erikj@502: echo "Comparing deploy images" ohair@494: elif [ -d "$THIS/images/j2sdk-image" ]; then ohair@494: THIS_J2SDK="$THIS/images/j2sdk-image" ohair@494: THIS_J2RE="$THIS/images/j2re-image" ohair@494: fi ohair@494: if [ -d "$THIS/images/j2sdk-overlay-image" ]; then ohair@494: THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image" ohair@494: THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image" ohair@494: fi ohair@494: ohair@494: if [ -d "$THIS/images/j2sdk-bundle" ]; then ohair@494: THIS_J2SDK_BUNDLE="$THIS/images/j2sdk-bundle" ohair@494: THIS_J2RE_BUNDLE="$THIS/images/j2re-bundle" ohair@494: fi ohair@494: ohair@494: # Figure out the layout of the other build (old or new, normal or overlay image) ohair@494: if [ -d "$OTHER/j2sdk-image" ]; then ohair@494: if [ -f "$OTHER/j2sdk-image/LICENSE" ]; then ohair@494: OTHER_J2SDK="$OTHER/j2sdk-image" ohair@494: OTHER_J2RE="$OTHER/j2re-image" ohair@494: else ohair@494: OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image" ohair@494: OTHER_J2RE_OVERLAY="$OTHER/j2re-image" ohair@494: fi ohair@494: ohair@494: fi ohair@494: ohair@494: if [ -d "$OTHER/j2sdk-bundle" ]; then ohair@494: OTHER_J2SDK_BUNDLE="$OTHER/j2sdk-bundle" ohair@494: OTHER_J2RE_BUNDLE="$OTHER/j2re-bundle" ohair@494: elif [ -d "$OTHER/images/j2sdk-bundle" ]; then ohair@494: OTHER_J2SDK_BUNDLE="$OTHER/images/j2sdk-bundle" ohair@494: OTHER_J2RE_BUNDLE="$OTHER/images/j2re-bundle" ohair@494: fi ohair@494: ohair@494: if [ -z "$THIS_J2SDK" ] || [ -z "$THIS_J2RE" ]; then ohair@494: if [ -z "$THIS_J2SDK_OVERLAY" ]; then ohair@494: echo "Cannot locate images for this build. Are you sure you have run 'make images'?" ohair@494: exit 1 ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ -z "$OTHER_J2SDK" ] && [ -n "$OTHER_J2SDK_OVERLAY" ] && [ -z "$THIS_J2SDK_OVERLAY" ]; then ohair@494: echo "OTHER build only has an overlay image while this build does not. Nothing to compare!" ohair@494: exit 1 ohair@494: fi ohair@494: ohair@494: if [ -z "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then ohair@494: echo "WARNING! OTHER build has bundles built while this build does not." ohair@494: echo "Skipping bundle compare!" ohair@494: fi ohair@494: ohair@494: ########################################################################################## ohair@494: # Do the work ohair@494: ohair@494: if [ "$CMP_NAMES" = "true" ]; then ohair@494: if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then ohair@494: echo -n "J2SDK " ohair@494: compare_dirs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk ohair@494: echo -n "J2RE " ohair@494: compare_dirs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re ohair@494: ohair@494: echo -n "J2SDK " ohair@494: compare_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk ohair@494: echo -n "J2RE " ohair@494: compare_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then ohair@494: echo -n "J2SDK Overlay " ohair@494: compare_dirs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay ohair@494: echo -n "J2RE Overlay " ohair@494: compare_dirs $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay ohair@494: ohair@494: echo -n "J2SDK Overlay " ohair@494: compare_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay ohair@494: echo -n "J2RE Overlay " ohair@494: compare_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then ohair@494: echo -n "J2SDK Bundle " ohair@494: compare_dirs $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle ohair@494: echo -n "J2RE Bundle " ohair@494: compare_dirs $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle ohair@494: ohair@494: echo -n "J2SDK Bundle " ohair@494: compare_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle ohair@494: echo -n "J2RE Bundle " ohair@494: compare_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ "$CMP_PERMS" = "true" ]; then ohair@494: if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then ohair@494: echo -n "J2SDK " ohair@494: compare_permissions $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk ohair@494: echo -n "J2RE " ohair@494: compare_permissions $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then ohair@494: echo -n "J2SDK Overlay " ohair@494: compare_permissions $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay ohair@494: echo -n "J2RE Overlay " ohair@494: compare_permissions $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then ohair@494: echo -n "J2SDK Bundle " ohair@494: compare_permissions $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle ohair@494: echo -n "J2RE Bundle " ohair@494: compare_permissions $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ "$CMP_TYPES" = "true" ]; then ohair@494: if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then ohair@494: echo -n "J2SDK " ohair@494: compare_file_types $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk ohair@494: echo -n "J2RE " ohair@494: compare_file_types $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then ohair@494: echo -n "J2SDK Overlay " ohair@494: compare_file_types $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay ohair@494: echo -n "J2RE Overlay " ohair@494: compare_file_types $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then ohair@494: echo -n "J2SDK Bundle " ohair@494: compare_file_types $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle ohair@494: echo -n "J2RE Bundle " ohair@494: compare_file_types $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ "$CMP_GENERAL" = "true" ]; then ohair@494: if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then ohair@494: echo -n "J2SDK " ohair@494: compare_general_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk ohair@494: echo -n "J2RE " ohair@494: compare_general_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then ohair@494: echo -n "J2SDK Overlay " ohair@494: compare_general_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay ohair@494: echo -n "J2RE Overlay " ohair@494: compare_general_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then ohair@494: echo -n "J2SDK Bundle " ohair@494: compare_general_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle ohair@494: echo -n "J2RE Bundle " ohair@494: compare_general_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ "$CMP_ZIPS" = "true" ]; then ohair@494: if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then ohair@494: compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ "$CMP_JARS" = "true" ]; then ohair@494: if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then ohair@494: compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ "$CMP_LIBS" = "true" ]; then ohair@494: if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then tbell@510: echo -n "J2SDK " ohair@494: compare_all_libs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk tbell@510: if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then tbell@510: echo -n "J2RE " tbell@510: compare_all_libs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re tbell@510: fi ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then ohair@494: echo -n "Bundle " ohair@494: compare_all_libs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay ohair@494: fi ohair@494: fi ohair@494: ohair@494: if [ "$CMP_EXECS" = "true" ]; then ohair@494: if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then ohair@494: compare_all_execs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk ohair@494: fi ohair@494: if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then ohair@494: echo -n "Overlay " ohair@494: compare_all_execs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay ohair@494: fi ohair@494: fi ohair@494: ohair@494: echo ohair@494: ohair@494: if [ -n "$REGRESSIONS" ]; then ohair@494: echo "REGRESSIONS FOUND!" ohair@494: echo ohair@494: exit 1 ohair@494: else ohair@494: echo "No regressions found" ohair@494: echo ohair@494: exit 0 ohair@494: fi