source: trunk/dports/databases/mysql56/Portfile

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

databases/mysql56: replace launchd plist removing daemondo dependency.

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