File mysql.spec of Package mysql

#
# spec file for package mysql (Version 5.0.67)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           mysql
BuildRequires:  gcc-c++ ncurses-devel openssl-devel procps pwdutils readline-devel tcpd-devel zlib-devel
License:        GPL v2 only
Group:          Productivity/Databases/Servers
Version:        5.0.67
Release:        12.<RELEASE18>
# required by rcmysql
Requires:       mysql-client = %{version}
Url:            http://www.mysql.com
Summary:        A True Multiuser, Multithreaded SQL Database Server
PreReq:         /usr/sbin/useradd /usr/sbin/groupadd %install_info_prereq %fillup_prereq %insserv_prereq coreutils sed grep
Source:         mysql-%{version}.tar.bz2
Source1:        rc.mysql
Source3:        README.debug
Source4:        suse-test-run
Source5:        mysql.SuSEfirewall2
Source6:        sysconfig.mysql
Source7:        rc.mysql-multi
Patch2:         mysql-cnf.patch
Patch3:         mysql-multi-configuration.patch
Patch4:         mysql-group.patch
Patch5:         mysql-install_db-quiet.patch
Patch7:         mysql-logrotate.patch
Patch8:         mysqld_multi.patch
Patch11:        mysql-5.0.67-compiler-warnings.patch
Patch13:        mysql_upgrade-exit-status.patch
Patch15:        mysql-vpath.patch
Patch16:        mysql-5.0.67-mysql_config.patch
Patch17:        mysql-5.0.67-CVE-2008-2079.patch
Patch18:        mysql-5.0.67-mysql_install_db-localhost.patch
Patch19:        mysql-5.0.67-CVE-2008-4456.patch
Patch20:        mysql-5.0.67-CVE-2009-2446.patch
Patch40:        mysql-5.1.36-CVE-2009-4028.patch
Patch41:        mysql-5.0.67-subqueries-errors.patch
Patch42:        mysql-5.0.67-gis.patch
Patch43:        mysql-5.0.67-CVE-2008-7247.patch
Patch44:        mysql-5.0.67-CVE-2009-4030.patch
Patch45:        mysql-5.0.67-variables-big.patch
Patch46:        mysql-5.0.67-CVE-2009-4484.patch
Patch47:        mysql-5.0.67-stack.patch
Patch48:        mysql-5.0.67-stack-guard.patch
Patch49:        mysql-5.0.67-CVE-2010-1626.patch
Patch50:        mysql-5.0.67-CVE-2010-1848.patch
Patch51:        mysql-5.0.67-CVE-2010-1849.patch
Patch52:        mysql-5.0.67-CVE-2010-1850.patch
Patch53:        mysql-5.0.67-bug54477.patch
Patch54:        mysql-5.0.67-bug54575.patch
Patch55:        mysql-5.0.67-bug52711.patch
Patch56:        mysql-5.0.67-bug54007.patch
Patch57:        mysql-5.0.67-bug52512.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
SQL is the most popular database language in the world. MySQL is a
client/server implementation that consists of a server daemon (mysqld)
and many different client programs and libraries.

The main goals of MySQL are speed, robustness, and ease of use. MySQL
was originally developed because the developers at TcX needed an SQL
server that could handle very large databases an order of magnitude
faster than what any database vendor could offer them. They have now
been using MySQL since 1996 in an environment with more than 40
databases containing 10,000 tables, of which more than 500 have more
than 7 million rows. This is about 100 gigabytes of mission-critical
data.

The base upon which MySQL is built is a set of routines that have been
used in a highly demanding production environment for many years. While
MySQL is still in development, it already offers a rich and highly
useful function set.

The official way to pronounce MySQL is "My Ess Que Ell" (Not
MY-SEQUEL).

This package only contains the server-side programs.



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%package -n libmysqlclient-devel
# mysql-devel was last used in openSUSE 10.2
Provides:       mysql-devel = %version-%release
Obsoletes:      mysql-devel <= 5.0.26
Requires:       libmysqlclient15 = %version libmysqlclient_r15 = %version glibc-devel zlib-devel openssl-devel
Summary:        MySQL Development Header Files and Libraries
License:        GPL v2 only; "with additional permissions: EXCEPTIONS-CLIENT ..."; with additional permissions: EXCEPTIONS-CLIENT
Group:          Development/Libraries/C and C++

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



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%package client
License:        GPL v2 only
Summary:        MySQL Client
Group:          Productivity/Databases/Clients

%description client
This package contains the standard MySQL clients.



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%package bench
Requires:       mysql-client perl-DBD-mysql
License:        LGPL v2.1 only
Summary:        MySQL - Benchmarks
Group:          Productivity/Databases/Tools

%description bench
This package contains MySQL benchmark scripts and data.

To run these database benchmarks, start the script "run-all-tests" in
the directory /usr/share/sql-bench after starting MySQL.



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%package -n libmysqlclient15
Summary:        MySQL Shared Libraries
License:        GPL v2 only; "with additional permissions: EXCEPTIONS-CLIENT ..."; with additional permissions: EXCEPTIONS-CLIENT
Group:          Development/Libraries/Other
# make sure libmysqlclient15 replaces the 5.0.x versions of mysql-shared,
# but can coexist with 4.x versions of mysql-shared
# libmysqlclient_r15 will then be pulled in when needed
# *** this has to be removed when the package name changes ***
Provides:       mysql-shared = %version
Obsoletes:      mysql-shared >= 5.0

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



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%package -n libmysqlclient_r15
Summary:        A True Multiuser, Multithreaded SQL Database Server
License:        GPL v2 only
Group:          Productivity/Databases/Servers

%description -n libmysqlclient_r15
SQL is the most popular database language in the world. MySQL is a
client/server implementation that consists of a server daemon (mysqld)
and many different client programs and libraries.

The main goals of MySQL are speed, robustness, and ease of use. MySQL
was originally developed because the developers at TcX needed an SQL
server that could handle very large databases an order of magnitude
faster than what any database vendor could offer them. They have now
been using MySQL since 1996 in an environment with more than 40
databases containing 10,000 tables, of which more than 500 have more
than 7 million rows. This is about 100 gigabytes of mission-critical
data.

The base upon which MySQL is built is a set of routines that have been
used in a highly demanding production environment for many years. While
MySQL is still in development, it already offers a rich and highly
useful function set.

The official way to pronounce MySQL is "My Ess Que Ell" (Not
MY-SEQUEL).

This package only contains the server-side programs.



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%package Max
License:        GPL v2 only
Summary:        MySQL - Server with Berkeley DB
Group:          Productivity/Databases/Servers
Requires:       mysql = %{version}

%description Max
An optional MySQL server binary that supports features such as
transactional tables. To make use of these features, just install this
package in addition to the MySQL package.



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%package debug
License:        GPL v2 only
Summary:        MySQL server with debug options turned on
Group:          Productivity/Databases/Servers
Requires:       mysql = %{version}

%description debug
A version of the mysql-Max server that has some debug code turned on.
It should be only used to track down problems with the standard
servers. Note that merely installing this package won't replace the
standard server. Read /usr/share/doc/packages/mysql/README.debug for
information on how to use the debug server.



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%package test
License:        GPL v2 only
Summary:        MySQL testsuite
Group:          Productivity/Databases/Servers
Requires:       mysql = %{version} mysql-client = %{version} perl-DBD-mysql

%description test
This package contains the MySQL test scripts and data.

To run the testsuite, run /usr/share/mysql-test/suse-test-run (or
suse-test-run-Max for the mysql-Max package).



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%package tools
License:        GPL v2 only
Summary:        MySQL tools
Group:          Productivity/Databases/Servers
Requires:       perl-DBD-mysql
# make sure this package is installed when updating from 10.2 and older
Provides:       mysql:/usr/bin/mysqlhotcopy mysql-client:/usr/bin/perror

%description tools
A set of scripts for administering a MySQL server or developing
applications with MySQL.



Authors:
--------
    Michael Widenius <monty@mysql.com>
    David Axmark <davida@mysql.com>

%prep
%setup -q
cp %_sourcedir/suse-test-run .
%patch2
%patch3
%patch4
%patch5
%patch7
%patch8
%patch11
%patch13
%patch15
%patch16
%patch17
%patch18
%patch19
%patch20
%patch40
%patch41
%patch42
%patch43
%patch44
%patch45
%patch46 -p1
%patch47 -p1
%patch48
%patch49
%patch50
%patch51
%patch52
%patch53
%patch54
%patch55
%patch56
%patch57
# remove unneeded man manpages
rm man/mysqlman.1 man/safe_mysqld.1 man/mysql.server.1 man/make_win_*.1
rm man/mysqlmanager-pwgen.1 man/mysqlmanagerc.1
# these are generated in the builddir, remove the pregenerated files to
# avoid accidentaly using them
rm innobase/ib_config.h scripts/mysqlbug bdb/Makefile

%build
%if 0%{?suse_version} < 1000
# on sles9 autoreconf fails otherwise
cp /usr/share/libtool/ltmain.sh innobase/
%endif
autoreconf -f -i
# For some platforms the berkeley DB backend does not work.
export BERKELEY="with"
%ifarch ppc ppc64 s390 s390x mips alpha x86_64 sparc hppa
export BERKELEY="without"
%endif
# Make the compile a function, since we do it thrice
BuildMySQL() {
	# The --enable-assembler simply does nothing on systems that do not
	# support assembler speedups.
	suffix="$1"; shift
	mkdir _build$suffix
	pushd _build$suffix
	export CFLAGS="$RPM_OPT_FLAGS -DPIC -fPIC -DUNDEF_HAVE_INITGROUPS -DFORCE_INIT_OF_VARS -fno-strict-aliasing"
	export CXXFLAGS="$CFLAGS -fno-exceptions -fno-rtti"
	../configure \
		--enable-assembler \
		--without-readline \
		--enable-large-files \
		--infodir=%{_infodir} \
		--libdir=%{_libdir} \
		--libexecdir=/usr/sbin \
		--localstatedir=/var/lib/mysql \
		--mandir=%{_mandir} \
		--prefix=%{_prefix} \
		--sysconfdir=/etc \
		--with-mysqld-user=mysql \
		--with-isam \
		--without-debug \
		--datadir=/usr/share \
		--includedir=/usr/include \
		--with-extra-charsets=complex \
		--with-unix-socket-path=/var/lib/mysql/mysql.sock \
		--enable-thread-safe-client \
		--with-comment="SUSE MySQL RPM" \
		--with-libwrap \
		--with-server-suffix=$suffix \
		--with-big-tables \
		HOSTNAME="/bin/hostname -f" \
		"$@"
	# Add this for MyISAM RAID support:
	# --with-raid
	# benchdir does not fit in above model. Fix when we make a separate package
	make %{?jobs:-j%jobs} benchdir=%buildroot/usr/share/sql-bench
	nm --numeric-sort sql/mysqld > sql/mysqld.sym
	# needed for make check, which is not VPATH aware
	# copy the files unconditionally so that manual 'make check' after
	# the build works, too
	cp -a ../mysql-test/* mysql-test/
	cp -a ../sql/share/{english,charsets} sql/share/
	cp -a ../scripts/*.sql scripts/
%if %{?_with_testsuite:1}0
	pushd mysql-test; perl ./mysql-test-run.pl --force; popd
%endif
	popd
}
# Build the client, extra tools, libraries and mysqld-max
BuildMySQL "-max" --with-server-suffix=-Max \
		--${BERKELEY}-berkeley-db \
		--with-openssl \
		--with-innodb \
		--with-embedded-server \
		--with-extra-tools \
		--with-archive-storage-engine \
		--with-csv-storage-engine \
		--with-example-storage-engine \
		--with-blackhole-storage-engine \
		--with-federated-storage-engine
# safeguard: don't use distributed pregenerated files instead of generated ones
find _build-max/ -type f -printf '%%P\n' | grep -v '^mysql-test' | sort >_t1
find . -type f -printf '%%P\n' | sort >_t2
join _t[12] | {
	err=0
	while read f; do
		if ! cmp "$f" _build-max/"$f"; then
			err=1;
		fi
	done
	if test "$err" = "1"; then
		echo "%buildsubdir/ seems to contain pregenerated distributed files"
		echo "that are different from generated files in %buildsubdir/_build-max/."
		echo "Better remove the distributed files in %%prep to avoid using these during build."
	fi
	exit $err
} || exit
rm _t[12]
# build mysqld-debug (speed up normal build by skipping tests/ and client/)
BuildMySQL "-debug" --with-server-suffix=-debug \
		--${BERKELEY}-berkeley-db \
		--with-openssl \
		--with-innodb \
		--with-debug \
		--without-extra-tools \
		--without-embedded-server \
		--with-csv-storage-engine \
		--with-example-storage-engine \
		--with-blackhole-storage-engine \
		--with-federated-storage-engine
# Now build the standard mysqld
BuildMySQL "" \
		--without-berkeley-db \
		--without-openssl \
		--with-innodb \
		--without-extra-tools \
		--without-embedded-server

%install
# install client, extra tools, libraries and mysql-max
make -C _build-max install DESTDIR=%buildroot benchdir_root=/usr/share/
mv %buildroot/usr/sbin/mysqld %buildroot/usr/sbin/mysqld-max
install -m 644 _build-max/sql/mysqld.sym \
	%buildroot%{_libdir}/mysql/mysqld-max.sym
# install the debug server
make -C _build-debug/sql install DESTDIR=%buildroot
mv %buildroot/usr/sbin/mysqld %buildroot/usr/sbin/mysqld-debug
install -m 644 _build-debug/sql/mysqld.sym %buildroot%_libdir/mysql/mysqld-debug.sym
# install the standard server
# (this must be the last one, otherwise /usr/sbin/mysqld would get overwritten)
make -C _build/sql install DESTDIR=%buildroot
install -m 644 _build/sql/mysqld.sym %buildroot%_libdir/mysql/mysqld.sym
# move the shared libs directly to %_libdir
pushd %buildroot%{_libdir}/mysql
	for f in libmysqlclient*.so*; do
		mv "$f" ..
		ln -s ../"$f"
	done
popd
# generate filelist for binaries and their manpages (easier than enumerating
# all the binaries and manapages manually, esp. when there are new manpages in
# each release)
filelist()
{
	echo '%%defattr(-, root, root)'
	pushd %buildroot >/dev/null
	for i; do
		if test -e usr/sbin/"$i"; then
			echo /usr/sbin/"$i"
		else
			# if it doesn't exist, rpmbuild will fail after
			# %%install
			echo /usr/bin/"$i"
		fi
		if ls usr/share/man/*/"$i".[1-9]* >/dev/null 2>&1; then
			echo "%%doc %_mandir/*/$i.[1-9]*"
		fi
	done
	popd >/dev/null
}
filelist innochecksum my_print_defaults myisam_ftdump myisamchk myisamlog myisampack mysql_fix_extensions mysql_fix_privilege_tables mysql_install_db mysql_secure_installation mysql_upgrade mysqlbug mysqld mysqld_multi mysqld_safe mysqlbinlog mysqldumpslow mysqlmanager resolve_stack_dump resolveip >mysql.files
filelist mysql mysqladmin mysqlcheck mysqldump mysqlimport mysqlshow >mysql-client.files
filelist comp_err mysql_config >libmysqlclient-devel.files
filelist mysql_client_test mysql_client_test_embedded mysql_waitpid mysqltest mysqltest_embedded mysqltestmanager mysqltestmanager-pwgen mysqltestmanagerc >mysql-test.files
# all binaries that don't need to be in a "default" install (mysql.rpm +
# mysql-client.rpm)
filelist msql2mysql mysql_convert_table_format mysql_explain_log mysql_find_rows mysql_setpermission mysql_tableinfo mysql_tzinfo_to_sql mysql_zap mysqlaccess mysqlhotcopy perror replace >mysql-tools.files
### files not installed by make install
# Create directory structure
DOCS=(COPYING README EXCEPTIONS-CLIENT %_sourcedir/README.debug)
DOCDIR=%buildroot%_defaultdocdir/%name
install -d -m 755 ${DOCDIR}
install -d -m 755 %buildroot/etc/logrotate.d
install -d -m 755 %buildroot/etc/init.d
install -d -m 755 %buildroot/var/lib/mysql
install -m 644 _build/support-files/mysql-log-rotate %buildroot/etc/logrotate.d/mysql
install -m 660 _build/support-files/my-medium.cnf %buildroot/etc/my.cnf
install -m 640 scripts/mysqlaccess.conf %buildroot/etc/mysqlaccess.conf
install -m 644 "${DOCS[@]}" ${DOCDIR}
install -m 755 %_sourcedir/rc.mysql-multi %buildroot/etc/init.d/mysql
ln -sf ../../etc/init.d/mysql %buildroot/usr/sbin/rcmysql
install -m 755 -d %buildroot/var/lib/mysql/.tmp
# this is used by the init script
install -m 700 -d %buildroot/var/lib/mysql/.protected
# SuSEfirewall service description
install -D -m 644 %_sourcedir/mysql.SuSEfirewall2 \
	%buildroot/etc/sysconfig/SuSEfirewall2.d/services/mysql
# testsuite
install -m 755 suse-test-run %buildroot/usr/share/mysql-test/
ln -s suse-test-run %buildroot/usr/share/mysql-test/suse-test-run-max
# XXX this should go under /var/..., but some tests get confused by a symlink
# var -> ../../../var/...
#ln -sf ../../../var/lib/mysql/mysql-test %buildroot/usr/share/mysql-test/var
mkdir %buildroot/usr/share/mysql-test/var
# Install the /etc/sysconfig/mysql file
mkdir -p %buildroot/var/adm/fillup-templates
install -m 700 %_sourcedir/sysconfig.mysql ${RPM_BUILD_ROOT}/var/adm/fillup-templates
# not needed, replaced by mysql_upgrade.c
rm %buildroot/usr/bin/mysql_upgrade_shell

%pre
/usr/sbin/groupadd -r mysql >/dev/null 2>/dev/null || :
/usr/sbin/useradd -r -o -g mysql -u 60 -c "MySQL database admin" \
                  -s /bin/false -d /var/lib/mysql mysql 2> /dev/null || :
/usr/sbin/usermod -g mysql -s /bin/false mysql
dbfile=var/mysql/mysql/db.ISM
olddir=var/mysql
newdir=var/lib/mysql
# Do the database files still belong to root (very old installation)?
# Change ownerships
if [ -O $dbfile ]
then
chown -Rv mysql:mysql var/mysql/
fi
# Copy existing database files to the new location
# only if they do not exist yet!
if [ -d $olddir ] && ! [ -d $newdir ]
then
cp -a $olddir $newdir || echo "Error while copying the database files to the new location!"
fi

%post
touch /var/lib/mysql/.run-mysql_upgrade
%{fillup_and_insserv mysql}
%install_info --info-dir=%{_infodir} %{_infodir}/mysql.info.gz
chown -R mysql:mysql /var/lib/mysql
# users usually look into /var/log for logfiles
# doing this in %%build wouldn't pass brp-symlink
# also we don't want to overwrite existing files (actaully sth like %%ghost)
ln -s ../lib/mysql/mysqld.log /var/log/mysqld.log 2>/dev/null || :
# err-log was renamed to log-error
if grep -q '^err-log' /etc/my.cnf; then
	sed -i 's/^err-log/log-error/' /etc/my.cnf
fi

%post Max
touch /var/lib/mysql/.run-mysql_upgrade

%post -n libmysqlclient15 -p /sbin/ldconfig

%post -n libmysqlclient_r15 -p /sbin/ldconfig

%postun -n libmysqlclient15 -p /sbin/ldconfig

%postun -n libmysqlclient_r15 -p /sbin/ldconfig

%preun
%stop_on_removal mysql

%postun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/mysql.info.gz
%restart_on_update mysql
%{insserv_cleanup}

%clean
rm -rf %buildroot

%files -f mysql.files
%defattr(-, root, root)
%config(noreplace) %attr(-, mysql, mysql) /etc/my.cnf
%config /etc/logrotate.d/mysql
%doc %{_defaultdocdir}/%{name}
%doc %{_infodir}/mysql.info.gz
/etc/init.d/mysql
/usr/sbin/rcmysql
/usr/share/mysql/
%attr(755,mysql,mysql)/var/lib/mysql
%attr(700,mysql,mysql)/var/lib/mysql/.protected
%dir %{_libdir}/mysql
%{_libdir}/mysql/mysqld.sym
%{_localstatedir}/adm/fillup-templates/sysconfig.mysql
/etc/sysconfig/SuSEfirewall2.d/services/mysql

%files client -f mysql-client.files
%defattr(-, root, root)
%config /etc/mysqlaccess.conf

%files -n libmysqlclient-devel -f libmysqlclient-devel.files
%defattr(-, root, root)
/usr/include/mysql
%dir %{_libdir}/mysql
%{_libdir}/mysql/*.*a
%{_libdir}/libmysqlclient.so
%{_libdir}/libmysqlclient_r.so
%{_libdir}/mysql/libmysqlclient.so
%{_libdir}/mysql/libmysqlclient_r.so

%files bench
%defattr(-, root, root)
/usr/share/sql-bench

%files -n libmysqlclient15
%defattr(-, root, root)
%{_libdir}/libmysqlclient.so.*
%{_libdir}/mysql/libmysqlclient.so.*

%files -n libmysqlclient_r15
%defattr(-, root, root)
%{_libdir}/libmysqlclient_r.so.*
%{_libdir}/mysql/libmysqlclient_r.so.*

%files Max
%defattr(-, root, root)
/usr/sbin/mysqld-max
%{_libdir}/mysql/mysqld-max.sym

%files debug
%defattr(-, root, root)
/usr/sbin/mysqld-debug
%{_libdir}/mysql/mysqld-debug.sym

%files test -f mysql-test.files
%defattr(-, root, root)
%_mandir/man1/mysql-test-run.pl.1*
%_mandir/man1/mysql-stress-test.pl.1*
/usr/share/mysql-test
%dir %attr(755, mysql, mysql) /usr/share/mysql-test/var

%files tools -f mysql-tools.files

%changelog
openSUSE Build Service is sponsored by