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@528: %define V_major 5.5
michael@528: %define V_minor 27
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@528: Release: 20120800
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@528: %option with_perfschema 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@528: # fixing implicit interplugin 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@528: Source0: http://www.mysql.com/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@698: BuildPreReq: OpenPKG, openpkg >= 20100101, perl, make, cmake, 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@528: MySQL is a multiuser Relational Database Management System (RDBMS),
michael@527: which is controlled through Structured Query Language (SQL)
michael@528: operating in full multithreading 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: # 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@528: %build
michael@528: # create build subdirectory
michael@528: %{l_shtool} mkdir -p objbld
michael@528: cd objbld
michael@527:
michael@528: # configure environment
michael@528: export CC="%{l_cc}"
michael@528: export CXX="%{l_cxx}"
michael@528: export CFLAGS="%{l_cflags -O}"
michael@528: export CXXFLAGS="%{l_cxxflags -O} -felide-constructors -fno-exceptions -fno-rtti"
michael@528: export CPPFLAGS="%{l_cppflags ncurses}"
michael@528: export LDFLAGS="-L`pwd`/libmysql %{l_ldflags}"
michael@528: export LIBS="-lz"
michael@528:
michael@528: # Configure source tree.
michael@528: # Tips are in mysql_release.cmake
michael@528: # or run cmake(1) -L for all opts
michael@528: # Disable dtrace(1) to avoid 'mysqld_dtrace_all.o: file not recognized: Bad value'
michael@528: %{l_prefix}/bin/cmake \
michael@528: -DCMAKE_INSTALL_PREFIX="%{l_prefix}" \
michael@528: -DCMAKE_BUILD_TYPE="RelWithDebInfo" \
michael@528: -DINSTALL_DOCDIR="share/mysql/doc" \
michael@528: -DINSTALL_DOCREADMEDIR="share/mysql/doc" \
michael@528: -DINSTALL_INCLUDEDIR="include/mysql" \
michael@528: -DINSTALL_INFODIR:STRING="info" \
michael@528: -DINSTALL_MYSQLSHAREDIR="share/mysql" \
michael@528: -DINSTALL_SBINDIR="libexec/mysql" \
michael@528: -DINSTALL_SHAREDIR="share/mysql" \
michael@528: -DINSTALL_SCRIPTDIR="bin" \
michael@528: -DINSTALL_SUPPORTFILESDIR="share/mysql" \
michael@528: -DMYSQL_UNIX_ADDR="%{l_prefix}/var/mysql/mysql.sock" \
michael@528: -DFEATURE_SET="community" \
michael@528: -DCOMPILATION_COMMENT="%{l_openpkg_release}" \
michael@528: -DMANUFACTURER="Built from OpenPKG sources" \
michael@528: -DDEFAULT_CHARSET="%{with_charset}" \
michael@528: -DDEFAULT_COLLATION="%{with_collation}" \
michael@528: -DMYSQL_USER="%{l_musr}" \
michael@528: -DWITH_ZLIB=system \
michael@528: -DWITH_READLINE=YES \
michael@528: -DWITH_LIBEDIT=NO \
michael@528: -DWITH_LIBWRAP=NO \
michael@528: -DDISABLE_SHARED=YES \
michael@528: -DENABLE_DTRACE=NO \
michael@528: -DZLIB_INCLUDE_DIR=%{l_cppflags zlib} \
michael@528: -DPKG_CONFIG_EXECUTABLE="PKG_CONFIG_EXECUTABLE-NOTFOUND" \
michael@527: %if "%{with_server}" != "yes"
michael@528: -DWITHOUT_SERVER=YES \
michael@528: %endif
michael@528: %if "%{with_ssl}" == "yes"
michael@528: -DWITH_SSL=system \
michael@528: -DOPENSSL_INCLUDE_DIR="%{l_cppflags openssl}" \
michael@528: -DOPENSSL_SSL_LIBRARY="%{l_prefix}/lib/libssl.a" \
michael@528: -DOPENSSL_CRYPTO_LIBRARY="%{l_prefix}/lib/libcrypto.a" \
michael@528: -DCRYPTO_LIBRARY="%{l_prefix}/lib/libcrypto.a" \
michael@527: %else
michael@528: -DWITH_SSL=NO \
michael@528: %endif
michael@527: %if "%{with_innobase}" == "yes"
michael@528: -DWITH_INNOBASE_STORAGE_ENGINE=YES \
michael@527: %else
michael@528: -DWITH_INNOBASE_STORAGE_ENGINE=NO \
michael@527: %endif
michael@527: %if "%{with_archive}" == "yes"
michael@528: -DWITH_ARCHIVE_STORAGE_ENGINE=YES \
michael@527: %else
michael@528: -DWITH_ARCHIVE_STORAGE_ENGINE=NO \
michael@527: %endif
michael@527: %if "%{with_blackhole}" == "yes"
michael@528: -DWITH_BLACKHOLE_STORAGE_ENGINE=YES \
michael@527: %else
michael@528: -DWITH_BLACKHOLE_STORAGE_ENGINE=NO \
michael@527: %endif
michael@527: %if "%{with_federated}" == "yes"
michael@528: -DWITH_FEDERATED_STORAGE_ENGINE=YES \
michael@527: %else
michael@528: -DWITH_FEDERATED_STORAGE_ENGINE=NO \
michael@527: %endif
michael@527: %if "%{with_ndbcluster}" == "yes"
michael@528: -DWITH_NDBCLUSTER_STORAGE_ENGINE=YES \
michael@527: %else
michael@528: -DWITH_NDBCLUSTER_STORAGE_ENGINE=NO \
michael@527: %endif
michael@527: %if "%{with_partition}" == "yes"
michael@528: -DWITH_PARTITION_STORAGE_ENGINE=YES \
michael@527: %else
michael@528: -DWITH_PARTITION_STORAGE_ENGINE=NO \
michael@527: %endif
michael@528: %if "%{with_perfschema}" == "yes"
michael@528: -DWITH_PERFSCHEMA_STORAGE_ENGINE=YES \
michael@528: %else
michael@528: -DWITH_PERFSCHEMA_STORAGE_ENGINE=NO \
michael@527: %endif
michael@527: %if "%{with_embedded}" == "yes"
michael@528: -DWITH_EMBEDDED_SERVER=YES \
michael@528: %else
michael@528: -DWITH_EMBEDDED_SERVER=NO \
michael@527: %endif
michael@528: ..
michael@527:
michael@528: # build source tree (VERBOSE=1)
michael@528: %{l_make} %{l_mflags -O}
michael@527:
michael@527: %install
michael@528: # install from build subdirectory
michael@528: cd objbld
michael@527:
michael@528: ## patch init script (this broken)
michael@528: #%{l_shtool} subst %{l_value -s -a} \
michael@528: # bin/mysql_install_db.sh
michael@527:
michael@527: # perform standard installation procedure
michael@527: %{l_make} %{l_mflags} install \
michael@527: DESTDIR=$RPM_BUILD_ROOT
michael@527:
michael@528: # cleanup scripts
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@528: # move utilities, patched for new paths
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@528: rm -rf $RPM_BUILD_ROOT%{l_prefix}/data
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}/share/mysql/binary-configure
michael@528: rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/ndb-config-2-node.ini
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: %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@528: # install runcommand 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@528: # mitigate complex buildconf
michael@528: %{l_shtool} install -c -m 644 \
michael@698: ../INSTALL-SOURCE $RPM_BUILD_ROOT%{l_prefix}/share/mysql/doc/
michael@528:
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@698: %{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@698: '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
michael@698: %else
michael@698: %{l_files_std}
michael@528: %endif
michael@527:
michael@528: %files -f objbld/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@698: cd $RPM_INSTALL_PREFIX && $RPM_INSTALL_PREFIX/bin/mysql_install_db \
michael@698: --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf \
michael@698: --ldata=$RPM_INSTALL_PREFIX/var/mysql \
michael@698: --user=%{l_rusr} >/dev/null 2>&1
michael@698: chgrp %{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/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@698: echo "...or alternatively, even better secure the database with:"
michael@698: echo ""
michael@698: echo " \$ $RPM_INSTALL_PREFIX/bin/mysql_secure_installation"
michael@698: 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: