1 #!/bin/bash 2 # 3 # Copyright (c) 2012, 2018, 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 32 if [ -z "$TOPDIR" ]; then 33 echo "Error: You must run this script using build/[conf]/compare.sh" 34 exit 1 35 fi 36 37 if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then 38 FULLDUMP_CMD="$OTOOL -v -V -h -X -d" 39 LDD_CMD="$OTOOL -L" 40 DIS_CMD="$OTOOL -v -V -t" 41 STAT_PRINT_SIZE="-f %z" 42 elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then 43 FULLDUMP_CMD="$DUMPBIN -all" 44 LDD_CMD="$DUMPBIN -dependents" 45 DIS_CMD="$DUMPBIN -disasm:nobytes" 46 STAT_PRINT_SIZE="-c %s" 47 elif [ "$OPENJDK_TARGET_OS" = "aix" ]; then 48 FULLDUMP_CMD="dump -h -r -t -n -X64" 49 LDD_CMD="$LDD" 50 DIS_CMD="$OBJDUMP -d" 51 STAT_PRINT_SIZE="-c %s" 52 else 53 FULLDUMP_CMD="$READELF -a" 54 LDD_CMD="$LDD" 55 DIS_CMD="$OBJDUMP -d" 56 STAT_PRINT_SIZE="-c %s" 57 fi 58 59 COMPARE_EXCEPTIONS_INCLUDE="$TOPDIR/make/scripts/compare_exceptions.sh.incl" 60 if [ ! -e "$COMPARE_EXCEPTIONS_INCLUDE" ]; then 61 echo "Error: Cannot locate the exceptions file, it should have been here: $COMPARE_EXCEPTIONS_INCLUDE" 62 exit 1 63 fi 64 # Include exception definitions 65 . "$COMPARE_EXCEPTIONS_INCLUDE" 66 67 ################################################################################ 68 # 69 # Disassembly diff filters. These filters try to filter out ephemeral parts of the 70 # disassembly, such as hard-coded addresses, to be able to catch "actual" differences. 71 72 if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then 73 if [ "$OPENJDK_TARGET_CPU" = "sparcv9" ]; then 74 DIS_DIFF_FILTER="$SED \ 75 -e 's/^[0-9a-f]\{16\}/<ADDR>:/' \ 76 -e 's/^ *[0-9a-f]\{3,12\}:/ <ADDR>:/' \ 77 -e 's/: [0-9a-f][0-9a-f]\( [0-9a-f][0-9a-f]\)\{2,10\}/: <NUMS>/' \ 78 -e 's/\$[a-zA-Z0-9_\$]\{15\}\./<SYM>./' \ 79 -e 's/, [0-9a-fx\-]\{1,8\}/, <ADDR>/g' \ 80 -e 's/0x[0-9a-f]\{1,8\}/<HEX>/g' \ 81 -e 's/\! [0-9a-f]\{1,8\} /! <ADDR> /' \ 82 -e 's/call [0-9a-f]\{4,7\}/call <ADDR>/' \ 83 -e 's/%hi(0),/%hi(<HEX>),/' \ 84 " 85 elif [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then 86 # Random strings looking like this differ: <.XAKoKoPIac2W0OA. 87 DIS_DIFF_FILTER="$SED \ 88 -e 's/<\.[A-Za-z0-9]\{\15}\./<.SYM./' \ 89 " 90 fi 91 elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then 92 if [ "$OPENJDK_TARGET_CPU" = "x86" ]; then 93 DIS_DIFF_FILTER="$SED -r \ 94 -e 's/^ [0-9A-F]{16}: //' \ 95 -e 's/^ [0-9A-F]{8}: / <ADDR>: /' \ 96 -e 's/(offset \?\?)_C@_.*/\1<SYM>/' \ 97 -e 's/[@?][A-Za-z0-9_]{1,25}/<SYM>/' \ 98 -e 's/([-,+])[0-9A-F]{2,16}/\1<HEXSTR>/g' \ 99 -e 's/\[[0-9A-F]{4,16}h\]/[<HEXSTR>]/' \ 100 -e 's/: ([a-z]{2}[a-z ]{2}) [0-9A-F]{2,16}h?$/: \1 <HEXSTR>/' \ 101 -e 's/_20[0-9]{2}_[0-1][0-9]_[0-9]{2}/_<DATE>/' \ 102 " 103 elif [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then 104 DIS_DIFF_FILTER="$SED -r \ 105 -e 's/^ [0-9A-F]{16}: //' \ 106 -e 's/\[[0-9A-F]{4,16}h\]/[<HEXSTR>]/' \ 107 -e 's/([,+])[0-9A-F]{2,16}h/\1<HEXSTR>/' \ 108 -e 's/([a-z]{2}[a-z ]{2}) [0-9A-F]{4,16}$/\1 <HEXSTR>/' \ 109 -e 's/\[\?\?_C@_.*/[<SYM>]/' \ 110 " 111 fi 112 elif [ "$OPENJDK_TARGET_OS" = "macosx" ]; then 113 DIS_DIFF_FILTER="LANG=C $SED \ 114 -e 's/0x[0-9a-f]\{3,16\}/<HEXSTR>/g' -e 's/^[0-9a-f]\{12,20\}/<ADDR>/' \ 115 -e 's/-20[0-9][0-9]-[0-1][0-9]-[0-3][0-9]-[0-2][0-9]\{5\}/<DATE>/g' \ 116 -e 's/), built on .*/), <DATE>/' \ 117 " 118 fi 119 120 ################################################################################ 121 # Compare text files and ignore specific differences: 122 # 123 # * Timestamps in Java sources generated by idl2java 124 # * Sorting order and cleanup style in .properties files 125 126 diff_text() { 127 OTHER_FILE=$1 128 THIS_FILE=$2 129 130 SUFFIX="${THIS_FILE##*.}" 131 NAME="${THIS_FILE##*/}" 132 133 TMP=1 134 135 if [[ "$THIS_FILE" = *"META-INF/MANIFEST.MF" ]]; then 136 # Filter out date string, ant version and java version differences. 137 TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \ 138 $GREP '^[<>]' | \ 139 $SED -e '/[<>] Ant-Version: Apache Ant .*/d' \ 140 -e '/[<>] Created-By: .* (Oracle [Corpatin)]*/d' \ 141 -e '/[<>] [Corpatin]*)/d' \ 142 -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d') 143 fi 144 if test "x$SUFFIX" = "xjava"; then 145 TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \ 146 $GREP '^[<>]' | \ 147 $SED -e '/[<>] \* from.*\.idl/d' \ 148 -e '/[<>] .*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \ 149 -e '/[<>] .*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d' \ 150 -e '/[<>] \*.*[0-9]\{4\} \(at \)*[0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \ 151 -e '/\/\/ Generated from input file.*/d' \ 152 -e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \ 153 -e '/\/\/ java GenerateCharacter.*/d') 154 fi 155 # Ignore date strings in class files. 156 # Anonymous lambda classes get randomly assigned counters in their names. 157 if test "x$SUFFIX" = "xclass"; then 158 if [ "$NAME" = "SystemModules\$all.class" ] \ 159 || [ "$NAME" = "SystemModules\$default.class" ]; then 160 # The SystemModules\$*.classes are not comparable as they contain the 161 # module hashes which would require a whole other level of 162 # reproducible builds to get reproducible. There is also random 163 # order of map initialization. 164 TMP="" 165 elif [ "$NAME" = "module-info.class" ]; then 166 # The module-info.class have several issues with random ordering of 167 # elements in HashSets. 168 MODULES_CLASS_FILTER="$SED \ 169 -e 's/,$//' \ 170 -e 's/;$//' \ 171 -e 's/^ *[0-9]*://' \ 172 -e 's/#[0-9]* */#/' \ 173 -e 's/ *\/\// \/\//' \ 174 -e 's/aload *[0-9]*/aload X/' \ 175 -e 's/ldc_w/ldc /' \ 176 | $SORT \ 177 " 178 $JAVAP -c -constants -l -p "${OTHER_FILE}" \ 179 | eval "$MODULES_CLASS_FILTER" > ${OTHER_FILE}.javap & 180 $JAVAP -c -constants -l -p "${THIS_FILE}" \ 181 | eval "$MODULES_CLASS_FILTER" > ${THIS_FILE}.javap & 182 wait 183 TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap) 184 # To improve performance when large diffs are found, do a rough filtering of classes 185 # elibeble for these exceptions 186 elif $GREP -R -e '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}' \ 187 -e 'lambda\$[a-zA-Z0-9]*\$[0-9]' ${THIS_FILE} > /dev/null 188 then 189 $JAVAP -c -constants -l -p "${OTHER_FILE}" > ${OTHER_FILE}.javap & 190 $JAVAP -c -constants -l -p "${THIS_FILE}" > ${THIS_FILE}.javap & 191 wait 192 TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \ 193 $GREP '^[<>]' | \ 194 $SED -e '/[<>].*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d' \ 195 -e '/[<>].*lambda\$[a-zA-Z0-9]*\$[0-9]*/d') 196 fi 197 fi 198 if test "x$SUFFIX" = "xproperties"; then 199 # Filter out date string differences. 200 TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \ 201 $GREP '^[<>]' | \ 202 $SED -e '/[<>].*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d') 203 fi 204 if test "x$SUFFIX" = "xhtml"; then 205 # Some javadoc versions do not put quotes around font size 206 HTML_FILTER="$SED \ 207 -e 's/<font size=-1>/<font size=\"-1\">/g'" 208 $CAT $THIS_FILE | eval "$HTML_FILTER" > $THIS_FILE.filtered 209 $CAT $OTHER_FILE | eval "$HTML_FILTER" > $OTHER_FILE.filtered 210 TMP=$(LC_ALL=C $DIFF $OTHER_FILE.filtered $THIS_FILE.filtered | \ 211 $GREP '^[<>]' | \ 212 $SED -e '/[<>] <!-- Generated by javadoc .* on .* -->/d' \ 213 -e '/[<>] <meta name="date" content=".*">/d' ) 214 fi 215 if test -n "$TMP"; then 216 echo Files $OTHER_FILE and $THIS_FILE differ 217 return 1 218 fi 219 220 return 0 221 } 222 223 ################################################################################ 224 # Compare directory structure 225 226 compare_dirs() { 227 THIS_DIR=$1 228 OTHER_DIR=$2 229 WORK_DIR=$3 230 231 mkdir -p $WORK_DIR 232 233 (cd $OTHER_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_other) 234 (cd $THIS_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_this) 235 236 $DIFF $WORK_DIR/dirs_other $WORK_DIR/dirs_this > $WORK_DIR/dirs_diff 237 238 echo -n Directory structure... 239 if [ -s $WORK_DIR/dirs_diff ]; then 240 echo Differences found. 241 REGRESSIONS=true 242 # Differences in directories found. 243 ONLY_OTHER=$($GREP '<' $WORK_DIR/dirs_diff) 244 if [ "$ONLY_OTHER" ]; then 245 echo Only in $OTHER 246 $GREP '<' $WORK_DIR/dirs_diff | $SED 's|< ./| |g' 247 fi 248 ONLY_THIS=$($GREP '>' $WORK_DIR/dirs_diff) 249 if [ "$ONLY_THIS" ]; then 250 echo Only in $THIS 251 $GREP '>' $WORK_DIR/dirs_diff | $SED 's|> ./| |g' 252 fi 253 else 254 echo Identical! 255 fi 256 } 257 258 259 ################################################################################ 260 # Compare file structure 261 262 compare_files() { 263 THIS_DIR=$1 264 OTHER_DIR=$2 265 WORK_DIR=$3 266 267 $MKDIR -p $WORK_DIR 268 269 (cd $OTHER_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_other) 270 (cd $THIS_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_this) 271 272 $DIFF $WORK_DIR/files_other $WORK_DIR/files_this > $WORK_DIR/files_diff 273 274 echo -n File names... 275 if [ -s $WORK_DIR/files_diff ]; then 276 echo Differences found. 277 REGRESSIONS=true 278 # Differences in files found. 279 ONLY_OTHER=$($GREP '<' $WORK_DIR/files_diff) 280 if [ "$ONLY_OTHER" ]; then 281 echo Only in $OTHER 282 $GREP '<' $WORK_DIR/files_diff | $SED 's|< ./| |g' 283 fi 284 ONLY_THIS=$($GREP '>' $WORK_DIR/files_diff) 285 if [ "$ONLY_THIS" ]; then 286 echo Only in $THIS 287 $GREP '>' $WORK_DIR/files_diff | $SED 's|> ./| |g' 288 fi 289 else 290 echo Identical! 291 fi 292 } 293 294 295 ################################################################################ 296 # Compare permissions 297 298 compare_permissions() { 299 THIS_DIR=$1 300 OTHER_DIR=$2 301 WORK_DIR=$3 302 303 mkdir -p $WORK_DIR 304 305 echo -n Permissions... 306 found="" 307 for f in `cd $OTHER_DIR && $FIND . -type f` 308 do 309 if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi 310 if [ ! -f ${THIS_DIR}/$f ]; then continue; fi 311 OP=`ls -l ${OTHER_DIR}/$f | awk '{printf("%.10s\n", $1);}'` 312 TP=`ls -l ${THIS_DIR}/$f | awk '{printf("%.10s\n", $1);}'` 313 if [ "$OP" != "$TP" ] 314 then 315 if [ -z "$found" ]; then echo ; found="yes"; fi 316 $PRINTF "\tother: ${OP} this: ${TP}\t$f\n" 317 fi 318 done 319 if [ -z "$found" ]; then 320 echo "Identical!" 321 else 322 REGRESSIONS=true 323 fi 324 } 325 326 ################################################################################ 327 # Compare file command output 328 329 compare_file_types() { 330 THIS_DIR=$1 331 OTHER_DIR=$2 332 WORK_DIR=$3 333 334 $MKDIR -p $WORK_DIR 335 336 FILE_TYPES_FILTER="$SED \ 337 -e 's/BuildID[^,]*//' \ 338 -e 's/last modified: .*//' \ 339 " 340 341 echo -n File types... 342 found="" 343 # The file command does not know about jmod files and this sometimes results 344 # in different types being detected more or less randomly. 345 for f in $(cd $OTHER_DIR && $FIND . ! -type d -a ! -name "*.jmod") 346 do 347 if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi 348 if [ ! -f ${THIS_DIR}/$f ]; then continue; fi 349 OF=$(cd ${OTHER_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER) 350 TF=$(cd ${THIS_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER) 351 if [ "$OF" != "$TF" ] 352 then 353 if [ "`echo $OF | $GREP -c 'Zip archive data'`" -gt 0 ] \ 354 && [ "`echo $TF | $GREP -c 'Zip archive data'`" -gt 0 ] 355 then 356 # the way we produce zip-files make it so that directories are stored in 357 # old file but not in new (only files with full-path) this makes file 358 # report them as different 359 continue 360 else 361 if [ -z "$found" ]; then echo ; found="yes"; fi 362 $PRINTF "\tother: ${OF}\n\tthis : ${TF}\n" 363 fi 364 fi 365 done 366 if [ -z "$found" ]; then 367 echo "Identical!" 368 else 369 REGRESSIONS=true 370 fi 371 } 372 373 ################################################################################ 374 # Compare the rest of the files 375 376 compare_general_files() { 377 THIS_DIR=$1 378 OTHER_DIR=$2 379 WORK_DIR=$3 380 381 GENERAL_FILES=$(cd $THIS_DIR && $FIND . -type f ! -name "*.so" ! -name "*.jar" \ 382 ! -name "*.zip" ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \ 383 ! -name "modules" ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \ 384 ! -name "*.cpl" ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \ 385 ! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" ! -name "*.jmod" \ 386 ! -name "*.obj" ! -name "*.o" ! -name "JavaControlPanelHelper" \ 387 ! -name "JavaUpdater" ! -name "JavaWSApplicationStub" \ 388 ! -name "jspawnhelper" ! -name "JavawsLauncher" ! -name "*.a" \ 389 ! -name "finish_installation" ! -name "Sparkle" ! -name "*.tar.gz" \ 390 ! -name "classes.jsa" \ 391 | $GREP -v "./bin/" | $SORT | $FILTER) 392 393 echo Other files with binary differences... 394 for f in $GENERAL_FILES 395 do 396 if [ -e $OTHER_DIR/$f ]; then 397 SUFFIX="${f##*.}" 398 if [ "$(basename $f)" = "release" ]; then 399 # In release file, ignore differences in change numbers and order 400 # of modules in list. 401 OTHER_FILE=$WORK_DIR/$f.other 402 THIS_FILE=$WORK_DIR/$f.this 403 $MKDIR -p $(dirname $OTHER_FILE) 404 $MKDIR -p $(dirname $THIS_FILE) 405 RELEASE_FILTER="$SED \ 406 -e 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' \ 407 -e 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}/<DATE>/g' \ 408 -e 's/^#.*/#COMMENT/g' \ 409 -e 's/MODULES=/MODULES=\'$'\n/' \ 410 -e 's/,/\'$'\n/g' \ 411 | $SORT 412 " 413 $CAT $OTHER_DIR/$f | eval "$RELEASE_FILTER" > $OTHER_FILE 414 $CAT $THIS_DIR/$f | eval "$RELEASE_FILTER" > $THIS_FILE 415 elif [ "x$SUFFIX" = "xhtml" ]; then 416 # Ignore time stamps in docs files 417 OTHER_FILE=$WORK_DIR/$f.other 418 THIS_FILE=$WORK_DIR/$f.this 419 $MKDIR -p $(dirname $OTHER_FILE) $(dirname $THIS_FILE) 420 # Older versions of compare might have left soft links with 421 # these names. 422 $RM $OTHER_FILE $THIS_FILE 423 #Note that | doesn't work on mac sed. 424 HTML_FILTER="$SED \ 425 -e 's/20[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6,7\}/<DATE>/g' \ 426 -e 's/20[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}/<DATE>/g' \ 427 -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \ 428 -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [0-9]\{4\} [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/<DATE>/' \ 429 -e 's/from .*\.idl/\.idl/' \ 430 " 431 $CAT $OTHER_DIR/$f | eval "$HTML_FILTER" > $OTHER_FILE & 432 $CAT $THIS_DIR/$f | eval "$HTML_FILTER" > $THIS_FILE & 433 wait 434 elif [[ "$f" = *"/lib/classlist" ]]; then 435 # The classlist files may have some lines in random order 436 OTHER_FILE=$WORK_DIR/$f.other 437 THIS_FILE=$WORK_DIR/$f.this 438 $MKDIR -p $(dirname $OTHER_FILE) $(dirname $THIS_FILE) 439 $RM $OTHER_FILE $THIS_FILE 440 $CAT $OTHER_DIR/$f | $SORT > $OTHER_FILE 441 $CAT $THIS_DIR/$f | $SORT > $THIS_FILE 442 else 443 OTHER_FILE=$OTHER_DIR/$f 444 THIS_FILE=$THIS_DIR/$f 445 fi 446 DIFF_OUT=$($DIFF $OTHER_FILE $THIS_FILE 2>&1) 447 if [ -n "$DIFF_OUT" ]; then 448 echo $f 449 REGRESSIONS=true 450 if [ "$SHOW_DIFFS" = "true" ]; then 451 echo "$DIFF_OUT" 452 fi 453 fi 454 fi 455 done 456 457 458 } 459 460 ################################################################################ 461 # Compare zip file 462 463 compare_zip_file() { 464 THIS_DIR=$1 465 OTHER_DIR=$2 466 WORK_DIR=$3 467 ZIP_FILE=$4 468 # Optionally provide different name for other zipfile 469 OTHER_ZIP_FILE=$5 470 471 THIS_ZIP=$THIS_DIR/$ZIP_FILE 472 if [ -n "$OTHER_ZIP_FILE" ]; then 473 OTHER_ZIP=$OTHER_DIR/$OTHER_ZIP_FILE 474 else 475 OTHER_ZIP=$OTHER_DIR/$ZIP_FILE 476 fi 477 478 THIS_SUFFIX="${THIS_ZIP##*.}" 479 OTHER_SUFFIX="${OTHER_ZIP##*.}" 480 if [ "$THIS_SUFFIX" != "$OTHER_SUFFIX" ]; then 481 echo "The files do not have the same suffix type! ($THIS_SUFFIX != $OTHER_SUFFIX)" 482 return 2 483 fi 484 485 TYPE="$THIS_SUFFIX" 486 487 if $CMP $OTHER_ZIP $THIS_ZIP > /dev/null 488 then 489 return 0 490 fi 491 # Not quite identical, the might still contain the same data. 492 # Unpack the jar/zip files in temp dirs 493 494 THIS_UNZIPDIR=$WORK_DIR/$ZIP_FILE.this 495 OTHER_UNZIPDIR=$WORK_DIR/$ZIP_FILE.other 496 $RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR 497 $MKDIR -p $THIS_UNZIPDIR 498 $MKDIR -p $OTHER_UNZIPDIR 499 if [ "$TYPE" = "jar" -o "$TYPE" = "war" -o "$TYPE" = "zip" ] 500 then 501 (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP) 502 (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP) 503 elif [ "$TYPE" = "gz" ] 504 then 505 (cd $THIS_UNZIPDIR && $GUNZIP -c $THIS_ZIP | $TAR xf -) 506 (cd $OTHER_UNZIPDIR && $GUNZIP -c $OTHER_ZIP | $TAR xf -) 507 elif [ "$TYPE" = "jmod" ] 508 then 509 (cd $THIS_UNZIPDIR && $JMOD extract $THIS_ZIP) 510 (cd $OTHER_UNZIPDIR && $JMOD extract $OTHER_ZIP) 511 else 512 (cd $THIS_UNZIPDIR && $JIMAGE extract $THIS_ZIP) 513 (cd $OTHER_UNZIPDIR && $JIMAGE extract $OTHER_ZIP) 514 fi 515 516 # Find all archives inside and unzip them as well to compare the contents rather than 517 # the archives. pie.jar.pack.gz i app3.war is corrupt, skip it. 518 EXCEPTIONS="pie.jar.pack.gz jdk.pack" 519 for pack in $($FIND $THIS_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a \ 520 ! -name pie.jar.pack.gz -a ! -name jdk.pack); do 521 ($UNPACK200 $pack $pack.jar) 522 # Filter out the unzipped archives from the diff below. 523 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar" 524 done 525 for pack in $($FIND $OTHER_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a \ 526 ! -name pie.jar.pack.gz -a ! -name jdk.pack); do 527 ($UNPACK200 $pack $pack.jar) 528 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar" 529 done 530 for zip in $($FIND $THIS_UNZIPDIR -name "*.jar" -o -name "*.zip"); do 531 $MKDIR $zip.unzip 532 (cd $zip.unzip && $UNARCHIVE $zip) 533 EXCEPTIONS="$EXCEPTIONS $zip" 534 done 535 for zip in $($FIND $OTHER_UNZIPDIR -name "*.jar" -o -name "*.zip"); do 536 $MKDIR $zip.unzip 537 (cd $zip.unzip && $UNARCHIVE $zip) 538 EXCEPTIONS="$EXCEPTIONS $zip" 539 done 540 541 CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff 542 # On solaris, there is no -q option. 543 if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then 544 LC_ALL=C $DIFF -r $OTHER_UNZIPDIR $THIS_UNZIPDIR \ 545 | $GREP -v -e "^<" -e "^>" -e "^Common subdirectories:" \ 546 > $CONTENTS_DIFF_FILE 547 else 548 LC_ALL=C $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE 549 fi 550 551 ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE) 552 ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE) 553 554 return_value=0 555 556 if [ -n "$ONLY_OTHER" ]; then 557 echo " Only OTHER $ZIP_FILE contains:" 558 echo "$ONLY_OTHER" | sed "s|Only in $OTHER_UNZIPDIR| |"g | sed 's|: |/|g' 559 return_value=1 560 fi 561 562 if [ -n "$ONLY_THIS" ]; then 563 echo " Only THIS $ZIP_FILE contains:" 564 echo "$ONLY_THIS" | sed "s|Only in $THIS_UNZIPDIR| |"g | sed 's|: |/|g' 565 return_value=1 566 fi 567 568 if [ "$CMP_ZIPS_CONTENTS" = "true" ]; then 569 if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then 570 DIFFING_FILES=$($GREP -e 'differ$' -e '^diff ' $CONTENTS_DIFF_FILE \ 571 | $SED -e 's/^Files //g' -e 's/diff -r //g' | $CUT -f 1 -d ' ' \ 572 | $SED "s|$OTHER_UNZIPDIR/||g") 573 else 574 DIFFING_FILES=$($GREP -e "differ$" $CONTENTS_DIFF_FILE \ 575 | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g") 576 fi 577 578 $RM -f $WORK_DIR/$ZIP_FILE.diffs 579 for file in $DIFFING_FILES; do 580 if [[ "$ACCEPTED_JARZIP_CONTENTS $EXCEPTIONS" != *"$file"* ]]; then 581 diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs 582 fi 583 done 584 585 if [ -s "$WORK_DIR/$ZIP_FILE.diffs" ]; then 586 return_value=1 587 echo " Differing files in $ZIP_FILE" 588 $CAT $WORK_DIR/$ZIP_FILE.diffs | $GREP 'differ$' | cut -f 2 -d ' ' | \ 589 $SED "s|$OTHER_UNZIPDIR| |g" > $WORK_DIR/$ZIP_FILE.difflist 590 $CAT $WORK_DIR/$ZIP_FILE.difflist 591 592 if [ -n "$SHOW_DIFFS" ]; then 593 for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do 594 if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then 595 LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap 596 elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then 597 LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i 598 else 599 LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i 600 fi 601 done 602 fi 603 fi 604 fi 605 606 return $return_value 607 } 608 609 ################################################################################ 610 # Compare jmod file 611 612 compare_jmod_file() { 613 THIS_DIR=$1 614 OTHER_DIR=$2 615 WORK_DIR=$3 616 JMOD_FILE=$4 617 618 THIS_JMOD=$THIS_DIR/$JMOD_FILE 619 OTHER_JMOD=$OTHER_DIR/$JMOD_FILE 620 621 if $CMP $OTHER_JMOD $THIS_JMOD > /dev/null; then 622 return 0 623 fi 624 625 THIS_JMOD_LIST=$WORK_DIR/$JMOD_FILE.list.this 626 OTHER_JMOD_LIST=$WORK_DIR/$JMOD_FILE.list.other 627 mkdir -p $(dirname $THIS_JMOD_LIST) $(dirname $OTHER_JMOD_LIST) 628 629 $JMOD list $THIS_JMOD | sort > $THIS_JMOD_LIST 630 $JMOD list $OTHER_JMOD | sort > $OTHER_JMOD_LIST 631 JMOD_LIST_DIFF_FILE=$WORK_DIR/$JMOD_FILE.list.diff 632 LC_ALL=C $DIFF $THIS_JMOD_LIST $OTHER_JMOD_LIST > $JMOD_LIST_DIFF_FILE 633 634 ONLY_THIS=$($GREP "^<" $JMOD_LIST_DIFF_FILE) 635 ONLY_OTHER=$($GREP "^>" $JMOD_LIST_DIFF_FILE) 636 637 if [ -n "$ONLY_OTHER" ]; then 638 echo " Only OTHER $JMOD_FILE contains:" 639 echo "$ONLY_OTHER" | sed "s|^>| |"g | sed 's|: |/|g' 640 return_value=1 641 fi 642 643 if [ -n "$ONLY_THIS" ]; then 644 echo " Only THIS $JMOD_FILE contains:" 645 echo "$ONLY_THIS" | sed "s|^<| |"g | sed 's|: |/|g' 646 return_value=1 647 fi 648 649 return $return_value 650 } 651 652 ################################################################################ 653 # Compare all zip files 654 655 compare_all_zip_files() { 656 THIS_DIR=$1 657 OTHER_DIR=$2 658 WORK_DIR=$3 659 660 ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" -o -name "*.tar.gz" \ 661 | $SORT | $FILTER ) 662 663 if [ -n "$ZIPS" ]; then 664 echo Zip/tar.gz files... 665 666 return_value=0 667 for f in $ZIPS; do 668 if [ -f "$OTHER_DIR/$f" ]; then 669 compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f 670 if [ "$?" != "0" ]; then 671 return_value=1 672 REGRESSIONS=true 673 fi 674 fi 675 done 676 fi 677 678 return $return_value 679 } 680 681 ################################################################################ 682 # Compare all jmod files 683 684 compare_all_jmod_files() { 685 THIS_DIR=$1 686 OTHER_DIR=$2 687 WORK_DIR=$3 688 689 JMODS=$(cd $THIS_DIR && $FIND . -type f -name "*.jmod" | $SORT | $FILTER ) 690 691 if [ -n "$JMODS" ]; then 692 echo Jmod files... 693 694 return_value=0 695 for f in $JMODS; do 696 if [ -f "$OTHER_DIR/$f" ]; then 697 compare_jmod_file $THIS_DIR $OTHER_DIR $WORK_DIR $f 698 if [ "$?" != "0" ]; then 699 return_value=1 700 REGRESSIONS=true 701 fi 702 fi 703 done 704 fi 705 706 return $return_value 707 } 708 709 ################################################################################ 710 # Compare all jar files 711 712 compare_all_jar_files() { 713 THIS_DIR=$1 714 OTHER_DIR=$2 715 WORK_DIR=$3 716 717 # TODO filter? 718 ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" -o -name "*.war" \ 719 -o -name "modules" | $SORT | $FILTER) 720 721 if [ -n "$ZIPS" ]; then 722 echo Jar files... 723 724 return_value=0 725 for f in $ZIPS; do 726 if [ -f "$OTHER_DIR/$f" ]; then 727 compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f 728 if [ "$?" != "0" ]; then 729 return_value=1 730 REGRESSIONS=true 731 fi 732 fi 733 done 734 fi 735 736 return $return_value 737 } 738 739 ################################################################################ 740 # Compare binary (executable/library) file 741 742 compare_bin_file() { 743 THIS_DIR=$1 744 OTHER_DIR=$2 745 WORK_DIR=$3 746 BIN_FILE=$4 747 OTHER_BIN_FILE=$5 748 749 THIS_FILE=$THIS_DIR/$BIN_FILE 750 if [ -n "$OTHER_BIN_FILE" ]; then 751 OTHER_FILE=$OTHER_DIR/$OTHER_BIN_FILE 752 else 753 OTHER_FILE=$OTHER_DIR/$BIN_FILE 754 fi 755 NAME=$(basename $BIN_FILE) 756 WORK_FILE_BASE=$WORK_DIR/$BIN_FILE 757 FILE_WORK_DIR=$(dirname $WORK_FILE_BASE) 758 759 $MKDIR -p $FILE_WORK_DIR 760 761 # Make soft links to original files from work dir to facilitate debugging 762 $LN -f -s $THIS_FILE $WORK_FILE_BASE.this 763 $LN -f -s $OTHER_FILE $WORK_FILE_BASE.other 764 765 ORIG_THIS_FILE="$THIS_FILE" 766 ORIG_OTHER_FILE="$OTHER_FILE" 767 768 if [ "$STRIP_ALL" = "true" ] || [[ "$STRIP_BEFORE_COMPARE" = *"$BIN_FILE"* ]]; then 769 THIS_STRIPPED_FILE=$FILE_WORK_DIR/this/$NAME 770 OTHER_STRIPPED_FILE=$FILE_WORK_DIR/other/$NAME 771 $MKDIR -p $FILE_WORK_DIR/this $FILE_WORK_DIR/other 772 $CP $THIS_FILE $THIS_STRIPPED_FILE 773 $CP $OTHER_FILE $OTHER_STRIPPED_FILE 774 $STRIP $THIS_STRIPPED_FILE 775 $STRIP $OTHER_STRIPPED_FILE 776 THIS_FILE="$THIS_STRIPPED_FILE" 777 OTHER_FILE="$OTHER_STRIPPED_FILE" 778 fi 779 780 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then 781 unset _NT_SYMBOL_PATH 782 if [ "$(uname -o)" = "Cygwin" ]; then 783 THIS=$(cygpath -msa $THIS) 784 OTHER=$(cygpath -msa $OTHER) 785 fi 786 # Build an _NT_SYMBOL_PATH that contains all known locations for 787 # pdb files. 788 PDB_DIRS="$(ls -d \ 789 {$OTHER,$THIS}/support/modules_{cmds,libs}/{*,*/*} \ 790 {$OTHER,$THIS}/support/native/java.base/java_objs \ 791 )" 792 export _NT_SYMBOL_PATH="$(echo $PDB_DIRS | tr ' ' ';')" 793 fi 794 795 if [ -z "$SKIP_BIN_DIFF" ]; then 796 if cmp $OTHER_FILE $THIS_FILE > /dev/null; then 797 # The files were bytewise identical. 798 if [ -n "$VERBOSE" ]; then 799 echo " : : : : : : $BIN_FILE" 800 fi 801 return 0 802 fi 803 BIN_MSG=" diff " 804 if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then 805 DIFF_BIN=true 806 if [[ "$KNOWN_BIN_DIFF" != *"$BIN_FILE"* ]]; then 807 BIN_MSG="*$BIN_MSG*" 808 REGRESSIONS=true 809 else 810 BIN_MSG=" $BIN_MSG " 811 fi 812 else 813 BIN_MSG="($BIN_MSG)" 814 DIFF_BIN= 815 fi 816 fi 817 818 if [ -n "$STAT" ]; then 819 THIS_SIZE=$($STAT $STAT_PRINT_SIZE "$THIS_FILE") 820 OTHER_SIZE=$($STAT $STAT_PRINT_SIZE "$OTHER_FILE") 821 else 822 THIS_SIZE=$(ls -l "$THIS_FILE" | awk '{ print $5 }') 823 OTHER_SIZE=$(ls -l "$OTHER_FILE" | awk '{ print $5 }') 824 fi 825 if [ $THIS_SIZE -ne $OTHER_SIZE ]; then 826 DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE) 827 DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE) 828 SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM) 829 if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \ 830 && [ "$DIFF_SIZE_REL" -lt 102 ]; then 831 SIZE_MSG="($SIZE_MSG)" 832 DIFF_SIZE= 833 elif [ "$OPENJDK_TARGET_OS" = "windows" ] \ 834 && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \ 835 && [ "$DIFF_SIZE_NUM" = 512 ]; then 836 # On windows, size of binaries increase in 512 increments. 837 SIZE_MSG="($SIZE_MSG)" 838 DIFF_SIZE= 839 elif [ "$OPENJDK_TARGET_OS" = "windows" ] \ 840 && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \ 841 && [ "$DIFF_SIZE_NUM" = -512 ]; then 842 # On windows, size of binaries increase in 512 increments. 843 SIZE_MSG="($SIZE_MSG)" 844 DIFF_SIZE= 845 else 846 if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then 847 DIFF_SIZE=true 848 if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then 849 SIZE_MSG="*$SIZE_MSG*" 850 REGRESSIONS=true 851 else 852 SIZE_MSG=" $SIZE_MSG " 853 fi 854 else 855 SIZE_MSG="($SIZE_MSG)" 856 DIFF_SIZE= 857 fi 858 fi 859 else 860 SIZE_MSG=" " 861 DIFF_SIZE= 862 if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then 863 SIZE_MSG=" ! " 864 fi 865 fi 866 867 if [ "$SORT_ALL_SYMBOLS" = "true" ] || [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then 868 SYM_SORT_CMD="sort" 869 else 870 SYM_SORT_CMD="cat" 871 fi 872 873 if [ -n "$SYMBOLS_DIFF_FILTER" ] && [ -z "$NEED_SYMBOLS_DIFF_FILTER" ] \ 874 || [[ "$NEED_SYMBOLS_DIFF_FILTER" = *"$BIN_FILE"* ]]; then 875 this_SYMBOLS_DIFF_FILTER="$SYMBOLS_DIFF_FILTER" 876 else 877 this_SYMBOLS_DIFF_FILTER="$CAT" 878 fi 879 880 # Check symbols 881 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then 882 # The output from dumpbin on windows differs depending on if the debug symbol 883 # files are still around at the location the binary is pointing too. Need 884 # to filter out that extra information. 885 $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 886 $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 887 elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then 888 # Some symbols get seemingly random 15 character prefixes. Filter them out. 889 $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 890 $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 891 elif [ "$OPENJDK_TARGET_OS" = "aix" ]; then 892 $OBJDUMP -T $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other 893 $OBJDUMP -T $ORIG_THIS_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this 894 elif [ "$OPENJDK_TARGET_OS" = "macosx" ]; then 895 $NM -j $ORIG_OTHER_FILE 2> /dev/null | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other 896 $NM -j $ORIG_THIS_FILE 2> /dev/null | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this 897 else 898 $NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME \ 899 | $AWK '{print $2, $3, $4, $5}' \ 900 | eval "$this_SYMBOLS_DIFF_FILTER" \ 901 | $SYM_SORT_CMD \ 902 > $WORK_FILE_BASE.symbols.other 903 $NM -a $ORIG_THIS_FILE 2> /dev/null | $GREP -v $NAME \ 904 | $AWK '{print $2, $3, $4, $5}' \ 905 | eval "$this_SYMBOLS_DIFF_FILTER" \ 906 | $SYM_SORT_CMD \ 907 > $WORK_FILE_BASE.symbols.this 908 fi 909 910 LC_ALL=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff 911 if [ -s $WORK_FILE_BASE.symbols.diff ]; then 912 SYM_MSG=" diff " 913 if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then 914 DIFF_SYM=true 915 if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then 916 SYM_MSG="*$SYM_MSG*" 917 REGRESSIONS=true 918 else 919 SYM_MSG=" $SYM_MSG " 920 fi 921 else 922 SYM_MSG="($SYM_MSG)" 923 DIFF_SYM= 924 fi 925 else 926 SYM_MSG=" " 927 DIFF_SYM= 928 if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then 929 SYM_MSG=" ! " 930 fi 931 fi 932 933 # Check dependencies 934 if [ -n "$LDD_CMD" ]; then 935 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then 936 LDD_FILTER="$GREP \.dll" 937 else 938 LDD_FILTER="$CAT" 939 fi 940 (cd $FILE_WORK_DIR && $CP $OTHER_FILE . && $LDD_CMD $NAME 2>/dev/null \ 941 | $LDD_FILTER | $AWK '{ print $1;}' | $SORT \ 942 | $TEE $WORK_FILE_BASE.deps.other \ 943 | $UNIQ > $WORK_FILE_BASE.deps.other.uniq) 944 (cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME 2</dev/null \ 945 | $LDD_FILTER | $AWK '{ print $1;}' | $SORT \ 946 | $TEE $WORK_FILE_BASE.deps.this \ 947 | $UNIQ > $WORK_FILE_BASE.deps.this.uniq) 948 (cd $FILE_WORK_DIR && $RM -f $NAME) 949 950 LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this \ 951 > $WORK_FILE_BASE.deps.diff 952 LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq \ 953 > $WORK_FILE_BASE.deps.diff.uniq 954 955 if [ -s $WORK_FILE_BASE.deps.diff ]; then 956 if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then 957 DEP_MSG=" diff " 958 else 959 DEP_MSG=" redun " 960 fi 961 if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then 962 DIFF_DEP=true 963 if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then 964 DEP_MSG="*$DEP_MSG*" 965 REGRESSIONS=true 966 else 967 DEP_MSG=" $DEP_MSG " 968 fi 969 else 970 DEP_MSG="($DEP_MSG)" 971 DIFF_DEP= 972 fi 973 else 974 DEP_MSG=" " 975 DIFF_DEP= 976 if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then 977 DEP_MSG=" ! " 978 fi 979 fi 980 else 981 DEP_MSG=" - " 982 fi 983 984 # Some linux compilers add a unique Build ID 985 if [ "$OPENJDK_TARGET_OS" = "linux" ]; then 986 BUILD_ID_FILTER="$SED -r 's/(Build ID:) [0-9a-f]{40}/\1/'" 987 else 988 BUILD_ID_FILTER="$CAT" 989 fi 990 991 # Compare fulldump output 992 if [ -n "$FULLDUMP_CMD" ] && [ -z "$SKIP_FULLDUMP_DIFF" ]; then 993 if [ -z "$FULLDUMP_DIFF_FILTER" ]; then 994 FULLDUMP_DIFF_FILTER="$CAT" 995 fi 996 $FULLDUMP_CMD $OTHER_FILE | eval "$BUILD_ID_FILTER" | eval "$FULLDUMP_DIFF_FILTER" \ 997 > $WORK_FILE_BASE.fulldump.other 2>&1 & 998 $FULLDUMP_CMD $THIS_FILE | eval "$BUILD_ID_FILTER" | eval "$FULLDUMP_DIFF_FILTER" \ 999 > $WORK_FILE_BASE.fulldump.this 2>&1 & 1000 wait 1001 1002 LC_ALL=C $DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this \ 1003 > $WORK_FILE_BASE.fulldump.diff 1004 1005 if [ -s $WORK_FILE_BASE.fulldump.diff ]; then 1006 FULLDUMP_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.fulldump.diff | awk '{print $5}') 1007 FULLDUMP_MSG=$($PRINTF "%8d" $FULLDUMP_DIFF_SIZE) 1008 if [[ "$ACCEPTED_FULLDUMP_DIFF" != *"$BIN_FILE"* ]]; then 1009 DIFF_FULLDUMP=true 1010 if [[ "$KNOWN_FULLDUMP_DIFF" != *"$BIN_FILE"* ]]; then 1011 FULLDUMP_MSG="*$FULLDUMP_MSG*" 1012 REGRESSIONS=true 1013 else 1014 FULLDUMP_MSG=" $FULLDUMP_MSG " 1015 fi 1016 else 1017 FULLDUMP_MSG="($FULLDUMP_MSG)" 1018 DIFF_FULLDUMP= 1019 fi 1020 else 1021 FULLDUMP_MSG=" " 1022 DIFF_FULLDUMP= 1023 if [[ "$KNOWN_FULLDUMP_DIFF $ACCEPTED_FULLDUMP_DIFF" = *"$BIN_FILE"* ]]; then 1024 FULLDUMP_MSG=" ! " 1025 fi 1026 fi 1027 fi 1028 1029 # Compare disassemble output 1030 if [ -n "$DIS_CMD" ] && [ -z "$SKIP_DIS_DIFF" ]; then 1031 this_DIS_DIFF_FILTER="$CAT" 1032 if [ -n "$DIS_DIFF_FILTER" ]; then 1033 if [ -z "$NEED_DIS_DIFF_FILTER" ] \ 1034 || [[ "$NEED_DIS_DIFF_FILTER" = *"$BIN_FILE"* ]]; then 1035 this_DIS_DIFF_FILTER="$DIS_DIFF_FILTER" 1036 fi 1037 fi 1038 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then 1039 DIS_GREP_ARG=-a 1040 else 1041 DIS_GREP_ARG= 1042 fi 1043 $DIS_CMD $OTHER_FILE | $GREP $DIS_GREP_ARG -v $NAME \ 1044 | eval "$this_DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.other 2>&1 & 1045 $DIS_CMD $THIS_FILE | $GREP $DIS_GREP_ARG -v $NAME \ 1046 | eval "$this_DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.this 2>&1 & 1047 wait 1048 1049 LC_ALL=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff 1050 1051 if [ -s $WORK_FILE_BASE.dis.diff ]; then 1052 DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}') 1053 DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE) 1054 if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then 1055 DIFF_DIS=true 1056 if [ "$MAX_KNOWN_DIS_DIFF_SIZE" = "" ]; then 1057 MAX_KNOWN_DIS_DIFF_SIZE="0" 1058 fi 1059 if [[ "$KNOWN_DIS_DIFF" = *"$BIN_FILE"* ]] \ 1060 && [ "$DIS_DIFF_SIZE" -lt "$MAX_KNOWN_DIS_DIFF_SIZE" ]; then 1061 DIS_MSG=" $DIS_MSG " 1062 else 1063 DIS_MSG="*$DIS_MSG*" 1064 REGRESSIONS=true 1065 fi 1066 else 1067 DIS_MSG="($DIS_MSG)" 1068 DIFF_DIS= 1069 fi 1070 else 1071 DIS_MSG=" " 1072 DIFF_DIS= 1073 if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then 1074 DIS_MSG=" ! " 1075 fi 1076 fi 1077 fi 1078 1079 1080 if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_FULLDUMP$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then 1081 if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi 1082 if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi 1083 if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi 1084 if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi 1085 if [ -n "$FULLDUMP_MSG" ]; then echo -n "$FULLDUMP_MSG:"; fi 1086 if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi 1087 echo " $BIN_FILE" 1088 if [ "$SHOW_DIFFS" = "true" ]; then 1089 if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then 1090 echo "Symbols diff:" 1091 $CAT $WORK_FILE_BASE.symbols.diff 1092 fi 1093 if [ -s "$WORK_FILE_BASE.deps.diff" ]; then 1094 echo "Deps diff:" 1095 $CAT $WORK_FILE_BASE.deps.diff 1096 fi 1097 if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then 1098 echo "Fulldump diff:" 1099 $CAT $WORK_FILE_BASE.fulldump.diff 1100 fi 1101 if [ -s "$WORK_FILE_BASE.dis.diff" ]; then 1102 echo "Disassembly diff:" 1103 $CAT $WORK_FILE_BASE.dis.diff 1104 fi 1105 fi 1106 return 1 1107 fi 1108 return 0 1109 } 1110 1111 ################################################################################ 1112 # Print binary diff header 1113 1114 print_binary_diff_header() { 1115 if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi 1116 if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n " Size :"; fi 1117 if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi 1118 if [ -z "$SKIP_DEP_DIFF" ]; then echo -n " Deps :"; fi 1119 if [ -z "$SKIP_FULLDUMP_DIFF" ]; then echo -n " Fulldump :"; fi 1120 if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass :"; fi 1121 echo 1122 } 1123 1124 ################################################################################ 1125 # Compare all libraries 1126 1127 compare_all_libs() { 1128 THIS_DIR=$1 1129 OTHER_DIR=$2 1130 WORK_DIR=$3 1131 1132 LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' \ 1133 -o -name '*.dll' -o -name '*.obj' -o -name '*.o' -o -name '*.a' \ 1134 -o -name '*.cpl' \) | $SORT | $FILTER) 1135 1136 # On macos, filter out the dSYM debug symbols files as they are also 1137 # named *.dylib. 1138 if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then 1139 LIBS=$(echo "$LIBS" | $GREP -v '\.dSYM/') 1140 fi 1141 1142 if [ -n "$LIBS" ]; then 1143 echo Libraries... 1144 print_binary_diff_header 1145 for l in $LIBS; do 1146 if [ -f "$OTHER_DIR/$l" ]; then 1147 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l 1148 if [ "$?" != "0" ]; then 1149 return_value=1 1150 fi 1151 fi 1152 done 1153 fi 1154 1155 return $return_value 1156 } 1157 1158 ################################################################################ 1159 # Compare all executables 1160 1161 compare_all_execs() { 1162 THIS_DIR=$1 1163 OTHER_DIR=$2 1164 WORK_DIR=$3 1165 1166 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then 1167 EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER) 1168 else 1169 EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \ 1170 \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \ 1171 -o -name '*.jar' -o -name '*.diz' -o -name 'jcontrol' -o -name '*.properties' \ 1172 -o -name '*.data' -o -name '*.bfc' -o -name '*.src' -o -name '*.txt' \ 1173 -o -name '*.cfg' -o -name 'meta-index' -o -name '*.properties.ja' \ 1174 -o -name '*.xml' -o -name '*.html' -o -name '*.png' -o -name 'README' \ 1175 -o -name '*.zip' -o -name '*.jimage' -o -name '*.java' -o -name '*.mf' \ 1176 -o -name '*.jpg' -o -name '*.wsdl' -o -name '*.js' -o -name '*.sh' \ 1177 -o -name '*.bat' -o -name '*LICENSE' -o -name '*.d' -o -name '*store' \ 1178 -o -name 'blacklist' -o -name '*certs' -o -name '*.ttf' \ 1179 -o -name '*.jfc' -o -name '*.dat' -o -name 'release' -o -name '*.dir'\ 1180 -o -name '*.sym' -o -name '*.idl' -o -name '*.h' -o -name '*.access' \ 1181 -o -name '*.template' -o -name '*.policy' -o -name '*.security' \ 1182 -o -name 'COPYRIGHT' -o -name '*.1' -o -name '*.debuginfo' \ 1183 -o -name 'classlist' \) | $SORT | $FILTER) 1184 fi 1185 1186 if [ -n "$EXECS" ]; then 1187 echo Executables... 1188 print_binary_diff_header 1189 for e in $EXECS; do 1190 if [ -f "$OTHER_DIR/$e" ]; then 1191 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e 1192 if [ "$?" != "0" ]; then 1193 return_value=1 1194 fi 1195 fi 1196 done 1197 fi 1198 1199 return $return_value 1200 } 1201 1202 ################################################################################ 1203 # Initiate configuration 1204 1205 THIS="$SCRIPT_DIR" 1206 echo "$THIS" 1207 THIS_SCRIPT="$0" 1208 1209 if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then 1210 echo "bash ./compare.sh [OPTIONS] [FILTER]" 1211 echo "" 1212 echo "-all Compare all files in all known ways" 1213 echo "-names Compare the file names and directory structure" 1214 echo "-perms Compare the permission bits on all files and directories" 1215 echo "-types Compare the output of the file command on all files" 1216 echo "-general Compare the files not convered by the specialized comparisons" 1217 echo "-zips Compare the contents of all zip files and files in them" 1218 echo "-zips-names Compare the file names inside all zip files" 1219 echo "-jars Compare the contents of all jar files" 1220 echo "-jmods Compare the listings of all jmod files" 1221 echo "-libs Compare all native libraries" 1222 echo "-execs Compare all executables" 1223 echo "-v Verbose output, does not hide known differences" 1224 echo "-vv More verbose output, shows diff output of all comparisons" 1225 echo "-o [OTHER] Compare with build in other directory. Will default to the old build directory" 1226 echo "" 1227 echo "--sort-symbols Sort all symbols before comparing" 1228 echo "--strip Strip all binaries before comparing" 1229 echo "--clean Clean all previous comparison results first" 1230 echo "" 1231 echo "[FILTER] List filenames in the image to compare, works for jars, zips, libs and execs" 1232 echo "Example:" 1233 echo "bash ./make/scripts/compareimages.sh CodePointIM.jar" 1234 echo "" 1235 echo "-2zips <file1> <file2> Compare two zip files only" 1236 echo "-2bins <file1> <file2> Compare two binary files only" 1237 echo "-2dirs <dir1> <dir2> Compare two directories as if they were images" 1238 echo "" 1239 exit 10 1240 fi 1241 1242 CMP_NAMES=false 1243 CMP_PERMS=false 1244 CMP_TYPES=false 1245 CMP_GENERAL=false 1246 CMP_ZIPS=false 1247 CMP_ZIPS_CONTENTS=true 1248 CMP_JARS=false 1249 CMP_JMODS=false 1250 CMP_LIBS=false 1251 CMP_EXECS=false 1252 1253 while [ -n "$1" ]; do 1254 case "$1" in 1255 -v) 1256 VERBOSE=true 1257 ;; 1258 -vv) 1259 VERBOSE=true 1260 SHOW_DIFFS=true 1261 ;; 1262 -o) 1263 OTHER="$2" 1264 shift 1265 ;; 1266 -all) 1267 CMP_NAMES=true 1268 if [ "$OPENJDK_TARGET_OS" != "windows" ]; then 1269 CMP_PERMS=true 1270 fi 1271 CMP_TYPES=true 1272 CMP_GENERAL=true 1273 CMP_ZIPS=true 1274 CMP_JARS=true 1275 CMP_JMODS=true 1276 CMP_LIBS=true 1277 CMP_EXECS=true 1278 ;; 1279 -names) 1280 CMP_NAMES=true 1281 ;; 1282 -perms) 1283 CMP_PERMS=true 1284 ;; 1285 -types) 1286 CMP_TYPES=true 1287 ;; 1288 -general) 1289 CMP_GENERAL=true 1290 ;; 1291 -zips) 1292 CMP_ZIPS=true 1293 CMP_ZIPS_CONTENTS=true 1294 ;; 1295 -zips-names) 1296 CMP_ZIPS=true 1297 CMP_ZIPS_CONTENTS=false 1298 ;; 1299 -jars) 1300 CMP_JARS=true 1301 ;; 1302 -jmods) 1303 CMP_JMODS=true 1304 ;; 1305 -libs) 1306 CMP_LIBS=true 1307 ;; 1308 -execs) 1309 CMP_EXECS=true 1310 ;; 1311 -2dirs) 1312 THIS="$(cd "$2" > /dev/null && pwd )" 1313 OTHER="$(cd "$3" > /dev/null && pwd )" 1314 THIS_BASE_DIR="$THIS" 1315 OTHER_BASE_DIR="$OTHER" 1316 SKIP_DEFAULT=true 1317 shift 1318 shift 1319 ;; 1320 -2zips) 1321 CMP_2_ZIPS=true 1322 THIS_FILE=$2 1323 OTHER_FILE=$3 1324 shift 1325 shift 1326 ;; 1327 -2bins) 1328 CMP_2_BINS=true 1329 THIS_FILE=$2 1330 OTHER_FILE=$3 1331 shift 1332 shift 1333 ;; 1334 --sort-symbols) 1335 SORT_ALL_SYMBOLS=true 1336 ;; 1337 --strip) 1338 STRIP_ALL=true 1339 ;; 1340 --clean) 1341 CLEAN_OUTPUT=true 1342 ;; 1343 *) 1344 CMP_NAMES=false 1345 CMP_PERMS=false 1346 CMP_TYPES=false 1347 CMP_ZIPS=true 1348 CMP_JARS=true 1349 CMP_JMODS=true 1350 CMP_LIBS=true 1351 CMP_EXECS=true 1352 1353 if [ -z "$FILTER" ]; then 1354 FILTER="$GREP" 1355 fi 1356 FILTER="$FILTER -e $1" 1357 ;; 1358 esac 1359 shift 1360 done 1361 1362 if [ "$STRIP_ALL" = "true" ] && [ -z "$STRIP" ]; then 1363 echo Warning: Not stripping even with --strip, since strip is missing on this platform 1364 STRIP_ALL=false 1365 fi 1366 1367 COMPARE_ROOT=$OUTPUTDIR/compare-support 1368 if [ "$CLEAN_OUTPUT" = "true" ]; then 1369 echo Cleaning old output in $COMPARE_ROOT. 1370 $RM -rf $COMPARE_ROOT 1371 fi 1372 $MKDIR -p $COMPARE_ROOT 1373 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then 1374 if [ "$(uname -o)" = "Cygwin" ]; then 1375 COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT) 1376 fi 1377 fi 1378 1379 if [ "$CMP_2_ZIPS" = "true" ]; then 1380 THIS_DIR="$(dirname $THIS_FILE)" 1381 THIS_DIR="$(cd "$THIS_DIR" > /dev/null && pwd )" 1382 OTHER_DIR="$(dirname $OTHER_FILE)" 1383 OTHER_DIR="$(cd "$OTHER_DIR" > /dev/null && pwd )" 1384 THIS_FILE_NAME="$(basename $THIS_FILE)" 1385 OTHER_FILE_NAME="$(basename $OTHER_FILE)" 1386 echo Comparing $THIS_DIR/$THIS_FILE_NAME and $OTHER_DIR/$OTHER_FILE_NAME 1387 compare_zip_file $THIS_DIR $OTHER_DIR $COMPARE_ROOT/2zips $THIS_FILE_NAME $OTHER_FILE_NAME 1388 exit 1389 fi 1390 1391 if [ "$CMP_2_BINS" = "true" ]; then 1392 THIS_DIR="$(dirname $THIS_FILE)" 1393 THIS_DIR="$(cd "$THIS_DIR" > /dev/null && pwd )" 1394 OTHER_DIR="$(dirname $OTHER_FILE)" 1395 OTHER_DIR="$(cd "$OTHER_DIR" > /dev/null && pwd )" 1396 THIS_FILE_NAME="$(basename $THIS_FILE)" 1397 OTHER_FILE_NAME="$(basename $OTHER_FILE)" 1398 echo Comparing $THIS_DIR/$THIS_FILE_NAME and $OTHER_DIR/$OTHER_FILE_NAME 1399 compare_bin_file $THIS_DIR $OTHER_DIR $COMPARE_ROOT/2bins $THIS_FILE_NAME $OTHER_FILE_NAME 1400 exit 1401 fi 1402 1403 if [ "$CMP_NAMES" = "false" ] \ 1404 && [ "$CMP_TYPES" = "false" ] \ 1405 && [ "$CMP_PERMS" = "false" ] \ 1406 && [ "$CMP_GENERAL" = "false" ] \ 1407 && [ "$CMP_ZIPS" = "false" ] \ 1408 && [ "$CMP_JARS" = "false" ] \ 1409 && [ "$CMP_JMODS" = "false" ] \ 1410 && [ "$CMP_LIBS" = "false" ] \ 1411 && [ "$CMP_EXECS" = "false" ]; then 1412 CMP_NAMES=true 1413 CMP_PERMS=true 1414 CMP_TYPES=true 1415 CMP_GENERAL=true 1416 CMP_ZIPS=true 1417 CMP_JARS=true 1418 CMP_JMODS=true 1419 CMP_LIBS=true 1420 CMP_EXECS=true 1421 fi 1422 1423 if [ -z "$FILTER" ]; then 1424 FILTER="$CAT" 1425 fi 1426 1427 if [ "$SKIP_DEFAULT" != "true" ]; then 1428 if [ -z "$OTHER" ]; then 1429 echo "Nothing to compare to, set with -o" 1430 exit 1 1431 else 1432 if [ ! -d "$OTHER" ]; then 1433 echo "Other build directory does not exist:" 1434 echo "$OTHER" 1435 exit 1 1436 fi 1437 OTHER="$( cd "$OTHER" > /dev/null && pwd )" 1438 echo "Comparing to:" 1439 echo "$OTHER" 1440 echo 1441 fi 1442 1443 1444 # Find the common images to compare, prioritizing later build stages 1445 if [ -d "$THIS/install/jdk" ] && [ -d "$OTHER/install/jdk" ]; then 1446 THIS_JDK="$THIS/install/jdk" 1447 OTHER_JDK="$OTHER/install/jdk" 1448 echo "Selecting install images for JDK compare" 1449 elif [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/images/jdk" ]; then 1450 THIS_JDK="$THIS/images/jdk" 1451 OTHER_JDK="$OTHER/images/jdk" 1452 echo "Selecting normal images for JDK compare" 1453 elif [ -d "$(ls -d $THIS/licensee-src/build/*/images/jdk 2> /dev/null)" ] \ 1454 && [ -d "$(ls -d $OTHER/licensee-src/build/*/images/jdk 2> /dev/null)" ] 1455 then 1456 echo "Selecting licensee images for compare" 1457 # Simply override the THIS and OTHER dir with the build dir from 1458 # the nested licensee source build for the rest of the script 1459 # execution. 1460 OLD_THIS="$THIS" 1461 OLD_OTHER="$OTHER" 1462 THIS="$(ls -d $THIS/licensee-src/build/*)" 1463 OTHER="$(ls -d $OTHER/licensee-src/build/*)" 1464 THIS_JDK="$THIS/images/jdk" 1465 OTHER_JDK="$OTHER/images/jdk" 1466 # Rewrite the path to tools that are used from the build 1467 JIMAGE="$(echo "$JIMAGE" | $SED "s|$OLD_THIS|$THIS|g")" 1468 JMOD="$(echo "$JMOD" | $SED "s|$OLD_THIS|$THIS|g")" 1469 JAVAP="$(echo "$JAVAP" | $SED "s|$OLD_THIS|$THIS|g")" 1470 else 1471 echo "No common images found." 1472 exit 1 1473 fi 1474 echo " $THIS_JDK" 1475 echo " $OTHER_JDK" 1476 1477 if [ -d "$THIS/images/jdk-bundle" -o -d "$THIS/deploy/images/jdk-bundle" ] \ 1478 && [ -d "$OTHER/images/jdk-bundle" -o -d "$OTHER/deploy/images/jdk-bundle" ]; then 1479 if [ -d "$THIS/deploy/images/jdk-bundle" ]; then 1480 THIS_JDK_BUNDLE="$THIS/deploy/images/jdk-bundle" 1481 else 1482 THIS_JDK_BUNDLE="$THIS/images/jdk-bundle" 1483 fi 1484 if [ -d "$OTHER/deploy/images/jdk-bundle" ]; then 1485 OTHER_JDK_BUNDLE="$OTHER/deploy/images/jdk-bundle" 1486 else 1487 OTHER_JDK_BUNDLE="$OTHER/images/jdk-bundle" 1488 fi 1489 echo "Also comparing jdk macosx bundles" 1490 echo " $THIS_JDK_BUNDLE" 1491 echo " $OTHER_JDK_BUNDLE" 1492 fi 1493 1494 if [ -d "$THIS/deploy/bundles" -o -d "$THIS/deploy/images/bundles" ] \ 1495 && [ -d "$OTHER/deploy/bundles" -o -d "$OTHER/deploy/images/bundles" ]; then 1496 if [ -d "$THIS/deploy/images/bundles" ]; then 1497 THIS_DEPLOY_BUNDLE_DIR="$THIS/deploy/images/bundles" 1498 else 1499 THIS_DEPLOY_BUNDLE_DIR="$THIS/deploy/bundles" 1500 fi 1501 if [ -d "$OTHER/deploy/images/bundles" ]; then 1502 OTHER_DEPLOY_BUNDLE_DIR="$OTHER/deploy/images/bundles" 1503 else 1504 OTHER_DEPLOY_BUNDLE_DIR="$OTHER/deploy/bundles" 1505 fi 1506 echo "Also comparing deploy javadoc bundles" 1507 fi 1508 1509 if [ -d "$THIS/images/JavaAppletPlugin.plugin" ] \ 1510 && [ -d "$OTHER/images/JavaAppletPlugin.plugin" -o -d "$OTHER/deploy/images/JavaAppletPlugin.plugin" ]; then 1511 if [ -d "$THIS/images/JavaAppletPlugin.plugin" ]; then 1512 THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/images/JavaAppletPlugin.plugin" 1513 else 1514 THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/deploy/images/JavaAppletPlugin.plugin" 1515 fi 1516 if [ -d "$OTHER/images/JavaAppletPlugin.plugin" ]; then 1517 OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/images/JavaAppletPlugin.plugin" 1518 else 1519 OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/deploy/images/JavaAppletPlugin.plugin" 1520 fi 1521 echo "Also comparing deploy applet image" 1522 echo " $THIS_DEPLOY_APPLET_PLUGIN_DIR" 1523 echo " $OTHER_DEPLOY_APPLET_PLUGIN_DIR" 1524 fi 1525 1526 if [ -d "$THIS/install/sparkle/Sparkle.framework" ] \ 1527 && [ -d "$OTHER/install/sparkle/Sparkle.framework" ]; then 1528 THIS_SPARKLE_DIR="$THIS/install/sparkle/Sparkle.framework" 1529 OTHER_SPARKLE_DIR="$OTHER/install/sparkle/Sparkle.framework" 1530 echo "Also comparing install sparkle framework" 1531 echo " $THIS_SPARKLE_DIR" 1532 echo " $OTHER_SPARKLE_DIR" 1533 fi 1534 1535 THIS_SEC_DIR="$THIS/images" 1536 OTHER_SEC_DIR="$OTHER/images" 1537 if [ -f "$THIS_SEC_DIR/sec-bin.zip" ] && [ -f "$OTHER_SEC_DIR/sec-bin.zip" ]; then 1538 OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip" 1539 THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip" 1540 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then 1541 if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then 1542 JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip" 1543 else 1544 JGSS_WINDOWS_BIN="jgss-windows-i586-bin.zip" 1545 fi 1546 OTHER_SEC_WINDOWS_BIN="$OTHER_SEC_DIR/sec-windows-bin.zip" 1547 OTHER_JGSS_WINDOWS_BIN="$OTHER_SEC_DIR/$JGSS_WINDOWS_BIN" 1548 THIS_SEC_WINDOWS_BIN="$THIS_SEC_DIR/sec-windows-bin.zip" 1549 THIS_JGSS_WINDOWS_BIN="$THIS_SEC_DIR/$JGSS_WINDOWS_BIN" 1550 fi 1551 fi 1552 1553 if [ -d "$THIS/images/docs" ] && [ -d "$OTHER/images/docs" ]; then 1554 THIS_DOCS="$THIS/images/docs" 1555 OTHER_DOCS="$OTHER/images/docs" 1556 echo "Also comparing docs" 1557 else 1558 echo "WARNING! Docs haven't been built and won't be compared." 1559 fi 1560 fi 1561 1562 ################################################################################ 1563 # Do the work 1564 1565 if [ "$CMP_NAMES" = "true" ]; then 1566 if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then 1567 echo -n "JDK " 1568 compare_dirs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1569 echo -n "JDK " 1570 compare_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1571 fi 1572 if [ -n "$THIS_JDK_BUNDLE" ] && [ -n "$OTHER_JDK_BUNDLE" ]; then 1573 echo -n "JDK Bundle " 1574 compare_dirs $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle 1575 1576 echo -n "JDK Bundle " 1577 compare_files $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle 1578 fi 1579 if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then 1580 echo -n "Docs " 1581 compare_dirs $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs 1582 echo -n "Docs " 1583 compare_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs 1584 fi 1585 if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then 1586 compare_dirs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1587 compare_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1588 fi 1589 if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then 1590 echo -n "JavaAppletPlugin " 1591 compare_dirs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin 1592 echo -n "JavaAppletPlugin " 1593 compare_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin 1594 fi 1595 if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then 1596 echo -n "Sparkle.framework " 1597 compare_dirs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle 1598 echo -n "Sparkle.framework " 1599 compare_files $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle 1600 fi 1601 fi 1602 1603 if [ "$CMP_LIBS" = "true" ]; then 1604 if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then 1605 echo -n "JDK " 1606 compare_all_libs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1607 fi 1608 if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then 1609 compare_all_libs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1610 fi 1611 if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then 1612 echo -n "JavaAppletPlugin " 1613 compare_all_libs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin 1614 fi 1615 if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then 1616 echo -n "Sparkle.framework " 1617 compare_all_libs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle 1618 fi 1619 fi 1620 1621 if [ "$CMP_EXECS" = "true" ]; then 1622 if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then 1623 compare_all_execs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1624 fi 1625 if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then 1626 compare_all_execs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1627 fi 1628 if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then 1629 echo -n "JavaAppletPlugin " 1630 compare_all_execs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin 1631 fi 1632 if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then 1633 echo -n "Sparkle.framework " 1634 compare_all_execs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle 1635 fi 1636 fi 1637 1638 if [ "$CMP_GENERAL" = "true" ]; then 1639 if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then 1640 echo -n "JDK " 1641 compare_general_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1642 fi 1643 if [ -n "$THIS_JDK_BUNDLE" ] && [ -n "$OTHER_JDK_BUNDLE" ]; then 1644 echo -n "JDK Bundle " 1645 compare_general_files $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle 1646 fi 1647 if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then 1648 echo -n "Docs " 1649 compare_general_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs 1650 fi 1651 if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then 1652 compare_general_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1653 fi 1654 if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then 1655 echo -n "JavaAppletPlugin " 1656 compare_general_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin 1657 fi 1658 if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then 1659 echo -n "Sparkle.framework " 1660 compare_general_files $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle 1661 fi 1662 fi 1663 1664 if [ "$CMP_ZIPS" = "true" ]; then 1665 if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then 1666 compare_all_zip_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1667 fi 1668 if [ -n "$THIS_SEC_BIN" ] && [ -n "$OTHER_SEC_BIN" ]; then 1669 if [ -n "$(echo $THIS_SEC_BIN | $FILTER)" ]; then 1670 echo "sec-bin.zip..." 1671 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-bin.zip 1672 fi 1673 fi 1674 if [ -n "$THIS_SEC_WINDOWS_BIN" ] && [ -n "$OTHER_SEC_WINDOWS_BIN" ]; then 1675 if [ -n "$(echo $THIS_SEC_WINDOWS_BIN | $FILTER)" ]; then 1676 echo "sec-windows-bin.zip..." 1677 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-windows-bin.zip 1678 fi 1679 fi 1680 if [ -n "$THIS_JGSS_WINDOWS_BIN" ] && [ -n "$OTHER_JGSS_WINDOWS_BIN" ]; then 1681 if [ -n "$(echo $THIS_JGSS_WINDOWS_BIN | $FILTER)" ]; then 1682 echo "$JGSS_WINDOWS_BIN..." 1683 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin $JGSS_WINDOWS_BIN 1684 fi 1685 fi 1686 if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then 1687 compare_all_zip_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1688 fi 1689 if [ -n "$THIS_DEPLOY_BUNDLE_DIR" ] && [ -n "$OTHER_DEPLOY_BUNDLE_DIR" ]; then 1690 compare_all_zip_files $THIS_DEPLOY_BUNDLE_DIR $OTHER_DEPLOY_BUNDLE_DIR $COMPARE_ROOT/deploy-bundle 1691 fi 1692 if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then 1693 compare_all_zip_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin 1694 fi 1695 fi 1696 1697 if [ "$CMP_JARS" = "true" ]; then 1698 if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then 1699 compare_all_jar_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1700 fi 1701 if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then 1702 compare_all_jar_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1703 fi 1704 if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then 1705 compare_all_jar_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin 1706 fi 1707 fi 1708 1709 if [ "$CMP_JMODS" = "true" ]; then 1710 if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then 1711 compare_all_jmod_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1712 fi 1713 if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then 1714 compare_all_jmod_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1715 fi 1716 fi 1717 1718 if [ "$CMP_PERMS" = "true" ]; then 1719 if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then 1720 echo -n "JDK " 1721 compare_permissions $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1722 fi 1723 if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then 1724 compare_permissions $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1725 fi 1726 if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then 1727 echo -n "JavaAppletPlugin " 1728 compare_permissions $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin 1729 fi 1730 if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then 1731 echo -n "Sparkle.framework " 1732 compare_permissions $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle 1733 fi 1734 fi 1735 1736 if [ "$CMP_TYPES" = "true" ]; then 1737 if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then 1738 echo -n "JDK " 1739 compare_file_types $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk 1740 fi 1741 if [ -n "$THIS_JDK_BUNDLE" ] && [ -n "$OTHER_JDK_BUNDLE" ]; then 1742 echo -n "JDK Bundle " 1743 compare_file_types $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle 1744 fi 1745 if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then 1746 compare_file_types $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir 1747 fi 1748 if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then 1749 echo -n "JavaAppletPlugin " 1750 compare_file_types $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin 1751 fi 1752 if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then 1753 echo -n "Sparkle.framework " 1754 compare_file_types $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle 1755 fi 1756 fi 1757 1758 echo 1759 1760 if [ -n "$REGRESSIONS" ]; then 1761 echo "REGRESSIONS FOUND!" 1762 echo 1763 exit 1 1764 else 1765 echo "No regressions found" 1766 echo 1767 exit 0 1768 fi