/
Portfile
183 lines (149 loc) · 6.22 KB
/
Portfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# -*- 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
PortSystem 1.0
name mysql5
version 5.1.72
# Please set revision_client and revision_server to 0 if you bump version.
set revision_client 5
set revision_server 1
set version_branch [join [lrange [split ${version} .] 0 1] .]
homepage https://www.mysql.com/
categories databases
platforms darwin
maintainers {ryandesign @ryandesign}
license GPL-2
distname mysql-${version}
dist_subdir mysql51
use_parallel_build yes
description \
Multithreaded SQL database server
long_description \
MySQL is an open-source, multi-threaded SQL database \
with a command syntax very similar to mSQL.
master_sites mysql:MySQL-${version_branch}
checksums rmd160 a5ba8bedf4027af90a4612a1a7f3a848999cfbf5 \
sha256 c414a64722ffa89d315152a030661d34764894e293e33792809cea61c8a5303e
set major_version [strsed ${version} {s/\..*$//}]
set mysql mysql${major_version}
set libdir ${prefix}/lib/${mysql}
set bindir ${libdir}/bin
set dbdir ${prefix}/var/db/${mysql}
set sysconfdir ${prefix}/etc/${mysql}
if {"darwin" eq ${os.platform} && ${os.major} > 8} {
set mysqluser _mysql
} else {
set mysqluser mysql
}
add_users ${mysqluser} group=${mysqluser} realname=MySQL\ Server
if {${name} eq ${subport}} {
# http://bugs.mysql.com/bug.php?id=47360
PortGroup muniversal 1.0
revision ${revision_client}
depends_lib \
port:zlib \
path:lib/libssl.dylib:openssl \
port:tcp_wrappers
patch.pre_args-replace -p0 -p1
patchfiles patch-Makefile.in.diff \
patch-scripts-mysql_secure_installation.sh.diff
post-patch {
reinplace s%@BINDIR@%${bindir}%g ${worksrcpath}/scripts/mysql_secure_installation.sh
}
configure.args \
--mandir=${prefix}/share/man \
--infodir=${prefix}/share/info \
--localstatedir=${dbdir} \
--libdir=${libdir} \
--bindir=${bindir} \
--includedir=${prefix}/include/${mysql} \
--datadir=${prefix}/share/${mysql} \
--sysconfdir=${sysconfdir} \
--with-zlib-dir=${prefix} \
--with-ssl=${prefix} \
--with-extra-charsets=complex \
--with-unix-socket-path=${prefix}/var/run/${mysql}/mysqld.sock \
--with-mysqld-user=${mysqluser} \
--without-docs \
--with-plugins=all \
--enable-thread-safe-client
# the following is in store for future
# --program-suffix=5
# Add readline support.
# "--without-readline" has the peculiar meaning "do not use the bundled copy
# of readline but use the system's (i.e. MacPorts') copy of readline"
depends_lib-append port:readline
configure.args-append --without-readline
# Build libmysqld embedded server.
configure.cflags-append -fPIC
configure.cxxflags-append -fPIC
configure.args-append --with-embedded-server --with-pic
# doesn't build with clang as of 2011.06.27
# This is a bug in mysql's build system, fixed in 5.5
compiler.blacklist-append *clang*
post-build {
if {[variant_exists universal] && [variant_isset universal]} {
set dirs {}
foreach arch ${universal_archs_to_use} {
lappend dirs ${worksrcpath}-${arch}
}
} else {
set dirs ${worksrcpath}
}
foreach dir ${dirs} {
reinplace -E {s|-arch [a-z0-9_]+||g} \
${dir}/scripts/mysql_config \
${dir}/scripts/mysqlbug
}
}
pre-destroot {
xinstall -m 755 -d ${destroot}${sysconfdir}
destroot.keepdirs-append ${destroot}${sysconfdir}
}
post-destroot {
# Fix paths in manpages and sample configuration files
foreach manpage [glob -type f ${destroot}${prefix}/share/man/man\[1-9\]/*] {
reinplace "s|/etc/my.cnf|${sysconfdir}/my.cnf|g" ${manpage}
}
foreach samp_conffile [glob -type f ${destroot}${prefix}/share/${mysql}/mysql/my-*.cnf] {
reinplace "s|/etc/my.cnf|${sysconfdir}/my.cnf|g" ${samp_conffile}
}
# Symlink mysql binaries into bin directory, with ${major_version} appended to the name
foreach f [glob -tails -directory ${destroot}${bindir} my*] {
ln -sf ${bindir}/${f} ${destroot}${prefix}/bin/${f}${major_version}
}
}
post-install {
if {![file exists ${prefix}/etc/LaunchDaemons/org.macports.${mysql}/org.macports.${mysql}.plist]} {
ui_msg "The MySQL client has been installed."
ui_msg "If you also want a MySQL server, install the mysql5-server port."
}
}
}
subport mysql5-server {
revision ${revision_server}
supported_archs noarch
depends_run \
port:mysql5
distfiles
use_configure no
build {}
destroot {
xinstall -m 755 -o root -d ${destroot}${prefix}/var/run
xinstall -m 755 -o ${mysqluser} -g ${mysqluser} -d \
${destroot}${dbdir} \
${destroot}${prefix}/var/log/${mysql} \
${destroot}${prefix}/var/run/${mysql}
destroot.keepdirs-append \
${destroot}${dbdir} \
${destroot}${prefix}/var/log/${mysql} \
${destroot}${prefix}/var/run/${mysql}
}
startupitem.create yes
startupitem.name ${mysql}
startupitem.start "${prefix}/share/${mysql}/mysql/mysql.server start"
startupitem.stop "${prefix}/share/${mysql}/mysql/mysql.server stop"
notes "If this is a new install, in order to setup the database you might want to run:" \
"sudo -u ${mysqluser} mysql_install_db5"
}
livecheck.type regex
livecheck.url https://dev.mysql.com/downloads/mysql/${version_branch}.html
livecheck.regex "<h1>MySQL Community Server (${version_branch}(\.\[0-9.\]+)?)</h1>"