Path: blob/aarch64-shenandoah-jdk8u272-b10/common/bin/compare.sh
32278 views
#!/bin/bash1#2# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4#5# This code is free software; you can redistribute it and/or modify it6# under the terms of the GNU General Public License version 2 only, as7# published by the Free Software Foundation.8#9# This code is distributed in the hope that it will be useful, but WITHOUT10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12# version 2 for more details (a copy is included in the LICENSE file that13# accompanied this code).14#15# You should have received a copy of the GNU General Public License version16# 2 along with this work; if not, write to the Free Software Foundation,17# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18#19# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20# or visit www.oracle.com if you need additional information or have any21# questions.22#2324# This script is processed by configure before it's usable. It is run from25# the root of the build directory.262728##########################################################################################2930# Check that we are run via the wrapper generated by configure31if [ -z "$SRC_ROOT" ]; then32echo "Error: You must run this script using build/[conf]/compare.sh"33exit 134fi3536if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then37FULLDUMP_CMD="$OTOOL -v -V -h -X -t -d"38LDD_CMD="$OTOOL -L"39DIS_CMD="$OTOOL -v -t"40STAT_PRINT_SIZE="-f %z"41elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then42FULLDUMP_CMD="$DUMPBIN -all"43LDD_CMD="$DUMPBIN -dependants | $GREP .dll"44DIS_CMD="$DUMPBIN -disasm:nobytes"45STAT_PRINT_SIZE="-c %s"46else47FULLDUMP_CMD="$READELF -a"48LDD_CMD="$LDD"49DIS_CMD="$OBJDUMP -d"50STAT_PRINT_SIZE="-c %s"51fi5253UNARCHIVE="$UNZIP -q"5455COMPARE_EXCEPTIONS_INCLUDE="$SRC_ROOT/common/bin/compare_exceptions.sh.incl"56if [ ! -e "$COMPARE_EXCEPTIONS_INCLUDE" ]; then57echo "Error: Cannot locate the exceptions file, it should have been here: $COMPARE_EXCEPTIONS_INCLUDE"58exit 159fi60# Include exception definitions61. "$COMPARE_EXCEPTIONS_INCLUDE"6263##########################################################################################64# Compare text files and ignore specific differences:65#66# * Timestamps in Java sources generated by idl2java67# * Sorting order and cleanup style in .properties files6869diff_text() {70OTHER_FILE=$171THIS_FILE=$27273SUFFIX="${THIS_FILE##*.}"7475TMP=17677if [[ "$THIS_FILE" = *"META-INF/MANIFEST.MF" ]]; then78TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \79$GREP '^[<>]' | \80$SED -e '/[<>] Ant-Version: Apache Ant .*/d' \81-e '/[<>] Created-By: .* (Oracle Corporation).*/d')82fi83if test "x$SUFFIX" = "xjava"; then84TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \85$GREP '^[<>]' | \86$SED -e '/[<>] \* from.*\.idl/d' \87-e '/[<>] \*.*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \88-e '/[<>] \*.*[0-9]\{4\} [0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \89-e '/\/\/ Generated from input file.*/d' \90-e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \91-e '/\/\/ java GenerateCharacter.*/d')92fi93# Ignore date strings in class files.94# On Macosx the system sources for generated java classes produce different output on95# consequtive invokations seemingly randomly.96# For example a method parameter randomly named "thePoint" or "aPoint". Ignore this.97if test "x$SUFFIX" = "xclass"; then98# To improve performance when large diffs are found, do a rough filtering of classes99# elibeble for these exceptions100if $GREP -R -e '[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}' \101-e '[0-9]\{2\}/[0-9]\{2\}/[0-9]\{4\}' \102-e thePoint -e aPoint -e setItemsPtr ${THIS_FILE} > /dev/null; then103$JAVAP -c -constants -l -p ${OTHER_FILE} > ${OTHER_FILE}.javap104$JAVAP -c -constants -l -p ${THIS_FILE} > ${THIS_FILE}.javap105TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \106$GREP '^[<>]' | \107$SED -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \108-e '/[0-9]\{2\}\/[0-9]\{2\}\/[0-9]\{4\}/d' \109-e '/[<>].*Point Lcom\/apple\/jobjc\/foundation\/NSPoint;/d' \110-e '/[<>].*public com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*itemsPtr();/d' \111-e '/[<>].*public void setItemsPtr(com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*);/d')112fi113fi114if test "x$SUFFIX" = "xproperties"; then115# Run through nawk to add possibly missing newline at end of file.116$CAT $OTHER_FILE | $NAWK '{ print }' | LC_ALL=C $SORT > $OTHER_FILE.cleaned117# Disable this exception since we aren't changing the properties cleaning method yet.118# $CAT $OTHER_FILE | $SED -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \119# | $SED -f "$SRC_ROOT/common/makefiles/support/unicode2x.sed" \120# | $SED -e '/^#/d' -e '/^$/d' \121# -e :a -e '/\\$/N; s/\\\n//; ta' \122# -e 's/^[ \t]*//;s/[ \t]*$//' \123# -e 's/\\=/=/' | LC_ALL=C $SORT > $OTHER_FILE.cleaned124TMP=$(LC_ALL=C $DIFF $OTHER_FILE.cleaned $THIS_FILE)125fi126if test -n "$TMP"; then127echo Files $OTHER_FILE and $THIS_FILE differ128return 1129fi130131return 0132}133134##########################################################################################135# Compare directory structure136137compare_dirs() {138THIS_DIR=$1139OTHER_DIR=$2140WORK_DIR=$3141142mkdir -p $WORK_DIR143144(cd $OTHER_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_other)145(cd $THIS_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_this)146147$DIFF $WORK_DIR/dirs_other $WORK_DIR/dirs_other > $WORK_DIR/dirs_diff148149echo -n Directory structure...150if [ -s $WORK_DIR/dirs_diff ]; then151echo Differences found.152REGRESSIONS=true153# Differences in directories found.154ONLY_OTHER=$($GREP '<' $WORK_DIR/dirs_diff)155if [ "$ONLY_OTHER" ]; then156echo Only in $OTHER157$GREP '<' $WORK_DIR/dirs_diff | $SED 's|< ./| |g'158fi159ONLY_THIS=$($GREP '>' $WORK_DIR/dirs_diff)160if [ "$ONLY_THIS" ]; then161echo Only in $THIS162$GREP '>' $WORK_DIR/dirs_diff | $SED 's|> ./| |g'163fi164else165echo Identical!166fi167}168169170##########################################################################################171# Compare file structure172173compare_files() {174THIS_DIR=$1175OTHER_DIR=$2176WORK_DIR=$3177178$MKDIR -p $WORK_DIR179180(cd $OTHER_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_other)181(cd $THIS_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_this)182183$DIFF $WORK_DIR/files_other $WORK_DIR/files_this > $WORK_DIR/files_diff184185echo -n File names...186if [ -s $WORK_DIR/files_diff ]; then187echo Differences found.188REGRESSIONS=true189# Differences in files found.190ONLY_OTHER=$($GREP '<' $WORK_DIR/files_diff)191if [ "$ONLY_OTHER" ]; then192echo Only in $OTHER193$GREP '<' $WORK_DIR/files_diff | $SED 's|< ./| |g'194fi195ONLY_THIS=$($GREP '>' $WORK_DIR/files_diff)196if [ "$ONLY_THIS" ]; then197echo Only in $THIS198$GREP '>' $WORK_DIR/files_diff | $SED 's|> ./| |g'199fi200else201echo Identical!202fi203}204205206##########################################################################################207# Compare permissions208209compare_permissions() {210THIS_DIR=$1211OTHER_DIR=$2212WORK_DIR=$3213214mkdir -p $WORK_DIR215216echo -n Permissions...217found=""218for f in `cd $OTHER_DIR && $FIND . -type f`219do220if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi221if [ ! -f ${THIS_DIR}/$f ]; then continue; fi222OP=`ls -l ${OTHER_DIR}/$f | awk '{printf("%.10s\n", $1);}'`223TP=`ls -l ${THIS_DIR}/$f | awk '{printf("%.10s\n", $1);}'`224if [ "$OP" != "$TP" ]225then226if [ -z "$found" ]; then echo ; found="yes"; fi227$PRINTF "\told: ${OP} new: ${TP}\t$f\n"228fi229done230if [ -z "$found" ]; then231echo "Identical!"232else233REGRESSIONS=true234fi235}236237##########################################################################################238# Compare file command output239240compare_file_types() {241THIS_DIR=$1242OTHER_DIR=$2243WORK_DIR=$3244245$MKDIR -p $WORK_DIR246247echo -n File types...248found=""249for f in `cd $OTHER_DIR && $FIND . ! -type d`250do251if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi252if [ ! -f ${THIS_DIR}/$f ]; then continue; fi253OF=`cd ${OTHER_DIR} && $FILE -h $f`254TF=`cd ${THIS_DIR} && $FILE -h $f`255if [ "$f" = "./src.zip" ] || [[ "$f" = *"/Home/src.zip" ]] || [[ "$f" = *"/lib/JObjC.jar" ]]256then257if [ "`echo $OF | $GREP -ic zip`" -gt 0 -a "`echo $TF | $GREP -ic zip`" -gt 0 ]258then259# the way we produces zip-files make it so that directories are stored in old file260# but not in new (only files with full-path)261# this makes file-5.09 report them as different262continue;263fi264fi265266if [ "$OF" != "$TF" ]267then268if [ -z "$found" ]; then echo ; found="yes"; fi269$PRINTF "\tother: ${OF}\n\tthis : ${TF}\n"270fi271done272if [ -z "$found" ]; then273echo "Identical!"274else275REGRESSIONS=true276fi277}278279##########################################################################################280# Compare the rest of the files281282compare_general_files() {283THIS_DIR=$1284OTHER_DIR=$2285WORK_DIR=$3286287GENERAL_FILES=$(cd $THIS_DIR && $FIND . -type f ! -name "*.so" ! -name "*.jar" ! -name "*.zip" \288! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \289! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \290! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \291! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" \292| $GREP -v "./bin/" | $SORT | $FILTER)293294echo General files...295for f in $GENERAL_FILES296do297if [ -e $OTHER_DIR/$f ]; then298SUFFIX="${f##*.}"299if [ "$(basename $f)" = "release" ]; then300# Ignore differences in change numbers in release file.301OTHER_FILE=$WORK_DIR/$f.other302THIS_FILE=$WORK_DIR/$f.this303$MKDIR -p $(dirname $OTHER_FILE)304$MKDIR -p $(dirname $THIS_FILE)305$CAT $OTHER_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $OTHER_FILE306$CAT $THIS_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $THIS_FILE307elif [ "x$SUFFIX" = "xhtml" ]; then308# Ignore time stamps in docs files309OTHER_FILE=$WORK_DIR/$f.other310THIS_FILE=$WORK_DIR/$f.this311$MKDIR -p $(dirname $OTHER_FILE)312$MKDIR -p $(dirname $THIS_FILE)313#Note that | doesn't work on mac sed.314$CAT $OTHER_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \315-e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \316-e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/(removed)/' \317-e 's/[A-Z][a-z]* [A-Z][a-z]* [0-9][0-9] [0-9][0-9:]* [A-Z][A-Z]* [12][0-9]*/(removed)/' \318-e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \319> $OTHER_FILE320$CAT $THIS_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \321-e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \322-e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/(removed)/' \323-e 's/[A-Z][a-z]* [A-Z][a-z]* [0-9][0-9] [0-9][0-9:]* [A-Z][A-Z]* [12][0-9]*/(removed)/' \324-e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \325> $THIS_FILE326else327OTHER_FILE=$OTHER_DIR/$f328THIS_FILE=$THIS_DIR/$f329fi330DIFF_OUT=$($DIFF $OTHER_FILE $THIS_FILE 2>&1)331if [ -n "$DIFF_OUT" ]; then332echo $f333REGRESSIONS=true334if [ "$SHOW_DIFFS" = "true" ]; then335echo "$DIFF_OUT"336fi337fi338fi339done340341342}343344##########################################################################################345# Compare zip file346347compare_zip_file() {348THIS_DIR=$1349OTHER_DIR=$2350WORK_DIR=$3351ZIP_FILE=$4352# Optionally provide different name for other zipfile353OTHER_ZIP_FILE=$5354355THIS_ZIP=$THIS_DIR/$ZIP_FILE356if [ -n "$OTHER_ZIP_FILE" ]; then357OTHER_ZIP=$OTHER_DIR/$OTHER_ZIP_FILE358else359OTHER_ZIP=$OTHER_DIR/$ZIP_FILE360fi361362THIS_SUFFIX="${THIS_ZIP##*.}"363OTHER_SUFFIX="${OTHER_ZIP##*.}"364if [ "$THIS_SUFFIX" != "$OTHER_SUFFIX" ]; then365echo The files do not have the same suffix type!366return 2367fi368369TYPE="$THIS_SUFFIX"370371if $CMP $OTHER_ZIP $THIS_ZIP > /dev/null372then373return 0374fi375# Not quite identical, the might still contain the same data.376# Unpack the jar/zip files in temp dirs377378THIS_UNZIPDIR=$WORK_DIR/$ZIP_FILE.this379OTHER_UNZIPDIR=$WORK_DIR/$ZIP_FILE.other380$RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR381$MKDIR -p $THIS_UNZIPDIR382$MKDIR -p $OTHER_UNZIPDIR383(cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)384(cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)385386# Find all archives inside and unzip them as well to compare the contents rather than387# the archives. pie.jar.pack.gz i app3.war is corrupt, skip it.388EXCEPTIONS="pie.jar.pack.gz"389for pack in $($FIND $THIS_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do390($UNPACK200 $pack $pack.jar)391# Filter out the unzipped archives from the diff below.392EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"393done394for pack in $($FIND $OTHER_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do395($UNPACK200 $pack $pack.jar)396EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"397done398for zip in $($FIND $THIS_UNZIPDIR -name "*.jar" -o -name "*.zip"); do399$MKDIR $zip.unzip400(cd $zip.unzip && $UNARCHIVE $zip)401EXCEPTIONS="$EXCEPTIONS $zip"402done403for zip in $($FIND $OTHER_UNZIPDIR -name "*.jar" -o -name "*.zip"); do404$MKDIR $zip.unzip405(cd $zip.unzip && $UNARCHIVE $zip)406EXCEPTIONS="$EXCEPTIONS $zip"407done408409CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff410# On solaris, there is no -q option.411if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then412LC_ALL=C $DIFF -r $OTHER_UNZIPDIR $THIS_UNZIPDIR \413| $GREP -v -e "^<" -e "^>" -e "^Common subdirectories:" \414> $CONTENTS_DIFF_FILE415else416LC_ALL=C $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE417fi418419ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE)420ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE)421422return_value=0423424if [ -n "$ONLY_OTHER" ]; then425echo " Only OTHER $ZIP_FILE contains:"426echo "$ONLY_OTHER" | sed "s|Only in $OTHER_UNZIPDIR| |"g | sed 's|: |/|g'427return_value=1428fi429430if [ -n "$ONLY_THIS" ]; then431echo " Only THIS $ZIP_FILE contains:"432echo "$ONLY_THIS" | sed "s|Only in $THIS_UNZIPDIR| |"g | sed 's|: |/|g'433return_value=1434fi435436if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then437DIFFING_FILES=$($GREP -e "differ$" -e "^diff " $CONTENTS_DIFF_FILE \438| $CUT -f 3 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")439else440DIFFING_FILES=$($GREP -e "differ$" $CONTENTS_DIFF_FILE \441| $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")442fi443444$RM -f $WORK_DIR/$ZIP_FILE.diffs445for file in $DIFFING_FILES; do446if [[ "$ACCEPTED_JARZIP_CONTENTS $EXCEPTIONS" != *"$file"* ]]; then447diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs448fi449done450451if [ -s "$WORK_DIR/$ZIP_FILE.diffs" ]; then452return_value=1453echo " Differing files in $ZIP_FILE"454$CAT $WORK_DIR/$ZIP_FILE.diffs | $GREP differ | cut -f 2 -d ' ' | \455$SED "s|$OTHER_UNZIPDIR| |g" > $WORK_DIR/$ZIP_FILE.difflist456$CAT $WORK_DIR/$ZIP_FILE.difflist457458if [ -n "$SHOW_DIFFS" ]; then459for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do460if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then461LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap462elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then463LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i464else465LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i466fi467done468fi469fi470471return $return_value472}473474475##########################################################################################476# Compare all zip files477478compare_all_zip_files() {479THIS_DIR=$1480OTHER_DIR=$2481WORK_DIR=$3482483ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER )484485if [ -n "$ZIPS" ]; then486echo Zip files...487488return_value=0489for f in $ZIPS; do490if [ -f "$OTHER_DIR/$f" ]; then491compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f492if [ "$?" != "0" ]; then493return_value=1494REGRESSIONS=true495fi496fi497done498fi499500return $return_value501}502503##########################################################################################504# Compare all jar files505506compare_all_jar_files() {507THIS_DIR=$1508OTHER_DIR=$2509WORK_DIR=$3510511# TODO filter?512ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" -o -name "*.war" | $SORT | $FILTER)513514if [ -n "$ZIPS" ]; then515echo Jar files...516517return_value=0518for f in $ZIPS; do519if [ -f "$OTHER_DIR/$f" ]; then520compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f521if [ "$?" != "0" ]; then522return_value=1523REGRESSIONS=true524fi525fi526done527fi528529return $return_value530}531532##########################################################################################533# Compare binary (executable/library) file534535compare_bin_file() {536THIS_DIR=$1537OTHER_DIR=$2538WORK_DIR=$3539BIN_FILE=$4540541THIS_FILE=$THIS_DIR/$BIN_FILE542OTHER_FILE=$OTHER_DIR/$BIN_FILE543NAME=$(basename $BIN_FILE)544WORK_FILE_BASE=$WORK_DIR/$BIN_FILE545FILE_WORK_DIR=$(dirname $WORK_FILE_BASE)546547$MKDIR -p $FILE_WORK_DIR548549ORIG_THIS_FILE="$THIS_FILE"550ORIG_OTHER_FILE="$OTHER_FILE"551552if [[ "$STRIP_BEFORE_COMPARE" = *"$BIN_FILE"* ]]; then553THIS_STRIPPED_FILE=$FILE_WORK_DIR/this/$NAME554OTHER_STRIPPED_FILE=$FILE_WORK_DIR/other/$NAME555$MKDIR -p $FILE_WORK_DIR/this $FILE_WORK_DIR/other556$CP $THIS_FILE $THIS_STRIPPED_FILE557$CP $OTHER_FILE $OTHER_STRIPPED_FILE558$STRIP $THIS_STRIPPED_FILE559$STRIP $OTHER_STRIPPED_FILE560THIS_FILE="$THIS_STRIPPED_FILE"561OTHER_FILE="$OTHER_STRIPPED_FILE"562fi563564if [ "$OPENJDK_TARGET_OS" = "windows" ]; then565unset _NT_SYMBOL_PATH566# On windows we need to unzip the debug symbols, if present567OTHER_FILE_BASE=${OTHER_FILE/.dll/}568OTHER_FILE_BASE=${OTHER_FILE_BASE/.exe/}569DIZ_NAME=$(basename $OTHER_FILE_BASE).diz570# java.exe and java.dll diz files will have the same name. Have to571# make sure java.exe gets the right one. This is only needed for572# OTHER since in the new build, all pdb files are left around.573if [ "$NAME" = "java.exe" ] && [ -f "$OTHER/tmp/java/java/obj64/java.diz" ]; then574OTHER_DIZ_FILE="$OTHER/tmp/java/java/obj64/java.diz"575elif [ -f "${OTHER_FILE_BASE}.diz" ]; then576OTHER_DIZ_FILE=${OTHER_FILE_BASE}.diz577else578# Some files, jli.dll, appears twice in the image but only one of579# thme has a diz file next to it.580OTHER_DIZ_FILE="$($FIND $OTHER_DIR -name $DIZ_NAME | $SED 1q)"581if [ ! -f "$OTHER_DIZ_FILE" ]; then582# As a last resort, look for diz file in the whole build output583# dir.584OTHER_DIZ_FILE="$($FIND $OTHER -name $DIZ_NAME | $SED 1q)"585fi586fi587if [ -n "$OTHER_DIZ_FILE" ]; then588$MKDIR -p $FILE_WORK_DIR/other589(cd $FILE_WORK_DIR/other ; $UNARCHIVE -o $OTHER_DIZ_FILE)590export _NT_SYMBOL_PATH="$FILE_WORK_DIR/other"591fi592THIS_FILE_BASE=${THIS_FILE/.dll/}593THIS_FILE_BASE=${THIS_FILE_BASE/.exe/}594if [ -f "${THIS_FILE/.dll/}.diz" ]; then595THIS_DIZ_FILE=${THIS_FILE/.dll/}.diz596else597THIS_DIZ_FILE="$($FIND $THIS_DIR -name $DIZ_NAME | $SED 1q)"598if [ ! -f "$THIS_DIZ_FILE" ]; then599# As a last resort, look for diz file in the whole build output600# dir.601THIS_DIZ_FILE="$($FIND $THIS -name $DIZ_NAME | $SED 1q)"602fi603fi604if [ -n "$THIS_DIZ_FILE" ]; then605$MKDIR -p $FILE_WORK_DIR/this606(cd $FILE_WORK_DIR/this ; $UNARCHIVE -o $THIS_DIZ_FILE)607export _NT_SYMBOL_PATH="$_NT_SYMBOL_PATH;$FILE_WORK_DIR/this"608fi609fi610611if [ -z "$SKIP_BIN_DIFF" ]; then612if cmp $OTHER_FILE $THIS_FILE > /dev/null; then613# The files were bytewise identical.614if [ -n "$VERBOSE" ]; then615echo " : : : : : $BIN_FILE"616fi617return 0618fi619BIN_MSG=" diff "620if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then621DIFF_BIN=true622if [[ "$KNOWN_BIN_DIFF" != *"$BIN_FILE"* ]]; then623BIN_MSG="*$BIN_MSG*"624REGRESSIONS=true625else626BIN_MSG=" $BIN_MSG "627fi628else629BIN_MSG="($BIN_MSG)"630DIFF_BIN=631fi632fi633634if [ -n "$STAT" ]; then635THIS_SIZE=$($STAT $STAT_PRINT_SIZE "$THIS_FILE")636OTHER_SIZE=$($STAT $STAT_PRINT_SIZE "$OTHER_FILE")637else638THIS_SIZE=$(ls -l "$THIS_FILE" | awk '{ print $5 }')639OTHER_SIZE=$(ls -l "$OTHER_FILE" | awk '{ print $5 }')640fi641if [ $THIS_SIZE -ne $OTHER_SIZE ]; then642DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE)643DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE)644SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM)645if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \646&& [ "$DIFF_SIZE_REL" -lt 102 ]; then647SIZE_MSG="($SIZE_MSG)"648DIFF_SIZE=649elif [ "$OPENJDK_TARGET_OS" = "windows" ] \650&& [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \651&& [ "$DIFF_SIZE_NUM" = 512 ]; then652# On windows, size of binaries increase in 512 increments.653SIZE_MSG="($SIZE_MSG)"654DIFF_SIZE=655elif [ "$OPENJDK_TARGET_OS" = "windows" ] \656&& [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \657&& [ "$DIFF_SIZE_NUM" = -512 ]; then658# On windows, size of binaries increase in 512 increments.659SIZE_MSG="($SIZE_MSG)"660DIFF_SIZE=661else662if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then663DIFF_SIZE=true664if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then665SIZE_MSG="*$SIZE_MSG*"666REGRESSIONS=true667else668SIZE_MSG=" $SIZE_MSG "669fi670else671SIZE_MSG="($SIZE_MSG)"672DIFF_SIZE=673fi674fi675else676SIZE_MSG=" "677DIFF_SIZE=678if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then679SIZE_MSG=" ! "680fi681fi682683if [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then684SYM_SORT_CMD="sort"685else686SYM_SORT_CMD="cat"687fi688689# Check symbols690if [ "$OPENJDK_TARGET_OS" = "windows" ]; then691# The output from dumpbin on windows differs depending on if the debug symbol692# files are still around at the location the binary is pointing too. Need693# to filter out that extra information.694$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.other695$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.this696elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then697# Some symbols get seemingly random 15 character prefixes. Filter them out.698$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.other699$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.this700else701$NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other702$NM -a $ORIG_THIS_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this703fi704705LC_ALL=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff706if [ -s $WORK_FILE_BASE.symbols.diff ]; then707SYM_MSG=" diff "708if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then709DIFF_SYM=true710if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then711SYM_MSG="*$SYM_MSG*"712REGRESSIONS=true713else714SYM_MSG=" $SYM_MSG "715fi716else717SYM_MSG="($SYM_MSG)"718DIFF_SYM=719fi720else721SYM_MSG=" "722DIFF_SYM=723if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then724SYM_MSG=" ! "725fi726fi727728# Check dependencies729if [ -n "$LDD_CMD" ]; then730(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)731(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)732(cd $FILE_WORK_DIR && $RM -f $NAME)733734LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this > $WORK_FILE_BASE.deps.diff735LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq > $WORK_FILE_BASE.deps.diff.uniq736737if [ -s $WORK_FILE_BASE.deps.diff ]; then738if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then739DEP_MSG=" diff "740else741DEP_MSG=" redun "742fi743if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then744DIFF_DEP=true745if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then746DEP_MSG="*$DEP_MSG*"747REGRESSIONS=true748else749DEP_MSG=" $DEP_MSG "750fi751else752DEP_MSG="($DEP_MSG)"753DIFF_DEP=754fi755else756DEP_MSG=" "757DIFF_DEP=758if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then759DEP_MSG=" ! "760fi761fi762else763DEP_MSG=" - "764fi765766# Compare fulldump output767if [ -n "$FULLDUMP_CMD" ] && [ -z "$SKIP_FULLDUMP_DIFF" ]; then768$FULLDUMP_CMD $OTHER_FILE > $WORK_FILE_BASE.fulldump.other 2>&1769$FULLDUMP_CMD $THIS_FILE > $WORK_FILE_BASE.fulldump.this 2>&1770LC_ALL=C $DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this > $WORK_FILE_BASE.fulldump.diff771772if [ -s $WORK_FILE_BASE.fulldump.diff ]; then773ELF_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.fulldump.diff | awk '{print $5}')774ELF_MSG=$($PRINTF "%8d" $ELF_DIFF_SIZE)775if [[ "$ACCEPTED_ELF_DIFF" != *"$BIN_FILE"* ]]; then776DIFF_ELF=true777if [[ "$KNOWN_ELF_DIFF" != *"$BIN_FILE"* ]]; then778ELF_MSG="*$ELF_MSG*"779REGRESSIONS=true780else781ELF_MSG=" $ELF_MSG "782fi783else784ELF_MSG="($ELF_MSG)"785DIFF_ELF=786fi787else788ELF_MSG=" "789DIFF_ELF=790if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then791ELF_MSG=" ! "792fi793fi794fi795796# Compare disassemble output797if [ -n "$DIS_CMD" ] && [ -z "$SKIP_DIS_DIFF" ]; then798if [ -z "$DIS_DIFF_FILTER" ]; then799DIS_DIFF_FILTER="$CAT"800fi801$DIS_CMD $OTHER_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.other 2>&1802$DIS_CMD $THIS_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.this 2>&1803804LC_ALL=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff805806if [ -s $WORK_FILE_BASE.dis.diff ]; then807DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}')808DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE)809if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then810DIFF_DIS=true811if [[ "$KNOWN_DIS_DIFF" != *"$BIN_FILE"* ]]; then812DIS_MSG="*$DIS_MSG*"813REGRESSIONS=true814else815DIS_MSG=" $DIS_MSG "816fi817else818DIS_MSG="($DIS_MSG)"819DIFF_DIS=820fi821else822DIS_MSG=" "823DIFF_DIS=824if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then825DIS_MSG=" ! "826fi827fi828fi829830831if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_ELF$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then832if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi833if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi834if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi835if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi836if [ -n "$ELF_MSG" ]; then echo -n "$ELF_MSG:"; fi837if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi838echo " $BIN_FILE"839if [ "$SHOW_DIFFS" = "true" ]; then840if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then841echo "Symbols diff:"842$CAT $WORK_FILE_BASE.symbols.diff843fi844if [ -s "$WORK_FILE_BASE.deps.diff" ]; then845echo "Deps diff:"846$CAT $WORK_FILE_BASE.deps.diff847fi848if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then849echo "Fulldump diff:"850$CAT $WORK_FILE_BASE.fulldump.diff851fi852if [ -s "$WORK_FILE_BASE.dis.diff" ]; then853echo "Disassembly diff:"854$CAT $WORK_FILE_BASE.dis.diff855fi856fi857return 1858fi859return 0860}861862##########################################################################################863# Print binary diff header864865print_binary_diff_header() {866if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi867if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n " Size :"; fi868if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi869if [ -z "$SKIP_DEP_DIFF" ]; then echo -n " Deps :"; fi870if [ -z "$SKIP_FULLDUMP_DIFF" ]; then echo -n " Fulldump :"; fi871if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass :"; fi872echo873}874875##########################################################################################876# Compare all libraries877878compare_all_libs() {879THIS_DIR=$1880OTHER_DIR=$2881WORK_DIR=$3882883LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' -o -name 'JavaControlPanel' \) | $SORT | $FILTER)884885if [ -n "$LIBS" ]; then886echo Libraries...887print_binary_diff_header888for l in $LIBS; do889if [ -f "$OTHER_DIR/$l" ]; then890compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l891if [ "$?" != "0" ]; then892return_value=1893fi894fi895done896fi897898return $return_value899}900901##########################################################################################902# Compare all executables903904compare_all_execs() {905THIS_DIR=$1906OTHER_DIR=$2907WORK_DIR=$3908909if [ "$OPENJDK_TARGET_OS" = "windows" ]; then910EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER)911else912EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \913\( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \914-o -name '*.jar' -o -name '*.diz' -o -name 'jcontrol' -o -name '*.properties' \915-o -name '*.data' -o -name '*.bfc' -o -name '*.src' -o -name '*.txt' \916-o -name '*.cfg' -o -name 'meta-index' -o -name '*.properties.ja' \917-o -name 'classlist' \) | $SORT | $FILTER)918fi919920if [ -n "$EXECS" ]; then921echo Executables...922print_binary_diff_header923for e in $EXECS; do924if [ -f "$OTHER_DIR/$e" ]; then925compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e926if [ "$?" != "0" ]; then927return_value=1928fi929fi930done931fi932933return $return_value934}935936##########################################################################################937# Initiate configuration938939COMPARE_ROOT=/tmp/cimages.$USER940$MKDIR -p $COMPARE_ROOT941if [ "$OPENJDK_TARGET_OS" = "windows" ]; then942if [ "$(uname -o)" = "Cygwin" ]; then943COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT)944fi945fi946947THIS="$( cd "$( dirname "$0" )" && pwd )"948echo "$THIS"949THIS_SCRIPT="$0"950951if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then952echo "bash ./compare.sh [OPTIONS] [FILTER]"953echo ""954echo "-all Compare all files in all known ways"955echo "-names Compare the file names and directory structure"956echo "-perms Compare the permission bits on all files and directories"957echo "-types Compare the output of the file command on all files"958echo "-general Compare the files not convered by the specialized comparisons"959echo "-zips Compare the contents of all zip files"960echo "-jars Compare the contents of all jar files"961echo "-libs Compare all native libraries"962echo "-execs Compare all executables"963echo "-v Verbose output, does not hide known differences"964echo "-vv More verbose output, shows diff output of all comparisons"965echo "-o [OTHER] Compare with build in other directory. Will default to the old build directory"966echo ""967echo "[FILTER] List filenames in the image to compare, works for jars, zips, libs and execs"968echo "Example:"969echo "bash ./common/bin/compareimages.sh CodePointIM.jar"970echo ""971echo "-2zips <file1> <file2> Compare two zip files only"972echo ""973exit 10974fi975976CMP_NAMES=false977CMP_PERMS=false978CMP_TYPES=false979CMP_GENERAL=false980CMP_ZIPS=false981CMP_JARS=false982CMP_LIBS=false983CMP_EXECS=false984985while [ -n "$1" ]; do986case "$1" in987-v)988VERBOSE=true989;;990-vv)991VERBOSE=true992SHOW_DIFFS=true993;;994-o)995OTHER="$2"996shift997;;998-all)999CMP_NAMES=true1000if [ "$OPENJDK_TARGET_OS" != "windows" ]; then1001CMP_PERMS=true1002fi1003CMP_TYPES=true1004CMP_GENERAL=true1005CMP_ZIPS=true1006CMP_JARS=true1007CMP_LIBS=true1008CMP_EXECS=true1009;;1010-names)1011CMP_NAMES=true1012;;1013-perms)1014CMP_PERMS=true1015;;1016-types)1017CMP_TYPES=true1018;;1019-general)1020CMP_GENERAL=true1021;;1022-zips)1023CMP_ZIPS=true1024;;1025-jars)1026CMP_JARS=true1027;;1028-libs)1029CMP_LIBS=true1030;;1031-execs)1032CMP_EXECS=true1033;;1034-2zips)1035CMP_2_ZIPS=true1036THIS_FILE=$21037OTHER_FILE=$31038shift1039shift1040;;1041*)1042CMP_NAMES=false1043CMP_PERMS=false1044CMP_TYPES=false1045CMP_ZIPS=true1046CMP_JARS=true1047CMP_LIBS=true1048CMP_EXECS=true10491050if [ -z "$FILTER" ]; then1051FILTER="$GREP"1052fi1053FILTER="$FILTER -e $1"1054;;1055esac1056shift1057done10581059if [ "$CMP_2_ZIPS" = "true" ]; then1060THIS_DIR="$(dirname $THIS_FILE)"1061THIS_DIR="$(cd "$THIS_DIR" && pwd )"1062OTHER_DIR="$(dirname $OTHER_FILE)"1063OTHER_DIR="$(cd "$OTHER_DIR" && pwd )"1064THIS_FILE_NAME="$(basename $THIS_FILE)"1065OTHER_FILE_NAME="$(basename $OTHER_FILE)"1066echo Comparing $THIS_DIR/$THIS_FILE_NAME and $OTHER_DIR/$OTHER_FILE_NAME1067compare_zip_file $THIS_DIR $OTHER_DIR $COMPARE_ROOT/2zips $THIS_FILE_NAME $OTHER_FILE_NAME1068exit1069fi10701071if [ "$CMP_NAMES" = "false" ] && [ "$CMP_TYPES" = "false" ] && [ "$CMP_PERMS" = "false" ] && [ "$CMP_GENERAL" = "false" ] && [ "$CMP_ZIPS" = "false" ] && [ "$CMP_JARS" = "false" ] && [ "$CMP_LIBS" = "false" ] && [ "$CMP_EXECS" = "false" ]; then1072CMP_NAMES=true1073CMP_PERMS=true1074CMP_TYPES=true1075CMP_GENERAL=true1076CMP_ZIPS=true1077CMP_JARS=true1078CMP_LIBS=true1079CMP_EXECS=true1080fi10811082if [ -z "$FILTER" ]; then1083FILTER="$CAT"1084fi10851086if [ -z "$OTHER" ]; then1087OTHER="$THIS/../$LEGACY_BUILD_DIR"1088if [ -d "$OTHER" ]; then1089OTHER="$( cd "$OTHER" && pwd )"1090else1091echo "Default old build directory does not exist:"1092echo "$OTHER"1093exit 11094fi1095echo "Comparing to default old build:"1096echo "$OTHER"1097echo1098else1099if [ ! -d "$OTHER" ]; then1100echo "Other build directory does not exist:"1101echo "$OTHER"1102exit 11103fi1104OTHER="$( cd "$OTHER" && pwd )"1105echo "Comparing to:"1106echo "$OTHER"1107echo1108fi110911101111# Figure out the layout of the this build. Which kinds of images have been produced1112if [ -d "$THIS/install/j2sdk-image" ]; then1113THIS_J2SDK="$THIS/install/j2sdk-image"1114THIS_J2RE="$THIS/install/j2re-image"1115echo "Selecting install images in this build"1116elif [ -d "$THIS/deploy/j2sdk-image" ]; then1117THIS_J2SDK="$THIS/deploy/j2sdk-image"1118THIS_J2RE="$THIS/deploy/j2re-image"1119echo "Selecting deploy images in this build"1120elif [ -d "$THIS/images/j2sdk-image" ]; then1121THIS_J2SDK="$THIS/images/j2sdk-image"1122THIS_J2RE="$THIS/images/j2re-image"1123echo "Selecting jdk images in this build"1124fi11251126if [ -d "$THIS/images/j2sdk-overlay-image" ]; then1127if [ -d "$THIS/install/j2sdk-image" ]; then1128# If there is an install image, prefer that, it's also overlay1129THIS_J2SDK_OVERLAY="$THIS/install/j2sdk-image"1130THIS_J2RE_OVERLAY="$THIS/install/j2re-image"1131echo "Selecting install overlay images in this build"1132else1133THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image"1134THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image"1135echo "Selecting jdk overlay images in this build"1136fi1137fi11381139if [ -d "$THIS/images/j2sdk-bundle" ]; then1140THIS_J2SDK_BUNDLE="$THIS/images/j2sdk-bundle"1141THIS_J2RE_BUNDLE="$THIS/images/j2re-bundle"1142echo "Selecting bundles in this build"1143fi11441145# Figure out the layout of the other build (old or new, normal or overlay image)1146if [ -d "$OTHER/j2sdk-image" ]; then1147if [ -f "$OTHER/j2sdk-image/LICENSE" ]; then1148OTHER_J2SDK="$OTHER/j2sdk-image"1149OTHER_J2RE="$OTHER/j2re-image"1150echo "Selecting old-style images in other build"1151else1152OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image"1153OTHER_J2RE_OVERLAY="$OTHER/j2re-image"1154echo "Selecting overlay images in other build"1155fi1156elif [ -d "$OTHER/install/j2sdk-image" ]; then1157OTHER_J2SDK="$OTHER/install/j2sdk-image"1158OTHER_J2RE="$OTHER/install/j2re-image"1159echo "Selecting install images in other build"1160elif [ -d "$OTHER/deploy/j2sdk-image" ]; then1161OTHER_J2SDK="$OTHER/deploy/j2sdk-image"1162OTHER_J2RE="$OTHER/deploy/j2re-image"1163echo "Selecting deploy images in other build"1164elif [ -d "$OTHER/images/j2sdk-image" ]; then1165OTHER_J2SDK="$OTHER/images/j2sdk-image"1166OTHER_J2RE="$OTHER/images/j2re-image"1167echo "Selecting jdk images in other build"1168fi11691170if [ -d "$OTHER/j2sdk-bundle" ]; then1171OTHER_J2SDK_BUNDLE="$OTHER/j2sdk-bundle"1172OTHER_J2RE_BUNDLE="$OTHER/j2re-bundle"1173echo "Selecting bundles in other build"1174elif [ -d "$OTHER/images/j2sdk-bundle" ]; then1175OTHER_J2SDK_BUNDLE="$OTHER/images/j2sdk-bundle"1176OTHER_J2RE_BUNDLE="$OTHER/images/j2re-bundle"1177echo "Selecting jdk bundles in other build"1178fi11791180if [ -z "$THIS_J2SDK" ] || [ -z "$THIS_J2RE" ]; then1181if [ -z "$THIS_J2SDK_OVERLAY" ]; then1182echo "Cannot locate images for this build. Are you sure you have run 'make images'?"1183exit 11184fi1185fi11861187if [ -z "$OTHER_J2SDK" ] && [ -n "$OTHER_J2SDK_OVERLAY" ] && [ -z "$THIS_J2SDK_OVERLAY" ]; then1188echo "OTHER build only has an overlay image while this build does not. Nothing to compare!"1189exit 11190fi11911192if [ -z "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then1193echo "WARNING! OTHER build has bundles built while this build does not."1194echo "Skipping bundle compare!"1195fi11961197if [ -d "$THIS/docs" ]; then1198THIS_DOCS="$THIS/docs"1199fi12001201if [ -d "$OTHER/docs" ]; then1202OTHER_DOCS="$OTHER/docs"1203fi12041205if [ -z "$THIS_DOCS" ]; then1206echo "WARNING! Docs haven't been built and won't be compared."1207fi12081209if [ -z "$OTHER_DOCS" ]; then1210echo "WARNING! Other build doesn't contain docs, skipping doc compare."1211fi12121213if [ -d "$OTHER/images" ]; then1214OTHER_SEC_DIR="$OTHER/images"1215else1216OTHER_SEC_DIR="$OTHER/tmp"1217fi1218OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip"1219THIS_SEC_DIR="$THIS/images"1220THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip"1221if [ "$OPENJDK_TARGET_OS" = "windows" ]; then1222if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then1223JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip"1224else1225JGSS_WINDOWS_BIN="jgss-windows-i586-bin.zip"1226fi1227OTHER_SEC_WINDOWS_BIN="$OTHER_SEC_DIR/sec-windows-bin.zip"1228OTHER_JGSS_WINDOWS_BIN="$OTHER_SEC_DIR/$JGSS_WINDOWS_BIN"1229THIS_SEC_WINDOWS_BIN="$THIS_SEC_DIR/sec-windows-bin.zip"1230THIS_JGSS_WINDOWS_BIN="$THIS_SEC_DIR/$JGSS_WINDOWS_BIN"1231fi12321233##########################################################################################1234# Do the work12351236if [ "$CMP_NAMES" = "true" ]; then1237if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then1238echo -n "J2SDK "1239compare_dirs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk1240echo -n "J2RE "1241compare_dirs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re12421243echo -n "J2SDK "1244compare_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk1245echo -n "J2RE "1246compare_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re1247fi1248if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then1249echo -n "J2SDK Overlay "1250compare_dirs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay1251echo -n "J2RE Overlay "1252compare_dirs $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay12531254echo -n "J2SDK Overlay "1255compare_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay1256echo -n "J2RE Overlay "1257compare_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay1258fi1259if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then1260echo -n "J2SDK Bundle "1261compare_dirs $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle1262echo -n "J2RE Bundle "1263compare_dirs $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle12641265echo -n "J2SDK Bundle "1266compare_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle1267echo -n "J2RE Bundle "1268compare_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle1269fi1270if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then1271echo -n "Docs "1272compare_dirs $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs1273echo -n "Docs "1274compare_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs1275fi1276fi12771278if [ "$CMP_PERMS" = "true" ]; then1279if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then1280echo -n "J2SDK "1281compare_permissions $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk1282echo -n "J2RE "1283compare_permissions $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re1284fi1285if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then1286echo -n "J2SDK Overlay "1287compare_permissions $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay1288echo -n "J2RE Overlay "1289compare_permissions $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay1290fi1291if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then1292echo -n "J2SDK Bundle "1293compare_permissions $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle1294echo -n "J2RE Bundle "1295compare_permissions $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle1296fi1297fi12981299if [ "$CMP_TYPES" = "true" ]; then1300if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then1301echo -n "J2SDK "1302compare_file_types $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk1303echo -n "J2RE "1304compare_file_types $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re1305fi1306if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then1307echo -n "J2SDK Overlay "1308compare_file_types $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay1309echo -n "J2RE Overlay "1310compare_file_types $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay1311fi1312if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then1313echo -n "J2SDK Bundle "1314compare_file_types $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle1315echo -n "J2RE Bundle "1316compare_file_types $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle1317fi1318fi13191320if [ "$CMP_GENERAL" = "true" ]; then1321if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then1322echo -n "J2SDK "1323compare_general_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk1324echo -n "J2RE "1325compare_general_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re1326fi1327if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then1328echo -n "J2SDK Overlay "1329compare_general_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay1330echo -n "J2RE Overlay "1331compare_general_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay1332fi1333if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then1334echo -n "J2SDK Bundle "1335compare_general_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle1336echo -n "J2RE Bundle "1337compare_general_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle1338fi1339if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then1340echo -n "Docs "1341compare_general_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs1342fi1343fi13441345if [ "$CMP_ZIPS" = "true" ]; then1346if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then1347compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk1348fi1349if [ -n "$THIS_SEC_BIN" ] && [ -n "$OTHER_SEC_BIN" ]; then1350if [ -n "$(echo $THIS_SEC_BIN | $FILTER)" ]; then1351echo "sec-bin.zip..."1352compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-bin.zip1353fi1354fi1355if [ -n "$THIS_SEC_WINDOWS_BIN" ] && [ -n "$OTHER_SEC_WINDOWS_BIN" ]; then1356if [ -n "$(echo $THIS_SEC_WINDOWS_BIN | $FILTER)" ]; then1357echo "sec-windows-bin.zip..."1358compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-windows-bin.zip1359fi1360fi1361if [ -n "$THIS_JGSS_WINDOWS_BIN" ] && [ -n "$OTHER_JGSS_WINDOWS_BIN" ]; then1362if [ -n "$(echo $THIS_JGSS_WINDOWS_BIN | $FILTER)" ]; then1363echo "$JGSS_WINDOWS_BIN..."1364compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin $JGSS_WINDOWS_BIN1365fi1366fi1367fi13681369if [ "$CMP_JARS" = "true" ]; then1370if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then1371compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk1372fi1373fi13741375if [ "$CMP_LIBS" = "true" ]; then1376if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then1377echo -n "J2SDK "1378compare_all_libs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk1379if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then1380echo -n "J2RE "1381compare_all_libs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re1382fi1383fi1384if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then1385echo -n "Bundle "1386compare_all_libs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay1387fi1388fi13891390if [ "$CMP_EXECS" = "true" ]; then1391if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then1392compare_all_execs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk1393fi1394if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then1395echo -n "Overlay "1396compare_all_execs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay1397fi1398fi13991400echo14011402if [ -n "$REGRESSIONS" ]; then1403echo "REGRESSIONS FOUND!"1404echo1405exit 11406else1407echo "No regressions found"1408echo1409exit 01410fi141114121413