|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -e |
| 4 | +set -u |
| 5 | + |
| 6 | +MONGO_VERSION="2.4.12" |
| 7 | + |
| 8 | +source "$(dirname $0)/build-dev-bundle-common.sh" |
| 9 | +echo CHECKOUT DIR IS "$CHECKOUT_DIR" |
| 10 | +echo BUILDING MONGO "v$MONGO_VERSION" IN "$DIR" |
| 11 | + |
| 12 | +# Checkout and build mongodb. |
| 13 | +# We want to build a binary that includes SSL support but does not depend on a |
| 14 | +# particular version of openssl on the host system. |
| 15 | + |
| 16 | +OPENSSL="openssl-1.0.1j" |
| 17 | +OPENSSL_URL="http://www.openssl.org/source/$OPENSSL.tar.gz" |
| 18 | +wget $OPENSSL_URL || curl -O $OPENSSL_URL |
| 19 | +tar xzf $OPENSSL.tar.gz |
| 20 | + |
| 21 | +cd $OPENSSL |
| 22 | +if [ "$UNAME" == "Linux" ]; then |
| 23 | + ./config --prefix="$DIR/build/openssl-out" no-shared |
| 24 | +else |
| 25 | + # This configuration line is taken from Homebrew formula: |
| 26 | + # https://github.com/mxcl/homebrew/blob/master/Library/Formula/openssl.rb |
| 27 | + ./Configure no-shared zlib-dynamic --prefix="$DIR/build/openssl-out" darwin64-x86_64-cc enable-ec_nistp_64_gcc_128 |
| 28 | +fi |
| 29 | +make install |
| 30 | + |
| 31 | +# To see the mongo changelog, go to http://www.mongodb.org/downloads, |
| 32 | +# click 'changelog' under the current version, then 'release notes' in |
| 33 | +# the upper right. |
| 34 | +cd "$DIR/build" |
| 35 | + |
| 36 | +# We use Meteor fork since we added some changes to the building script. |
| 37 | +# Our patches allow us to link most of the libraries statically. |
| 38 | +git clone --branch "ssl-r$MONGO_VERSION" --depth 1 \ |
| 39 | + git://github.com/meteor/mongo.git |
| 40 | +cd mongo |
| 41 | +rm -rf .git |
| 42 | + |
| 43 | +# Compile |
| 44 | + |
| 45 | +MONGO_FLAGS="--ssl --release -j4 " |
| 46 | +MONGO_FLAGS+="--cpppath=$DIR/build/openssl-out/include --libpath=$DIR/build/openssl-out/lib " |
| 47 | + |
| 48 | +if [ "$OS" == "osx" ]; then |
| 49 | + # NOTE: '--64' option breaks the compilation, even it is on by default on x64 mac: https://jira.mongodb.org/browse/SERVER-5575 |
| 50 | + MONGO_FLAGS+="--openssl=$DIR/build/openssl-out/lib " |
| 51 | + /usr/local/bin/scons $MONGO_FLAGS mongo mongod |
| 52 | +elif [ "$OS" == "linux" ]; then |
| 53 | + MONGO_FLAGS+="--no-glibc-check --prefix=./ " |
| 54 | + if [ "$ARCH" == "x86_64" ]; then |
| 55 | + MONGO_FLAGS+="--64" |
| 56 | + fi |
| 57 | + scons $MONGO_FLAGS mongo mongod |
| 58 | +else |
| 59 | + echo "We don't know how to compile mongo for this platform" |
| 60 | + exit 1 |
| 61 | +fi |
| 62 | + |
| 63 | +echo "Done with scons build" |
| 64 | + |
| 65 | +# Copy binaries |
| 66 | +mkdir -p "$DIR/mongodb/bin" |
| 67 | +cp mongo "$DIR/mongodb/bin/" |
| 68 | +cp mongod "$DIR/mongodb/bin/" |
| 69 | + |
| 70 | +# Copy mongodb distribution information |
| 71 | +find ./distsrc -maxdepth 1 -type f -exec cp '{}' ../mongodb \; |
| 72 | + |
| 73 | +cd "$DIR" |
| 74 | +stripBinary mongodb/bin/mongo |
| 75 | +stripBinary mongodb/bin/mongod |
| 76 | + |
| 77 | +echo BUNDLING |
| 78 | + |
| 79 | +cd "$DIR" |
| 80 | +rm -rf build |
| 81 | +tar czvf "${CHECKOUT_DIR}/mongo_${PLATFORM}_v${MONGO_VERSION}.tar.gz" . |
| 82 | + |
| 83 | +echo DONE |
0 commit comments