source: trunk/dports/databases/percona/Portfile

Last change on this file was 153731, checked in by pixilla@…, 12 months ago

databases/percona: replace launchd plist removing daemondo dependency.

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