#!/bin/bash # # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. # # This script is processed by configure before it's usable. It is run from # the root of the build directory. ########################################################################################## # Substitutions from autoconf LEGACY_BUILD_DIR=@OPENJDK_TARGET_OS@-@OPENJDK_TARGET_CPU_LEGACY@ OPENJDK_TARGET_OS="@OPENJDK_TARGET_OS@" OPENJDK_TARGET_CPU="@OPENJDK_TARGET_CPU@" AWK="@AWK@" CAT="@CAT@" CMP="@CMP@" CP="@CP@" CUT="@CUT@" DIFF="@DIFF@" DUMPBIN="@UNCYGDRIVE@ @DUMPBIN@" EXPR="@EXPR@" FILE="@FILE@" FIND="@FIND@" GREP="@GREP@" JAVAP="@UNCYGDRIVE@ @BOOT_JDK@/bin/javap" LDD="@LDD@" MKDIR="@MKDIR@" NM="@NM@" OBJDUMP="@OBJDUMP@" OTOOL="@OTOOL@" PRINTF="@PRINTF@" READELF="@READELF@" RM="@RM@" SED="@SED@" SORT="@SORT@" STRIP="@POST_STRIP_CMD@" TEE="@TEE@" UNIQ="@UNIQ@" UNZIP="@UNZIP@" SRC_ROOT="@SRC_ROOT@" if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then READELF_CMD="otool -v -V -h -X -t -d" elif [ -n "$READELF" ] && [ "$OPENJDK_TARGET_OS" != "windows" ]; then READELF_CMD="$READELF -a" fi if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then LDD_CMD="$OTOOL -L" elif [ -n "$LDD" ]; then LDD_CMD="$LDD" fi ########################################################################################## # Diff exceptions if [ "$OPENJDK_TARGET_OS" = "linux" ] && [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then STRIP_BEFORE_COMPARE=" ./demo/jvmti/compiledMethodLoad/lib/libcompiledMethodLoad.so ./demo/jvmti/gctest/lib/libgctest.so ./demo/jvmti/heapTracker/lib/libheapTracker.so ./demo/jvmti/heapViewer/lib/libheapViewer.so ./demo/jvmti/hprof/lib/libhprof.so ./demo/jvmti/minst/lib/libminst.so ./demo/jvmti/mtrace/lib/libmtrace.so ./demo/jvmti/versionCheck/lib/libversionCheck.so ./demo/jvmti/waiters/lib/libwaiters.so " KNOWN_BIN_DIFF=" " ACCEPTED_BIN_DIFF=" ./demo/jvmti/compiledMethodLoad/lib/libcompiledMethodLoad.so ./demo/jvmti/gctest/lib/libgctest.so ./demo/jvmti/heapTracker/lib/libheapTracker.so ./demo/jvmti/heapViewer/lib/libheapViewer.so ./demo/jvmti/hprof/lib/libhprof.so ./demo/jvmti/minst/lib/libminst.so ./demo/jvmti/mtrace/lib/libmtrace.so ./demo/jvmti/versionCheck/lib/libversionCheck.so ./demo/jvmti/waiters/lib/libwaiters.so ./jre/lib/amd64/libattach.so ./jre/lib/amd64/libdt_socket.so ./jre/lib/amd64/libhprof.so ./jre/lib/amd64/libinstrument.so ./jre/lib/amd64/libjava_crw_demo.so ./jre/lib/amd64/libjsdt.so ./jre/lib/amd64/libjsig.so ./jre/lib/amd64/libmanagement.so ./jre/lib/amd64/libnpt.so ./jre/lib/amd64/libsaproc.so ./jre/lib/amd64/libverify.so ./jre/lib/amd64/server/libjsig.so ./jre/lib/amd64/server/libjvm.so ./bin/appletviewer ./bin/extcheck ./bin/idlj ./bin/jar ./bin/jarsigner ./bin/java ./bin/javac ./bin/javadoc ./bin/javah ./bin/javap ./bin/jcmd ./bin/jconsole ./bin/jdb ./bin/jhat ./bin/jinfo ./bin/jmap ./bin/jps ./bin/jrunscript ./bin/jsadebugd ./bin/jstack ./bin/jstat ./bin/jstatd ./bin/keytool ./bin/native2ascii ./bin/orbd ./bin/pack200 ./bin/policytool ./bin/rmic ./bin/rmid ./bin/rmiregistry ./bin/schemagen ./bin/serialver ./bin/servertool ./bin/tnameserv ./bin/wsgen ./bin/wsimport ./bin/xjc ./jre/bin/java ./jre/bin/keytool ./jre/bin/orbd ./jre/bin/pack200 ./jre/bin/policytool ./jre/bin/rmid ./jre/bin/rmiregistry ./jre/bin/servertool ./jre/bin/tnameserv " KNOWN_SIZE_DIFF=" " KNOWN_SYM_DIFF=" " KNOWN_ELF_DIFF=" ./demo/jvmti/heapTracker/lib/libheapTracker.so ./demo/jvmti/hprof/lib/libhprof.so ./demo/jvmti/waiters/lib/libwaiters.so " fi if [ "$OPENJDK_TARGET_OS" = "solaris" ] && [ "$OPENJDK_TARGET_CPU" = "x86" ]; then STRIP_BEFORE_COMPARE=" ./demo/jni/Poller/lib/libPoller.so ./demo/jvmti/compiledMethodLoad/lib/libcompiledMethodLoad.so ./demo/jvmti/gctest/lib/libgctest.so ./demo/jvmti/heapTracker/lib/libheapTracker.so ./demo/jvmti/heapViewer/lib/libheapViewer.so ./demo/jvmti/hprof/lib/libhprof.so ./demo/jvmti/minst/lib/libminst.so ./demo/jvmti/mtrace/lib/libmtrace.so ./demo/jvmti/versionCheck/lib/libversionCheck.so ./demo/jvmti/waiters/lib/libwaiters.so ./jre/lib/i386/jexec " SORT_SYMBOLS=" ./jre/lib/i386/client/libjvm.so ./jre/lib/i386/server/libjvm.so " SKIP_BIN_DIFF="true" ACCEPTED_SMALL_SIZE_DIFF=" ./demo/jni/Poller/lib/libPoller.so ./demo/jvmti/compiledMethodLoad/lib/libcompiledMethodLoad.so ./demo/jvmti/gctest/lib/libgctest.so ./demo/jvmti/heapTracker/lib/libheapTracker.so ./demo/jvmti/heapViewer/lib/libheapViewer.so ./demo/jvmti/hprof/lib/libhprof.so ./demo/jvmti/minst/lib/libminst.so ./demo/jvmti/mtrace/lib/libmtrace.so ./demo/jvmti/versionCheck/lib/libversionCheck.so ./demo/jvmti/waiters/lib/libwaiters.so ./jre/lib/i386/client/libjvm.so ./jre/lib/i386/jli/libjli.so ./jre/lib/i386/libJdbcOdbc.so ./jre/lib/i386/libattach.so ./jre/lib/i386/libawt.so ./jre/lib/i386/libawt_headless.so ./jre/lib/i386/libawt_xawt.so ./jre/lib/i386/libdcpr.so ./jre/lib/i386/libdt_socket.so ./jre/lib/i386/libfontmanager.so ./jre/lib/i386/libhprof.so ./jre/lib/i386/libinstrument.so ./jre/lib/i386/libj2gss.so ./jre/lib/i386/libj2pcsc.so ./jre/lib/i386/libj2pkcs11.so ./jre/lib/i386/libj2ucrypto.so ./jre/lib/i386/libjaas_unix.so ./jre/lib/i386/libjava.so ./jre/lib/i386/libjava_crw_demo.so ./jre/lib/i386/libjawt.so ./jre/lib/i386/libjdwp.so ./jre/lib/i386/libjfr.so ./jre/lib/i386/libjpeg.so ./jre/lib/i386/libjsdt.so ./jre/lib/i386/libjsound.so ./jre/lib/i386/libkcms.so ./jre/lib/i386/libmanagement.so ./jre/lib/i386/libmlib_image.so ./jre/lib/i386/libnet.so ./jre/lib/i386/libnio.so ./jre/lib/i386/libnpt.so ./jre/lib/i386/libsctp.so ./jre/lib/i386/libsplashscreen.so ./jre/lib/i386/libsunec.so ./jre/lib/i386/libsunwjdga.so ./jre/lib/i386/libt2k.so ./jre/lib/i386/libunpack.so ./jre/lib/i386/libverify.so ./jre/lib/i386/libzip.so ./jre/lib/i386/server/libjvm.so ./bin/appletviewer ./bin/extcheck ./bin/idlj ./bin/jar ./bin/jarsigner ./bin/java ./bin/javac ./bin/javadoc ./bin/javah ./bin/javap ./bin/jcmd ./bin/jconsole ./bin/jdb ./bin/jhat ./bin/jinfo ./bin/jmap ./bin/jps ./bin/jrunscript ./bin/jsadebugd ./bin/jstack ./bin/jstat ./bin/jstatd ./bin/keytool ./bin/native2ascii ./bin/orbd ./bin/pack200 ./bin/policytool ./bin/rmic ./bin/rmid ./bin/rmiregistry ./bin/schemagen ./bin/serialver ./bin/servertool ./bin/tnameserv ./bin/unpack200 ./bin/wsgen ./bin/wsimport ./bin/xjc ./jre/bin/java ./jre/bin/keytool ./jre/bin/orbd ./jre/bin/pack200 ./jre/bin/policytool ./jre/bin/rmid ./jre/bin/rmiregistry ./jre/bin/servertool ./jre/bin/tnameserv ./jre/bin/unpack200 ./jre/lib/i386/jexec " SKIP_ELF_DIFF="true" # libjvm.so differs in the random 15 char prefix on some symbols. ACCEPTED_DIS_DIFF=" ./jre/lib/i386/client/libjvm.so ./jre/lib/i386/server/libjvm.so " fi if [ "$OPENJDK_TARGET_OS" = "solaris" ] && [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then STRIP_BEFORE_COMPARE=" ./demo/jni/Poller/lib/amd64/libPoller.so ./demo/jvmti/compiledMethodLoad/lib/amd64/libcompiledMethodLoad.so ./demo/jvmti/gctest/lib/amd64/libgctest.so ./demo/jvmti/heapTracker/lib/amd64/libheapTracker.so ./demo/jvmti/heapViewer/lib/amd64/libheapViewer.so ./demo/jvmti/hprof/lib/amd64/libhprof.so ./demo/jvmti/minst/lib/amd64/libminst.so ./demo/jvmti/mtrace/lib/amd64/libmtrace.so ./demo/jvmti/versionCheck/lib/amd64/libversionCheck.so ./demo/jvmti/waiters/lib/amd64/libwaiters.so " SORT_SYMBOLS=" ./jre/lib/amd64/server/libjvm.so " SKIP_BIN_DIFF="true" ACCEPTED_SMALL_SIZE_DIFF=" ./demo/jni/Poller/lib/amd64/libPoller.so ./demo/jvmti/compiledMethodLoad/lib/amd64/libcompiledMethodLoad.so ./demo/jvmti/gctest/lib/amd64/libgctest.so ./demo/jvmti/heapTracker/lib/amd64/libheapTracker.so ./demo/jvmti/heapViewer/lib/amd64/libheapViewer.so ./demo/jvmti/hprof/lib/amd64/libhprof.so ./demo/jvmti/minst/lib/amd64/libminst.so ./demo/jvmti/mtrace/lib/amd64/libmtrace.so ./demo/jvmti/versionCheck/lib/amd64/libversionCheck.so ./demo/jvmti/waiters/lib/amd64/libwaiters.so ./jre/lib/amd64/jli/libjli.so ./jre/lib/amd64/libJdbcOdbc.so ./jre/lib/amd64/libattach.so ./jre/lib/amd64/libawt.so ./jre/lib/amd64/libawt_headless.so ./jre/lib/amd64/libawt_xawt.so ./jre/lib/amd64/libdcpr.so ./jre/lib/amd64/libdt_socket.so ./jre/lib/amd64/libfontmanager.so ./jre/lib/amd64/libhprof.so ./jre/lib/amd64/libinstrument.so ./jre/lib/amd64/libj2gss.so ./jre/lib/amd64/libj2pcsc.so ./jre/lib/amd64/libj2pkcs11.so ./jre/lib/amd64/libj2ucrypto.so ./jre/lib/amd64/libjaas_unix.so ./jre/lib/amd64/libjava.so ./jre/lib/amd64/libjava_crw_demo.so ./jre/lib/amd64/libjawt.so ./jre/lib/amd64/libjdwp.so ./jre/lib/amd64/libjfr.so ./jre/lib/amd64/libjpeg.so ./jre/lib/amd64/libjsdt.so ./jre/lib/amd64/libjsound.so ./jre/lib/amd64/libkcms.so ./jre/lib/amd64/libmanagement.so ./jre/lib/amd64/libmlib_image.so ./jre/lib/amd64/libnet.so ./jre/lib/amd64/libnio.so ./jre/lib/amd64/libnpt.so ./jre/lib/amd64/libsctp.so ./jre/lib/amd64/libsplashscreen.so ./jre/lib/amd64/libsunec.so ./jre/lib/amd64/libsunwjdga.so ./jre/lib/amd64/libt2k.so ./jre/lib/amd64/libunpack.so ./jre/lib/amd64/libverify.so ./jre/lib/amd64/libzip.so ./jre/lib/amd64/server/64/libjvm_db.so ./jre/lib/amd64/server/64/libjvm_dtrace.so ./bin/amd64/appletviewer ./bin/amd64/extcheck ./bin/amd64/idlj ./bin/amd64/jar ./bin/amd64/jarsigner ./bin/amd64/java ./bin/amd64/javac ./bin/amd64/javadoc ./bin/amd64/javah ./bin/amd64/javap ./bin/amd64/jcmd ./bin/amd64/jconsole ./bin/amd64/jdb ./bin/amd64/jhat ./bin/amd64/jinfo ./bin/amd64/jmap ./bin/amd64/jps ./bin/amd64/jrunscript ./bin/amd64/jsadebugd ./bin/amd64/jstack ./bin/amd64/jstat ./bin/amd64/jstatd ./bin/amd64/keytool ./bin/amd64/native2ascii ./bin/amd64/orbd ./bin/amd64/pack200 ./bin/amd64/policytool ./bin/amd64/rmic ./bin/amd64/rmid ./bin/amd64/rmiregistry ./bin/amd64/schemagen ./bin/amd64/serialver ./bin/amd64/servertool ./bin/amd64/tnameserv ./bin/amd64/unpack200 ./bin/amd64/wsgen ./bin/amd64/wsimport ./bin/amd64/xjc ./jre/bin/amd64/java ./jre/bin/amd64/keytool ./jre/bin/amd64/orbd ./jre/bin/amd64/pack200 ./jre/bin/amd64/policytool ./jre/bin/amd64/rmid ./jre/bin/amd64/rmiregistry ./jre/bin/amd64/servertool ./jre/bin/amd64/tnameserv ./jre/bin/amd64/unpack200 ./jre/lib/amd64/jexec " SKIP_ELF_DIFF="true" # Can't find an explaination for the diff in libmlib_image.so. KNOWN_DIS_DIFF=" ./jre/lib/amd64/libmlib_image.so " # libjvm.so differs in the random 15 char prefix on some symbols. ACCEPTED_DIS_DIFF=" ./jre/lib/amd64/server/libjvm.so " fi if [ "$OPENJDK_TARGET_OS" = "windows" ] && [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then ACCEPTED_BIN_DIFF=" ./bin/jli.dll ./demo/jvmti/compiledMethodLoad/lib/compiledMethodLoad.dll ./demo/jvmti/gctest/lib/gctest.dll ./demo/jvmti/heapTracker/lib/heapTracker.dll ./demo/jvmti/heapViewer/lib/heapViewer.dll ./demo/jvmti/hprof/lib/hprof.dll ./demo/jvmti/minst/lib/minst.dll ./demo/jvmti/mtrace/lib/mtrace.dll ./demo/jvmti/versionCheck/lib/versionCheck.dll ./demo/jvmti/waiters/lib/waiters.dll ./jre/bin/attach.dll ./jre/bin/awt.dll ./jre/bin/dcpr.dll ./jre/bin/dt_shmem.dll ./jre/bin/dt_socket.dll ./jre/bin/fontmanager.dll ./jre/bin/hprof.dll ./jre/bin/instrument.dll ./jre/bin/j2pcsc.dll ./jre/bin/j2pkcs11.dll ./jre/bin/jaas_nt.dll ./jre/bin/java.dll ./jre/bin/java_crw_demo.dll ./jre/bin/jawt.dll ./jre/bin/JdbcOdbc.dll ./jre/bin/jdwp.dll ./jre/bin/jfr.dll ./jre/bin/jli.dll ./jre/bin/jpeg.dll ./jre/bin/jsdt.dll ./jre/bin/jsound.dll ./jre/bin/jsoundds.dll ./jre/bin/kcms.dll ./jre/bin/management.dll ./jre/bin/mlib_image.dll ./jre/bin/net.dll ./jre/bin/nio.dll ./jre/bin/npt.dll ./jre/bin/sawindbg.dll ./jre/bin/server/jvm.dll ./jre/bin/splashscreen.dll ./jre/bin/sunec.dll ./jre/bin/sunmscapi.dll ./jre/bin/t2k.dll ./jre/bin/unpack.dll ./jre/bin/verify.dll ./jre/bin/w2k_lsa_auth.dll ./jre/bin/zip.dll ./bin/appletviewer.exe ./bin/extcheck.exe ./bin/idlj.exe ./bin/jar.exe ./bin/jarsigner.exe ./bin/java.exe ./bin/javac.exe ./bin/javadoc.exe ./bin/javah.exe ./bin/javap.exe ./bin/java-rmi.exe ./bin/javaw.exe ./bin/jcmd.exe ./bin/jconsole.exe ./bin/jdb.exe ./bin/jhat.exe ./bin/jinfo.exe ./bin/jmap.exe ./bin/jps.exe ./bin/jrunscript.exe ./bin/jsadebugd.exe ./bin/jstack.exe ./bin/jstat.exe ./bin/jstatd.exe ./bin/keytool.exe ./bin/kinit.exe ./bin/klist.exe ./bin/ktab.exe ./bin/native2ascii.exe ./bin/orbd.exe ./bin/pack200.exe ./bin/policytool.exe ./bin/rmic.exe ./bin/rmid.exe ./bin/rmiregistry.exe ./bin/schemagen.exe ./bin/serialver.exe ./bin/servertool.exe ./bin/tnameserv.exe ./bin/unpack200.exe ./bin/wsgen.exe ./bin/wsimport.exe ./bin/xjc.exe ./jre/bin/java.exe ./jre/bin/java-rmi.exe ./jre/bin/javaw.exe ./jre/bin/keytool.exe ./jre/bin/kinit.exe ./jre/bin/klist.exe ./jre/bin/ktab.exe ./jre/bin/orbd.exe ./jre/bin/pack200.exe ./jre/bin/policytool.exe ./jre/bin/rmid.exe ./jre/bin/rmiregistry.exe ./jre/bin/servertool.exe ./jre/bin/tnameserv.exe ./jre/bin/unpack200.exe " KNOWN_SIZE_DIFF=" ./demo/jvmti/heapTracker/lib/heapTracker.dll ./demo/jvmti/minst/lib/minst.dll ./jre/bin/awt.dll ./jre/bin/java_crw_demo.dll ./bin/java.exe ./bin/javaw.exe ./bin/unpack200.exe ./jre/bin/java.exe ./jre/bin/javaw.exe ./jre/bin/unpack200.exe " KNOWN_SYM_DIFF=" ./jre/bin/awt.dll ./jre/bin/java_crw_demo.dll " fi if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then ACCEPTED_JARZIP_CONTENTS=" /META-INF/INDEX.LIST " KNOWN_BIN_DIFF=" ./jre/lib/libJObjC.dylib ./jre/lib/libsaproc.dylib ./jre/lib/server/libjvm.dylib " ACCEPTED_BIN_DIFF=" ./bin/appletviewer ./bin/extcheck ./bin/idlj ./bin/jar ./bin/jarsigner ./bin/java ./bin/javac ./bin/javadoc ./bin/javah ./bin/javap ./bin/jcmd ./bin/jconsole ./bin/jdb ./bin/jhat ./bin/jinfo ./bin/jmap ./bin/jps ./bin/jrunscript ./bin/jsadebugd ./bin/jstack ./bin/jstat ./bin/jstatd ./bin/keytool ./bin/native2ascii ./bin/orbd ./bin/pack200 ./bin/policytool ./bin/rmic ./bin/rmid ./bin/rmiregistry ./bin/schemagen ./bin/serialver ./bin/servertool ./bin/tnameserv ./bin/wsgen ./bin/wsimport ./bin/xjc ./jre/bin/java ./jre/bin/keytool ./jre/bin/orbd ./jre/bin/pack200 ./jre/bin/policytool ./jre/bin/rmid ./jre/bin/rmiregistry ./jre/bin/servertool ./jre/bin/tnameserv " KNOWN_SIZE_DIFF=" ./jre/lib/libJObjC.dylib ./jre/lib/server/libjvm.dylib " KNOWN_SYM_DIFF=" ./jre/lib/libJObjC.dylib ./jre/lib/server/libjvm.dylib " KNOWN_ELF_DIFF=" ./jre/lib/libJObjC.dylib ./jre/lib/server/libjvm.dylib " SKIP_DIS_DIFF="true" fi ########################################################################################## # Compare text files and ignore specific differences: # # * Timestamps in Java sources generated by idl2java # * Sorting order and cleanup style in .properties files diff_text() { OTHER_FILE=$1 THIS_FILE=$2 SUFFIX="${THIS_FILE##*.}" TMP=1 if [[ "$THIS_FILE" = *"META-INF/MANIFEST.MF" ]]; then TMP=$(LANG=C $DIFF $OTHER_FILE $THIS_FILE | \ $GREP '^[<>]' | \ $SED -e '/[<>] Ant-Version: Apache Ant .*/d' \ -e '/[<>] Created-By: .* (Oracle Corporation).*/d') fi if test "x$SUFFIX" = "xjava"; then TMP=$(LANG=C $DIFF $OTHER_FILE $THIS_FILE | \ $GREP '^[<>]' | \ $SED -e '/[<>] \* from.*\.idl/d' \ -e '/[<>] \*.*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \ -e '/[<>] \*.*[0-9]\{4\} [0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \ -e '/\/\/ Generated from input file.*/d' \ -e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \ -e '/\/\/ java GenerateCharacter.*/d') fi # Ignore date strings in class files. # On Macosx the system sources for generated java classes produce different output on # consequtive invokations seemingly randomly. # For example a method parameter randomly named "thePoint" or "aPoint". Ignore this. if test "x$SUFFIX" = "xclass"; then $JAVAP -c -constants -l -p ${OTHER_FILE} > ${OTHER_FILE}.javap $JAVAP -c -constants -l -p ${THIS_FILE} > ${THIS_FILE}.javap TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \ $GREP '^[<>]' | \ $SED -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \ -e '/[<>].*Point Lcom\/apple\/jobjc\/foundation\/NSPoint;/d' \ -e '/[<>].*public com\.apple\.jobjc\.Pointer].*public void setItemsPtr(com\.apple\.jobjc\.Pointer $OTHER_FILE.cleaned TMP=$(LANG=C $DIFF $OTHER_FILE.cleaned $THIS_FILE) fi if test -n "$TMP"; then echo Files $OTHER_FILE and $THIS_FILE differ return 1 fi return 0 } ########################################################################################## # Compare directory structure compare_dirs() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 mkdir -p $WORK_DIR (cd $OTHER_DIR && $FIND . -type d | $SORT > $WORK_DIR/other_dirs) (cd $THIS_DIR && $FIND . -type d | $SORT > $WORK_DIR/this_dirs) echo -n Directory structure... if $DIFF $WORK_DIR/other_dirs $WORK_DIR/this_dirs > /dev/null; then echo Identical! else echo Differences found. REGRESSIONS=true # Differences in directories found. ONLY_OTHER=$($DIFF $WORK_DIR/other_dirs $WORK_DIR/this_dirs | $GREP '<') if [ "$ONLY_OTHER" ]; then echo Only in $OTHER echo $ONLY_OTHER | $SED 's|< ./|\t|g' | $SED 's/ /\n/g' fi # Differences in directories found. ONLY_THIS=$($DIFF $WORK_DIR/other_dirs $WORK_DIR/this_dirs | $GREP '>') if [ "$ONLY_THIS" ]; then echo Only in $THIS echo $ONLY_THIS | $SED 's|> ./|\t|g' | $SED 's/ /\n/g' fi fi } ########################################################################################## # Compare file structure compare_files() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 mkdir -p $WORK_DIR (cd $OTHER_DIR && $FIND . -type f | $SORT > $WORK_DIR/other_files) (cd $THIS_DIR && $FIND . -type f | $SORT > $WORK_DIR/this_files) echo -n File names... if diff $WORK_DIR/other_files $WORK_DIR/this_files > /dev/null; then echo Identical! else echo Differences found. REGRESSIONS=true # Differences in directories found. ONLY_OTHER=$(diff $WORK_DIR/other_files $WORK_DIR/this_files | $GREP '<') if [ "$ONLY_OTHER" ]; then echo Only in $OTHER echo "$ONLY_OTHER" | sed 's|< ./| |g' fi # Differences in directories found. ONLY_THIS=$(diff $WORK_DIR/other_files $WORK_DIR/this_files | $GREP '>') if [ "$ONLY_THIS" ]; then echo Only in $THIS echo "$ONLY_THIS" | sed 's|> ./| |g' fi fi } ########################################################################################## # Compare permissions compare_permissions() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 mkdir -p $WORK_DIR echo -n Permissions... found="" for f in `cd $OTHER_DIR && $FIND . -type f` do if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi if [ ! -f ${THIS_DIR}/$f ]; then continue; fi OP=`ls -l ${OTHER_DIR}/$f | awk '{printf("%.10s\n", $1);}'` TP=`ls -l ${THIS_DIR}/$f | awk '{printf("%.10s\n", $1);}'` if [ "$OP" != "$TP" ] then if [ -z "$found" ]; then echo ; found="yes"; fi $PRINTF "\told: ${OP} new: ${TP}\t$f\n" fi done if [ -z "$found" ]; then echo "Identical!" else REGRESSIONS=true fi } ########################################################################################## # Compare file command output compare_file_types() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 $MKDIR -p $WORK_DIR echo -n File types... found="" for f in `cd $OTHER_DIR && $FIND . -type f` do if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi if [ ! -f ${THIS_DIR}/$f ]; then continue; fi OF=`cd ${OTHER_DIR} && $FILE $f` TF=`cd ${THIS_DIR} && $FILE $f` if [ "$f" = "./src.zip" ] || [ "$f" = "./jre/lib/JObjC.jar" ] || [ "$f" = "./lib/JObjC.jar" ] then if [ "`echo $OF | $GREP -ic zip`" -gt 0 -a "`echo $TF | $GREP -ic zip`" -gt 0 ] then # the way we produces zip-files make it so that directories are stored in old file # but not in new (only files with full-path) # this makes file-5.09 report them as different continue; fi fi if [ "$OF" != "$TF" ] then if [ -z "$found" ]; then echo ; found="yes"; fi $PRINTF "\tother: ${OF}\n\tthis : ${TF}\n" fi done if [ -z "$found" ]; then echo "Identical!" else REGRESSIONS=true fi } ########################################################################################## # Compare the rest of the files compare_general_files() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 GENERAL_FILES=$(cd $THIS_DIR && $FIND . -type f ! -name "*.so" ! -name "*.jar" ! -name "*.zip" \ ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \ ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \ ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \ ! -name "*.lib" \ | $GREP -v "./bin/" | $SORT | $FILTER) echo General files... for f in $GENERAL_FILES do if [ -e $OTHER_DIR/$f ]; then DIFF_OUT=$($DIFF $OTHER_DIR/$f $THIS_DIR/$f 2>&1) if [ -n "$DIFF_OUT" ]; then echo $f REGRESSIONS=true if [ "$SHOW_DIFFS" = "true" ]; then echo "$DIFF_OUT" fi fi fi done } ########################################################################################## # Compare zip file compare_zip_file() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 ZIP_FILE=$4 THIS_ZIP=$THIS_DIR/$ZIP_FILE OTHER_ZIP=$OTHER_DIR/$ZIP_FILE THIS_SUFFIX="${THIS_ZIP##*.}" OTHER_SUFFIX="${OTHER_ZIP##*.}" if [ "$THIS_SUFFIX" != "$OTHER_SUFFIX" ]; then echo The files do not have the same suffix type! return 2 fi UNARCHIVE="$UNZIP -q" TYPE="$THIS_SUFFIX" if $CMP $OTHER_ZIP $THIS_ZIP > /dev/null then return 0 fi # Not quite identical, the might still contain the same data. # Unpack the jar/zip files in temp dirs THIS_UNZIPDIR=$WORK_DIR/$ZIP_FILE.this OTHER_UNZIPDIR=$WORK_DIR/$ZIP_FILE.other $RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR $MKDIR -p $THIS_UNZIPDIR $MKDIR -p $OTHER_UNZIPDIR (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP) (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP) CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff LANG=C $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE) ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE) return_value=0 if [ -n "$ONLY_OTHER" ]; then echo " Only OTHER $ZIP_FILE contains:" echo "$ONLY_OTHER" | sed "s|Only in $OTHER_UNZIPDIR| |"g | sed 's|: |/|g' return_value=1 fi if [ -n "$ONLY_THIS" ]; then echo " Only THIS $ZIP_FILE contains:" echo "$ONLY_THIS" | sed "s|Only in $THIS_UNZIPDIR| |"g | sed 's|: |/|g' return_value=1 fi DIFFING_FILES=$($GREP differ $CONTENTS_DIFF_FILE | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g") $RM -f $WORK_DIR/$ZIP_FILE.diffs for file in $DIFFING_FILES; do if [[ "$ACCEPTED_JARZIP_CONTENTS" != *"$file"* ]]; then diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs fi done if [ -s "$WORK_DIR/$ZIP_FILE.diffs" ]; then return_value=1 echo " Differing files in $ZIP_FILE" $CAT $WORK_DIR/$ZIP_FILE.diffs | $GREP differ | cut -f 2 -d ' ' | \ $SED "s|$OTHER_UNZIPDIR| |g" > $WORK_DIR/$ZIP_FILE.difflist $CAT $WORK_DIR/$ZIP_FILE.difflist if [ -n "$SHOW_DIFFS" ]; then for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then LANG=C $DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then LANG=C $DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i else LANG=C $DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i fi done fi fi return $return_value } ########################################################################################## # Compare all zip files compare_all_zip_files() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER ) if [ -n "$ZIPS" ]; then echo Zip files... return_value=0 for f in $ZIPS; do if [ -f "$OTHER_DIR/$f" ]; then compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f if [ "$?" != "0" ]; then return_value=1 REGRESSIONS=true fi fi done fi return $return_value } ########################################################################################## # Compare all jar files compare_all_jar_files() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 # TODO filter? ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" | $SORT | $FILTER) if [ -n "$ZIPS" ]; then echo Jar files... return_value=0 for f in $ZIPS; do if [ -f "$OTHER_DIR/$f" ]; then compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f if [ "$?" != "0" ]; then return_value=1 REGRESSIONS=true fi fi done fi return $return_value } ########################################################################################## # Compare binary (executable/library) file compare_bin_file() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 BIN_FILE=$4 THIS_FILE=$THIS_DIR/$BIN_FILE OTHER_FILE=$OTHER_DIR/$BIN_FILE NAME=$(basename $BIN_FILE) WORK_FILE_BASE=$WORK_DIR/$BIN_FILE FILE_WORK_DIR=$(dirname $WORK_FILE_BASE) $MKDIR -p $FILE_WORK_DIR ORIG_THIS_FILE="$THIS_FILE" ORIG_OTHER_FILE="$OTHER_FILE" if [[ "$STRIP_BEFORE_COMPARE" = *"$BIN_FILE"* ]]; then THIS_STRIPPED_FILE=$FILE_WORK_DIR/this/$NAME OTHER_STRIPPED_FILE=$FILE_WORK_DIR/other/$NAME $MKDIR -p $FILE_WORK_DIR/this $FILE_WORK_DIR/other $CP $THIS_FILE $THIS_STRIPPED_FILE $CP $OTHER_FILE $OTHER_STRIPPED_FILE $STRIP $THIS_STRIPPED_FILE $STRIP $OTHER_STRIPPED_FILE THIS_FILE="$THIS_STRIPPED_FILE" OTHER_FILE="$OTHER_STRIPPED_FILE" fi if [ -z "$SKIP_BIN_DIFF" ]; then if cmp $OTHER_FILE $THIS_FILE > /dev/null; then # The files were bytewise identical. if [ -n "$VERBOSE" ]; then echo " : : : : : $BIN_FILE" fi return 0 fi BIN_MSG=" diff " if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then DIFF_BIN=true if [[ "$KNOWN_BIN_DIFF" != *"$BIN_FILE"* ]]; then BIN_MSG="*$BIN_MSG*" REGRESSIONS=true else BIN_MSG=" $BIN_MSG " fi else BIN_MSG="($BIN_MSG)" DIFF_BIN= fi fi THIS_SIZE=$(ls -l "$THIS_FILE" | awk '{ print $5 }') OTHER_SIZE=$(ls -l "$OTHER_FILE" | awk '{ print $5 }') if [ $THIS_SIZE -ne $OTHER_SIZE ]; then DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE) DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE) SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM) if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] && [ "$DIFF_SIZE_REL" -lt 102 ]; then SIZE_MSG="($SIZE_MSG)" DIFF_SIZE= else if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then DIFF_SIZE=true if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then SIZE_MSG="*$SIZE_MSG*" REGRESSIONS=true else SIZE_MSG=" $SIZE_MSG " fi else SIZE_MSG="($SIZE_MSG)" DIFF_SIZE= fi fi else SIZE_MSG=" " DIFF_SIZE= if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then SIZE_MSG=" ! " fi fi if [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then SYM_SORT_CMD="sort" else SYM_SORT_CMD="cat" fi # Check symbols if [ "$OPENJDK_TARGET_OS" = "windows" ]; then $DUMPBIN -exports $OTHER_FILE | $GREP " = " | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other $DUMPBIN -exports $THIS_FILE | $GREP " = " | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then # Some symbols get seemingly random 15 character prefixes. Filter them out. $NM -a $ORIG_OTHER_FILE | $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 $NM -a $ORIG_THIS_FILE | $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 else $NM -a $ORIG_OTHER_FILE | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other $NM -a $ORIG_THIS_FILE | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this fi LANG=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff if [ -s $WORK_FILE_BASE.symbols.diff ]; then SYM_MSG=" diff " if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then DIFF_SYM=true if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then SYM_MSG="*$SYM_MSG*" REGRESSIONS=true else SYM_MSG=" $SYM_MSG " fi else SYM_MSG="($SYM_MSG)" DIFF_SYM= fi else SYM_MSG=" " DIFF_SYM= if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then SYM_MSG=" ! " fi fi # Check dependencies if [ -n "$LDD_CMD" ];then (cd $FILE_WORK_DIR && $CP $OTHER_FILE . && $LDD_CMD $NAME | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.other | $UNIQ > $WORK_FILE_BASE.deps.other.uniq) (cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.this | $UNIQ > $WORK_FILE_BASE.deps.this.uniq) (cd $FILE_WORK_DIR && $RM -f $NAME) LANG=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this > $WORK_FILE_BASE.deps.diff LANG=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq > $WORK_FILE_BASE.deps.diff.uniq if [ -s $WORK_FILE_BASE.deps.diff ]; then if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then DEP_MSG=" diff " else DEP_MSG=" redun " fi if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then DIFF_DEP=true if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then DEP_MSG="*$DEP_MSG*" REGRESSIONS=true else DEP_MSG=" $DEP_MSG " fi else DEP_MSG="($DEP_MSG)" DIFF_DEP= fi else DEP_MSG=" " DIFF_DEP= if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then DEP_MSG=" ! " fi fi fi # Compare readelf output if [ -n "$READELF_CMD" ] && [ -z "$SKIP_ELF_DIFF" ]; then $READELF_CMD $OTHER_FILE > $WORK_FILE_BASE.readelf.other 2>&1 $READELF_CMD $THIS_FILE > $WORK_FILE_BASE.readelf.this 2>&1 LANG=C $DIFF $WORK_FILE_BASE.readelf.other $WORK_FILE_BASE.readelf.this > $WORK_FILE_BASE.readelf.diff if [ -s $WORK_FILE_BASE.readelf.diff ]; then ELF_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.readelf.diff | awk '{print $5}') ELF_MSG=$($PRINTF "%8d" $ELF_DIFF_SIZE) if [[ "$ACCEPTED_ELF_DIFF" != *"$BIN_FILE"* ]]; then DIFF_ELF=true if [[ "$KNOWN_ELF_DIFF" != *"$BIN_FILE"* ]]; then ELF_MSG="*$ELF_MSG*" REGRESSIONS=true else ELF_MSG=" $ELF_MSG " fi else ELF_MSG="($ELF_MSG)" DIFF_ELF= fi else ELF_MSG=" " DIFF_ELF= if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then ELF_MSG=" ! " fi fi fi # Compare disassemble output if [ -f "$OBJDUMP" ] && [ -z "$SKIP_DIS_DIFF" ]; then $OBJDUMP -d $OTHER_FILE | $GREP -v $NAME > $WORK_FILE_BASE.dis.other 2>&1 $OBJDUMP -d $THIS_FILE | $GREP -v $NAME > $WORK_FILE_BASE.dis.this 2>&1 LANG=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff if [ -s $WORK_FILE_BASE.dis.diff ]; then DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}') DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE) if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then DIFF_DIS=true if [[ "$KNOWN_DIS_DIFF" != *"$BIN_FILE"* ]]; then DIS_MSG="*$DIS_MSG*" REGRESSIONS=true else DIS_MSG=" $DIS_MSG " fi else DIS_MSG="($DIS_MSG)" DIFF_DIS= fi else DIS_MSG=" " DIFF_DIS= if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then DIS_MSG=" ! " fi fi fi if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_ELF$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi if [ -n "$ELF_MSG" ]; then echo -n "$ELF_MSG:"; fi if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi echo " $BIN_FILE" if [ "$SHOW_DIFFS" = "true" ]; then if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then echo "Symbols diff:" $CAT $WORK_FILE_BASE.symbols.diff fi if [ -s "$WORK_FILE_BASE.deps.diff" ]; then echo "Deps diff:" $CAT $WORK_FILE_BASE.deps.diff fi if [ -s "$WORK_FILE_BASE.readelf.diff" ]; then echo "Readelf diff:" $CAT $WORK_FILE_BASE.readelf.diff fi if [ -s "$WORK_FILE_BASE.dis.diff" ]; then echo "Disassembly diff:" $CAT $WORK_FILE_BASE.dis.diff fi fi return 1 fi return 0 } ########################################################################################## # Print binary diff header print_binary_diff_header() { if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n " Size :"; fi if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi if [ -z "$SKIP_DEP_DIFF" ]; then echo -n " Deps :"; fi if [ -z "$SKIP_ELF_DIFF" ]; then echo -n " Readelf :"; fi if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass :"; fi echo } ########################################################################################## # Compare all libraries compare_all_libs() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 LIBS=$(cd $THIS_DIR && $FIND . -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' | $SORT | $FILTER) if [ -n "$LIBS" ]; then echo Libraries... print_binary_diff_header for l in $LIBS; do if [ -f "$OTHER_DIR/$l" ]; then compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l if [ "$?" != "0" ]; then return_value=1 fi fi done fi return $return_value } ########################################################################################## # Compare all executables compare_all_execs() { THIS_DIR=$1 OTHER_DIR=$2 WORK_DIR=$3 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER) else EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \) | $SORT | $FILTER) fi if [ -n "$EXECS" ]; then echo Executables... print_binary_diff_header for e in $EXECS; do if [ -f "$OTHER_DIR/$e" ]; then compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e if [ "$?" != "0" ]; then return_value=1 fi fi done fi return $return_value } ########################################################################################## # Initiate configuration COMPARE_ROOT=/tmp/cimages.$USER $MKDIR -p $COMPARE_ROOT if [ "$OPENJDK_TARGET_OS" = "windows" ]; then if [ "$(uname -o)" = "Cygwin" ]; then COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT) fi fi THIS="$( cd "$( dirname "$0" )" && pwd )" echo "$THIS" THIS_SCRIPT="$0" if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then echo "bash ./compare.sh [OPTIONS] [FILTER]" echo "" echo "-all Compare all files in all known ways" echo "-names Compare the file names and directory structure" echo "-perms Compare the permission bits on all files and directories" echo "-types Compare the output of the file command on all files" echo "-general Compare the files not convered by the specialized comparisons" echo "-zips Compare the contents of all zip files" echo "-jars Compare the contents of all jar files" echo "-libs Compare all native libraries" echo "-execs Compare all executables" echo "-v Verbose output, does not hide known differences" echo "-vv More verbose output, shows diff output of all comparisons" echo "-o [OTHER] Compare with build in other directory. Will default to the old build directory" echo "" echo "[FILTER] List filenames in the image to compare, works for jars, zips, libs and execs" echo "Example:" echo "bash ./common/bin/compareimages.sh CodePointIM.jar" exit 10 fi CMP_NAMES=false CMP_PERMS=false CMP_TYPES=false CMP_GENERAL=false CMP_ZIPS=false CMP_JARS=false CMP_LIBS=false CMP_EXECS=false while [ -n "$1" ]; do case "$1" in -v) VERBOSE=true ;; -vv) VERBOSE=true SHOW_DIFFS=true ;; -o) OTHER=$2 shift ;; -all) CMP_NAMES=true if [ "$OPENJDK_TARGET_OS" != "windows" ]; then CMP_PERMS=true fi CMP_TYPES=true CMP_GENERAL=true CMP_ZIPS=true CMP_JARS=true CMP_LIBS=true CMP_EXECS=true ;; -names) CMP_NAMES=true ;; -perms) CMP_PERMS=true ;; -types) CMP_TYPES=true ;; -general) CMP_GENERAL=true ;; -zips) CMP_ZIPS=true ;; -jars) CMP_JARS=true ;; -libs) CMP_LIBS=true ;; -execs) CMP_EXECS=true ;; *) CMP_NAMES=false CMP_PERMS=false CMP_TYPES=false CMP_ZIPS=true CMP_JARS=true CMP_LIBS=true CMP_EXECS=true if [ -z "$FILTER" ]; then FILTER="$GREP" fi FILTER="$FILTER -e $1" ;; esac shift done if [ "$CMP_NAMES" = "false" ] && [ "$CMP_TYPES" = "false" ] && [ "$CMP_PERMS" = "false" ] && [ "$CMP_GENERAL" = "false" ] && [ "$CMP_ZIPS" = "false" ] && [ "$CMP_JARS" = "false" ] && [ "$CMP_LIBS" = "false" ] && [ "$CMP_EXECS" = "false" ]; then CMP_NAMES=true CMP_PERMS=true CMP_TYPES=true CMP_GENERAL=true CMP_ZIPS=true CMP_JARS=true CMP_LIBS=true CMP_EXECS=true fi if [ -z "$FILTER" ]; then FILTER="$CAT" fi if [ -z "$OTHER" ]; then OTHER="$THIS/../$LEGACY_BUILD_DIR" if [ -d "$OTHER" ]; then OTHER="$( cd "$OTHER" && pwd )" else echo "Default old build directory does not exist:" echo "$OTHER" fi echo "Comparing to default old build:" echo "$OTHER" echo else echo "Comparing to:" echo "$OTHER" echo fi if [ ! -d "$OTHER" ]; then echo "Other build directory does not exist:" echo "$OTHER" exit 1; fi # Figure out the layout of the new build. Which kinds of images have been produced if [ -d "$THIS/images/j2sdk-image" ]; then THIS_J2SDK="$THIS/images/j2sdk-image" THIS_J2RE="$THIS/images/j2re-image" fi if [ -d "$THIS/images/j2sdk-overlay-image" ]; then THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image" THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image" fi # Figure out the layout of the other build (old or new, normal or overlay image) if [ -d "$OTHER/j2sdk-image" ]; then if [ -f "$OTHER/j2sdk-image/LICENSE" ]; then OTHER_J2SDK="$OTHER/j2sdk-image" OTHER_J2RE="$OTHER/j2re-image" else OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image" OTHER_J2RE_OVERLAY="$OTHER/j2re-image" fi fi if [ -z "$OTHER_J2SDK" ] && [ -n "$OTHER_J2SDK_OVERLAY" ] && [ -z "$THIS_J2SDK_OVERLAY" ]; then echo "OTHER build only has an overlay image while this build does not. Nothing to compare!" exit 1 fi ########################################################################################## # Do the work if [ "$CMP_NAMES" = "true" ]; then if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then echo -n "J2SDK " compare_dirs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk echo -n "J2RE " compare_dirs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re echo -n "J2SDK " compare_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk echo -n "J2RE " compare_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re fi if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then echo -n "J2SDK Overlay " compare_dirs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay echo -n "J2RE Overlay " compare_dirs $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay echo -n "J2SDK Overlay " compare_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay echo -n "J2RE Overlay " compare_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay fi fi if [ "$CMP_PERMS" = "true" ]; then if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then echo -n "J2SDK " compare_permissions $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk echo -n "J2RE " compare_permissions $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re fi if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then echo -n "J2SDK Overlay " compare_permissions $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay echo -n "J2RE Overlay " compare_permissions $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay fi fi if [ "$CMP_TYPES" = "true" ]; then if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then echo -n "J2SDK " compare_file_types $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk echo -n "J2RE " compare_file_types $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re fi if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then echo -n "J2SDK Overlay " compare_file_types $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay echo -n "J2RE Overlay " compare_file_types $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay fi fi if [ "$CMP_GENERAL" = "true" ]; then if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then echo -n "J2SDK " compare_general_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk echo -n "J2RE " compare_general_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re fi if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then echo -n "J2SDK Overlay " compare_general_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay echo -n "J2RE Overlay " compare_general_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay fi fi if [ "$CMP_ZIPS" = "true" ]; then if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk fi fi if [ "$CMP_JARS" = "true" ]; then if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk fi fi if [ "$CMP_LIBS" = "true" ]; then if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then compare_all_libs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk fi if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then echo -n "Overlay " compare_all_libs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay fi fi if [ "$CMP_EXECS" = "true" ]; then if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then compare_all_execs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk fi if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then echo -n "Overlay " compare_all_execs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay fi fi echo if [ -n "$REGRESSIONS" ]; then echo "REGRESSIONS FOUND!" echo exit 1 else echo "No regressions found" echo exit 0 fi