3
# Execute this tool to setup the environment and build binary releases
4
# for Percona-Server starting from a fresh tree.
6
# Usage: build-binary.sh [target dir]
7
# The default target directory is the current directory. If it is not
8
# supplied and the current directory is not empty, it will issue an error in
9
# order to avoid polluting the current directory after a test run.
12
# Bail out on errors, be strict
19
# Check if we have a functional getopt(1)
22
go_out="$(getopt --options="i" --longoptions=i686 \
23
--name="$(basename "$0")" -- "$@")"
24
test $? -eq 0 || exit 1
35
TARGET_CFLAGS="-m32 -march=i686"
45
# Check that the current directory is not empty
46
if test "x$(echo *)" != "x*"
49
"Current directory is not empty. Use $0 . to force build in ."
57
# Check that the provided directory exists and is a directory
58
if ! test -d "$WORKDIR"
60
echo >&2 "$WORKDIR is not a directory"
64
WORKDIR_ABS="$(cd "$WORKDIR"; pwd)"
67
echo >&2 "Usage: $0 [target dir]"
72
SOURCEDIR="$(cd $(dirname "$0"); cd ..; pwd)"
73
test -e "$SOURCEDIR/Makefile" || exit 2
75
# Extract version from the Makefile
76
MYSQL_VERSION="$(grep ^MYSQL_VERSION= "$SOURCEDIR/Makefile" \
78
PERCONA_SERVER_VERSION="$(grep ^PERCONA_SERVER_VERSION= \
79
"$SOURCEDIR/Makefile" | cut -d = -f 2)"
80
PRODUCT="Percona-Server-$MYSQL_VERSION-$PERCONA_SERVER_VERSION"
83
REVISION="$(cd "$SOURCEDIR"; bzr log -r-1 | grep ^revno: | cut -d ' ' -f 2)"
84
PRODUCT_FULL="Percona-Server-$MYSQL_VERSION-$PERCONA_SERVER_VERSION"
85
PRODUCT_FULL="$PRODUCT_FULL-$REVISION.$(uname -s).$TARGET"
86
COMMENT="Percona Server with XtraDB (GPL), Release $PERCONA_SERVER_VERSION"
87
COMMENT="$COMMENT, Revision $REVISION"
92
export CFLAGS="-fPIC -Wall -O3 -g -static-libgcc -fno-omit-frame-pointer $TARGET_CFLAGS"
93
export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fno-exceptions $TARGET_CFLAGS"
96
# Create a temporary working directory
97
INSTALLDIR="$(TMPDIR="$WORKDIR_ABS" mktemp -d)"
104
# Execute clean and download mysql, apply patches
108
cmake . -DBUILD_CONFIG=mysql_release \
109
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
110
-DWITH_EMBEDDED_SERVER=OFF \
111
-DFEATURE_SET=community \
112
-DCMAKE_INSTALL_PREFIX="/usr/local/$PRODUCT_FULL" \
113
-DMYSQL_DATADIR="/usr/local/$PRODUCT_FULL/data" \
114
-DMYSQL_SERVER_SUFFIX="-$PERCONA_SERVER_VERSION" \
115
-DCOMPILATION_COMMENT="$COMMENT"
117
make $MAKE_JFLAG VERBOSE=1
118
make DESTDIR="$INSTALLDIR" install
122
# Package the archive
124
cd "$INSTALLDIR/usr/local/"
126
tar czf "$WORKDIR_ABS/$PRODUCT_FULL.tar.gz" \
127
--owner=root --group=root "$PRODUCT_FULL/"