3
# Execute this tool to setup and build the shared-compat RPM starting
6
# Usage: build-shared-compat-rpm.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.
11
# The program will setup the rpm building environment, download the sources
12
# and ultimately call rpmbuild with the appropiate parameters.
15
# Bail out on errors, be strict
23
# Check if we have a functional getopt(1)
26
go_out="$(getopt --options="i" --longoptions=i686 \
27
--name="$(basename "$0")" -- "$@")"
28
test $? -eq 0 || exit 1
39
TARGET_ARG="--target i686"
40
TARGET_CFLAGS="-m32 -march=i686"
50
# Check that the current directory is not empty
51
if test "x$(echo *)" != "x*"
54
"Current directory is not empty. Use $0 . to force build in ."
58
WORKDIR_ABS="$(cd "$WORKDIR"; pwd)"
64
# Check that the provided directory exists and is a directory
65
if ! test -d "$WORKDIR"
67
echo >&2 "$WORKDIR is not a directory"
71
WORKDIR_ABS="$(cd "$WORKDIR"; pwd)"
74
echo >&2 "Usage: $0 [target dir]"
79
SOURCEDIR="$(cd $(dirname "$0"); cd ..; pwd)"
80
test -e "$SOURCEDIR/Makefile" || exit 2
82
# Extract version from the Makefile
83
MYSQL_VERSION="$(grep ^MYSQL_VERSION= "$SOURCEDIR/Makefile" \
85
PERCONA_SERVER_VERSION="$(grep ^PERCONA_SERVER_VERSION= \
86
"$SOURCEDIR/Makefile" | cut -d = -f 2)"
87
PRODUCT="Percona-Server-$MYSQL_VERSION-$PERCONA_SERVER_VERSION"
90
REDHAT_RELEASE="$(grep -o 'release [0-9][0-9]*' /etc/redhat-release | \
92
REVISION="$(cd "$SOURCEDIR"; bzr log -r-1 | grep ^revno: | cut -d ' ' -f 2)"
97
export CFLAGS="-fPIC -Wall -O3 -g -static-libgcc -fno-omit-frame-pointer $TARGET_CFLAGS"
98
export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fno-exceptions $TARGET_CFLAGS"
101
# Create directories for rpmbuild if these don't exist
102
(cd "$WORKDIR" && mkdir -p BUILD RPMS SOURCES SPECS SRPMS)
106
cd "$WORKDIR/SOURCES/"
108
# Download the sources from the community site
109
if test "x$TARGET" = "xi686"
112
elif test "x$(uname -m)" = "xx86_64"
119
wget "http://www.percona.com/downloads/community/shared-compat/MySQL-shared-compat-5.5.9-1.linux2.6.$RPMVER.rpm"
123
# Issue rpmbuild command
128
rpmbuild --sign -ba --clean --with yassl \
129
"$SOURCEDIR/build/percona-shared-compat.spec" \
130
--define "_topdir $WORKDIR_ABS" \
131
--define "redhat_version $REDHAT_RELEASE" \
132
--define "gotrevision $REVISION" \
133
--define "release $PERCONA_SERVER_VERSION" \