Ticket #57776: Portfile

File Portfile, 10.1 KB (added by Schamschula (Marius Schamschula), 6 years ago)
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
3PortSystem          1.0
4
5name                mysql8
6set name_mysql      ${name}
7version             8.0.13
8set boost_version   1.67.0
9# Set revision_client and revision_server to 0 on version bump.
10set revision_client 0
11set revision_server 0
12set version_branch  [join [lrange [split ${version} .] 0 1] .]
13categories          databases
14platforms           darwin
15license             GPL-2
16maintainers         {pixilla @pixilla} openmaintainer
17homepage            http://www.mysql.com/
18
19if {$subport eq $name} {
20    PortGroup           muniversal 1.0
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}:mysql \
30                        sourceforge:project/boost/boost/${boost_version}:boost
31
32    distname            mysql-${version}
33    cmake.out_of_source yes
34    set boost_distver   [join [split ${boost_version} .] _]
35    set boost_distname  boost_${boost_distver}
36
37    distfiles           ${distname}${extract.suffix}:mysql \
38                        ${boost_distname}${extract.suffix}:boost
39
40    checksums           ${distname}${extract.suffix} \
41                        rmd160  479da7095bb1e270bc69e1c078d3ee57a1ddbd20 \
42                        sha256  d85eb7f98b6aa3e2c6fe38263bf40b22acb444a4ce1f4668473e9e59fb98d62e \
43                        size    107625916 \
44                        ${boost_distname}${extract.suffix} \
45                        rmd160  7148477c531ea7c4ed3a377213c954055c6291d7 \
46                        sha256  8aa4e330c870ef50a896634c931adf468b21f8a69b77007e45c444151229f665 \
47                        size    103363944
48
49    depends_lib-append  port:zlib
50    depends_run-append  port:mysql_select
51
52    post-extract {
53        file mkdir ${cmake.build_dir}/macports
54        copy ${filespath}/macports-default.cnf \
55            ${filespath}/my.cnf \
56            ${cmake.build_dir}/macports/
57    }
58
59    patch.pre_args  -p1
60    patchfiles      patch-cmake-install_layout.cmake.diff \
61                    patch-cmake-install_layout.cmake-yassl.diff \
62                    patch-configure.cmake.diff \
63                    patch-innodb_memcached-daemon_memcached-include-memcached-util.h.diff
64
65    post-patch {
66        reinplace "s|@NAME@|${name_mysql}|g" \
67            ${worksrcpath}/cmake/install_layout.cmake
68        reinplace "s|@WORKSRCPATH@|${worksrcpath}|g" \
69            ${worksrcpath}/cmake/install_layout.cmake
70        reinplace "s|@NAME@|${name_mysql}|g" \
71            ${cmake.build_dir}/macports/macports-default.cnf \
72            ${cmake.build_dir}/macports/my.cnf
73        reinplace "s|@PREFIX@|${prefix}|g" \
74            ${cmake.build_dir}/macports/macports-default.cnf \
75            ${cmake.build_dir}/macports/my.cnf
76    }
77
78    configure.args-delete \
79        -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib
80    configure.args-append \
81        -DCMAKE_INSTALL_NAME_DIR:STRING=${prefix}/lib/${name_mysql}/mysql \
82        -DINSTALL_LAYOUT:STRING=MACPORTS \
83        -DSYSCONFDIR:PATH=${prefix}/etc/${name_mysql} \
84        -DMYSQL_UNIX_ADDR:PATH=${prefix}/var/run/${name_mysql}/mysqld.sock \
85        -DMYSQL_DATADIR:PATH=${prefix}/var/db/${name_mysql} \
86        -DDEFAULT_CHARSET:STRING=utf8 \
87        -DDEFAULT_COLLATION:STRING=utf8_general_ci \
88        -DWITH_ZLIB:STRING=system \
89        -DWITH_UNIT_TESTS:BOOL=ON \
90        -DENABLE_DOWNLOADS:BOOL=OFF \
91        -DENABLE_GCOV:BOOL=OFF \
92        -DWITH_LIBWRAP:BOOL=OFF \
93        -DWITH_SSL:STRING=bundled \
94        -DWITH_INNODB_MEMCACHED=1 \
95        -DDOWNLOAD_BOOST=1 \
96        -DWITH_BOOST=${worksrcpath}/../${boost_distname} \
97        -DDOWNLOAD_BOOST_TIMEOUT=2400
98    configure.cppflags-delete \
99        -I${prefix}/include
100
101    use_parallel_build  yes
102
103    select.group        mysql
104    select.file         ${filespath}/${name_mysql}
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 -q "s|/etc/|${prefix}/etc/${name_mysql}/|g" ${manpage}
114            # Compress all manpages with gzip
115            system "$gzip -9vf ${manpage}"
116        }
117
118        foreach samp_conffile [glob -type f ${destroot}${prefix}/share/${name_mysql}/support-files/my-*.cnf] {
119            # Fix paths in sample configuration files
120            reinplace -q "s|/etc/my.cnf|${prefix}/etc/${name_mysql}/my.cnf|g" ${samp_conffile}
121        }
122        xinstall -m 755 -o root -d \
123            ${destroot}${prefix}/etc/${name_mysql}
124        copy ${cmake.build_dir}/macports/macports-default.cnf \
125            ${destroot}${prefix}/etc/${name_mysql}/
126        xinstall -m 755 -o root -d \
127            ${destroot}${prefix}/share/${name_mysql}/support-files/macports
128        copy ${cmake.build_dir}/macports/my.cnf \
129            ${destroot}${prefix}/share/${name_mysql}/support-files/macports/
130    }
131
132    post-install {
133        if {![file exists ${prefix}/etc/LaunchDaemons/org.macports.${name_mysql}/org.macports.${name_mysql}-server.plist]} {
134            ui_msg "The ${name_mysql} client has been installed."
135            ui_msg "To install the ${name_mysql} server, install the ${name_mysql}-server port."
136        }
137    }
138
139    post-activate {
140        if {![file exists ${prefix}/etc/${name_mysql}/my.cnf]} {
141            copy ${prefix}/share/${name_mysql}/support-files/macports/my.cnf \
142                ${prefix}/etc/${name_mysql}/
143        }
144    }
145
146    variant openssl description {Enable OpenSSL support} {
147        depends_lib-append      path:lib/libssl.dylib:openssl
148
149        patchfiles-delete       patch-cmake-install_layout.cmake-yassl.diff
150
151        configure.args-delete   -DWITH_SSL:STRING=bundled
152        configure.args-append   -DWITH_SSL:STRING=${prefix}
153    }
154
155    notes "
156On activation if no ${prefix}/etc/${name_mysql}/my.cnf file exists one
157will be created which loads
158${prefix}/etc/${name_mysql}/macports-default.cnf.
159
160If a ${prefix}/etc/${name_mysql}/my.cnf file exists MacPorts does not
161touch it and any changes you make to ${prefix}/etc/${name_mysql}/my.cnf
162will be preserved (e.g., during port upgrades, deactivations or
163activations). ${prefix}/etc/${name_mysql}/my.cnf is a good place to
164customize your ${name_mysql} installation.
165
166Any changes made to ${prefix}/etc/${name_mysql}/macports-default.cnf
167will be lost during port upgrades, deactivations or activations so you
168are advised to not make changes here. Currently
169${prefix}/etc/${name_mysql}/macports-default.cnf contains only one
170directive; to disable networking. With disabled networking it is
171possible to install and have running all the MacPorts mysql ports
172simultaneously.
173"
174
175    livecheck.type      regex
176    livecheck.url       http://dev.mysql.com/downloads/mysql/${version_branch}.html
177    livecheck.regex     "MySQL Community Server (${version_branch}(\.\[0-9.\]+)?)"
178}
179
180subport ${name_mysql}-server {
181    revision            ${revision_server}
182    license             BSD
183    description         Run ${name_mysql} as server
184    long_description    ${description}
185
186    supported_archs     noarch
187    distfiles
188
189    depends_run         port:${name_mysql}
190
191    if {"darwin" eq ${os.platform} && ${os.major} > 8} {
192        set mysqluser       _mysql
193    } else {
194        set mysqluser       mysql
195    }
196    add_users ${mysqluser} group=${mysqluser} realname=MySQL\ Server
197
198    pre-extract {
199        copy ${filespath}/org.macports.mysql-server.plist ${workpath}/org.macports.${subport}.plist
200    }
201
202    post-patch {
203        reinplace "s|@NAME@|${subport}|g" \
204            ${workpath}/org.macports.${subport}.plist
205        reinplace "s|@NAMEMYSQL@|${name_mysql}|g" \
206            ${workpath}/org.macports.${subport}.plist
207        reinplace "s|@PREFIX@|${prefix}|g" \
208            ${workpath}/org.macports.${subport}.plist
209        reinplace "s|@SUBPORT@|${subport}|g" \
210            ${workpath}/org.macports.${subport}.plist
211        reinplace "s|@USER@|${mysqluser}|g" \
212            ${workpath}/org.macports.${subport}.plist
213        reinplace "s|@GROUP@|${mysqluser}|g" \
214            ${workpath}/org.macports.${subport}.plist
215    }
216   
217    use_configure       no
218
219    build {}
220
221    destroot {
222        xinstall -d -m 755 ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${subport}
223        xinstall -m 0644 -o root -W ${workpath} \
224            org.macports.${subport}.plist \
225            ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${subport}
226        xinstall -d -m 755 ${destroot}/Library/LaunchDaemons
227        ln -s ${prefix}/etc/LaunchDaemons/org.macports.${subport}/org.macports.${subport}.plist \
228            ${destroot}/Library/LaunchDaemons/org.macports.${subport}.plist
229        xinstall -m 755 -o root -d \
230            ${destroot}${prefix}/var/run
231        xinstall -m 755 -o ${mysqluser} -g ${mysqluser} -d \
232            ${destroot}${prefix}/etc/${name_mysql} \
233            ${destroot}${prefix}/var/db/${name_mysql} \
234            ${destroot}${prefix}/var/log/${name_mysql} \
235            ${destroot}${prefix}/var/run/${name_mysql}
236        xinstall -m 700 -o ${mysqluser} -g ${mysqluser} -d \
237            ${destroot}${prefix}/var/db/${name_mysql}-files \
238            ${destroot}${prefix}/var/db/${name_mysql}-keyring
239        destroot.keepdirs-append  \
240            ${destroot}${prefix}/var/db/${name_mysql} \
241            ${destroot}${prefix}/var/db/${name_mysql}-files \
242            ${destroot}${prefix}/var/db/${name_mysql}-keyring \
243            ${destroot}${prefix}/var/log/${name_mysql} \
244            ${destroot}${prefix}/var/run/${name_mysql}
245    }
246
247    notes "
248If this is a new install you might want to run:
249
250\$ sudo ${prefix}/lib/${name_mysql}/bin/mysqld --initialize --user=${mysqluser}
251\$ ${prefix}/lib/${name_mysql}/bin/mysql_secure_installation
252"
253
254    livecheck.type          none
255}