=== modified file 'build-ps/debian/changelog'
--- build-ps/debian/changelog	2014-08-22 10:09:55 +0000
+++ build-ps/debian/changelog	2014-09-01 07:18:02 +0000
@@ -1,3 +1,9 @@
+percona-server-5.5 (5.5.39-rel36.0) unstable; urgency=low
+
+  * Added mysqld-debug
+
+ -- Tomislav Plavcic <tomislav.plavcic@percona.com>  Thu, 28 Aug 2014 09:25:38 +0200
+
 percona-server-5.5 (5.5.38-rel35.2) unstable; urgency=low
 
   * Fixed missing libperconaserverclient lib in lucid/squeeze

=== modified file 'build-ps/percona-server.spec'
--- build-ps/percona-server.spec	2014-08-22 10:09:55 +0000
+++ build-ps/percona-server.spec	2014-09-01 07:18:02 +0000
@@ -38,6 +38,19 @@
 %define release         rel%{percona_server_version}%{?dist}
 
 #
+%bcond_with systemd
+#
+%if %{with systemd}
+  %define systemd 1
+%else
+  %if 0%{?rhel} > 6
+    %define systemd 1
+  %else
+    %define systemd 0
+  %endif
+%endif
+
+#
 # Macros we use which are not available in all supported versions of RPM
 #
 # - defined/undefined are missing on RHEL4
@@ -185,7 +198,7 @@
   %define distro_description            Generic Linux (kernel %{generic_kernel})
   %define distro_releasetag             linux%{generic_kernel}
   %define distro_buildreq               gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel libaio-devel bison cmake
-  %define distro_requires               coreutils grep procps /sbin/chkconfig /usr/sbin/useradd /usr/sbin/groupadd
+  %define distro_requires               coreutils grep procps /usr/sbin/useradd /usr/sbin/groupadd
 %endif
 
 # ----------------------------------------------------------------------------
@@ -226,6 +239,9 @@
 Vendor:         %{percona_server_vendor}
 Provides:       mysql-server
 BuildRequires:  %{distro_buildreq} pam-devel openssl-devel
+%if 0%{?systemd}
+BuildRequires:  systemd
+%endif
 
 # Think about what you use here since the first step is to
 # run a rm -rf
@@ -249,6 +265,16 @@
 Summary:        Percona Server: a very fast and reliable SQL database server
 Group:          Applications/Databases
 Requires:       %{distro_requires} Percona-Server-shared%{product_suffix} Percona-Server-client%{product_suffix}
+Requires:       perl(Data::Dumper)
+%if 0%{?systemd}
+Requires(post):   systemd
+Requires(preun):  systemd
+Requires(postun): systemd
+%else
+Requires(post):   /sbin/chkconfig
+Requires(preun):  /sbin/chkconfig
+Requires(preun):  /sbin/service
+%endif
 Provides:       mysql-server MySQL-server
 Conflicts:	Percona-SQL-server-50 Percona-Server-server-51
 
@@ -268,6 +294,28 @@
 package "Percona-Server-client%{product_suffix}" as well!
 
 # ----------------------------------------------------------------------------
+%package -n Percona-Server-selinux%{product_suffix}
+Summary: 		Percona Server - Selinux policy module
+Group:          	Applications/Databases
+%if 0%{?rhel} >= 6
+BuildArch:		noarch
+%endif
+Requires:		selinux-policy
+Requires(post):		policycoreutils
+Requires(postun):	policycoreutils
+
+%if 0%{?rhel} == 6
+BuildRequires: 		selinux-policy
+%else
+BuildRequires: 		selinux-policy-devel
+%endif
+
+%description -n Percona-Server-selinux%{product_suffix}
+This package contains SELinux policy module for Percona Server package.
+
+For a description of Percona Server see http://www.percona.com/software/percona-server/
+
+# ----------------------------------------------------------------------------
 %package -n Percona-Server-client%{product_suffix}
 Summary:        Percona Server - Client
 Group:          Applications/Databases
@@ -283,6 +331,7 @@
 # ----------------------------------------------------------------------------
 %package -n Percona-Server-test%{product_suffix}
 Requires:       Percona-Server-client%{product_suffix} perl
+Requires:       perl(Socket), perl(Time::HiRes), perl(Data::Dumper), perl(Test::More), perl(Env)
 Summary:        Percona Server - Test suite
 Group:          Applications/Databases
 Provides:       mysql-test
@@ -474,6 +523,13 @@
 install -d $RBR%{_sbindir}
 install -d $RBR%{_libdir}/mysql/plugin
 
+# SElinux
+pushd ${MBD}/policy
+make -f /usr/share/selinux/devel/Makefile
+install -D -m 0644 $MBD/policy/percona-server.pp $RBR%{_datadir}/selinux/packages/percona-server/percona-server.pp
+popd
+# SElinux END
+
 (
   cd $MBD/release
   make DESTDIR=$RBR benchdir_root=%{_datadir} install
@@ -496,7 +552,12 @@
 
 # Install logrotate and autostart
 install -m 644 $MBD/release/support-files/mysql-log-rotate $RBR%{_sysconfdir}/logrotate.d/mysql
+%if 0%{?systemd}
+install -D -m 0755 $MBD/build-ps/rpm/mysql-systemd $RBR%{_bindir}/mysql-systemd
+install -D -m 0644 $MBD/build-ps/rpm/mysql.service $RBR%{_unitdir}/mysql.service
+%else
 install -m 755 $MBD/release/support-files/mysql.server $RBR%{_sysconfdir}/init.d/mysql
+%endif
 
 # Delete the symlinks to the libraries from the libdir. These are created by
 # ldconfig(8) afterwards.
@@ -522,9 +583,12 @@
   "$RBR%{_libdir}/mysql/%{malloc_lib_target}"
 %endif
 
-# Remove man pages we explicitly do not want to package, avoids 'unpackaged
+# Remove files we explicitly do not want to package, avoids 'unpackaged
 # files' warning.
 rm -f $RBR%{_mandir}/man1/make_win_bin_dist.1*
+%if 0%{?systemd}
+rm -rf $RBR%{_sysconfdir}/init.d/mysql
+%endif
 
 ##############################################################################
 #  Post processing actions, i.e. when installed
@@ -532,6 +596,15 @@
 
 %pre -n Percona-Server-server%{product_suffix}
 
+# On rhel7 change default MariaDB options if they exists (only on initial installation)
+%if "%rhel" > "6"
+if [ $1 -eq 1 -a -f /etc/my.cnf ]; then
+  sed -i 's/log-error=\/var\/log\/mariadb\/mariadb.log/log-error=\/var\/log\/mysqld.log/g' /etc/my.cnf;
+  sed -i 's/pid-file=\/var\/run\/mariadb\/mariadb.pid/pid-file=\/var\/run\/mysqld\/mysqld.pid/g' /etc/my.cnf;
+  sed -i 's/\!includedir \/etc\/my.cnf.d/\#\!includedir \/etc\/my.cnf.d/g' /etc/my.cnf;
+fi
+%endif
+
 # ATTENTION: Parts of this are duplicated in the "triggerpostun" !
 
 # There are users who deviate from the default file system layout.
@@ -687,11 +760,31 @@
 # Note we *could* make that depend on $SERVER_TO_START, but we rather don't,
 # so a "stop" is attempted even if there is no PID file.
 # (Maybe the "stop" doesn't work then, but we might fix that in itself.)
+%if 0%{?systemd}
+SYSD_ACTIVE=$(systemctl is-active mysql)
+if [ $SYSD_ACTIVE == "active" ] ; then
+	%{_bindir}/systemctl stop mysql >/dev/null 2>&1
+	echo "Giving mysqld 5 seconds to exit nicely"
+	sleep 5
+fi
+%else
 if [ -x %{_sysconfdir}/init.d/mysql ] ; then
         %{_sysconfdir}/init.d/mysql stop > /dev/null 2>&1
         echo "Giving mysqld 5 seconds to exit nicely"
         sleep 5
 fi
+%endif
+
+# SElinux
+%post -n Percona-Server-selinux%{product_suffix}
+/usr/sbin/semodule -i %{_datadir}/selinux/packages/percona-server/percona-server.pp >/dev/null 2>&1 || :
+
+%postun -n Percona-Server-selinux%{product_suffix}
+if [ $1 -eq 0 ] ; then
+    /usr/sbin/semodule -r percona-server >/dev/null 2>&1 || :
+fi
+
+#SElinux
 
 %post -n Percona-Server-server%{product_suffix}
 if [ X${PERCONA_DEBUG} == X1 ]; then
@@ -761,12 +854,18 @@
 # NOTE: This still needs to be debated. Should we check whether these links
 # for the other run levels exist(ed) before the upgrade?
 # use chkconfig on Enterprise Linux and newer SuSE releases
+%if 0%{?systemd}
+if [ -x %{_bindir}/systemctl ] ; then
+	%{_bindir}/systemctl enable mysql >/dev/null 2>&1
+fi
+%else
 if [ -x /sbin/chkconfig ] ; then
         /sbin/chkconfig --add mysql
 # use insserv for older SuSE Linux versions
 elif [ -x /sbin/insserv ] ; then
         /sbin/insserv %{_sysconfdir}/init.d/mysql
 fi
+%endif
 
 # ----------------------------------------------------------------------
 # Upgrade databases if needed would go here - but it cannot be automated yet
@@ -797,12 +896,18 @@
 
 # Was the server running before the upgrade? If so, restart the new one.
 if [ "$SERVER_TO_START" = "true" ] ; then
+%if 0%{?systemd}
+if [ -x %{_bindir}/systemctl ] ; then
+	%{_bindir}/systemctl start mysql
+fi
+%else
 	# Restart in the same way that mysqld will be started normally.
 	if [ -x %{_sysconfdir}/init.d/mysql ] ; then
 		%{_sysconfdir}/init.d/mysql start
-		echo "Giving mysqld 5 seconds to start"
-		sleep 5
 	fi
+%endif
+  echo "Giving mysqld 5 seconds to start"
+  sleep 5
 fi
 
 echo "Percona Server is distributed with several useful UDF (User Defined Function) from Percona Toolkit."
@@ -839,6 +944,12 @@
 #  http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s04s05.html
  
 if [ $1 = 0 ] ; then
+%if 0%{?systemd}
+	if [ -x %{_bindir}/systemctl ] ; then
+		%{_bindir}/systemctl stop mysql > /dev/null
+		%{_bindir}/systemctl disable mysql > /dev/null
+	fi
+%else
         # Stop MySQL before uninstalling it
         if [ -x %{_sysconfdir}/init.d/mysql ] ; then
                 %{_sysconfdir}/init.d/mysql stop > /dev/null
@@ -851,6 +962,7 @@
                         /sbin/insserv -r %{_sysconfdir}/init.d/mysql
                 fi
         fi
+%endif
 fi
 
 # We do not remove the mysql user since it may still own a lot of
@@ -893,21 +1005,35 @@
 fi
 echo "Analyzed: SERVER_TO_START=$SERVER_TO_START"
 
+%if 0%{?systemd}
+if [ -x %{_bindir}/systemctl ] ; then
+	%{_bindir}/systemctl enable mysql >/dev/null 2>&1
+fi
+%else
 if [ -x /sbin/chkconfig ] ; then
         /sbin/chkconfig --add mysql
 # use insserv for older SuSE Linux versions
 elif [ -x /sbin/insserv ] ; then
         /sbin/insserv %{_sysconfdir}/init.d/mysql
 fi
+%endif
 
 # Was the server running before the upgrade? If so, restart the new one.
 if [ "$SERVER_TO_START" = "true" ] ; then
-	# Restart in the same way that mysqld will be started normally.
+# Restart in the same way that mysqld will be started normally.
+%if 0%{?systemd}
+	if [ -x %{_bindir}/systemctl ] ; then 
+		%{_bindir}/systemctl start mysql
+		echo "Giving mysqld 5 seconds to start"
+		sleep 5
+	fi
+%else
 	if [ -x %{_sysconfdir}/init.d/mysql ] ; then
 		%{_sysconfdir}/init.d/mysql start
 		echo "Giving mysqld 5 seconds to start"
 		sleep 5
 	fi
+%endif
 fi
 
 echo "Trigger 'postun --community' finished at `date`"        >> $STATUS_HISTORY
@@ -926,6 +1052,10 @@
 #  Files section
 ##############################################################################
 
+%files -n Percona-Server-selinux%{product_suffix}
+%dir %attr(755, root, root) %{_datadir}/selinux/packages/percona-server
+%attr(644, root, root) %{_datadir}/selinux/packages/percona-server/percona-server.pp
+
 %files -n Percona-Server-server%{product_suffix}
 %defattr(-,root,root,0755)
 
@@ -965,6 +1095,9 @@
 %doc %attr(644, root, man) %{_mandir}/man1/resolve_stack_dump.1*
 %doc %attr(644, root, man) %{_mandir}/man1/resolveip.1*
 %doc %attr(644, root, man) %{_mandir}/man1/mysql_plugin.1*
+%if 0%{?systemd}
+%attr(755, root, root) %{_bindir}/mysql-systemd
+%endif
 
 %ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf
 
@@ -1052,7 +1185,11 @@
 %endif
 
 %attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql
+%if 0%{?systemd}
+%attr(644, root, root) %{_unitdir}/mysql.service
+%else
 %attr(755, root, root) %{_sysconfdir}/init.d/mysql
+%endif
 
 %attr(755, root, root) %{_datadir}/percona-server/
 
@@ -1141,6 +1278,10 @@
 %doc %attr(644, root, man) %{_mandir}/man1/mysqltest_embedded.1*
 
 %changelog
+* Tue Aug 26 2014 Tomislav Plavcic <tomislav.plavcic@percona.com>
+
+- Added support for centos7
+
 * Thu May 29 2014 Tomislav Plavcic <tomislav.plavcic@percona.com>
 
 - UDF and HandlerSocket moved to plugin

=== added directory 'build-ps/rpm'
=== added file 'build-ps/rpm/mysql-systemd'
--- build-ps/rpm/mysql-systemd	1970-01-01 00:00:00 +0000
+++ build-ps/rpm/mysql-systemd	2014-09-01 07:18:02 +0000
@@ -0,0 +1,92 @@
+#! /bin/bash
+#
+# Scripts to run by Percona Server systemd service
+# 
+# Needed argument: pre | post
+# 
+# pre mode  :  try to run mysql_install_db and fix perms and SELinux contexts
+# post mode :  ping server until answer is received
+# 
+
+parse_cnf()
+{
+    local var=$1
+    shift
+    local groups=$*
+    reval=$(my_print_defaults $groups | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -n 1 )
+    if [[ -z ${reval:-} ]];then 
+        reval=""
+    fi
+    echo $reval
+}
+
+install_db () {    
+    # Note: something different than datadir=/var/lib/mysql requires SELinux policy changes (in enforcing mode)
+    log=$(parse_cnf log-error server mysqld mysqld_safe)
+    datadir=$(parse_cnf datadir server mysqld)
+    if [[ -z ${datadir:-} ]]; then
+        datadir="/var/lib/mysql"
+    fi
+
+    # Check that pid-file directory exists and has valid permissions
+    pid_path=$(parse_cnf pid-file server mysqld mysqld_safe)
+    if [[ -z "${pid_path:-}" ]]; then
+      pid_path=$datadir/`hostname`.pid
+    else
+      case "$pid_path" in
+        /* ) ;;
+        * )  pid_path="$datadir/$pid_path" ;;
+      esac
+    fi
+    pidfiledir=$(dirname $pid_path)
+
+    if [ ! -z $pidfiledir ]; then
+        [ -d "$pidfiledir" ] || install -d -m 0755 -omysql -gmysql "$pidfiledir" || exit 1
+    fi
+    
+    # Restore log, dir, perms and SELinux contexts
+    [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || exit 1
+    if [ -x /usr/sbin/restorecon ]; then
+        /usr/sbin/restorecon "$datadir"
+        if [ ! -z $pidfiledir ]; then
+            /usr/sbin/restorecon "$pidfiledir"
+        fi
+    fi
+
+    # If log file is not specified it's put into datadir by default
+    if [ ! -z $log ]; then
+        [ -e $log ] || touch $log
+        chmod 0640 $log
+        chown mysql:mysql $log || exit 1
+        if [ -x /usr/sbin/restorecon ]; then
+            /usr/sbin/restorecon $log
+        fi
+    fi
+
+    # If special mysql dir is in place, skip db install 
+    [ -d "$datadir/mysql" ] && exit 0
+
+    # Create initial db
+    /usr/bin/mysql_install_db --rpm --datadir="$datadir" --user=mysql
+    exit 0
+}
+
+pinger () {
+    # Wait for ping to answer to signal startup completed,
+    # might take a while in case of e.g. crash recovery
+    # MySQL systemd service will timeout script if no answer
+    while /bin/true ; do
+        sleep 1
+        mysqladmin ping >/dev/null 2>&1 && break
+    done
+    exit 0
+}
+
+# main
+case $1 in
+    "pre") install_db ;;
+    "post") pinger ;;
+esac
+
+exit 0
+

=== added file 'build-ps/rpm/mysql.service'
--- build-ps/rpm/mysql.service	1970-01-01 00:00:00 +0000
+++ build-ps/rpm/mysql.service	2014-09-01 07:18:02 +0000
@@ -0,0 +1,31 @@
+#
+# Systemd service file for Percona Server
+#
+# # This service file is to start PS just with mysqld_safe
+#
+
+[Unit]
+Description=MySQL Percona Server
+After=network.target
+After=syslog.target
+
+[Install]
+WantedBy=multi-user.target
+Alias=mysql.service
+
+[Service]
+# Needed to create system tables etc.
+ExecStartPre=/usr/bin/mysql-systemd pre
+
+# Start main service
+ExecStart=/usr/bin/mysqld_safe
+
+# Don't signal startup success before a ping works
+ExecStartPost=/usr/bin/mysql-systemd post
+
+# Give up if ping don't get an answer
+TimeoutSec=600
+
+Restart=always
+PrivateTmp=false
+

=== modified file 'policy/selinux/percona-server.te'
--- policy/selinux/percona-server.te	2013-03-01 19:17:07 +0000
+++ policy/selinux/percona-server.te	2014-09-01 07:18:02 +0000
@@ -11,8 +11,9 @@
         class sock_file { getattr unlink create };
         class capability { sys_nice sys_resource };
         class blk_file { read write open };
-        class file { write getattr read create unlink open };
+        class file { append write getattr read create unlink open setattr };
         class dir { search read write remove_name open add_name };
+        class process { siginh noatsecure rlimitinh };
 }
 
 #============= mysqld_safe_t ==============
@@ -22,6 +23,9 @@
 allow mysqld_safe_t tmp_t:sock_file { getattr unlink };
 allow mysqld_safe_t user_tmp_t:sock_file { getattr unlink };
 
+#!!!! This avc has a dontaudit rule in the current policy
+allow mysqld_safe_t mysqld_t:process { siginh rlimitinh noatsecure };
+
 #============= mysqld_t ==============
 allow mysqld_t fixed_disk_device_t:blk_file { read write open };
 allow mysqld_t tmp_t:sock_file { create unlink };

=== modified file 'storage/innobase/include/univ.i'
--- storage/innobase/include/univ.i	2014-08-22 10:09:55 +0000
+++ storage/innobase/include/univ.i	2014-09-01 07:18:02 +0000
@@ -64,7 +64,7 @@
 	(INNODB_VERSION_MAJOR << 8 | INNODB_VERSION_MINOR)
 
 #ifndef PERCONA_INNODB_VERSION
-#define PERCONA_INNODB_VERSION 35.2
+#define PERCONA_INNODB_VERSION 36.0
 #endif
 
 #define INNODB_VERSION_STR	MYSQL_SERVER_VERSION

