-# TODO
-# - which configure args should be set? same as mysql.spec?
-Summary: Open source backup tool for InnoDB and XtraDB
+# NOTES
+# - build instructions: http://www.percona.com/doc/percona-xtrabackup/2.2/installation/compiling_xtrabackup.html
+Summary: XtraBackup online backup for MySQL / InnoDB
Name: xtrabackup
-Version: 0.7
-Release: 0.2
+Version: 2.4.12
+Release: 1
License: GPL v2
Group: Applications/Databases
-URL: http://www.percona.com/docs/wiki/percona-xtrabackup:start
-Source0: http://ftp.gwdg.de/pub/misc/mysql/Downloads/MySQL-5.0/mysql-5.0.83.tar.gz
-# Source0-md5: 051392064a1e32cca5c23a593908b10e
-Source1: xtrabackup.tar.bz2
-# Source1-md5: 79ad151ec9055d30ee30d66993751f98
+Source0: https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-%{version}/source/tarball/percona-%{name}-%{version}.tar.gz
+# Source0-md5: c086206421a77f7c1ad28771a75cf396
+Source1: http://downloads.sourceforge.net/boost/boost_1_59_0.tar.bz2
+# Source1-md5: 6aa9a5c6a4ca1016edd0ed1178e3cb87
+Patch0: jsmn.patch
+URL: http://www.percona.com/doc/percona-xtrabackup/
+BuildRequires: bash
+BuildRequires: cmake >= 2.6
+BuildRequires: acl-devel
+BuildRequires: curl-devel
+BuildRequires: expat-devel
+BuildRequires: jsmn-devel
+BuildRequires: gnupg
+BuildRequires: libaio-devel
+BuildRequires: libarchive-devel
+BuildRequires: bison
+BuildRequires: libev-devel
+BuildRequires: libgcrypt-devel
BuildRequires: libstdc++-devel
+BuildRequires: libxml2-devel
+BuildRequires: zlib-devel
+BuildRequires: ncurses-devel >= 4.2
+BuildRequires: python-modules
+BuildRequires: readline-devel
+BuildRequires: xxd
+BuildRequires: sphinx-pdg
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-# CFLAGS for innodb are altered
-%undefine configure_cache
-
%description
-Percona XtraBackup is OpenSource online (non-blockable) backup
-solution for InnoDB and XtraDB engines. It works with MySQL 5.0 and
-5.1 versions (InnoDB Plugin is not supported yet as for alpha-0.3) and
-also can handle MyISAM tables.
+Percona XtraBackup is an open-source hot backup utility for
+MySQL-based servers that doesn't lock your database during the backup.
+
+It can back up data from InnoDB, XtraDB, and MyISAM tables on MySQL
+5.1, 5.5 and 5.6 servers, as well as Percona Server with XtraDB.
+
+Percona XtraBackup is a combination of the xtrabackup C program, and
+the innobackupex Perl script. The xtrabackup program copies and
+manipulates InnoDB and XtraDB data files, and the Perl script enables
+enhanced functionality, such as interacting with a running MySQL
+server and backing up MyISAM tables.
%prep
-%setup -qc -a1
-mv mysql-*/* .
-%{__patch} -p1 < xtrabackup/fix_innodb_for_backup.patch
-mv xtrabackup innobase
+%setup -q -n percona-%{name}-%{version} -a1
+%patch0 -p1
+
+# use system package
+mv storage/innobase/xtrabackup/src/jsmn .
+mv zlib zlib.dist
%build
-# The compiler flags are as per mysql "official" spec ;)
-CXXFLAGS="%{rpmcflags} -felide-constructors -fno-rtti -fno-exceptions %{!?debug:-fomit-frame-pointer}"
-CFLAGS="%{rpmcflags} %{!?debug:-fomit-frame-pointer}"
+install -d build
+cd build
+%cmake \
+ -DBUILD_CONFIG=xtrabackup_release \
+ -DCMAKE_BUILD_TYPE=%{!?debug:RelWithDebInfo}%{?debug:Debug} \
+ -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{rpmcflags} -DNDEBUG -fno-omit-frame-pointer -fno-strict-aliasing" \
+ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{rpmcxxflags} -DNDEBUG -fno-omit-frame-pointer -fno-strict-aliasing" \
+ -DENABLE_DTRACE=OFF \
+ -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
+ -DWITH_PIC=ON \
+ -DWITH_READLINE=system \
+ -DWITH_ZLIB=system \
+ -DWITH_SSL=system \
+ -DWITH_BOOST="$(pwd)/$(ls -1d ../boost_*)" \
+ ..
-%configure \
- --with-extra-charsets=all
%{__make}
-%{__make} -C innobase/xtrabackup \
- CC="%{__cc}" \
- CXXFLAGS="$CFLAGS" \
- CFLAGS="$CFLAGS"
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT%{_bindir}
-install innobase/xtrabackup/innobackupex-1.5.1 $RPM_BUILD_ROOT%{_bindir}/innobackupex
-install innobase/xtrabackup/xtrabackup $RPM_BUILD_ROOT%{_bindir}
+%{__make} -C build install \
+ DESTDIR=$RPM_BUILD_ROOT
+
+# TODO: find fix in make or cmake rules
+install -d $RPM_BUILD_ROOT%{_mandir}
+b=$(readlink -f %{_builddir})
+mv $RPM_BUILD_ROOT$b/percona-xtrabackup-%{version}/build/man/man1 $RPM_BUILD_ROOT%{_mandir}
+
+%{__rm} -r $RPM_BUILD_ROOT%{_prefix}/xtrabackup-test
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/innobackupex
+%attr(755,root,root) %{_bindir}/xbcloud
+%attr(755,root,root) %{_bindir}/xbcloud_osenv
+%attr(755,root,root) %{_bindir}/xbcrypt
+%attr(755,root,root) %{_bindir}/xbstream
%attr(755,root,root) %{_bindir}/xtrabackup
+%{_mandir}/man1/innobackupex.1*
+%{_mandir}/man1/xbcrypt.1*
+%{_mandir}/man1/xbstream.1*
+%{_mandir}/man1/xtrabackup.1*