source: trunk/dports/databases/mysql55/Portfile @ 93521

Last change on this file since 93521 was 93521, checked in by pixilla@…, 8 years ago

databases/mysql55:

  • Fix readline bundled and system_readline variant. Closes #34552
  • Consistently use name_mysql.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.2 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 93521 2012-05-25 16:12:14Z pixilla@macports.org $
3
4PortSystem          1.0
5
6name                mysql55
7set name_mysql      ${name}
8version             5.5.24
9# Please set revision_client and revision_server to 0 if you bump version.
10set revision_client 3
11set revision_server 1
12categories          databases
13platforms           darwin
14license             GPL-2
15maintainers         pixilla openmaintainer
16
17if {$subport == $name} {
18
19    PortGroup           archcheck 1.0
20    PortGroup           cmake 1.0
21    PortGroup           select 1.0
22
23    set branch          [join [lrange [split ${version} .] 0 1] .]
24
25    revision            ${revision_client}
26    license             GPL-2
27    description         Multithreaded SQL database server
28    long_description    MySQL is an open-source, multi-threaded SQL database with a command \
29                        syntax very similar to mSQL.
30
31    homepage            http://www.mysql.com/
32    master_sites \
33        http://mysql.he.net/Downloads/MySQL-${branch}/ \
34        http://mirrors.sunsite.dk/mysql/Downloads/MySQL-${branch}/ \
35        http://sunsite.informatik.rwth-aachen.de/mysql/Downloads/MySQL-${branch}/ \
36        http://mirror.facebook.net/mysql/Downloads/MySQL-${branch}/ \
37        http://ftp.plusline.de/mysql/Downloads/MySQL-${branch}/
38
39# This mirror has a bad distfile for version 5.5.23
40#        http://mysql.mirrors.pair.com/Downloads/MySQL-${branch}/ \
41
42    distname            mysql-${version}
43    use_parallel_build  yes
44
45    patch.pre_args      -p1
46    patchfiles          patch-cmake-install_layout.cmake.diff \
47                        patch-configure.cmake.diff
48# http://bugs.mysql.com/bug.php?id=65050
49
50    checksums           rmd160  8a6cf0ff40d7b21bb9bb2fab82d0695574e6f2f9 \
51                        sha256  41e687dfec416a8b50d8d550899346c0e7096fe1200228cce24ed8daf3a779c6
52
53    depends_lib-append  port:zlib \
54                        port:cmake
55    depends_run         port:mysql_select
56
57    select.group        mysql
58    select.file         ${filespath}/${name_mysql}
59
60    archcheck.files     lib/libz.dylib
61
62    post-patch {
63        reinplace "s|@NAME@|${name_mysql}|g" ${worksrcpath}/cmake/install_layout.cmake
64    }
65
66    configure.args-delete \
67                        -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib
68    configure.args-append \
69                        -DCMAKE_INSTALL_NAME_DIR:STRING=${prefix}/lib/${name_mysql}/mysql \
70                        -DINSTALL_LAYOUT:STRING=MACPORTS \
71                        -DSYSCONFDIR:PATH=${prefix}/etc/${name_mysql} \
72                        -DMYSQL_UNIX_ADDR:PATH=${prefix}/var/run/${name_mysql}/mysqld.sock \
73                        -DMYSQL_DATADIR:PATH=${prefix}/var/db/${name_mysql} \
74                        -DDEFAULT_CHARSET:STRING=utf8 \
75                        -DDEFAULT_COLLATION:STRING=utf8_general_ci \
76                        -DWITH_EMBEDDED_SERVER:BOOL=OFF \
77                        -DWITH_ZLIB:STRING=system \
78                        -DWITH_UNIT_TESTS:BOOL=OFF \
79                        -DENABLE_GCOV:BOOL=OFF \
80                        -DENABLE_DTRACE:BOOL=OFF \
81                        -DWITH_READLINE:BOOL=ON \
82                        -DWITH_LIBEDIT:BOOL=OFF \
83                        -DWITH_LIBWRAP:BOOL=ON
84
85
86    post-build {
87        set dirs ${worksrcpath}
88        foreach dir ${dirs} {
89            reinplace -E {s|-arch [a-z0-9_]+||g} \
90                ${dir}/scripts/mysql_config \
91                ${dir}/scripts/mysqlbug
92        }
93    }
94
95    pre-destroot {
96        xinstall -m 755 -d ${destroot}${prefix}/etc/${name_mysql}
97        destroot.keepdirs-append ${destroot}${prefix}/etc/${name_mysql}
98    }
99
100    post-destroot {
101        # proc portdestroot::destroot_finish fails to find and compress our man pages
102        # so borrow the compress command and run on our files now.
103        set manpath "${destroot}${prefix}/share/man"
104        set gzip [findBinary gzip ${portutil::autoconf::gzip_path}]
105        foreach manpage [glob -type f ${destroot}${prefix}/share/man/${name_mysql}/man\[1-9\]/*] {
106            # Fix paths in manpages
107            reinplace "s|/etc/|${prefix}/etc/${name_mysql}/|g" ${manpage}
108            # Compress all manpages with gzip
109            system "$gzip -9vf ${manpage}"
110        }
111        foreach samp_conffile [glob -type f ${destroot}${prefix}/share/${name_mysql}/support-files/my-*.cnf] {
112            # Fix paths in sample configuration files
113            reinplace "s|/etc/my.cnf|${prefix}/etc/${name_mysql}/my.cnf|g" ${samp_conffile}
114        }
115    }
116
117    post-install {
118        if {![file exists ${prefix}/etc/LaunchDaemons/org.macports.${name_mysql}/org.macports.${name_mysql}-server.plist]} {
119            ui_msg "The ${name_mysql} client has been installed."
120            ui_msg "To install the ${name_mysql} server, install the ${name_mysql}-server port."
121        }
122    }
123
124    variant openssl description {Enable OpenSSL support} {
125
126        depends_lib-append      port:openssl
127        configure.args-append   -DWITH_SSL:STRING=ON
128        archcheck.files-append  lib/libssl.dylib
129    }
130
131    variant system_readline description {Use system readline instead of bundled readline} {
132   
133        # Add readline support.
134        # "-DWITH_READLINE:BOOL=OFF" has the peculiar meaning "do not use the bundled copy
135        # of readline but use the system's (i.e. MacPorts') copy of readline"
136        depends_lib-append      port:readline
137        configure.args-delete   -DWITH_READLINE:BOOL=ON
138        configure.args-append   -DWITH_READLINE:BOOL=OFF
139        archcheck.files-append  lib/libreadline.dylib
140    }
141
142    livecheck.type          regex
143    livecheck.version       [lindex [split ${version} -] 0]
144    livecheck.url           http://dev.mysql.com/
145    livecheck.regex         "<a href=\"http://dev.mysql.com/downloads/mysql/\[^\"\]+\">(${branch}(\.\[0-9.\]+)?)\[^<\]*</a>"
146}
147
148subport ${name_mysql}-server {
149
150    revision            ${revision_server}
151    license             BSD
152    description         Run ${name_mysql} as server
153    long_description    ${description}
154
155    supported_archs     noarch
156    distfiles
157
158    depends_run         port:${name_mysql}
159
160    if {"darwin" == ${os.platform} && ${os.major} > 8} {
161        set mysqluser       _mysql
162    } else {
163        set mysqluser       mysql
164    }
165    add_users ${mysqluser} group=${mysqluser} realname=MySQL\ Server
166
167    startupitem.create      yes
168    startupitem.executable  ${prefix}/lib/${name_mysql}/bin/mysqld --user=${mysqluser}
169
170    use_configure       no
171
172    build {}
173
174    destroot {
175        xinstall -m 755 -o root -d ${destroot}${prefix}/var/run
176        xinstall -m 755 -o ${mysqluser} -g ${mysqluser} -d \
177            ${destroot}${prefix}/etc/${name_mysql} \
178            ${destroot}${prefix}/var/db/${name_mysql} \
179            ${destroot}${prefix}/var/log/${name_mysql} \
180            ${destroot}${prefix}/var/run/${name_mysql}
181        destroot.keepdirs-append  \
182            ${destroot}${prefix}/var/db/${name_mysql} \
183            ${destroot}${prefix}/var/log/${name_mysql} \
184            ${destroot}${prefix}/var/run/${name_mysql}
185        set fp [open "${destroot}${prefix}/etc/${name_mysql}/macports-default.cnf" "w"]
186        puts $fp "# WARNING! ANY CHANGES TO THIS FILE WILL BE LOST ON UNINSTALL/UPGRADES!"
187        puts $fp "# Make your changes to ${prefix}/etc/${name_mysql}/my.cnf"
188        puts $fp "# YOU HAVE BEEN WARNED!"
189        puts $fp ""
190        puts $fp "# MacPorts default options"
191        puts $fp "\[mysqld\]"
192        puts $fp "# skip-networking so multple mysql server ports can be loaded"
193        puts $fp "# without each competing for port 3306."
194        puts $fp "# One can always put the servers on different ports and"
195        puts $fp "# remove or comment this option."
196        puts $fp "skip-networking"
197        close $fp
198    }
199
200    post-activate {
201        if {![file exists ${prefix}/etc/${name_mysql}/my.cnf]} {
202            set fp [open "${prefix}/etc/${name_mysql}/my.cnf" "w"]
203            puts $fp "# Use default MacPorts settings"
204            puts $fp "!include ${prefix}/etc/${name_mysql}/macports-default.cnf"
205            close $fp
206        }
207    }
208
209    notes "
210If this is a new install you might want to run:
211
212\$ sudo -u ${mysqluser} ${prefix}/lib/${name_mysql}/bin/mysql_install_db
213"
214
215    livecheck.type          none
216}
Note: See TracBrowser for help on using the repository browser.