common/bin/compare.sh

changeset 581
dc84b505b408
parent 574
db3984e4eb97
child 601
ea6379d4624f
equal deleted inserted replaced
555:4090847a5444 581:dc84b505b408
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 3 # Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # 5 #
6 # This code is free software; you can redistribute it and/or modify it 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 7 # under the terms of the GNU General Public License version 2 only, as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
96 # consequtive invokations seemingly randomly. 96 # consequtive invokations seemingly randomly.
97 # For example a method parameter randomly named "thePoint" or "aPoint". Ignore this. 97 # For example a method parameter randomly named "thePoint" or "aPoint". Ignore this.
98 if test "x$SUFFIX" = "xclass"; then 98 if test "x$SUFFIX" = "xclass"; then
99 # To improve performance when large diffs are found, do a rough filtering of classes 99 # To improve performance when large diffs are found, do a rough filtering of classes
100 # elibeble for these exceptions 100 # elibeble for these exceptions
101 if $GREP -R -e '[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}' -e thePoint -e aPoint -e setItemsPtr ${THIS_FILE} > /dev/null; then 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
102 $JAVAP -c -constants -l -p ${OTHER_FILE} > ${OTHER_FILE}.javap 104 $JAVAP -c -constants -l -p ${OTHER_FILE} > ${OTHER_FILE}.javap
103 $JAVAP -c -constants -l -p ${THIS_FILE} > ${THIS_FILE}.javap 105 $JAVAP -c -constants -l -p ${THIS_FILE} > ${THIS_FILE}.javap
104 TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \ 106 TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \
105 $GREP '^[<>]' | \ 107 $GREP '^[<>]' | \
106 $SED -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \ 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' \
107 -e '/[<>].*Point Lcom\/apple\/jobjc\/foundation\/NSPoint;/d' \ 110 -e '/[<>].*Point Lcom\/apple\/jobjc\/foundation\/NSPoint;/d' \
108 -e '/[<>].*public com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*itemsPtr();/d' \ 111 -e '/[<>].*public com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*itemsPtr();/d' \
109 -e '/[<>].*public void setItemsPtr(com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*);/d') 112 -e '/[<>].*public void setItemsPtr(com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*);/d')
110 fi 113 fi
111 fi 114 fi
112 if test "x$SUFFIX" = "xproperties"; then 115 if test "x$SUFFIX" = "xproperties"; then
113 $CAT $OTHER_FILE | $SED -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \ 116 # Run through nawk to add possibly missing newline at end of file.
114 | $SED -f "$SRC_ROOT/common/makefiles/support/unicode2x.sed" \ 117 $CAT $OTHER_FILE | $NAWK '{ print }' > $OTHER_FILE.cleaned
115 | $SED -e '/^#/d' -e '/^$/d' \ 118 # Disable this exception since we aren't changing the properties cleaning method yet.
116 -e :a -e '/\\$/N; s/\\\n//; ta' \ 119 # $CAT $OTHER_FILE | $SED -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \
117 -e 's/^[ \t]*//;s/[ \t]*$//' \ 120 # | $SED -f "$SRC_ROOT/common/makefiles/support/unicode2x.sed" \
118 -e 's/\\=/=/' | LANG=C $SORT > $OTHER_FILE.cleaned 121 # | $SED -e '/^#/d' -e '/^$/d' \
122 # -e :a -e '/\\$/N; s/\\\n//; ta' \
123 # -e 's/^[ \t]*//;s/[ \t]*$//' \
124 # -e 's/\\=/=/' | LANG=C $SORT > $OTHER_FILE.cleaned
119 TMP=$(LANG=C $DIFF $OTHER_FILE.cleaned $THIS_FILE) 125 TMP=$(LANG=C $DIFF $OTHER_FILE.cleaned $THIS_FILE)
120 fi 126 fi
121 if test -n "$TMP"; then 127 if test -n "$TMP"; then
122 echo Files $OTHER_FILE and $THIS_FILE differ 128 echo Files $OTHER_FILE and $THIS_FILE differ
123 return 1 129 return 1
303 # Ignore time stamps in docs files 309 # Ignore time stamps in docs files
304 OTHER_FILE=$WORK_DIR/$f.other 310 OTHER_FILE=$WORK_DIR/$f.other
305 THIS_FILE=$WORK_DIR/$f.this 311 THIS_FILE=$WORK_DIR/$f.this
306 $MKDIR -p $(dirname $OTHER_FILE) 312 $MKDIR -p $(dirname $OTHER_FILE)
307 $MKDIR -p $(dirname $THIS_FILE) 313 $MKDIR -p $(dirname $THIS_FILE)
314 #Note that | doesn't work on mac sed.
308 $CAT $OTHER_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \ 315 $CAT $OTHER_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
309 -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \ 316 -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \
310 -e 's/\(Monday\|Tuesday\|Wednesday\|Thursday\|Friday\|Saturday\|Sunday\), [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* \(AM\|PM\) [A-Z][A-Z]*/(removed)/' \ 317 -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)/' \
318 -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)/' \
311 -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \ 319 -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \
312 > $OTHER_FILE 320 > $OTHER_FILE
313 $CAT $THIS_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \ 321 $CAT $THIS_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
314 -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \ 322 -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \
315 -e 's/\(Monday\|Tuesday\|Wednesday\|Thursday\|Friday\|Saturday\|Sunday\), [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* \(AM\|PM\) [A-Z][A-Z]*/(removed)/' \ 323 -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)/' \
324 -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/' \ 325 -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \
317 > $THIS_FILE 326 > $THIS_FILE
318 else 327 else
319 OTHER_FILE=$OTHER_DIR/$f 328 OTHER_FILE=$OTHER_DIR/$f
320 THIS_FILE=$THIS_DIR/$f 329 THIS_FILE=$THIS_DIR/$f
368 $MKDIR -p $OTHER_UNZIPDIR 377 $MKDIR -p $OTHER_UNZIPDIR
369 (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP) 378 (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)
370 (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP) 379 (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)
371 380
372 # Find all archives inside and unzip them as well to compare the contents rather than 381 # Find all archives inside and unzip them as well to compare the contents rather than
373 # the archives. 382 # the archives. pie.jar.pack.gz i app3.war is corrupt, skip it.
374 EXCEPTIONS="" 383 EXCEPTIONS="pie.jar.pack.gz"
375 for pack in $($FIND $THIS_UNZIPDIR -name "*.pack" -o -name "*.pack.gz"); do 384 for pack in $($FIND $THIS_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do
376 ($UNPACK200 $pack $pack.jar) 385 ($UNPACK200 $pack $pack.jar)
377 # Filter out the unzipped archives from the diff below. 386 # Filter out the unzipped archives from the diff below.
378 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar" 387 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
379 done 388 done
380 for pack in $($FIND $OTHER_UNZIPDIR -name "*.pack" -o -name "*.pack.gz"); do 389 for pack in $($FIND $OTHER_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do
381 ($UNPACK200 $pack $pack.jar) 390 ($UNPACK200 $pack $pack.jar)
382 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar" 391 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
383 done 392 done
384 for zip in $($FIND $THIS_UNZIPDIR -name "*.jar" -o -name "*.zip"); do 393 for zip in $($FIND $THIS_UNZIPDIR -name "*.jar" -o -name "*.zip"); do
385 $MKDIR $zip.unzip 394 $MKDIR $zip.unzip
1071 echo 1080 echo
1072 fi 1081 fi
1073 1082
1074 1083
1075 # Figure out the layout of the this build. Which kinds of images have been produced 1084 # Figure out the layout of the this build. Which kinds of images have been produced
1076 if [ -d "$THIS/deploy/j2sdk-image" ]; then 1085 if [ -d "$THIS/install/j2sdk-image" ]; then
1086 THIS_J2SDK="$THIS/install/j2sdk-image"
1087 THIS_J2RE="$THIS/install/j2re-image"
1088 echo "Comparing install images"
1089 elif [ -d "$THIS/deploy/j2sdk-image" ]; then
1077 THIS_J2SDK="$THIS/deploy/j2sdk-image" 1090 THIS_J2SDK="$THIS/deploy/j2sdk-image"
1078 THIS_J2RE="$THIS/deploy/j2re-image" 1091 THIS_J2RE="$THIS/deploy/j2re-image"
1079 echo "Comparing deploy images" 1092 echo "Comparing deploy images"
1080 elif [ -d "$THIS/images/j2sdk-image" ]; then 1093 elif [ -d "$THIS/images/j2sdk-image" ]; then
1081 THIS_J2SDK="$THIS/images/j2sdk-image" 1094 THIS_J2SDK="$THIS/images/j2sdk-image"
1082 THIS_J2RE="$THIS/images/j2re-image" 1095 THIS_J2RE="$THIS/images/j2re-image"
1083 fi 1096 fi
1097
1084 if [ -d "$THIS/images/j2sdk-overlay-image" ]; then 1098 if [ -d "$THIS/images/j2sdk-overlay-image" ]; then
1085 THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image" 1099 if [ -d "$THIS/install/j2sdk-image" ]; then
1086 THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image" 1100 # If there is an install image, prefer that, it's also overlay
1101 THIS_J2SDK_OVERLAY="$THIS/install/j2sdk-image"
1102 THIS_J2RE_OVERLAY="$THIS/install/j2re-image"
1103 else
1104 THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image"
1105 THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image"
1106 fi
1087 fi 1107 fi
1088 1108
1089 if [ -d "$THIS/images/j2sdk-bundle" ]; then 1109 if [ -d "$THIS/images/j2sdk-bundle" ]; then
1090 THIS_J2SDK_BUNDLE="$THIS/images/j2sdk-bundle" 1110 THIS_J2SDK_BUNDLE="$THIS/images/j2sdk-bundle"
1091 THIS_J2RE_BUNDLE="$THIS/images/j2re-bundle" 1111 THIS_J2RE_BUNDLE="$THIS/images/j2re-bundle"
1098 OTHER_J2RE="$OTHER/j2re-image" 1118 OTHER_J2RE="$OTHER/j2re-image"
1099 else 1119 else
1100 OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image" 1120 OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image"
1101 OTHER_J2RE_OVERLAY="$OTHER/j2re-image" 1121 OTHER_J2RE_OVERLAY="$OTHER/j2re-image"
1102 fi 1122 fi
1103 1123 elif [ -d "$OTHER/images/j2sdk-image" ]; then
1124 OTHER_J2SDK="$OTHER/images/j2sdk-image"
1125 OTHER_J2RE="$OTHER/images/j2re-image"
1104 fi 1126 fi
1105 1127
1106 if [ -d "$OTHER/j2sdk-bundle" ]; then 1128 if [ -d "$OTHER/j2sdk-bundle" ]; then
1107 OTHER_J2SDK_BUNDLE="$OTHER/j2sdk-bundle" 1129 OTHER_J2SDK_BUNDLE="$OTHER/j2sdk-bundle"
1108 OTHER_J2RE_BUNDLE="$OTHER/j2re-bundle" 1130 OTHER_J2RE_BUNDLE="$OTHER/j2re-bundle"
1140 echo "WARNING! Docs haven't been built and won't be compared." 1162 echo "WARNING! Docs haven't been built and won't be compared."
1141 fi 1163 fi
1142 1164
1143 if [ -z "$OTHER_DOCS" ]; then 1165 if [ -z "$OTHER_DOCS" ]; then
1144 echo "WARNING! Other build doesn't contain docs, skipping doc compare." 1166 echo "WARNING! Other build doesn't contain docs, skipping doc compare."
1167 fi
1168
1169 if [ -d "$OTHER/images" ]; then
1170 OTHER_SEC_DIR="$OTHER/images"
1171 else
1172 OTHER_SEC_DIR="$OTHER/tmp"
1173 fi
1174 OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip"
1175 THIS_SEC_DIR="$THIS/images"
1176 THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip"
1177 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
1178 if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
1179 JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip"
1180 else
1181 JGSS_WINDOWS_BIN="jgss-windows-i586-bin.zip"
1182 fi
1183 OTHER_SEC_WINDOWS_BIN="$OTHER_SEC_DIR/sec-windows-bin.zip"
1184 OTHER_JGSS_WINDOWS_BIN="$OTHER_SEC_DIR/$JGSS_WINDOWS_BIN"
1185 THIS_SEC_WINDOWS_BIN="$THIS_SEC_DIR/sec-windows-bin.zip"
1186 THIS_JGSS_WINDOWS_BIN="$THIS_SEC_DIR/$JGSS_WINDOWS_BIN"
1145 fi 1187 fi
1146 1188
1147 ########################################################################################## 1189 ##########################################################################################
1148 # Do the work 1190 # Do the work
1149 1191
1258 1300
1259 if [ "$CMP_ZIPS" = "true" ]; then 1301 if [ "$CMP_ZIPS" = "true" ]; then
1260 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then 1302 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1261 compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk 1303 compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
1262 fi 1304 fi
1305 if [ -n "$THIS_SEC_BIN" ] && [ -n "$OTHER_SEC_BIN" ]; then
1306 if [ -n "$(echo $THIS_SEC_BIN | $FILTER)" ]; then
1307 echo "sec-bin.zip..."
1308 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-bin.zip
1309 fi
1310 fi
1311 if [ -n "$THIS_SEC_WINDOWS_BIN" ] && [ -n "$OTHER_SEC_WINDOWS_BIN" ]; then
1312 if [ -n "$(echo $THIS_SEC_WINDOWS_BIN | $FILTER)" ]; then
1313 echo "sec-windows-bin.zip..."
1314 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-windows-bin.zip
1315 fi
1316 fi
1317 if [ -n "$THIS_JGSS_WINDOWS_BIN" ] && [ -n "$OTHER_JGSS_WINDOWS_BIN" ]; then
1318 if [ -n "$(echo $THIS_JGSS_WINDOWS_BIN | $FILTER)" ]; then
1319 echo "$JGSS_WINDOWS_BIN..."
1320 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin $JGSS_WINDOWS_BIN
1321 fi
1322 fi
1263 fi 1323 fi
1264 1324
1265 if [ "$CMP_JARS" = "true" ]; then 1325 if [ "$CMP_JARS" = "true" ]; then
1266 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then 1326 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
1267 compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk 1327 compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk

mercurial