source: trunk/dports/databases/mysql55/Portfile

Last change on this file was 153728, checked in by pixilla@…, 14 months ago

databases/mysql55: replace launchd plist removing daemondo dependency.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.0 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 153728 2016-10-09 16:55:40Z ryandesign@macports.org $
3
4PortSystem          1.0
5
6name                mysql55
7set name_mysql      ${name}
8version             5.5.52
9# Set revision_client and revision_server to 0 if you bump version.
10set revision_client 0
11set revision_server 1
12set version_branch  [join [lrange [split ${version} .] 0 1] .]
13categories          databases
14platforms           darwin
15license             GPL-2
16maintainers         pixilla openmaintainer
17homepage            http://www.mysql.com/
18
19if {$subport eq $name} {
20
21    PortGroup           cmake 1.0
22    PortGroup           select 1.0
23
24    revision            ${revision_client}
25    license             GPL-2
26    description         Multithreaded SQL database server
27    long_description    MySQL is an open-source, multi-threaded SQL database.
28
29    master_sites        mysql:MySQL-${version_branch}
30
31    distname            mysql-${version}
32    cmake.out_of_source yes
33    use_parallel_build  yes
34
35    patch.pre_args      -p1
36    patchfiles          patch-cmake-install_layout.cmake.diff
37
38    checksums           rmd160  26125b7045073f7962d43df14135caa89e6b436c \
39                        sha256  7820e13de6b3f4dadd255e12b2e9f3de43daf4507c218018c382d45aad8162fd
40
41    depends_lib-append  port:zlib port:tcp_wrappers
42    depends_run-append  port:mysql_select
43
44    select.group        mysql
45    select.file         ${filespath}/${name_mysql}
46
47    post-extract {
48        file mkdir ${cmake.build_dir}/macports
49        copy ${filespath}/macports-default.cnf \
50            ${filespath}/my.cnf \
51            ${cmake.build_dir}/macports/
52    }
53
54    post-patch {
55        reinplace "s|@NAME@|${name_mysql}|g" \
56            ${worksrcpath}/cmake/install_layout.cmake
57        reinplace "s|@NAME@|${name_mysql}|g" \
58            ${cmake.build_dir}/macports/macports-default.cnf \
59            ${cmake.build_dir}/macports/my.cnf
60        reinplace "s|@PREFIX@|${prefix}|g" \
61            ${cmake.build_dir}/macports/macports-default.cnf \
62            ${cmake.build_dir}/macports/my.cnf
63    }
64
65    configure.args-delete \
66                        -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib
67    configure.args-append \
68                        -DCMAKE_INSTALL_NAME_DIR:STRING=${prefix}/lib/${name_mysql}/mysql \
69                        -DINSTALL_LAYOUT:STRING=MACPORTS \
70                        -DSYSCONFDIR:PATH=${prefix}/etc/${name_mysql} \
71                        -DMYSQL_UNIX_ADDR:PATH=${prefix}/var/run/${name_mysql}/mysqld.sock \
72                        -DMYSQL_DATADIR:PATH=${prefix}/var/db/${name_mysql} \
73                        -DDEFAULT_CHARSET:STRING=utf8 \
74                        -DDEFAULT_COLLATION:STRING=utf8_general_ci \
75                        -DWITH_EMBEDDED_SERVER:BOOL=ON \
76                        -DWITH_ZLIB:STRING=system \
77                        -DWITH_UNIT_TESTS:BOOL=ON \
78                        -DENABLE_GCOV:BOOL=OFF \
79                        -DENABLE_DTRACE:BOOL=OFF \
80                        -DWITH_READLINE:BOOL=ON \
81                        -DWITH_LIBEDIT:BOOL=OFF \
82                        -DWITH_LIBWRAP:BOOL=ON \
83                        -DWITH_SSL:STRING=no
84
85    post-build {
86        set dirs ${cmake.build_dir}
87        foreach dir ${dirs} {
88            reinplace -E {s|-arch [a-z0-9_]+||g} \
89                ${dir}/scripts/mysql_config \
90                ${dir}/scripts/mysqlbug
91        }
92    }
93
94    post-destroot {
95        # proc portdestroot::destroot_finish fails to find and compress our man pages
96        # so borrow the compress command and run on our files now.
97        set manpath "${destroot}${prefix}/share/man"
98        set gzip [findBinary gzip ${portutil::autoconf::gzip_path}]
99        foreach manpage [glob -type f ${destroot}${prefix}/share/man/${name_mysql}/man\[1-9\]/*] {
100            # Fix paths in manpages
101            reinplace "s|/etc/|${prefix}/etc/${name_mysql}/|g" ${manpage}
102            # Compress all manpages with gzip
103            system "$gzip -9vf ${manpage}"
104        }
105        foreach samp_conffile [glob -type f ${destroot}${prefix}/share/${name_mysql}/support-files/my-*.cnf] {
106            # Fix paths in sample configuration files
107            reinplace "s|/etc/my.cnf|${prefix}/etc/${name_mysql}/my.cnf|g" ${samp_conffile}
108        }
109        xinstall -m 755 -o root -d \
110            ${destroot}${prefix}/etc/${name_mysql}
111        copy ${cmake.build_dir}/macports/macports-default.cnf \
112            ${destroot}${prefix}/etc/${name_mysql}/
113        xinstall -m 755 -o root -d \
114            ${destroot}${prefix}/share/${name_mysql}/support-files/macports
115        copy ${cmake.build_dir}/macports/my.cnf \
116            ${destroot}${prefix}/share/${name_mysql}/support-files/macports/
117    }
118
119    post-install {
120        if {![file exists ${prefix}/etc/LaunchDaemons/org.macports.${name_mysql}/org.macports.${name_mysql}-server.plist]} {
121            ui_msg "The ${name_mysql} client has been installed."
122            ui_msg "To install the ${name_mysql} server, install the ${name_mysql}-server port."
123        }
124    }
125
126    pre-activate {
127        # The macports-default.cnf is installed by ${name_mysql}.
128        # Early versions of ${name_mysql}-server installed macports-default.cnf so for a
129        # reasonable period we need to deactivate older versions of the ${name_mysql}-server.
130        if { [file exists ${prefix}/etc/${name_mysql}/macports-default.cnf]
131            && ![catch {set vers [lindex [registry_active ${name_mysql}-server] 0]}]
132            && [vercmp [lindex $vers 1] 5.5.25] < 0 } {
133
134            registry_deactivate_composite ${name_mysql}-server "" [list ports_nodepcheck 1]
135        }
136    }
137
138    post-activate {
139        if {![file exists ${prefix}/etc/${name_mysql}/my.cnf]} {
140            copy ${prefix}/share/${name_mysql}/support-files/macports/my.cnf \
141                ${prefix}/etc/${name_mysql}/
142        }
143    }
144
145    variant openssl description {Enable OpenSSL support} {
146
147        depends_lib-append      path:lib/libssl.dylib:openssl
148        configure.args-delete   -DWITH_SSL:STRING=no
149        configure.args-append   -DWITH_SSL:STRING=system
150    }
151
152    variant system_readline description {Use system readline instead of bundled readline} {
153   
154        # Add readline support.
155        # "-DWITH_READLINE:BOOL=OFF" has the peculiar meaning "do not use the bundled copy
156        # of readline but use the system's (i.e. MacPorts') copy of readline"
157        depends_lib-append      port:readline
158        configure.args-delete   -DWITH_READLINE:BOOL=ON
159        configure.args-append   -DWITH_READLINE:BOOL=OFF
160    }
161
162    notes "
163On activation if no ${prefix}/etc/${name_mysql}/my.cnf file exists one
164will be created which loads
165${prefix}/etc/${name_mysql}/macports-default.cnf.
166
167If a ${prefix}/etc/${name_mysql}/my.cnf file exists MacPorts does not
168touch it and any changes you make to ${prefix}/etc/${name_mysql}/my.cnf
169will be preserved (e.g., during port upgrades, deactivations or
170activations). ${prefix}/etc/${name_mysql}/my.cnf is a good place to
171customize your ${name_mysql} installation.
172
173Any changes made to ${prefix}/etc/${name_mysql}/macports-default.cnf
174will be lost during port upgrades, deactivations or activations so you
175are advised to not make changes here. Currently
176${prefix}/etc/${name_mysql}/macports-default.cnf contains only one
177directive; to disable networking. With disabled networking it is
178possible to install and have running all the MacPorts mysql ports
179simultaneously.
180"
181
182    livecheck.type          regex
183    livecheck.url           http://dev.mysql.com/downloads/mysql/${version_branch}.html
184    livecheck.regex         "MySQL Community Server (${version_branch}(\.\[0-9.\]+)?)"
185}
186
187subport ${name_mysql}-server {
188
189    revision            ${revision_server}
190    license             BSD
191    description         Run ${name_mysql} as server
192    long_description    ${description}
193
194    supported_archs     noarch
195    distfiles
196
197    depends_run         port:${name_mysql}
198
199    if {"darwin" eq ${os.platform} && ${os.major} > 8} {
200        set mysqluser       _mysql
201    } else {
202        set mysqluser       mysql
203    }
204    add_users ${mysqluser} group=${mysqluser} realname=MySQL\ Server
205
206    pre-extract {
207        copy ${filespath}/org.macports.mysql-server.plist ${workpath}/org.macports.${subport}.plist
208    }
209
210    post-patch {
211        reinplace "s|@NAME@|${subport}|g" \
212            ${workpath}/org.macports.${subport}.plist
213        reinplace "s|@NAMEMYSQL@|${name_mysql}|g" \
214            ${workpath}/org.macports.${subport}.plist
215        reinplace "s|@PREFIX@|${prefix}|g" \
216            ${workpath}/org.macports.${subport}.plist
217        reinplace "s|@SUBPORT@|${subport}|g" \
218            ${workpath}/org.macports.${subport}.plist
219        reinplace "s|@USER@|${mysqluser}|g" \
220            ${workpath}/org.macports.${subport}.plist
221        reinplace "s|@GROUP@|${mysqluser}|g" \
222            ${workpath}/org.macports.${subport}.plist
223    }
224   
225    use_configure       no
226
227    build {}
228
229    destroot {
230        xinstall -d -m 755 ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${subport}
231        xinstall -m 0644 -o root -W ${workpath} \
232            org.macports.${subport}.plist \
233            ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${subport}
234        xinstall -d -m 755 ${destroot}/Library/LaunchDaemons
235        ln -s ${prefix}/etc/LaunchDaemons/org.macports.${subport}/org.macports.${subport}.plist \
236            ${destroot}/Library/LaunchDaemons/org.macports.${subport}.plist
237        xinstall -m 755 -o root -d \
238            ${destroot}${prefix}/var/run
239        xinstall -m 755 -o ${mysqluser} -g ${mysqluser} -d \
240            ${destroot}${prefix}/etc/${name_mysql} \
241            ${destroot}${prefix}/var/db/${name_mysql} \
242            ${destroot}${prefix}/var/log/${name_mysql} \
243            ${destroot}${prefix}/var/run/${name_mysql}
244        destroot.keepdirs-append  \
245            ${destroot}${prefix}/var/db/${name_mysql} \
246            ${destroot}${prefix}/var/log/${name_mysql} \
247            ${destroot}${prefix}/var/run/${name_mysql}
248    }
249
250    notes "
251If this is a new install you might want to run:
252
253\$ sudo -u ${mysqluser} ${prefix}/lib/${name_mysql}/bin/mysql_install_db
254"
255
256    livecheck.type          none
257}
Note: See TracBrowser for help on using the repository browser.