~hrvojem/percona-xtrabackup/bug1052847-2.0

1
2
3
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
55
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
#!/bin/bash

set -e

function usage()
{
    cat <<EOF
Usage: 
$0 xtrabackup_target [installation_directory]
$0 path_to_server_tarball [installation_directory]

Prepares a server binary directory to be used by run.sh when running XtraBackup
tests.

If the argument is one of the build targets passed to build.sh 
(i.e. innodb51_builtin innodb51 innodb55 xtradb51 xtradb55) then the 
appropriate Linux tarball is downloaded from a pre-defined location and
unpacked into the specified installation  directory ('./server' by default).

Otherwise the argument is assumed to be a path to a server binary tarball.
EOF
}

if [ -z "$1" ]
then
    usage
fi

arch="`uname -m`"
if [ "$arch" = "i386" ]
then
    arch="i686"
fi

case "$1" in
    innodb50)
        url="http://s3.amazonaws.com/percona.com/downloads/community"
        tarball="mysql-5.0.96-linux-$arch-glibc23.tar.gz"
	;;
    innodb51_builtin | innodb51)
	url="http://s3.amazonaws.com/percona.com/downloads/community"
	tarball="mysql-5.1.49-linux-$arch-glibc23.tar.gz"
	;;
    innodb55)
	url="http://s3.amazonaws.com/percona.com/downloads/community"
	tarball="mysql-5.5.16-linux2.6-$arch.tar.gz"
	;;
    xtradb51)
	url="http://www.percona.com/redir/downloads/Percona-Server-5.1/Percona-Server-5.1.60-13.1/binary/linux/$arch"
	tarball="Percona-Server-5.1.60-rel13.1-413.Linux.$arch.tar.gz"
	;;
    xtradb55)
	url="http://s3.amazonaws.com/percona.com/downloads/Percona-Server-5.5/Percona-Server-5.5.11-20.2/Linux/binary"
	tarball="Percona-Server-5.5.11-rel20.2-116.Linux.$arch.tar.gz"
	;;
    galera55)
	galera=1
	;;
    *)
	if ! test -r "$1"
	then
	    echo "$1 does not exist"
	    exit 1
	fi
	tarball="$1"
	;;
esac

if test -n "$2"
then
    destdir="$2"
else
    destdir="./server"
fi

if test -d "$destdir"
then
    rm -rf "$destdir"
fi
mkdir "$destdir"

if test ! $galera
then
    if test -n "$url"
    then
	echo "Downloading $tarball"
	wget -qc "$url/$tarball"
    fi

    echo "Unpacking $tarball into $destdir"
    tar zxf $tarball -C $destdir 
    sourcedir="$destdir/`ls $destdir`"
    if test -n "$sourcedir"
    then
	mv $sourcedir/* $destdir
	rm -rf $sourcedir
    fi
else
    if test ! -d galerabuild
    then
	bzr init-repo galerabuild
    fi
    cd galerabuild

    rm -rf percona-xtradb-cluster
    bzr branch lp:percona-xtradb-cluster percona-xtradb-cluster
    rm -rf galera2x
    bzr branch lp:galera/2.x galera2x
    cd percona-xtradb-cluster
    cmake -DENABLE_DTRACE=0 -DWITH_WSREP:BOOL="1" -DCMAKE_INSTALL_PREFIX="../../server"

    if test -f /proc/cpuinfo
    then
	MAKE_J=`grep '^processor' /proc/cpuinfo | wc -l`
    else
	MAKE_J=4
    fi

    make -j$MAKE_J
    make install

    cd ../galera2x
    ./scripts/build.sh
    cp libgalera_smm.so ../../server/
    cd ..
fi