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