michael@527: ## michael@527: ## mysql.spec -- OpenPKG RPM Package Specification michael@527: ## Copyright (c) 2000-2012 OpenPKG Foundation e.V. michael@527: ## michael@527: ## Permission to use, copy, modify, and distribute this software for michael@527: ## any purpose with or without fee is hereby granted, provided that michael@527: ## the above copyright notice and this permission notice appear in all michael@527: ## copies. michael@527: ## michael@527: ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@527: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@527: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@527: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@527: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@527: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@527: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@527: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@527: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@527: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@527: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@527: ## SUCH DAMAGE. michael@527: ## michael@527: michael@527: # package version michael@527: %define V_major 5.1 michael@527: %define V_minor 63 michael@527: %define V_mysql %{V_major}.%{V_minor} michael@527: %define V_opkg %{V_major}.%{V_minor} michael@527: %define V_jdbc 5.1.21 michael@527: michael@527: # package information michael@527: Name: mysql michael@527: Summary: Fast Relational Database Management System michael@527: URL: http://www.mysql.com/products/mysql/ michael@527: Vendor: ORACLE michael@527: Packager: OpenPKG Foundation e.V. michael@527: Distribution: OpenPKG Community michael@527: Class: BASE michael@527: Group: Database michael@527: License: GPL michael@527: Version: %{V_opkg} michael@527: Release: 20120704 michael@527: michael@527: # package options michael@527: %option with_server yes michael@527: %option with_innobase yes michael@527: %option with_archive no michael@527: %option with_blackhole no michael@527: %option with_federated no michael@527: %option with_ndbcluster no michael@527: %option with_partition no michael@527: %option with_ssl no michael@527: %option with_embedded no michael@527: %option with_charset utf8 michael@527: %option with_collation utf8_unicode_ci michael@527: %option with_jdbc no michael@527: michael@527: # fixing implicit inter-plugin dependencies and correlations michael@527: %if "%{with_ndbcluster}" == "yes" michael@527: %undefine with_partition michael@527: %define with_partition yes michael@527: %endif michael@527: michael@527: # list of sources michael@527: Source0: http://ftp.gwdg.de/pub/misc/mysql/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz michael@527: Source1: http://ftp.gwdg.de/pub/misc/mysql/Downloads/Connector-J/mysql-connector-java-%{V_jdbc}.tar.gz michael@527: Source2: my.cnf michael@527: Source3: my.pwd michael@527: Source4: rc.mysql michael@527: Patch0: mysql.patch michael@527: michael@527: # build information michael@527: BuildPreReq: OpenPKG, openpkg >= 20100101, perl, make, gcc, gcc::with_cxx = yes michael@527: PreReq: OpenPKG, openpkg >= 20100101, perl michael@527: BuildPreReq: zlib, readline, ncurses michael@527: PreReq: zlib, readline, ncurses michael@527: %if "%{with_ssl}" == "yes" michael@527: BuildPreReq: openssl michael@527: PreReq: openssl michael@527: %endif michael@527: %if "%{with_jdbc}" == "yes" michael@527: PreReq: java, JAVA-JDK michael@527: %endif michael@527: michael@527: %description michael@527: MySQL is a multi-user Relational Database Management System (RDBMS), michael@527: which is controlled through Structured Query Language (SQL) michael@527: operating in full multi-threading mode. The main goals of MySQL are michael@527: speed, robustness and ease of use. MySQL was originally developed michael@527: because of the need for a SQL server that could handle very big michael@527: databases with magnitude higher speed than what any database vendor michael@527: could offer. michael@527: michael@527: %track michael@527: prog mysql = { michael@527: version = %{V_mysql} michael@527: url = http://dev.mysql.com/downloads/mysql/%{V_major}.html michael@527: regex = mysql-(__VER__)\.tar\.gz michael@527: } michael@527: prog mysql:connector-jdbc = { michael@527: version = %{V_jdbc} michael@527: url = http://dev.mysql.com/downloads/connector/j/%{V_major}.html michael@527: regex = mysql-connector-java-(__VER__)\.tar\.gz michael@527: } michael@527: michael@527: %prep michael@527: %setup -q michael@527: %if "%{with_jdbc}" == "yes" michael@527: %setup -q -T -D -a 1 michael@527: %endif michael@527: %patch -p0 michael@527: michael@527: %build michael@527: # patch file search path michael@527: %{l_shtool} subst %{l_value -s -a} \ michael@527: mysys/default.c michael@527: michael@527: # fix shebang on supplemental Perl scripts michael@527: rm -f scripts/*.orig michael@527: %{l_shtool} subst \ michael@527: -e 's;^#!/usr/bin/perl;#!%{l_prefix}/bin/perl;' \ michael@527: scripts/* michael@527: michael@527: # determine additional configure options michael@527: case "%{l_platform -t}" in michael@527: *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;; michael@527: *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;; michael@527: *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;; michael@527: esac michael@527: michael@527: # configure source tree michael@527: CC="%{l_cc}" \ michael@527: CXX="%{l_cxx}" \ michael@527: CFLAGS="%{l_cflags -O}" \ michael@527: CXXFLAGS="%{l_cxxflags -O}" \ michael@527: CPPFLAGS="%{l_cppflags ncurses}" \ michael@527: LDFLAGS="-L`pwd`/libmysql %{l_ldflags}" \ michael@527: LIBS="-lz" \ michael@527: ./configure \ michael@527: --prefix=%{l_prefix} \ michael@527: --mandir=%{l_prefix}/man \ michael@527: --infodir=%{l_prefix}/info \ michael@527: --sysconfdir=%{l_prefix}/etc/mysql \ michael@527: --localstatedir=%{l_prefix}/var/mysql \ michael@527: --libexecdir=%{l_prefix}/libexec/mysql \ michael@527: --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \ michael@527: --with-mysqld-user=%{l_musr} \ michael@527: --enable-thread-safe-client \ michael@527: --with-comment="%{l_openpkg_release}" \ michael@527: %if "%{with_server}" != "yes" michael@527: --without-server \ michael@527: %else michael@527: --with-server \ michael@527: --with-plugin-csv \ michael@527: --with-plugin-heap \ michael@527: --with-plugin-myisam \ michael@527: --with-plugin-myisammrg \ michael@527: %if "%{with_innobase}" == "yes" michael@527: --with-plugin-innobase \ michael@527: %else michael@527: --without-plugin-innobase \ michael@527: %endif michael@527: %if "%{with_archive}" == "yes" michael@527: --with-plugin-archive \ michael@527: %else michael@527: --without-plugin-archive \ michael@527: %endif michael@527: %if "%{with_blackhole}" == "yes" michael@527: --with-plugin-blackhole \ michael@527: %else michael@527: --without-plugin-blackhole \ michael@527: %endif michael@527: %if "%{with_federated}" == "yes" michael@527: --with-plugin-federated \ michael@527: %else michael@527: --without-plugin-federated \ michael@527: %endif michael@527: %if "%{with_ndbcluster}" == "yes" michael@527: --with-plugin-ndbcluster \ michael@527: %else michael@527: --without-plugin-ndbcluster \ michael@527: %endif michael@527: %if "%{with_partition}" == "yes" michael@527: --with-plugin-partition \ michael@527: %else michael@527: --without-plugin-partition \ michael@527: %endif michael@527: %endif michael@527: --with-zlib-dir=%{l_prefix} \ michael@527: %if "%{with_ssl}" == "yes" michael@527: --with-ssl=%{l_prefix} \ michael@527: %endif michael@527: %if "%{with_embedded}" == "yes" michael@527: --with-embedded-server \ michael@527: %endif michael@527: --with-charset=%{with_charset} \ michael@527: --with-collation=%{with_collation} \ michael@527: --without-readline \ michael@527: --without-libedit \ michael@527: --with-big-tables \ michael@527: --with-low-memory \ michael@527: --disable-shared \ michael@527: $opt michael@527: michael@527: # build source tree michael@527: %{l_make} %{l_mflags} michael@527: michael@527: %install michael@527: michael@527: # patch init script michael@527: %{l_shtool} subst %{l_value -s -a} \ michael@527: scripts/mysql_install_db.sh michael@527: michael@527: # perform standard installation procedure michael@527: %{l_make} %{l_mflags} install \ michael@527: AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \ michael@527: DESTDIR=$RPM_BUILD_ROOT michael@527: michael@527: # cleanup mysql_config script michael@527: %{l_shtool} subst \ michael@527: -e 's;^\(ldflags=.\).*\(.\)$;\1%{l_ldflags}\2;' \ michael@527: $RPM_BUILD_ROOT%{l_prefix}/bin/mysql_config michael@527: michael@527: # move utility 'replace', msql2mysql is patched for new path michael@527: mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \ michael@527: $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/ michael@527: michael@527: # strip installation area michael@527: rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test michael@527: rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err michael@527: strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true michael@527: strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true michael@527: %if "%{with_ndbcluster}" == "yes" michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ndb* michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/ndb* michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/ndb* michael@527: rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/mysql/storage/ndb michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/libndb* michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/ndb* michael@527: rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/ndb-config-2-node.ini michael@527: %endif michael@527: michael@527: # install global configuration michael@527: %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql michael@527: sed <%{SOURCE my.cnf} >my.cnf \ michael@527: %if "%{with_innobase}" == "yes" michael@527: -e '/<\/\{0,1\}with_innobase>/d' michael@527: %else michael@527: -e '//,/<\/with_innobase>/d' michael@527: %endif michael@527: %{l_shtool} install -c -m 644 %{l_value -s -a} \ michael@527: my.cnf \ michael@527: $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/ michael@527: %{l_shtool} install -c -m 600 \ michael@527: %{SOURCE my.pwd} \ michael@527: $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/ michael@527: michael@527: # install run-command script michael@527: %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d michael@527: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@527: %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ michael@527: michael@527: # make sure the database directory exists michael@527: %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql michael@527: michael@527: # directory for temporary tables michael@527: %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp michael@527: michael@527: # optional client-only installation michael@527: %if "%{with_server}" != "yes" michael@527: rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql michael@527: ( cd $RPM_BUILD_ROOT%{l_prefix}/bin michael@527: for bin in *; do michael@527: case "$bin" in michael@527: mysql | mysql_config ) ;; michael@527: * ) rm -f $bin ;; michael@527: esac michael@527: done michael@527: ) || exit $? michael@527: ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1 michael@527: for man in *; do michael@527: case "$man" in michael@527: mysql.1 | mysql_config.1 ) ;; michael@527: * ) rm -f $man ;; michael@527: esac michael@527: done michael@527: ) || exit $? michael@527: %endif michael@527: michael@527: # install JDBC driver michael@527: %if "%{with_jdbc}" == "yes" michael@527: ( cd mysql-connector-java-%{V_jdbc} michael@527: %{l_shtool} install -c -m 644 \ michael@527: mysql-connector-java-%{V_jdbc}-bin.jar \ michael@527: $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/mysql.jar michael@527: ) || exit $? michael@527: %endif michael@527: michael@527: # determine the package files michael@527: %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ michael@527: %if "%{with_server}" == "yes" michael@527: %{l_files_std} \ michael@527: '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \ michael@527: '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \ michael@527: '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \ michael@527: '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp' michael@527: %else michael@527: %{l_files_std} michael@527: %endif michael@527: michael@527: %files -f files michael@527: michael@527: %clean michael@527: michael@527: %pre michael@527: %if "%{with_server}" == "yes" michael@527: # before upgrade, save status and stop service michael@527: [ $1 -eq 2 ] || exit 0 michael@527: eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}` michael@527: %{l_rc} mysql stop 2>/dev/null michael@527: %endif michael@527: exit 0 michael@527: michael@527: %post michael@527: %if "%{with_server}" == "yes" michael@527: if [ $1 -eq 1 ]; then michael@527: # after install, create initial database michael@527: $RPM_INSTALL_PREFIX/bin/mysql_install_db \ michael@527: --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1 michael@527: chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/* michael@527: ( echo "An initial MySQL DB was created. The owner of the database" michael@527: echo "is the DB user 'root'. Its initial password is empty." michael@527: echo "After starting MySQL with..." michael@527: echo "" michael@527: echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start" michael@527: echo "" michael@527: echo "...you should change the password as soon as possible with:" michael@527: echo "" michael@527: echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ " michael@527: echo " -u root password ''" michael@527: echo "" michael@527: echo "Additionally, because the MySQL package includes automated" michael@527: echo "maintenance procedures that require administrator access to" michael@527: echo "the database, you must maintain a (plain text) copy of the" michael@527: echo "administrator account name and password:" michael@527: echo "" michael@527: echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd" michael@527: ) | %{l_rpmtool} msg -b -t notice michael@527: fi michael@527: if [ $1 -eq 2 ]; then michael@527: # after upgrade, restore status michael@527: { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1 michael@527: [ ".$mysql_active" = .yes ] && %{l_rc} mysql start michael@527: fi michael@527: %endif michael@527: exit 0 michael@527: michael@527: %preun michael@527: %if "%{with_server}" == "yes" michael@527: # before erase, stop service and remove log files michael@527: [ $1 -eq 0 ] || exit 0 michael@527: %{l_rc} mysql stop 2>/dev/null michael@527: rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true michael@527: rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true michael@527: %endif michael@527: exit 0 michael@527: