File xtrabackup.spec of Package xtrabackup

%{!?mysql_version: %global mysql_version 5.0.91}
%{!?xtrabackup_version: %global xtrabackup_revision -bzr}

Name:           xtrabackup
Version:        1.2
Release:        1.1%{?dist}
Summary:        Online backup for MySQL / InnoDB

Group:          Applications/Archiving
License:        GPLv2
URL:            http://launchpad.net/percona-xtrabackup
# http://downloads.mysql.com/archives.php
Source0:        http://downloads.mysql.com/archives/mysql-5.0/mysql-%{mysql_version}.tar.gz
# http://launchpad.net/percona-xtrabackup/release-1.2/1.2/+download/xtrabackup-1.2.tar.gz
Source1:        xtrabackup-1.2.tar.gz
# ftp://ftp.feep.net/pub/software/libtar/libtar-1.2.11.tar.gz
# NOTE: This rpm does not distribute libtar - it only generates a tar4ibd binary
#       using the libtar sources
Source2:        libtar-1.2.11.tar.gz 
# This patches the MySQL source code for xtrabackup
Patch0:         fix_innodb_for_backup.patch
# This patches the xtrabackup makefile to compile for mysql-5.0 sources
Patch1:         xtrabackup_makefile.patch
# This patches libtar to create the tar4ibd binary
Patch2:         tar4ibd_libtar-1.2.11.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:  gperf, perl, readline-devel, openssl-devel
BuildRequires:  gcc-c++, ncurses-devel, zlib-devel
BuildRequires:  libtool automake autoconf gawk
Requires:       /usr/bin/mysql

%description
Percona XtraBackup is OpenSource online (non-blocking) backup solution 
for InnoDB and XtraDB engines.


%prep
# upstream mysql-5.0.91 sources
%setup -q -n mysql-%{mysql_version}
%patch0 -p1
# xtrabackup source
%{__tar} -zx -f %{SOURCE1} -C innobase --exclude ./xtrabackup-%{version}/.bzr/
%patch1 -p1
# libtar/tar4ibd
%{__tar} -zx -f %{SOURCE2}
%patch2 -p1


%build
# build main mysql source
export CFLAGS="%{optflags} -DXTRABACKUP_VERSION=\\\"%{version}\\\" -DXTRABACKUP_REVISION=\\\"%{xtrabackup_revision}\\\""
%configure \
    --with-readline \
    --with-ssl=/usr \
    --without-debug \
    --localstatedir=/var/lib/mysql \
    --with-unix-socket-path=/var/lib/mysql/mysql.sock \
    --with-mysqld-user="mysql" \
    --with-extra-charsets=all \
    --enable-thread-safe-client \
    --disable-dependency-tracking \
    --with-zlib-dir=bundled
make %{?_smp_mflags}
# build xtrabackup
cd innobase/xtrabackup-%{version}
make
cd -
# build tar4ibd
cd libtar-1.2.11
%configure
make
cd -


%install
rm -rf %{buildroot}
cd innobase/xtrabackup-%{version}
install -m 755 -D xtrabackup %{buildroot}%{_bindir}/xtrabackup
install -m 755 -D innobackupex-1.5.1 %{buildroot}%{_bindir}/innobackupex-1.5.1
cd -
# install tar4ibd
install -m 755 libtar-1.2.11/libtar/tar4ibd %{buildroot}%{_bindir}


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%doc
%{_bindir}/xtrabackup
%{_bindir}/innobackupex-1.5.1
%{_bindir}/tar4ibd

%changelog
* Mon Jun 07 2010 Andrew Garner <andrew.garner@rackspace.com> - 1.2-1.1
- Initial spec build
openSUSE Build Service is sponsored by