# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils gnuconfig gcc flag-o-matic versionator SVER=$(get_version_component_range 1-2) PLV="" NEWP="${PN}-${SVER}.$( get_version_component_range 3-3 )${PLV}" # shorten the path because the socket path length must be shorter than 107 chars # and we will run a mysql server during test phase S="${WORKDIR}/${PN}" DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" HOMEPAGE="http://www.mysql.com/" SRC_URI="mirror://mysql/Downloads/MySQL-${SVER}/${NEWP}.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="~x86 ~amd64" IUSE="debug ssl tcpd" RESTRICT="nomirror" DEPEND="readline? ( >=sys-libs/readline-4.1 ) tcpd? ( >=sys-apps/tcp-wrappers-7.6-r6 ) ssl? ( >=dev-libs/openssl-0.9.6d ) >=sys-libs/zlib-1.1.3 >=sys-apps/texinfo-4.7-r1 || ( sys-apps/procps sys-process/procps ) >=sys-apps/sed-4" RDEPEND="${DEPEND} selinux? ( sec-policy/selinux-mysql )" src_unpack() { unpack ${A} || die mv "${WORKDIR}/${NEWP}" "${S}" cd "${S}" epatch "${FILESDIR}/gentoo-nptl-4.0.18.diff" # attempt to get libmysqlclient_r linked against ssl if USE="ssl" enabled # i would really prefer to fix this at the Makefile.am level, but can't # get the software to autoreconf as distributed - too many missing files epatch "${FILESDIR}/thrssl-4.1.9.patch" if use tcpd; then epatch "${FILESDIR}/tcpd-vars-fix-4.0.14-r1.diff" fi for d in ${S} ; do cd ${d} # WARNING, plain autoconf breaks it! #autoconf # must use this instead WANT_AUTOCONF=2.59 autoreconf --force # Fix the evil "libtool.m4 and ltmain.sh have a version mismatch!" libtoolize --copy --force # Saving this for a rainy day, in case we need it again #WANT_AUTOMAKE=1.7 automake gnuconfig_update done } src_compile() { local myconf myconf="${myconf} `use_with tcpd libwrap`" use ssl \ && myconf="${myconf} --with-vio --with-openssl" \ || myconf="${myconf} --without-openssl" if use debug; then myconf="${myconf} --with-debug=full" else myconf="${myconf} --without-debug" version_is_at_least "4.1.3" && use cluster && myconf="${myconf} --without-ndb-debug" fi myconf="${myconf} --without-bench" # these are things we exclude from a minimal build # note that the server actually does get built and installed # but we then delete it before packaging. local minimal_exclude_list="server embedded-server extra-tools innodb raid" for i in ${minimal_exclude_list}; do myconf="${myconf} --without-${i}" done myconf="${myconf} --without-berkeley-db" myconf="${myconf} --with-extra-charsets=none" #glibc-2.3.2_pre fix; bug #16496 append-flags " -DHAVE_ERRNO_AS_DEFINE=1" #the compiler flags are as per their "official" spec ;) #CFLAGS="${CFLAGS/-O?/} -O3" \ export CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-exceptions -fno-rtti" append-flags "-D_GNU_SOURCE" econf \ --libexecdir=/usr/sbin \ --sysconfdir=/etc/mysql \ --localstatedir=/var/lib/mysql \ --with-low-memory \ --enable-assembler \ --enable-local-infile \ --with-mysqld-user=mysql \ --with-client-ldflags=-lstdc++ \ --enable-thread-safe-client \ --with-comment="Gentoo Linux ${PF}" \ --with-unix-socket-path=/var/run/mysqld/mysqld.sock \ --with-zlib-dir=/usr \ --with-lib-ccflags="-fPIC" \ ${myconf} || die "bad ./configure" emake || die "compile problem" } src_install() { make install DESTDIR="${D}" benchdir_root="/usr/share/mysql" || die diropts "-m0750" dodir "${DATADIR}" /var/run/mysqld /var/log/mysql keepdir "${DATADIR}" /var/run/mysqld /var/log/mysql chown -R mysql:mysql ${D}/var/lib/mysql \ ${D}/var/run/mysqld \ ${D}/var/log/mysql diropts "-m0755" # move client libs, install a couple of missing headers mv ${D}/usr/$(get_libdir)/mysql/libmysqlclient*.so* ${D}/usr/$(get_libdir) dosym ../libmysqlclient.so /usr/$(get_libdir)/mysql/libmysqlclient.so dosym ../libmysqlclient_r.so /usr/$(get_libdir)/mysql/libmysqlclient_r.so insinto /usr/include/mysql ; doins include/{my_config.h,my_dir.h} # convenience links dosym /usr/bin/mysqlcheck /usr/bin/mysqlanalyze dosym /usr/bin/mysqlcheck /usr/bin/mysqlrepair dosym /usr/bin/mysqlcheck /usr/bin/mysqloptimize # various junk rm -f ${D}/usr/bin/make*distribution rm -f ${D}/usr/share/mysql/make_*_distribution rm -f ${D}/usr/share/mysql/mysql.server rm -f ${D}/usr/share/mysql/binary-configure rm -f ${D}/usr/share/mysql/mysql-log-rotate rm -f ${D}/usr/share/mysql/{post,pre}install rm -f ${D}/usr/share/mysql/mi_test* rm -f ${D}/usr/share/mysql/*.spec # Redhat gunk rm -f ${D}/usr/share/mysql/*.plist # Apple gunk rm -f ${D}/usr/share/mysql/my-*.cnf # Put them elsewhere # All of these (ab)use Perl. if ! use perl; then rm -f ${D}/usr/bin/{mysqlhotcopy,mysql_find_rows,mysql_convert_table_format,mysqld_multi,mysqlaccess,mysql_fix_extensions,mysqldumpslow,mysql_zap,mysql_explain_log,mysql_tableinfo,mysql_setpermission} rm -f ${D}/usr/bin/mysqlhotcopy rm -rf ${D}/usr/share/mysql/sql-bench fi rm -rf ${D}/usr/share/mysql/{mysql-test,sql-bench} rm -f ${D}/usr/bin/{mysql_install_db,mysqlmanager*,mysql_secure_installation,mysql_fix_privilege_tables,mysqlhotcopy,mysql_convert_table_format,mysqld_multi,mysql_fix_extensions,mysql_zap,mysql_explain_log,mysql_tableinfo,mysqld_safe,myisam*,isam*,mysql_install,mysql_waitpid,mysqlbinlog,mysqltest,pack_isam} rm -f ${D}/usr/sbin/mysqld rm -f ${D}/usr/lib/mysql/lib{heap,merge,nisam,mysys,mystrings,mysqld,myisammrg,vio,dbug,myisam}.a # config stuff insinto /etc/mysql doins scripts/mysqlaccess.conf newins "${FILESDIR}/my.cnf-4.1" my.cnf # minimal builds don't have the server exeinto /etc/init.d newexe "${FILESDIR}/rc6-4.1.sh" mysql insinto /etc/logrotate.d newins "${FILESDIR}/logrotate.mysql" mysql # docs dodoc README COPYING ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE } pkg_preinst() { enewgroup mysql 60 || die "problem adding group mysql" enewuser mysql 60 /bin/false /var/lib/mysql mysql \ || die "problem adding user mysql" }