Portfile

# $Id: Portfile 22478 2007-03-02 05:16:40Z pipping@macports.org $

PortSystem 1.0
name mysql4
version 4.1.22
categories databases
maintainers nomaintainer@macports.org
description Multithreaded SQL database server
long_description MySQL is an open-source, multi-threaded SQL database \
with a command syntax very similar to mSQL.
homepage http://www.mysql.com/
platforms darwin

set sitedir Downloads/MySQL-4.1/
master_sites http://www.mirrorservice.org/sites/ftp.mysql.com/${sitedir} \
http://www.softagency.co.jp/MySQL/${sitedir} \
http://mirrors.tilian.co.uk/mysql.com/${sitedir} \
ftp://planetmirror.com/pub/mysql/${sitedir} \
ftp://sunsite.dk/mirrors/mysql/${sitedir} \
http://mysql.mediatraffic.fi/${sitedir} \
ftp://filepile.tiscali.de/mirror/mysql/${sitedir} \
ftp://ftp.rtfm.no/pub/mysql/${sitedir} \
http://www.mysql.cz/${sitedir} \
ftp://ftp.u-paris10.fr/mysql.com/${sitedir} \
http://mysql.oms-net.nl/${sitedir} \
ftp://ftp.free.fr/pub/MySQL\${sitedir}

distname mysql-${version}
checksums md5 37b4479951fa0cf052269d27c41ca200

depends_lib port:openssl

set dbdir ${prefix}/var/db/mysql

post-patch {
cd ${worksrcpath}
reinplace "s%/etc/my.cnf%${prefix}/etc/${name}/my.cnf%g" \
scripts/mysqlaccess.sh \
scripts/mysqld_multi.sh \
scripts/mysqldumpslow.sh \
scripts/mysqlhotcopy.sh \
sql-bench/bench-init.pl.sh \
support-files/my-huge.cnf.sh \
support-files/my-innodb-heavy-4G.cnf.sh \
support-files/my-large.cnf.sh \
support-files/my-medium.cnf.sh \
support-files/my-small.cnf.sh \
support-files/mysql.server.sh
reinplace "s%/etc/%${prefix}/etc/${name}/%g" \
mysys/default.c
}

platform darwin 6 {
depends_lib-append lib:libdl:dlcompat

configure.env LDFLAGS="-L${prefix}/lib -lncurses" \
CPPFLAGS=-I${prefix}/include \
CFLAGS="-O3 -fno-omit-frame-pointer" \
CXX=gcc \
CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"

}

platform darwin 7 {
configure.env LDFLAGS="-lncurses" \
CFLAGS="-O3 -fno-omit-frame-pointer" \
CXX=gcc \
CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" \
LIBS=-ldl

}

platform darwin 8 {
configure.env CC=/usr/bin/gcc-4.0 CPP=/usr/bin/cpp-4.0 CXX=/usr/bin/g++-4.0
}

configure.args --sysconfdir=${prefix}/etc/${name} --without-debug \
--without-bench \
--mandir=${prefix}/share/man --infodir=${prefix}/share/info \
--enable-thread-safe-client --with-extra-charsets=complex \
--with-openssl=${prefix} --with-innodb \
--localstatedir=${dbdir} \
--with-unix-socket-path=${prefix}/var/run/mysqld/mysqld.sock \
--with-mysqld-user=mysql

variant server {
# Create a startupitem to start/stop the server
startupitem.create yes
startupitem.start "${prefix}/share/mysql/mysql.server start"
startupitem.stop "${prefix}/share/mysql/mysql.server stop"
}

pre-destroot {
xinstall -m 755 -d ${destroot}${prefix}/var/log/mysql
destroot.keepdirs ${destroot}${prefix}/var/log/mysql

if { [variant_isset server] } {
addgroup mysql
set gid [existsgroup mysql]
adduser mysql gid=${gid} realname=MySQL\ Server

system "chown mysql:mysql ${destroot}${prefix}/var/log/mysql"
}
}

post-destroot {
system "rm -rf ${destroot}${prefix}/mysql-test"

xinstall -m 775 -d ${destroot}${dbdir}
xinstall -m 755 -d ${destroot}${prefix}/var/run/mysqld
destroot.keepdirs-append ${destroot}${dbdir}
destroot.keepdirs-append ${destroot}${prefix}/var/run/mysqld
if { [variant_isset server] } {
xinstall -o root -m 755 -d ${destroot}${prefix}/etc/${name}
xinstall -o root -m 644 -c ${filespath}/my.cnf ${destroot}${prefix}/etc/${name}/my.cnf.sample
reinplace "s|__PREFIX|${prefix}|g" ${destroot}${prefix}/etc/${name}/my.cnf.sample
xinstall -o mysql -g mysql -m 775 -d ${destroot}${dbdir}
destroot.keepdirs-append ${destroot}${dbdir}
system "chown -R mysql:mysql ${destroot}${dbdir}"

xinstall -o mysql -g mysql -m 755 -d ${destroot}${prefix}/var/run/mysqld
destroot.keepdirs-append ${destroot}${prefix}/var/run/mysqld
system "chown -R mysql:mysql ${destroot}${prefix}/var/run/mysqld"
}

}

post-install {
ui_msg "******************************************************"
ui_msg "* You might want to run *"
ui_msg "* sudo -u mysql mysql_install_db *"
ui_msg "* if this is a new install *"
ui_msg "* *"
ui_msg "* If you did not choose the server variant you may *"
ui_msg "* add a mysql user and you will need to change the *"
ui_msg "* ownership to that user for the following: *"
ui_msg "* ${dbdir} *"
ui_msg "* ${prefix}/var/run/mysqld *"
ui_msg "* ${prefix}/var/log/mysql *"
ui_msg "******************************************************"
}

files