%define mysqld_user		mysql
%define mysqld_group		mysql
%define server_suffix -community
%define mysqldatadir /var/lib/mysql

%{?_with_static:%define STATIC_BUILD 1}
%{!?_with_static:%define STATIC_BUILD 0}

# Working around perl dependency problem
%define __find_requires %{SOURCE999}

# We don't package all files installed into the build root by intention -
# See BUG#998 for details.
%define _unpackaged_files_terminate_build 0

%define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com

%define mysql_version		5.1.44
%define client_version		16

%if %{?_dist_release}!="vl5"
%define libpkgname libmysqlclient%{client_version}
%else
%define libpkgname MySQL-shared
%endif

Packager:	tomop
Name: MySQL
Summary:	MySQL: a very fast and reliable SQL database server
Group:		Applications/Databases
Version:	%{mysql_version}
Release:	1%{_dist_release}
License:	GPL
Source:		mysql-%{version}.tar.gz
# Don't depend on lib::mtr*
Source999:	filter-requires-%{name}.sh
Patch0:		mysql-5.1.44-jp-all.patch
URL:		http://www.mysql.com/
Requires:	fileutils sh-utils
Provides:	msqlormysql MySQL-server mysql
Obsoletes:	mysql MySQL5
BuildRequires:  perl, readline-devel
BuildRequires:  gcc-c++, ncurses-devel, zlib-devel
BuildRequires:  groff, libtool, automake
BuildRoot:      %{_tmppath}/%{name}-%{version}-root

# From the manual
%description
The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
and robust SQL (Structured Query Language) database server. MySQL Server
is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Sun Microsystems, Inc.

Copyright 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license.

The MySQL web site (http://www.mysql.com/) provides the latest
news and information about the MySQL software. Also please see the
documentation and the manual for more information.

%package server
Release: %{release}
Summary:	MySQL: a very fast and reliable SQL database server
Group:		Applications/Databases
Requires:	fileutils sh-utils net-tools
Provides:	msqlormysql mysql-server mysql MySQL MySQL5-server
Obsoletes:	MySQL mysql mysql-server MySQL5-server MySQL-Max

%description server
The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
and robust SQL (Structured Query Language) database server. MySQL Server
is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Sun Microsystems, Inc.

Copyright 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license.

The MySQL web site (http://www.mysql.com/) provides the latest
news and information about the MySQL software. Also please see the
documentation and the manual for more information.

This package includes the MySQL server binary (incl. InnoDB) as well
as related utilities to run and administrate a MySQL server.

If you want to access and work with the database, you have to install
package "MySQL-client" as well!

%package client
Summary: MySQL - Client
Group: Applications/Databases
Obsoletes: mysql-client MySQL5-client
Provides: mysql-client MySQL5-client

%description client
This package contains the standard MySQL clients and administration tools. 

%{see_base}

%package ndb-storage
Summary:	MySQL - ndbcluster storage engine
Group:		Applications/Databases

%description ndb-storage
This package contains the ndbcluster storage engine. 
It is necessary to have this package installed on all 
computers that should store ndbcluster table data.
Note that this storage engine can only be used in conjunction
with the MySQL Max server.

%{see_base}

%package ndb-management
Summary:	MySQL - ndbcluster storage engine management
Group:		Applications/Databases

%description ndb-management
This package contains ndbcluster storage engine management.
It is necessary to have this package installed on at least 
one computer in the cluster.

%{see_base}

%package ndb-tools
Summary:	MySQL - ndbcluster storage engine basic tools
Group:		Applications/Databases

%description ndb-tools
This package contains ndbcluster storage engine basic tools.

%{see_base}

%package ndb-extra
Summary:	MySQL - ndbcluster storage engine extra tools
Group:		Applications/Databases

%description ndb-extra
This package contains some extra ndbcluster storage engine tools for the advanced user.
They should be used with caution.

%{see_base}

%package test
Requires: %{name}-client = %{version}-%{release} perl-DBI perl
Summary: MySQL - Test suite
Group: Applications/Databases
Obsoletes: mysql-bench MySQL5-bench MySQL-bench

%description test
This package contains the MySQL regression test suite.

%{see_base}


%package devel
Summary: MySQL - Development header files and libraries
Group: Applications/Databases
Requires: %{libpkgname} = %{version}-%{release}
Provides: mysql-devel MySQL5-devel
Obsoletes: mysql-devel MySQL5-devel

%description devel
This package contains the development header files and libraries
necessary to develop MySQL client applications.

%{see_base}

%package -n %{libpkgname}
Summary: MySQL - Shared libraries
Group: Applications/Databases
%if %{?_dist_release}!="vl5"
Obsoletes: MySQL-shared < %{version}
%endif

%description -n %{libpkgname}
This package contains the shared libraries (*.so*) which certain
languages and applications need to dynamically load and use MySQL.


#%package embedded
#Requires: %{name}-devel = %{version}-%{release}
#Summary: MySQL - embedded library
#Group: Applications/Databases
#Obsoletes: mysql-embedded MySQL5-embedded
#Provides: mysql-embedded MySQL5-embedded

#%description embedded
#This package contains the MySQL server as an embedded library.

#The embedded MySQL server library makes it possible to run a
#full-featured MySQL server inside the client application.
#The main benefits are increased speed and more simple management
#for embedded applications.

#The API is identical for the embedded MySQL version and the
#client/server version.

#%{see_base}

%prep
%setup -T -a 0 -c -n mysql-%{mysql_version}
mv mysql-%{mysql_version} mysql-debug-%{mysql_version}

pushd mysql-debug-%{mysql_version}
%patch0 -p1 -b .jp
aclocal
autoheader
libtoolize --automake --force
automake --add-missing --copy
autoconf
popd

%setup -D -T -a 0 -n mysql-%{mysql_version}
mv mysql-%{mysql_version} mysql-release-%{mysql_version}

pushd mysql-release-%{mysql_version}
%patch0 -p1 -b .jp
aclocal
autoheader
libtoolize --automake --force
automake --add-missing --copy
autoconf
popd

%build

BuildMySQL() {
# The --enable-assembler simply does nothing on systems that does not
# support assembler speedups.
sh -c  "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \
	CC=\"${CC:-$MYSQL_BUILD_CC}\" \
	CXX=\"${CXX:-$MYSQL_BUILD_CXX}\" \
	CFLAGS=\"$CFLAGS\" \
	CXXFLAGS=\"$CXXFLAGS\" \
	LDFLAGS=\"$MYSQL_BUILD_LDFLAGS\" \
	./configure \
 	    $* \
	    --with-mysqld-ldflags='-static' \
	    --with-client-ldflags='-static' \
	    --with-zlib-dir=bundled \
	    --enable-assembler \
	    --enable-local-infile \
	    --with-fast-mutexes \
            --with-mysqld-user=%{mysqld_user} \
            --with-unix-socket-path=/var/lib/mysql/mysql.sock \
	    --with-pic \
            --prefix=/ \
	    --with-extra-charsets=all \
            --exec-prefix=%{_exec_prefix} \
            --libexecdir=%{_sbindir} \
            --libdir=%{_libdir} \
            --sysconfdir=%{_sysconfdir} \
            --datadir=%{_datadir} \
            --localstatedir=%{mysqldatadir} \
            --infodir=%{_infodir} \
            --includedir=%{_includedir} \
            --mandir=%{_mandir} \
	    --enable-thread-safe-client \
	    --with-readline \
		--with-innodb \
		--with-ndbcluster \
		--with-archive-storage-engine \
		--with-csv-storage-engine \
		--with-blackhole-storage-engine \
		--with-federated-storage-engine \
		--with-partition \
		--with-big-tables \
		--enable-shared \
		--with-comment=\"VineLinux MySQL RPM\" \
		--with-charset=utf8 \
		--with-client-charset=utf8 \
		"
 make %{?_smp_mflags}
}
# end of function definition "BuildMySQL"

# Use the build root for temporary storage of the shared libraries.

RBR=$RPM_BUILD_ROOT

# Clean up the BuildRoot first
[ "$RBR" != "/" ] && [ -d $RBR ] && rm -rf $RBR;
mkdir -p $RBR%{_libdir}/mysql

#
# Use MYSQL_BUILD_PATH so that we can use a dedicated version of gcc
#
PATH=${MYSQL_BUILD_PATH:-/bin:/usr/bin}
export PATH

# Build the Debug binary.

# Use gcc for C and C++ code (to avoid a dependency on libstdc++ and
# including exceptions into the code
if [ -z "$CXX" -a -z "$CC" ]
then
	export CC="gcc"
	export CXX="gcc"
fi

# Prepare compiler flags
CFLAGS=${MYSQL_BUILD_CFLAGS:-$RPM_OPT_FLAGS}
CXXFLAGS=${MYSQL_BUILD_CXXFLAGS:-$RPM_OPT_FLAGS -felide-constructors -fno-exceptions -fno-rtti }

##############################################################################
#
#  Build the debug version
#
##############################################################################

(
# We are in a subshell, so we can modify variables just for one run.
CFLAGS=`echo   " $CFLAGS "   | \
    sed -e 's/ -O[0-9]* / /' -e 's/ -unroll2 / /' -e 's/ -ip / /' \
        -e 's/^ //' -e 's/ $//'`
CXXFLAGS=`echo " $CXXFLAGS " | \
    sed -e 's/ -O[0-9]* / /' -e 's/ -unroll2 / /' -e 's/ -ip / /' \
        -e 's/^ //' -e 's/ $//'`

# Add -g and --with-debug.
cd mysql-debug-%{mysql_version} &&
CFLAGS="$CFLAGS" \
CXXFLAGS="$CXXFLAGS" \
BuildMySQL --with-debug
)

# We might want to save the config log file
if test -n "$MYSQL_DEBUGCONFLOG_DEST"
then
  cp -fp mysql-debug-%{mysql_version}/config.log "$MYSQL_DEBUGCONFLOG_DEST"
fi

#(cd mysql-debug-%{mysql_version} ; make test-bt-debug)

##############################################################################
#
#  Build the release binary
#
##############################################################################

(cd mysql-release-%{mysql_version} &&
CFLAGS="$CFLAGS" \
CXXFLAGS="$CXXFLAGS" \
BuildMySQL --with-embedded-server
)
# We might want to save the config log file
if test -n "$MYSQL_CONFLOG_DEST"
then
  cp -fp  mysql-release-%{mysql_version}/config.log "$MYSQL_CONFLOG_DEST"
fi

#(cd mysql-release-%{mysql_version} ; make test-bt)

%install
RBR=$RPM_BUILD_ROOT
MBD=$RPM_BUILD_DIR/mysql-%{mysql_version}/mysql-release-%{mysql_version}

rm -rf $RBR

# Ensure that needed directories exists
install -d $RBR%{_sysconfdir}/{logrotate.d,init.d}
install -d $RBR%{mysqldatadir}/mysql
install -d $RBR%{_datadir}/mysql-test
install -d $RBR%{_includedir}
install -d $RBR%{_libdir}
install -d $RBR%{_mandir}
install -d $RBR%{_sbindir}

# Install all binaries 
(cd $MBD && make install DESTDIR=$RBR benchdir_root=%{_datadir})
# Old packages put shared libs in %{_libdir}/ (not %{_libdir}/mysql), so do
# the same here.
#mv $RBR/%{_libdir}/mysql/*.so* $RBR/%{_libdir}/

rm -rf $RBR/mysql-test

##############################################################################
# Include libgcc.a in the devel subpackage (BUG 4921)
if [ -z "$CXX" -a -z "$CC" ]
then
	export CC="gcc"
	export CXX="gcc"
fi

if expr "$CC" : ".*gcc.*" > /dev/null ;
then
  libgcc=`$CC $CFLAGS --print-libgcc-file`
  if [ -f $libgcc ]
  then
    %define have_libgcc 1
    install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a
  fi
fi

##############################################################################

# install "mysqld-debug"
$MBD/libtool --mode=execute install -m 755 \
                 $RPM_BUILD_DIR/mysql-%{mysql_version}/mysql-debug-%{mysql_version}/sql/mysqld \
                 $RBR%{_sbindir}/mysqld-debug

# install saved perror binary with NDB support (BUG#13740)
install -m 755 $MBD/extra/perror $RBR%{_bindir}/perror

# Install logrotate and autostart
install -m 644 $MBD/support-files/mysql-log-rotate $RBR%{_sysconfdir}/logrotate.d/mysql
install -m 755 $MBD/support-files/mysql.server $RBR%{_sysconfdir}/init.d/mysql

# in RPMs, it is unlikely that anybody should use "sql-bench"
rm -fr $RBR%{_datadir}/sql-bench

# Create a symlink "rcmysql", pointing to the init.script. SuSE users
# will appreciate that, as all services usually offer this.
ln -s %{_sysconfdir}/init.d/mysql $RPM_BUILD_ROOT%{_sbindir}/rcmysql

# Touch the place where the my.cnf config file and mysqlmanager.passwd
# (MySQL Instance Manager password file) might be located
# Just to make sure it's in the file list and marked as a config file
touch $RBR%{_sysconfdir}/my.cnf
touch $RBR%{_sysconfdir}/mysqlmanager.passwd

mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
echo "%{_libdir}/mysql" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/libmysqlclient%{client_version}-%{_arch}.conf

%pre server
# Shut down a previously installed server first
if test -x %{_sysconfdir}/init.d/mysql
then
  %{_sysconfdir}/init.d/mysql stop > /dev/null 2>&1
  echo "Giving mysqld a couple of seconds to exit nicely"
  sleep 5
elif test -x %{_sysconfdir}/rc.d/init.d/mysql
then
  %{_sysconfdir}/rc.d/init.d/mysql stop > /dev/null 2>&1
  echo "Giving mysqld a couple of seconds to exit nicely"
  sleep 5
fi

%post server
mysql_datadir=%{mysqldatadir}

# Create data directory if needed
if test ! -d $mysql_datadir; then mkdir -m 755 $mysql_datadir; fi
if test ! -d $mysql_datadir/mysql; then mkdir $mysql_datadir/mysql; fi
if test ! -d $mysql_datadir/test; then mkdir $mysql_datadir/test; fi

# Make MySQL start/shutdown automatically when the machine does it.
# use insserv for older SuSE Linux versions
if test -x /sbin/insserv
then
	/sbin/insserv %{_sysconfdir}/init.d/mysql
# use chkconfig on Red Hat and newer SuSE releases
elif test -x /sbin/chkconfig
then
	/sbin/chkconfig --add mysql
fi

# Create a MySQL user and group. Do not report any problems if it already
# exists.
groupadd -r %{mysqld_group} 2> /dev/null || true
useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true 
# The user may already exist, make sure it has the proper group nevertheless (BUG#12823)
usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true

# Change permissions so that the user that will run the MySQL daemon
# owns all database files.
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir

# Initiate databases if needed
%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}

# Upgrade databases if needed would go here - but it cannot be automated yet

# Change permissions again to fix any new files.
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir

# Fix permissions for the permission database so that only the user
# can read them.
chmod -R og-rw $mysql_datadir/mysql

# Restart in the same way that mysqld will be started normally.
%{_sysconfdir}/init.d/mysql start

# Allow mysqld_safe to start mysqld and print a message before we exit
sleep 2

#echo "Thank you for installing the MySQL Community Server! For Production
#systems, we recommend MySQL Enterprise, which contains enterprise-ready
#software, intelligent advisory services, and full production support with
#scheduled service packs and more.  Visit www.mysql.com/enterprise for more
#information." 

%post ndb-storage
mysql_clusterdir=/var/lib/mysql-cluster

# Create cluster directory if needed
if test ! -d $mysql_clusterdir; then mkdir -m 755 $mysql_clusterdir; fi

%preun server
if test $1 = 0
then
  # Stop MySQL before uninstalling it
  if test -x %{_sysconfdir}/init.d/mysql
  then
    %{_sysconfdir}/init.d/mysql stop > /dev/null

    # Remove autostart of mysql
    # for older SuSE Linux versions
    if test -x /sbin/insserv
    then
      /sbin/insserv -r %{_sysconfdir}/init.d/mysql
    # use chkconfig on Red Hat and newer SuSE releases
    elif test -x /sbin/chkconfig
    then
      /sbin/chkconfig --del mysql
    fi
  fi
fi

# We do not remove the mysql user since it may still own a lot of
# database files.

%post -n %{libpkgname}
/sbin/ldconfig

%postun -n %{libpkgname}
/sbin/ldconfig

# Clean up the BuildRoot
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;

%files server
%defattr(-,root,root,0755)

%doc mysql-release-%{mysql_version}/COPYING mysql-release-%{mysql_version}/README 
%doc mysql-release-%{mysql_version}/support-files/my-*.cnf
%doc mysql-release-%{mysql_version}/support-files/ndb-*.ini

%doc %attr(644, root, root) %{_infodir}/mysql.info*

%doc %attr(644, root, man) %{_mandir}/man1/innochecksum.1*
%doc %attr(644, root, man) %{_mandir}/man1/my_print_defaults.1*
%doc %attr(644, root, man) %{_mandir}/man1/myisam_ftdump.1*
%doc %attr(644, root, man) %{_mandir}/man1/myisamchk.1*
%doc %attr(644, root, man) %{_mandir}/man1/myisamlog.1*
%doc %attr(644, root, man) %{_mandir}/man1/myisampack.1*
%doc %attr(644, root, man) %{_mandir}/man8/mysqld.8*
%doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1*
%doc %attr(644, root, man) %{_mandir}/man8/mysqlmanager.8*
%doc %attr(644, root, man) %{_mandir}/man1/mysql.server.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqltest.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_tzinfo_to_sql.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_zap.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlbug.1*
%doc %attr(644, root, man) %{_mandir}/man1/perror.1*
%doc %attr(644, root, man) %{_mandir}/man1/replace.1*

%doc %attr(644, root, man) %{_mandir}/man1/mysql_convert_table_format.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_extensions.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_secure_installation.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_setpermission.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqldumpslow.1*
%doc %attr(644, root, man) %{_mandir}/man1/resolve_stack_dump.1*
%doc %attr(644, root, man) %{_mandir}/man1/resolveip.1*

%ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf
%ghost %config(noreplace,missingok) %{_sysconfdir}/mysqlmanager.passwd

%attr(755, root, root) %{_bindir}/innochecksum
%attr(755, root, root) %{_bindir}/my_print_defaults
%attr(755, root, root) %{_bindir}/myisam_ftdump
%attr(755, root, root) %{_bindir}/myisamchk
%attr(755, root, root) %{_bindir}/myisamlog
%attr(755, root, root) %{_bindir}/myisampack
%attr(755, root, root) %{_bindir}/mysql_convert_table_format
%attr(755, root, root) %{_bindir}/mysql_fix_extensions
%attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables
%attr(755, root, root) %{_bindir}/mysql_install_db
%attr(755, root, root) %{_bindir}/mysql_secure_installation
%attr(755, root, root) %{_bindir}/mysql_setpermission
%attr(755, root, root) %{_bindir}/mysql_tzinfo_to_sql
%attr(755, root, root) %{_bindir}/mysql_upgrade
%attr(755, root, root) %{_bindir}/mysql_zap
%attr(755, root, root) %{_bindir}/mysqlbug
%attr(755, root, root) %{_bindir}/mysqld_multi
%attr(755, root, root) %{_bindir}/mysqld_safe
%attr(755, root, root) %{_bindir}/mysqldumpslow
%attr(755, root, root) %{_bindir}/mysqlhotcopy
%attr(755, root, root) %{_bindir}/mysqltest
%attr(755, root, root) %{_bindir}/perror
%attr(755, root, root) %{_bindir}/replace
%attr(755, root, root) %{_bindir}/resolve_stack_dump
%attr(755, root, root) %{_bindir}/resolveip

%attr(755, root, root) %{_sbindir}/mysqld
%attr(755, root, root) %{_sbindir}/mysqld-debug
%attr(755, root, root) %{_sbindir}/mysqlmanager
%attr(755, root, root) %{_sbindir}/rcmysql

%dir %attr(755, root, root) %{_libdir}/mysql/plugin
%attr(755, root, root) %{_libdir}/mysql/plugin/*.so*

%attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql
%attr(755, root, root) %{_sysconfdir}/init.d/mysql

%attr(755, root, root) %{_datadir}/mysql/

%files client
%defattr(-, root, root, 0755)
%attr(755, root, root) %{_bindir}/msql2mysql
%attr(755, root, root) %{_bindir}/mysql
%attr(755, root, root) %{_bindir}/mysql_find_rows
%attr(755, root, root) %{_bindir}/mysql_waitpid
%attr(755, root, root) %{_bindir}/mysqlaccess
%attr(755, root, root) %{_bindir}/mysqladmin
%attr(755, root, root) %{_bindir}/mysqlbinlog
%attr(755, root, root) %{_bindir}/mysqlcheck
%attr(755, root, root) %{_bindir}/mysqldump
%attr(755, root, root) %{_bindir}/mysqlimport
%attr(755, root, root) %{_bindir}/mysqlshow
%attr(755, root, root) %{_bindir}/mysqlslap

%doc %attr(644, root, man) %{_mandir}/man1/msql2mysql.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_find_rows.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlaccess.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqladmin.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlbinlog.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlcheck.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqldump.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlimport.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlshow.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlslap.1*

%files ndb-storage
%defattr(-,root,root,0755)
%attr(755, root, root) %{_sbindir}/ndbd
%doc %attr(644, root, man) %{_mandir}/man8/ndbd.8*

%files ndb-management
%defattr(-,root,root,0755)
%attr(755, root, root) %{_sbindir}/ndb_mgmd
%doc %attr(644, root, man) %{_mandir}/man8/ndb_mgmd.8*

%files ndb-tools
%defattr(-,root,root,0755)
%attr(755, root, root) %{_bindir}/ndb_config
%attr(755, root, root) %{_bindir}/ndb_desc
%attr(755, root, root) %{_bindir}/ndb_error_reporter
%attr(755, root, root) %{_bindir}/ndb_mgm
%attr(755, root, root) %{_bindir}/ndb_print_backup_file
%attr(755, root, root) %{_bindir}/ndb_print_schema_file
%attr(755, root, root) %{_bindir}/ndb_print_sys_file
%attr(755, root, root) %{_bindir}/ndb_restore
%attr(755, root, root) %{_bindir}/ndb_select_all
%attr(755, root, root) %{_bindir}/ndb_select_count
%attr(755, root, root) %{_bindir}/ndb_show_tables
%attr(755, root, root) %{_bindir}/ndb_size.pl
%attr(755, root, root) %{_bindir}/ndb_test_platform
%attr(755, root, root) %{_bindir}/ndb_waiter
%doc %attr(644, root, man) %{_mandir}/man1/ndb_config.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_desc.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_error_reporter.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_mgm.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_restore.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_print_backup_file.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_print_schema_file.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_print_sys_file.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_select_all.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_select_count.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_show_tables.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_size.pl.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_waiter.1*

%files ndb-extra
%defattr(-,root,root,0755)
%attr(755, root, root) %{_bindir}/ndb_delete_all
%attr(755, root, root) %{_bindir}/ndb_drop_index
%attr(755, root, root) %{_bindir}/ndb_drop_table
%attr(755, root, root) %{_sbindir}/ndb_cpcd
%doc %attr(644, root, man) %{_mandir}/man1/ndb_delete_all.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_drop_index.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_drop_table.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_cpcd.1*

%files devel
%defattr(-, root, root, 0755)
%doc mysql-release-%{mysql_version}/EXCEPTIONS-CLIENT
%doc %attr(644, root, man) %{_mandir}/man1/mysql_config.1*
%attr(755, root, root) %{_bindir}/mysql_config
%dir %attr(755, root, root) %{_includedir}/mysql
%dir %attr(755, root, root) %{_libdir}/mysql
%{_includedir}/mysql/*
%{_datadir}/aclocal/mysql.m4
%{_libdir}/mysql/libmysql*.so
%{_libdir}/mysql/libndb*.so

#%{_libdir}/mysql/libdbug.a
#%{_libdir}/mysql/libheap.a
%if %{have_libgcc}
%{_libdir}/mysql/libmygcc.a
%endif
#%{_libdir}/mysql/libmyisam.a
#%{_libdir}/mysql/libmyisammrg.a
#%{_libdir}/mysql/libmysqlclient.a
#%{_libdir}/mysql/libmysqlclient_r.a
#%{_libdir}/mysql/libmystrings.a
#%{_libdir}/mysql/libmysys.a
#%{_libdir}/mysql/libndbclient.a
#%{_libdir}/mysql/libvio.a
#%{_libdir}/mysql/libz.a

%files -n %{libpkgname}
%defattr(-, root, root, 0755)
# Shared libraries (omit for architectures that don't support them)
%{_libdir}/mysql/libmysql*.so.*
%{_libdir}/mysql/libndb*.so.*
/etc/ld.so.conf.d/*

%files test
%defattr(-, root, root, 0755)
%attr(-, root, root) %{_datadir}/mysql-test
%attr(755, root, root) %{_bindir}/mysql_client_test
%attr(755, root, root) %{_bindir}/mysql_client_test_embedded
%attr(755, root, root) %{_bindir}/mysqltest_embedded
%doc %attr(644, root, man) %{_mandir}/man1/mysql_client_test.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_client_test_embedded.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql-stress-test.pl.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql-test-run.pl.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqltest_embedded.1*

#%files embedded
#%defattr(-, root, root, 0755)
#%attr(644, root, root) %{_libdir}/mysql/libmysqld.a

%changelog
* Fri Mar 05 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.44-1
- new upstream release.
- updated jp-patch.

* Thu Feb 04 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.43-2
- VineSeed: rebuilt with new toolchain.

* Wed Feb 03 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.43-1
- new upstream release.
  - fixed CVE-2009-4484.

* Fri Nov 20 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.41-1
- new upstream release.

* Thu Nov 19 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.40-2
- added net-tools to 'Requires'.
- added groff to 'BuildRequires'.
- renamed subpackage 'MySQL-shared' to 'libmysqlclient16' (VineSeed only).

* Tue Nov 10 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.40-1
- new upstream release.

* Sat Sep 26 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.39-1
- new upstream release.

* Sun Jul  5 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.36-1
- new upstream release.
- dropped %%Patch100 (fixed in upstream).

* Sat Jun  6 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.35-1
- new upstream release.
- add %%Patch100 (no longer needed for MySQL-5.1.36 or later).

* Thu May 21 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.1.34-1
- new upstream release.
- rename 'MySQL-bench' to 'MySQL-test'.
- update Patch0.
- change default charset to 'utf8'.

* Sat Apr 12 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 5.0.51a-1
- new upstream release.
- update Patch0.
- add "--with-client-charset=ujis".
- sync %%files to official RPM.
- remove MySQL-Max.

* Thu Dec 13 2007 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 5.0.27-0vl7
- for VineSeed

* Thu Dec 13 2007 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 5.0.27-0vl6
- move shared library from /usr/lib/ to /usr/lib/mysql/
- add /etc/ld.so.conf.d/*.conf
- fix broken libmysqlcient*.la files (or should we remove them permanently?)

* Sat Jun 16 2007 IWAI, Masaharu <iwai@alib.jp> 5.0.27-0vl5
- rebuild <BTS:VineLinux:534>

* Mon Nov 13 2006 NAKAMURA Kenta <kenta@vinelinux.org> 5.0.27-0vl4
- added -fPIC

* Mon Oct 30 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 5.0.27-0vl3
- fixed dependency. <BTS:338>

* Mon Oct 30 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 5.0.27-0vl2
- add %%Patch1. <BTS:320>

* Sat Oct 28 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 5.0.27-0vl1
- new upstream release.

* Fri Oct 27 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 5.0.26-0vl1
- new upstream release.

* Sat Jun  3 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 5.0.22-0vl1
- new upstream release.

* Sat May 13 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 5.0.21-0vl1
- release++.

* Wed May 10 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 5.0.21-0vl0
- new upstream release.
- for VineSeed.

* Wed Feb  8 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 4.1.16-0vl0
- new upstream release.
- replace Patch0 for MySQL-4.1.16.

* Thu Oct  6 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 4.1.14-0vl0
- new upstream release.
- add Patch0.

* Tue Sep 6 2005 Takeyuki FUJIOKA <fuji@ftserve.net> 4.0.25-0vl0
- new upstream version
	-- mysql-4.0.25

* Fri Jan 21 2005 Takeyuki FUJIOKA <fuji@ftserve.net> 4.0.23-0vl0
- new upstream version
	-- mysql-4.0.23

* Tue Sep 28 2004 Takeyuki FUJIOKA <fuji@ftserve.net> 4.0.22-0vl0
- new upstream version
	-- mysql-4.0.22
 
* Tue Sep 28 2004 Takeyuki FUJIOKA <fuji@ftserve.net> 4.0.21-0vl1
- new upstream version
	-- mysql-4.0.21
 
* Fri May 21 2004 Satoshi MACHINO <machino@vinelinux.org> 4.0.20-0vl1
- new upstream version
	-- mysql-4.0.20
 
* Tue May 04 2004 Tomoya TAKA <taka@vinelinux.org> 4.0.18-0vl2
- modify CFLAGS, CXXFLAGS and configure options for alpha

* Tue Mar 23 2004 Satoshi MACHINO <machino@vinelinux.org> 4.0.18-0vl1
- Upgraded to MySQL-4
- added "with-charset=ujis" and "without-readline" to configure (vineseed-plus-02150)
- merged to MySQL Official packages
	-- renamed package "MySQL" to "MySQL-server"
	-- when using gcc, _always_ use CXX=gcc 
	-- replaced Copyright with License field (Copyright is obsolete)
	-- added myisam_ftdump to the Server package
	-- marked /etc/logrotate.d/mysql as a config file (BUG 2156)
	-- fixed file permissions (BUG 1672)
	-- removed dependency on MySQL-client from the MySQL-devel subpackage
	-- as it is not really required. (BUG 1610)
	-- Fixed BUG 1162 (removed macro names from the changelog)
	-- Really fixed BUG 998 (disable the checking for installed but
	--  unpackaged files)
	-- Fixed BUG 959 (libmysqld not being compiled properly)
	-- Fixed BUG 998 (RPM build errors): added missing files to the
	-- distribution (mysql_fix_extensions, mysql_tableinfo, mysqldumpslow,
	-- mysql_fix_privilege_tables.1), removed "-n" from install section.
	-- removed the GIF Icon (file was not included in the sources anyway)
	-- removed unused variable shared_lib_version
	-- do not run automake before building the standard binary
	--  (should not be necessary)
	-- add server suffix '-standard' to standard binary (to be in line
	-- with the binary tarball distributions)
	-- allow overriding CC and CXX (required when building 
	-- with other compilers)

* Thu Apr 14 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 3.23.56-0vl5
- added BuildRequires:  automake16
                                                                                
* Thu Apr 03 2003 Tomoya TAKA <taka@vinelinux.org> 3.23.56-0vl3
- add '-fPIC -DPIC' to CFLAGS on alpha
- little fix of spec file
                                                                                
* Thu Mar 27 2003 Tomoya TAKA <taka@vinelinux.org> 3.23.56-0vl2
- enable MySQL-shared subpackage for alpha
- delete 'BuildPrereq: kernel24-headers' for alpha
- fix shared %files (exclude sparc)
                                                                                
* Tue Mar 18 2003 Satoshi MACHINO <machino@vinelinux.org> 3.23.56-0vl1
- new upstream version
                                                                                
* Sun Mar  9 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.23.55-0vl2
- fixed devel %files (dropped *.la files)
                                                                                
* Tue Jan 28 2003 Satoshi MACHINO <machino@vinelinux.org> 3.23.55-0vl1
- new upstream version
- fixed document permission
                                                                                
* Sat Dec 21 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.54a-0vl1
- new upstream version
                                                                                
* Sat Oct 19 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.53-0vl2
- dropped MySQL-Max sub-pakage for sparc/sparc64/alpha
        -- don't work
                                                                                
* Wed Oct 16 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.53-0vl1
- new upstream version
- diseble-assembler in configure on sparc,sparc64,alpha
                                                                                
* Wed Aug 21 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.52-0vl1
- new upstream version
- moved some man files to main package
- added enable-local-infile in configure
- changed --with-extra-charsets=all in configure
                                                                                
* Fri Jun 14 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.51-0vl2
- fixed changelog
                                                                                
* Thu Jun 13 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.51-0vl1
- updated to mysql-3.23.51
                                                                                
* Fri Mar 15 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.49-0vl2
- rebuild on zlib-1.1.4(security fix.)
                                                                                
* Mon Feb 18 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.49-0vl1
- updated to mysql-2.23.49
                                                                                
* Tue Feb 12 2002 Tomoya TAKA <taka@vinelinux.org> 3.23.48-0vl2
- add 'BuildPrereq: kernel24-headers' on alpha
- remove shared library and max on alpha
                                                                                
* Tue Feb 12 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.48-0vl1
- updated to mysql-3.23.48
                                                                                
* Thu Jan 03 2002 Satoshi MACHINO <machino@vinelinux.org> 3.23.47-0vl1
- updated to mysql-3.23.47
                                                                                
* Wed Dec 05 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.46-0vl1
- updated to mysql-3.23.46
                                                                                
* Thu Nov 29 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.45-0vl1
- updated to mysql-3.23.45
                                                                                
* Tue Nov 12 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.44-0vl1
- updated to mysql-3.23.44
                                                                                
* Sat Oct 13 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.43-0vl1
- updated to mysql-3.23.43
- removed shared library and max on sparc
                                                                                
* Wed Sep 12 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.42-0vl1
- updated to mysql-3.23.42
- changed MYSQL_BUILD_CC: and MYSQL_BUILD_XCC: to -gcc
                                                                                
* Thu Aug 30 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.41-0vl1
- updated to mysql-3.23.41
                                                                                
* Wed Aug 22 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.40-0vl1
- updated to mysql-3.23.40
                                                                                
* Tue Jul 10 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.39-0vl1
- updated to mysql-3.23.39

* Sat Jun 15 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.38-1vl2
- added configure --with-charset=ujis
                                                                                
* Sun May 27 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.38-1vl2
- used some rpmmacro
                                                                                
* Fri May 25 2001 Satoshi MACHINO <machino@vinelinux.org> 3.23.38-1vl1
- updated to MySQL-3.23.38
                                                                                
* Thu Dec 07 2000 Satoshi MACHINO <machino@vinelinux.org> 3.23.28-1vl2
- removed Bench pakages
                                                                                
* Tue Dec 05 2000 Satoshi MACHINO <machino@vinelinux.org> 3.23.28-1vl1
- removed pt_BR locale
- build on Vine Linux
- partially used rpmmacros
- added %clean tag
                                                                                
* Fri Aug 18 2000 Tim Smith <tim@mysql.com>
- Added separate libmysql_r directory; now both a threaded
  and non-threaded library is shipped.
                                                                                
* Wed Sep 28 1999 David Axmark <davida@mysql.com>
- Added the support-files/my-example.cnf to the docs directory.
- Removed devel dependency on base since it is about client
  development.
                                                                                
* Wed Sep 8 1999 David Axmark <davida@mysql.com>
- Cleaned up some for 3.23.
                                                                                
* Thu Jul 1 1999 David Axmark <davida@mysql.com>
- Added support for shared libraries in a separate sub
  package. Original fix by David Fox (dsfox@cogsci.ucsd.edu)
- The --enable-assembler switch is now automatically disables on
  platforms there assembler code is unavailable. This should allow
  building this RPM on non i386 systems.
                                                                                
* Mon Feb 22 1999 David Axmark <david@detron.se>
- Removed unportable cc switches from the spec file. The defaults can
  now be overridden with environment variables. This feature is used
  to compile the official RPM with optimal (but compiler version
  specific) switches.
- Removed the repetitive description parts for the sub rpms. Maybe add
  again if RPM gets a multiline macro capability.
- Added support for a pt_BR translation. Translation contributed by
  Jorge Godoy <jorge@bestway.com.br>.
                                                                                
* Wed Nov 4 1998 David Axmark <david@detron.se>
- A lot of changes in all the rpm and install scripts. This may even
  be a working RPM :-)
                                                                                
* Sun Aug 16 1998 David Axmark <david@detron.se>
- A developers changelog for MySQL is available in the source RPM. And
  there is a history of major user visible changed in the Reference
  Manual.  Only RPM specific changes will be documented here.