Portfile

# $Id: Portfile 20417 2006-11-03 02:16:04Z jberry@macports.org $

PortSystem 1.0
name mysql3
version 3.23.58
categories databases
maintainers nomaintainer@macports.org
description Multithreaded SQL database server
homepage http://www.mysql.com/
platforms darwin

long_description MySQL is an open-source, multi-threaded SQL database \
with a command syntax very similar to mSQL.

master_sites http://mysql.mirrors.pair.com/Downloads/MySQL-3.23/ \
http://mysql.he.net/Downloads/MySQL-3.23/ \
http://mirrors.sunsite.dk/mysql/Downloads/MySQL-3.23/ \
http://ftp.plusline.de/mysql/Downloads/MySQL-3.23/ \
freebsd

distname mysql-${version}
checksums md5 835a96c86132fbde0db36db60c5b34cd
patchfiles patch-libmysql-violite.c patch-sql-violite.c

depends_lib port:ncurses port:zlib

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

configure.env LDFLAGS="-L${prefix}/lib -lncurses" \
CPPFLAGS="-I${prefix}/include"

configure.args --includedir=${prefix}/include/${name} \
--libdir=${prefix}/lib/${name} \
--bindir=${prefix}/lib/${name}/bin \
--localstatedir=${dbdir} --without-server \
--sysconfdir=${prefix}/etc/${name} --without-bench \
--mandir=${prefix}/share/man --infodir=${prefix}/share/info

set binaries "mysql mysql_access"
post-destroot {
system "cd ${destroot}${prefix} && rm -rf mysql-test share/info"
system "cd ${destroot}${prefix}/share && mv mysql ${name}"
foreach b ${binaries} {
system "cd ${destroot}${prefix}/bin && ln -s ../lib/${name}/bin/${b} ${b}3"
}
}

variant innodb { configure.args-append --with-innodb }

variant server {
configure.args-delete --without-server

startupitem.create yes
startupitem.start "${prefix}/share/mysql/mysql.server start"
startupitem.stop "${prefix}/share/mysql/mysql.server stop"

pre-destroot {
addgroup mysql
set gid [existsgroup mysql]
adduser mysql gid=${gid} realname=MySQL\ Server

xinstall -o mysql -g mysql -m 755 -d ${dbdir}
}

post-destroot {
xinstall -m 644 ${worksrcpath}/support-files/my-medium.cnf \
${destroot}${prefix}/etc/${name}/my.cnf
}

post-install {
ui_msg "=================================================================\n"
ui_msg "If this is a new installation of MySQL, you must run\n${prefix}/bin/mysql_install_db after installing this port!\n"
ui_msg "You must also run:\n\n 'chown -R mysql:mysql ${dbdir}'\n\nbefore starting the MySQL daemon.\n"
ui_msg "=================================================================\n"
}
}

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

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

files