make.sh 4.0 KB
Newer Older
1 2
#!/bin/bash
# build properties
3
JDK_UPDATE_VERSION=202
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
DISTRO_NAME=Dragonwell
DISTRO_VERSION=8.0

if [ $# != 1 ]; then 
  echo "USAGE: $0 release/debug"
fi

ps -e | grep docker
if [ $? -eq 0 ]; then
    echo "We will build AJDK in Docker!"
    sudo docker pull reg.docker.alibaba-inc.com/ajdk/8-dev.alios5
    docker run -u admin -i --rm -e BUILD_NUMBER=$BUILD_NUMBER -v `pwd`:`pwd` -w `pwd` \
               --entrypoint=bash reg.docker.alibaba-inc.com/ajdk/8-dev.alios5 `pwd`/make.sh $1
    exit $?
fi


source /vmfarm/tools/env.sh
LC_ALL=C

BUILD_MODE=$1

case "$BUILD_MODE" in
    release)
        DEBUG_LEVEL="release"
        JDK_IMAGES_DIR=`pwd`/build/linux-x86_64-normal-server-release/images
    ;;
    debug)
        DEBUG_LEVEL="slowdebug"
        JDK_IMAGES_DIR=`pwd`/build/linux-x86_64-normal-server-slowdebug/images
    ;;
    *)
        echo "Argument must be release or debug!"
        exit 1
    ;;
esac

NEW_JAVA_HOME=$JDK_IMAGES_DIR/j2sdk-image
NEW_JRE_HOME=$JDK_IMAGES_DIR/j2re-image

\rm -rf build

if [ -z "$BUILD_NUMBER" ]; then
  BUILD_INDEX=b00
else
  BUILD_INDEX=b$BUILD_NUMBER
fi

export LDFLAGS_JDK="-L/vmfarm/tools/jemalloc/lib -ljemalloc"
bash ./configure --with-milestone=fcs \
                 --with-freetype=/vmfarm/tools/freetype/ \
55
                 --with-update-version=$JDK_UPDATE_VERSION \
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
                 --with-build-number=$BUILD_INDEX \
                 --with-user-release-suffix="" \
                 --enable-unlimited-crypto \
                 --with-cacerts-file=/vmfarm/security/cacerts \
                 --with-jtreg=/vmfarm/tools/jtreg4.1 \
                 --with-tools-dir=/vmfarm/tools/install/gcc-4.4.7/bin \
                 --with-jvm-variants=server \
                 --with-debug-level=$DEBUG_LEVEL \
                 --with-extra-cflags="-DVENDOR='\"Alibaba\"'                                         \
                                      -DVENDOR_URL='\"http://www.alibabagroup.com\"'                 \
                                      -DVENDOR_URL_BUG='\"mailto:jvm@list.alibaba-inc.com\"'"        \
                 --with-zlib=system \
                 --with-extra-ldflags="-Wl,--build-id=sha1"
make clean
make LOG=debug DISTRO_NAME=$DISTRO_NAME DISTRO_VERSION=$DISTRO_VERSION COMPANY_NAME=Alibaba images

\cp -f /vmfarm/tools/hsdis/8/amd64/hsdis-amd64.so  $NEW_JAVA_HOME/jre/lib/amd64/
\cp -f /vmfarm/tools/jemalloc/lib/libjemalloc.so.2 $NEW_JAVA_HOME/jre/lib/amd64/
\cp -f /vmfarm/tools/jemalloc/lib/libjemalloc.so.2 $NEW_JAVA_HOME/lib/amd64/
\cp -f /vmfarm/tools/jemalloc/lib/libjemalloc.so.2 $NEW_JRE_HOME/lib/amd64/

# Sanity tests
JAVA_EXES=("$NEW_JAVA_HOME/bin/java" "$NEW_JAVA_HOME/jre/bin/java" "$NEW_JRE_HOME/bin/java")
VERSION_OPTS=("-version" "-Xinternalversion" "-fullversion")
for exe in "${JAVA_EXES[@]}"; do
  for opt in "${VERSION_OPTS[@]}"; do
    $exe $opt > /dev/null 2>&1
    if [ 0 -ne $? ]; then
      echo "Failed: $exe $opt"
      exit 128
    fi
  done
done

# Keep old output
$NEW_JAVA_HOME/bin/java -version

cat > /tmp/systemProperty.java << EOF
public class systemProperty {
    public static void main(String[] args) {
        System.getProperties().list(System.out);
    }
}
EOF

$NEW_JAVA_HOME/bin/javac /tmp/systemProperty.java
$NEW_JAVA_HOME/bin/java -cp /tmp/ systemProperty > /tmp/systemProperty.out

EXPECTED_PATTERN=('^java\.vm\.vendor\=.*Alibaba.*$'
                '^java\.vendor\.url\=http\:\/\/www\.alibabagroup\.com$'
                '^java\.vendor\=Alibaba$'
                '^java\.vendor\.url\.bug\=mailto\:jvm@list\.alibaba-inc\.com$')
RET=0
for p in ${EXPECTED_PATTERN[*]}
do
    cat /tmp/systemProperty.out | grep "$p"
    if [ 0 != $? ]; then RET=1; fi
done

\rm -f /tmp/systemProperty*

# check version string
$NEW_JAVA_HOME/bin/java -version > /tmp/version.out 2>&1
grep "^OpenJDK Runtime" /tmp/version.out | grep "($DISTRO_NAME $DISTRO_VERSION)"
if [ 0 != $? ]; then RET=1; fi
grep "^OpenJDK .*VM" /tmp/version.out | grep "($DISTRO_NAME $DISTRO_VERSION)"
if [ 0 != $? ]; then RET=1; fi
\rm -f /tmp/version.out

ldd $NEW_JAVA_HOME/jre/lib/amd64/libzip.so|grep libz
if [ 0 != $? ]; then RET=1; fi

exit $RET