source: trunk/dports/databases/mysql51/Portfile

Last change on this file was 153727, checked in by pixilla@…, 10 months ago

databases/mysql51: 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 153727 2016-10-09 16:55:07Z ryandesign@macports.org $
3
4PortSystem          1.0
5
6name                mysql51
7set name_mysql      ${name}
8version             5.1.73
9# Set revision_client and revision_server to 0 if you bump version.
10set revision_client 3
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 {"darwin" eq ${os.platform} && ${os.major} > 8} {
20    set mysqluser       _mysql
21} else {
22    set mysqluser       mysql
23}
24
25if {${subport} eq ${name}} {
26
27    # http://bugs.mysql.com/bug.php?id=47360
28    PortGroup           muniversal 1.0
29    PortGroup           select 1.0
30
31    revision            ${revision_client}
32    license             GPL-2
33    description         Multithreaded SQL database server
34    long_description    MySQL is an open-source, multi-threaded SQL database.
35   
36    master_sites        mysql:MySQL-${version_branch}
37
38    distname            mysql-${version}
39    use_parallel_build  yes
40
41    patch.pre_args      -p1
42    patchfiles          patch-Makefile.in.diff \
43                        patch-scripts-mysql_secure_installation.sh.diff
44
45    checksums           rmd160  ceee36663abbf135d3ddbebe52ebc537ecba25a6 \
46                        sha256  05ebe21305408b24407d14b77607a3e5ffa3c300e03f1359d3066f301989dcb5
47   
48    depends_lib         port:zlib port:tcp_wrappers
49    depends_run         port:mysql_select
50   
51    select.group        mysql
52    select.file         ${filespath}/${name_mysql}
53
54    post-extract {
55        file mkdir ${worksrcpath}/build_macports/macports
56        copy ${filespath}/macports-default.cnf \
57            ${filespath}/my.cnf \
58            ${worksrcpath}/build_macports/macports/
59    }
60
61    post-patch {
62        reinplace "s%@BINDIR@%${prefix}/lib/${name_mysql}/bin%g" \
63            ${worksrcpath}/scripts/mysql_secure_installation.sh
64        reinplace "s|@NAME@|${name_mysql}|g" \
65            ${worksrcpath}/build_macports/macports/macports-default.cnf \
66            ${worksrcpath}/build_macports/macports/my.cnf
67        reinplace "s|@PREFIX@|${prefix}|g" \
68            ${worksrcpath}/build_macports/macports/macports-default.cnf \
69            ${worksrcpath}/build_macports/macports/my.cnf
70    }
71   
72    configure.args \
73        --bindir=${prefix}/lib/${name_mysql}/bin \
74        --sbindir=${prefix}/lib/${name_mysql}/bin \
75        --libexecdir=${prefix}/lib/${name_mysql}/bin \
76        --sysconfdir=${prefix}/etc/${name_mysql} \
77        --localstatedir=${prefix}/var/db/${name_mysql} \
78        --libdir=${prefix}/lib/${name_mysql} \
79        --includedir=${prefix}/include/${name_mysql} \
80        --datarootdir=${prefix}/share/${name_mysql} \
81        --infodir=${prefix}/share/info/${name_mysql} \
82        --mandir=${prefix}/share/man/${name_mysql} \
83        --with-zlib-dir=${prefix} \
84        --without-ssl \
85        --with-extra-charsets=complex \
86        --with-unix-socket-path=${prefix}/var/run/${name_mysql}/mysqld.sock \
87        --with-mysqld-user=${mysqluser} \
88        --without-docs \
89        --with-plugins=all \
90        --enable-thread-safe-client
91   
92    # Build libmysqld embedded server.
93    configure.cflags-append -fPIC
94    configure.cxxflags-append -fPIC
95    configure.args-append --with-embedded-server --with-pic
96   
97    # doesn't build with clang as of 2011.06.27
98    # This is a bug in mysql's build system, fixed in 5.5
99    compiler.blacklist-append *clang*
100
101    # https://trac.macports.org/ticket/45456?replyto=4#comment
102    compiler.fallback-append macports-llvm-gcc-4.2
103   
104    post-build {
105        if {[variant_isset universal]} {
106            set dirs {}
107            foreach arch ${universal_archs_to_use} {
108                lappend dirs ${worksrcpath}-${arch}
109            }
110        } else {
111            set dirs ${worksrcpath}
112        }
113        foreach dir ${dirs} {
114            reinplace -E {s|-arch [a-z0-9_]+||g} \
115                ${dir}/scripts/mysql_config \
116                ${dir}/scripts/mysqlbug
117        }
118    }
119
120    post-destroot {
121        # proc portdestroot::destroot_finish fails to find and compress our man pages
122        # so borrow the compress command and run on our files now.
123        set manpath "${destroot}${prefix}/share/man"
124        set gzip [findBinary gzip ${portutil::autoconf::gzip_path}]
125        foreach manpage [glob -type f ${destroot}${prefix}/share/man/${name_mysql}/man\[1-9\]/*] {
126            # Fix paths in manpages
127            reinplace "s|/etc/|${prefix}/etc/${name_mysql}/|g" ${manpage}
128            # Compress all manpages with gzip
129            system "$gzip -9vf ${manpage}"
130        }
131        foreach samp_conffile [glob -type f ${destroot}${prefix}/share/${name_mysql}/mysql/my-*.cnf] {
132            # Fix paths in sample configuration files
133            reinplace "s|/etc/my.cnf|${prefix}/etc/${name_mysql}/my.cnf|g" ${samp_conffile}
134        }
135        xinstall -m 755 -o root -d \
136            ${destroot}${prefix}/etc/${name_mysql}
137        copy ${worksrcpath}/build_macports/macports/macports-default.cnf \
138            ${destroot}${prefix}/etc/${name_mysql}/
139        xinstall -m 755 -o root -d \
140            ${destroot}${prefix}/share/${name_mysql}/support-files/macports
141        copy ${worksrcpath}/build_macports/macports/my.cnf \
142            ${destroot}${prefix}/share/${name_mysql}/support-files/macports/
143    }
144
145    post-install {
146        if {![file exists ${prefix}/etc/LaunchDaemons/org.macports.${name_mysql}/org.macports.${name_mysql}-server.plist]} {
147            ui_msg "The ${name_mysql} client has been installed."
148            ui_msg "To install the ${name_mysql} server, install the ${name_mysql}-server port."
149        }
150    }
151
152    pre-activate {
153        # The macports-default.cnf is installed by ${name_mysql}.
154        # Early versions of ${name_mysql}-server installed macports-default.cnf so for a
155        # reasonable period we need to deactivate older versions of the ${name_mysql}-server.
156        if { [file exists ${prefix}/etc/${name_mysql}/macports-default.cnf]
157            && ![catch {set vers [lindex [registry_active ${name_mysql}-server] 0]}]
158            && [vercmp [lindex $vers 1] 5.1.63] < 1
159            && [vercmp [lindex $vers 2] 3] < 0 } {
160
161            registry_deactivate_composite ${name_mysql}-server "" [list ports_nodepcheck 1]
162        }
163    }
164
165    post-activate {
166        if {![file exists ${prefix}/etc/${name_mysql}/my.cnf]} {
167            copy ${prefix}/share/${name_mysql}/support-files/macports/my.cnf \
168                ${prefix}/etc/${name_mysql}/
169        }
170    }
171   
172    variant openssl description {Enable OpenSSL support} {}
173    variant system_readline description {Use system readline instead of bundled readline} {}
174
175    if [variant_isset openssl] {
176        depends_lib-append      path:lib/libssl.dylib:openssl
177        configure.args-delete   --without-ssl
178        configure.args-append   --with-ssl=${prefix}
179    }
180    if [variant_isset system_readline] {
181        # "--without-readline" has the peculiar meaning "do not use the bundled copy
182        # of readline but use the system's (i.e. MacPorts') copy of readline"
183        depends_lib-append      port:readline
184        configure.args-append   --without-readline
185    }
186
187    notes "
188On activation if no ${prefix}/etc/${name_mysql}/my.cnf file exists one
189will be created which loads
190${prefix}/etc/${name_mysql}/macports-default.cnf.
191
192If a ${prefix}/etc/${name_mysql}/my.cnf file exists MacPorts does not
193touch it and any changes you make to ${prefix}/etc/${name_mysql}/my.cnf
194will be preserved (e.g., during port upgrades, deactivations or
195activations). ${prefix}/etc/${name_mysql}/my.cnf is a good place to
196customize your ${name_mysql} installation.
197
198Any changes made to ${prefix}/etc/${name_mysql}/macports-default.cnf
199will be lost during port upgrades, deactivations or activations so you
200are advised to not make changes here. Currently
201${prefix}/etc/${name_mysql}/macports-default.cnf contains only one
202directive; to disable networking. With disabled networking it is
203possible to install and have running all the MacPorts mysql ports
204simultaneously.
205"
206
207    livecheck.type          regex
208    livecheck.url           http://mirror.leaseweb.com/mysql/Downloads/MySQL-${version_branch}/
209    livecheck.regex         ">mysql-(\[\\d\\.-\]*)\\${extract.suffix}<"
210}
211
212subport ${name_mysql}-server {
213
214    revision            ${revision_server}
215    license             BSD
216    description         Run ${name_mysql} as server
217    long_description    ${description}
218
219    supported_archs     noarch
220    distfiles
221
222    depends_run         port:${name_mysql}
223   
224    add_users ${mysqluser} group=${mysqluser} realname=MySQL\ Server
225
226    pre-extract {
227        copy ${filespath}/org.macports.mysql-server.plist ${workpath}/org.macports.${subport}.plist
228    }
229
230    post-patch {
231        reinplace "s|@NAME@|${subport}|g" \
232            ${workpath}/org.macports.${subport}.plist
233        reinplace "s|@NAMEMYSQL@|${name_mysql}|g" \
234            ${workpath}/org.macports.${subport}.plist
235        reinplace "s|@PREFIX@|${prefix}|g" \
236            ${workpath}/org.macports.${subport}.plist
237        reinplace "s|@SUBPORT@|${subport}|g" \
238            ${workpath}/org.macports.${subport}.plist
239        reinplace "s|@USER@|${mysqluser}|g" \
240            ${workpath}/org.macports.${subport}.plist
241        reinplace "s|@GROUP@|${mysqluser}|g" \
242            ${workpath}/org.macports.${subport}.plist
243    }
244   
245    use_configure       no
246
247    build {}
248
249    destroot {
250        xinstall -d -m 755 ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${subport}
251        xinstall -m 0644 -o root -W ${workpath} \
252            org.macports.${subport}.plist \
253            ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${subport}
254        xinstall -d -m 755 ${destroot}/Library/LaunchDaemons
255        ln -s ${prefix}/etc/LaunchDaemons/org.macports.${subport}/org.macports.${subport}.plist \
256            ${destroot}/Library/LaunchDaemons/org.macports.${subport}.plist
257        xinstall -m 755 -o root -d \
258            ${destroot}${prefix}/var/run
259        xinstall -m 755 -o ${mysqluser} -g ${mysqluser} -d \
260            ${destroot}${prefix}/etc/${name_mysql} \
261            ${destroot}${prefix}/var/db/${name_mysql} \
262            ${destroot}${prefix}/var/log/${name_mysql} \
263            ${destroot}${prefix}/var/run/${name_mysql}
264        destroot.keepdirs-append  \
265            ${destroot}${prefix}/var/db/${name_mysql} \
266            ${destroot}${prefix}/var/log/${name_mysql} \
267            ${destroot}${prefix}/var/run/${name_mysql}
268    }
269
270    notes "
271If this is a new install you might want to run:
272
273\$ sudo -u ${mysqluser} ${prefix}/lib/${name_mysql}/bin/mysql_install_db
274"
275
276    livecheck.type          none
277}
Note: See TracBrowser for help on using the repository browser.