~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-shared-compat-rpm.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 and build the shared-compat RPM starting
 
4
# from a fresh tree
 
5
#
 
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.
 
10
#
 
11
# The program will setup the rpm building environment, download the sources
 
12
# and ultimately call rpmbuild with the appropiate parameters.
 
13
#
 
14
 
 
15
# Bail out on errors, be strict
 
16
set -ue
 
17
 
 
18
# Examine parameters
 
19
TARGET=''
 
20
TARGET_ARG=''
 
21
TARGET_CFLAGS=''
 
22
 
 
23
# Check if we have a functional getopt(1)
 
24
if ! getopt --test
 
25
then
 
26
    go_out="$(getopt --options="i" --longoptions=i686 \
 
27
        --name="$(basename "$0")" -- "$@")"
 
28
    test $? -eq 0 || exit 1
 
29
    eval set -- $go_out
 
30
fi
 
31
 
 
32
for arg
 
33
do
 
34
    case "$arg" in
 
35
    -- ) shift; break;;
 
36
    -i | --i686 )
 
37
        shift
 
38
        TARGET='i686'
 
39
        TARGET_ARG="--target i686"
 
40
        TARGET_CFLAGS="-m32 -march=i686"
 
41
        ;;
 
42
    esac
 
43
done
 
44
 
 
45
# Working directory
 
46
if test "$#" -eq 0
 
47
then
 
48
    WORKDIR="$(pwd)"
 
49
    
 
50
    # Check that the current directory is not empty
 
51
    if test "x$(echo *)" != "x*"
 
52
    then
 
53
        echo >&2 \
 
54
            "Current directory is not empty. Use $0 . to force build in ."
 
55
        exit 1
 
56
    fi
 
57
 
 
58
    WORKDIR_ABS="$(cd "$WORKDIR"; pwd)"
 
59
 
 
60
elif test "$#" -eq 1
 
61
then
 
62
    WORKDIR="$1"
 
63
 
 
64
    # Check that the provided directory exists and is a directory
 
65
    if ! test -d "$WORKDIR"
 
66
    then
 
67
        echo >&2 "$WORKDIR is not a directory"
 
68
        exit 1
 
69
    fi
 
70
 
 
71
    WORKDIR_ABS="$(cd "$WORKDIR"; pwd)"
 
72
 
 
73
else
 
74
    echo >&2 "Usage: $0 [target dir]"
 
75
    exit 1
 
76
 
 
77
fi
 
78
 
 
79
SOURCEDIR="$(cd $(dirname "$0"); cd ..; pwd)"
 
80
test -e "$SOURCEDIR/Makefile" || exit 2
 
81
 
 
82
# Extract version from the Makefile
 
83
MYSQL_VERSION="$(grep ^MYSQL_VERSION= "$SOURCEDIR/Makefile" \
 
84
    | cut -d = -f 2)"
 
85
PERCONA_SERVER_VERSION="$(grep ^PERCONA_SERVER_VERSION= \
 
86
    "$SOURCEDIR/Makefile" | cut -d = -f 2)"
 
87
PRODUCT="Percona-Server-$MYSQL_VERSION-$PERCONA_SERVER_VERSION"
 
88
 
 
89
# Build information
 
90
REDHAT_RELEASE="$(grep -o 'release [0-9][0-9]*' /etc/redhat-release | \
 
91
    cut -d ' ' -f 2)"
 
92
REVISION="$(cd "$SOURCEDIR"; bzr log -r-1 | grep ^revno: | cut -d ' ' -f 2)"
 
93
 
 
94
# Compilation flags
 
95
export CC=gcc
 
96
export CXX=gcc
 
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"
 
99
export MAKE_JFLAG=-j4
 
100
 
 
101
# Create directories for rpmbuild if these don't exist
 
102
(cd "$WORKDIR" && mkdir -p BUILD RPMS SOURCES SPECS SRPMS)
 
103
 
 
104
# Prepare sources
 
105
(
 
106
    cd "$WORKDIR/SOURCES/"
 
107
 
 
108
    # Download the sources from the community site
 
109
    if test "x$TARGET" = "xi686"
 
110
    then
 
111
        RPMVER=i386
 
112
    elif test "x$(uname -m)" = "xx86_64"
 
113
    then
 
114
        RPMVER=x86_64
 
115
    else
 
116
        RPMVER=i386
 
117
    fi
 
118
 
 
119
    wget "http://www.percona.com/downloads/community/shared-compat/MySQL-shared-compat-5.5.9-1.linux2.6.$RPMVER.rpm"
 
120
 
 
121
)
 
122
 
 
123
# Issue rpmbuild command
 
124
(
 
125
    cd "$WORKDIR"
 
126
 
 
127
    # Issue RPM 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" \
 
134
        $TARGET_ARG
 
135
 
 
136
)
 
137