~percona-dev/percona-server/release-5.5.11-20.2-fix-bug-764138

« back to all changes in this revision

Viewing changes to build/build-binary.sh

  • Committer: Ignacio Nin
  • Date: 2011-03-13 17:18:23 UTC
  • mfrom: (33.3.17 release-5.5.8-20)
  • Revision ID: ignacio.nin@percona.com-20110313171823-m06xs104nekulywb
Merge changes from release-5.5.8-20 to 5.5.9

Merge changes from the release branch of 5.5.8 to 5.5.9. These include
the HandlerSocket and UDF directories and the building scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Execute this tool to setup the environment and build binary releases
 
4
# for Percona-Server starting from a fresh tree.
 
5
#
 
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.
 
10
#
 
11
 
 
12
# Bail out on errors, be strict
 
13
set -ue
 
14
 
 
15
# Examine parameters
 
16
TARGET="$(uname -m)"
 
17
TARGET_CFLAGS=''
 
18
 
 
19
# Check if we have a functional getopt(1)
 
20
if ! getopt --test
 
21
then
 
22
    go_out="$(getopt --options="i" --longoptions=i686 \
 
23
        --name="$(basename "$0")" -- "$@")"
 
24
    test $? -eq 0 || exit 1
 
25
    eval set -- $go_out
 
26
fi
 
27
 
 
28
for arg
 
29
do
 
30
    case "$arg" in
 
31
    -- ) shift; break;;
 
32
    -i | --i686 )
 
33
        shift
 
34
        TARGET="i686"
 
35
        TARGET_CFLAGS="-m32 -march=i686"
 
36
        ;;
 
37
    esac
 
38
done
 
39
 
 
40
# Working directory
 
41
if test "$#" -eq 0
 
42
then
 
43
    WORKDIR="$(pwd)"
 
44
    
 
45
    # Check that the current directory is not empty
 
46
    if test "x$(echo *)" != "x*"
 
47
    then
 
48
        echo >&2 \
 
49
            "Current directory is not empty. Use $0 . to force build in ."
 
50
        exit 1
 
51
    fi
 
52
 
 
53
elif test "$#" -eq 1
 
54
then
 
55
    WORKDIR="$1"
 
56
 
 
57
    # Check that the provided directory exists and is a directory
 
58
    if ! test -d "$WORKDIR"
 
59
    then
 
60
        echo >&2 "$WORKDIR is not a directory"
 
61
        exit 1
 
62
    fi
 
63
 
 
64
    WORKDIR_ABS="$(cd "$WORKDIR"; pwd)"
 
65
 
 
66
else
 
67
    echo >&2 "Usage: $0 [target dir]"
 
68
    exit 1
 
69
 
 
70
fi
 
71
 
 
72
SOURCEDIR="$(cd $(dirname "$0"); cd ..; pwd)"
 
73
test -e "$SOURCEDIR/Makefile" || exit 2
 
74
 
 
75
# Extract version from the Makefile
 
76
MYSQL_VERSION="$(grep ^MYSQL_VERSION= "$SOURCEDIR/Makefile" \
 
77
    | cut -d = -f 2)"
 
78
PERCONA_SERVER_VERSION="$(grep ^PERCONA_SERVER_VERSION= \
 
79
    "$SOURCEDIR/Makefile" | cut -d = -f 2)"
 
80
PRODUCT="Percona-Server-$MYSQL_VERSION-$PERCONA_SERVER_VERSION"
 
81
 
 
82
# Build information
 
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"
 
88
 
 
89
# Compilation flags
 
90
export CC=gcc
 
91
export CXX=gcc
 
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"
 
94
export MAKE_JFLAG=-j4
 
95
 
 
96
# Create a temporary working directory
 
97
INSTALLDIR="$(TMPDIR="$WORKDIR_ABS" mktemp -d)"
 
98
echo "$INSTALLDIR"
 
99
 
 
100
# Build
 
101
(
 
102
    cd "$SOURCEDIR"
 
103
 
 
104
    # Execute clean and download mysql, apply patches
 
105
    make clean all
 
106
 
 
107
    cd "$PRODUCT"
 
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"
 
116
 
 
117
    make $MAKE_JFLAG VERBOSE=1
 
118
    make DESTDIR="$INSTALLDIR" install
 
119
 
 
120
)
 
121
 
 
122
# Package the archive
 
123
(
 
124
    cd "$INSTALLDIR/usr/local/"
 
125
 
 
126
    tar czf "$WORKDIR_ABS/$PRODUCT_FULL.tar.gz" \
 
127
        --owner=root --group=root "$PRODUCT_FULL/"
 
128
    
 
129
)
 
130
 
 
131
# Clean up
 
132
rm -rf "$INSTALLDIR"
 
133