2
# Usage: build-dpkg.sh [target dir]
3
# The default target directory is the current directory. If it is not
4
# supplied and the current directory is not empty, it will issue an error in
5
# order to avoid polluting the current directory after a test run.
7
# The program will setup the dpkg building environment and ultimately call
8
# dpkg-buildpackage with the appropiate parameters.
11
# Bail out on errors, be strict
15
go_out="$(getopt --options "k:" --longoptions key: \
16
--name "$(basename "$0")" -- "$@")"
17
test $? -eq 0 || exit 1
26
-k | --key ) shift; BUILDPKG_KEY="-pgpg -k$1"; shift;;
35
# Check that the current directory is not empty
36
if test "x$(echo *)" != "x*"
39
"Current directory is not empty. Use $0 . to force build in ."
47
# Check that the provided directory exists and is a directory
48
if ! test -d "$WORKDIR"
50
echo >&2 "$WORKDIR is not a directory"
55
echo >&2 "Usage: $0 [target dir]"
60
SOURCEDIR="$(cd $(dirname "$0"); cd ..; pwd)"
61
test -e "$SOURCEDIR/Makefile" || exit 2
63
# Extract version from the Makefile
64
MYSQL_VERSION="$(grep ^MYSQL_VERSION= "$SOURCEDIR/Makefile" \
66
PERCONA_SERVER_VERSION="$(grep ^PERCONA_SERVER_VERSION= "$SOURCEDIR/Makefile" | cut -d = -f 2)"
67
PRODUCT="Percona-Server-$MYSQL_VERSION-$PERCONA_SERVER_VERSION"
68
DEBIAN_VERSION="$(lsb_release -sc)"
72
export BB_PERCONA_REVISION="$(cd "$SOURCEDIR"; bzr log -r-1 | grep ^revno: | cut -d ' ' -f 2)"
73
export DEB_BUILD_OPTIONS='nostrip debug nocheck'
83
# Make a copy in workdir and copy debian files
87
cp -a "$SOURCEDIR/$PRODUCT/" .
91
# Copy debian files from source
92
cp -R "$SOURCEDIR/build/debian" .
95
# Update distribution name
96
dch -m -v "$MYSQL_VERSION-$PERCONA_SERVER_VERSION-$BB_PERCONA_REVISION.$DEBIAN_VERSION" 'Update distribution'
98
dpkg-buildpackage -rfakeroot $BUILDPKG_KEY