2011-03-21 17:04:45 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class PerconaServer < Formula
|
|
|
|
homepage 'http://www.percona.com'
|
2013-09-04 13:53:47 +00:00
|
|
|
url 'http://www.percona.com/redir/downloads/Percona-Server-5.6/Percona-Server-5.6.13-rc60.5/source/Percona-Server-5.6.13-rc60.5.tar.gz'
|
|
|
|
version '5.6.13-rc60.5'
|
|
|
|
sha1 'c8a11e5df24d74f3e362bd85ef6b30756ad3bcf6'
|
2011-09-02 16:08:18 +00:00
|
|
|
|
|
|
|
depends_on 'cmake' => :build
|
2012-11-11 03:12:26 +00:00
|
|
|
depends_on 'readline'
|
2011-09-02 16:08:18 +00:00
|
|
|
depends_on 'pidof'
|
|
|
|
|
2012-08-13 20:40:26 +00:00
|
|
|
option :universal
|
|
|
|
option 'with-tests', 'Build with unit tests'
|
|
|
|
option 'with-embedded', 'Build the embedded server'
|
|
|
|
option 'with-libedit', 'Compile with editline wrapper instead of readline'
|
|
|
|
option 'enable-local-infile', 'Build with local infile loading support'
|
|
|
|
|
2012-10-23 22:37:28 +00:00
|
|
|
|
2013-08-30 00:03:34 +00:00
|
|
|
conflicts_with 'mariadb', 'mysql', 'mysql-cluster',
|
|
|
|
:because => "percona, mariadb, and mysql install the same binaries."
|
2013-01-03 16:25:30 +00:00
|
|
|
|
2012-10-23 22:37:28 +00:00
|
|
|
env :std if build.universal?
|
|
|
|
|
2012-03-18 20:33:24 +00:00
|
|
|
fails_with :llvm do
|
2012-06-27 04:12:37 +00:00
|
|
|
build 2334
|
2012-03-18 20:33:24 +00:00
|
|
|
cause "https://github.com/mxcl/homebrew/issues/issue/144"
|
|
|
|
end
|
|
|
|
|
2012-11-14 21:38:51 +00:00
|
|
|
# Where the database files should be located. Existing installs have them
|
|
|
|
# under var/percona, but going forward they will be under var/msyql to be
|
|
|
|
# shared with the mysql and mariadb formulae.
|
|
|
|
def destination
|
|
|
|
@destination ||= (var/'percona').directory? ? 'percona' : 'mysql'
|
|
|
|
end
|
|
|
|
|
2011-03-21 17:04:45 +00:00
|
|
|
def install
|
2012-08-17 16:17:13 +00:00
|
|
|
# Build without compiler or CPU specific optimization flags to facilitate
|
|
|
|
# compilation of gems and other software that queries `mysql-config`.
|
|
|
|
ENV.minimal_optimization
|
|
|
|
|
2012-11-14 21:38:51 +00:00
|
|
|
# Make sure that data directory exists
|
|
|
|
(var/destination).mkpath
|
2011-09-02 16:08:18 +00:00
|
|
|
|
2012-11-14 21:38:51 +00:00
|
|
|
args = [
|
2011-09-02 16:08:18 +00:00
|
|
|
".",
|
2012-11-14 21:38:51 +00:00
|
|
|
"-DCMAKE_INSTALL_PREFIX=#{prefix}",
|
|
|
|
"-DMYSQL_DATADIR=#{var}/#{destination}",
|
2011-09-02 16:08:18 +00:00
|
|
|
"-DINSTALL_MANDIR=#{man}",
|
|
|
|
"-DINSTALL_DOCDIR=#{doc}",
|
|
|
|
"-DINSTALL_INFODIR=#{info}",
|
|
|
|
# CMake prepends prefix, so use share.basename
|
2012-11-14 21:38:51 +00:00
|
|
|
"-DINSTALL_MYSQLSHAREDIR=#{share.basename}/mysql",
|
2011-09-02 16:08:18 +00:00
|
|
|
"-DWITH_SSL=yes",
|
|
|
|
"-DDEFAULT_CHARSET=utf8",
|
|
|
|
"-DDEFAULT_COLLATION=utf8_general_ci",
|
2012-05-10 08:37:25 +00:00
|
|
|
"-DSYSCONFDIR=#{etc}",
|
2012-06-08 10:07:24 +00:00
|
|
|
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
|
|
|
|
# PAM plugin is Linux-only at the moment
|
|
|
|
"-DWITHOUT_AUTH_PAM=1",
|
|
|
|
"-DWITHOUT_AUTH_PAM_COMPAT=1",
|
|
|
|
"-DWITHOUT_DIALOG=1"
|
2011-09-02 16:08:18 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# To enable unit testing at build, we need to download the unit testing suite
|
2012-08-13 20:40:26 +00:00
|
|
|
if build.include? 'with-tests'
|
2011-09-02 16:08:18 +00:00
|
|
|
args << "-DENABLE_DOWNLOADS=ON"
|
|
|
|
else
|
|
|
|
args << "-DWITH_UNIT_TESTS=OFF"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Build the embedded server
|
2012-08-13 20:40:26 +00:00
|
|
|
args << "-DWITH_EMBEDDED_SERVER=ON" if build.include? 'with-embedded'
|
2011-09-02 16:08:18 +00:00
|
|
|
|
|
|
|
# Compile with readline unless libedit is explicitly chosen
|
2012-08-13 20:40:26 +00:00
|
|
|
args << "-DWITH_READLINE=yes" unless build.include? 'with-libedit'
|
2011-09-02 16:08:18 +00:00
|
|
|
|
|
|
|
# Make universal for binding to universal applications
|
2013-08-02 03:51:36 +00:00
|
|
|
args << "-DCMAKE_OSX_ARCHITECTURES='#{Hardware::CPU.universal_archs.as_cmake_arch_flags}'" if build.universal?
|
2011-09-02 16:08:18 +00:00
|
|
|
|
|
|
|
# Build with local infile loading support
|
2012-08-13 20:40:26 +00:00
|
|
|
args << "-DENABLED_LOCAL_INFILE=1" if build.include? 'enable-local-infile'
|
2011-09-02 16:08:18 +00:00
|
|
|
|
|
|
|
system "cmake", *args
|
|
|
|
system "make"
|
2013-07-23 10:02:42 +00:00
|
|
|
# Reported upstream:
|
|
|
|
# http://bugs.mysql.com/bug.php?id=69645
|
|
|
|
inreplace "scripts/mysql_config", / +-Wno[\w-]+/, ""
|
2011-03-21 17:04:45 +00:00
|
|
|
system "make install"
|
2011-09-02 16:08:18 +00:00
|
|
|
|
|
|
|
# Don't create databases inside of the prefix!
|
|
|
|
# See: https://github.com/mxcl/homebrew/issues/4975
|
|
|
|
rm_rf prefix+'data'
|
|
|
|
|
|
|
|
# Link the setup script into bin
|
|
|
|
ln_s prefix+'scripts/mysql_install_db', bin+'mysql_install_db'
|
2012-11-11 15:32:54 +00:00
|
|
|
|
2011-09-02 16:08:18 +00:00
|
|
|
# Fix up the control script and link into bin
|
|
|
|
inreplace "#{prefix}/support-files/mysql.server" do |s|
|
|
|
|
s.gsub!(/^(PATH=".*)(")/, "\\1:#{HOMEBREW_PREFIX}/bin\\2")
|
|
|
|
end
|
2012-11-11 15:32:54 +00:00
|
|
|
|
2011-09-02 16:08:18 +00:00
|
|
|
ln_s "#{prefix}/support-files/mysql.server", bin
|
2013-07-16 05:21:25 +00:00
|
|
|
|
|
|
|
# Move mysqlaccess to libexec
|
|
|
|
mv "#{bin}/mysqlaccess", libexec
|
|
|
|
mv "#{bin}/mysqlaccess.conf", libexec
|
2011-09-02 16:08:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
Set up databases to run AS YOUR USER ACCOUNT with:
|
|
|
|
unset TMPDIR
|
2012-11-14 21:38:51 +00:00
|
|
|
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix percona-server)" --datadir=#{var}/#{destination} --tmpdir=/tmp
|
2011-09-02 16:08:18 +00:00
|
|
|
|
|
|
|
To set up base tables in another folder, or use a different user to run
|
|
|
|
mysqld, view the help for mysqld_install_db:
|
|
|
|
mysql_install_db --help
|
|
|
|
|
|
|
|
and view the MySQL documentation:
|
|
|
|
* http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html
|
|
|
|
* http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html
|
|
|
|
|
|
|
|
To run as, for instance, user "mysql", you may need to `sudo`:
|
|
|
|
sudo mysql_install_db ...options...
|
|
|
|
|
|
|
|
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
|
|
|
|
server starting up correctly.
|
|
|
|
|
|
|
|
To connect:
|
|
|
|
mysql -uroot
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
plist_options :manual => 'mysql.server start'
|
|
|
|
|
|
|
|
def plist; <<-EOS.undent
|
2011-09-02 16:08:18 +00:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>KeepAlive</key>
|
|
|
|
<true/>
|
|
|
|
<key>Label</key>
|
2011-12-31 05:56:52 +00:00
|
|
|
<string>#{plist_name}</string>
|
2011-09-02 16:08:18 +00:00
|
|
|
<key>Program</key>
|
2012-11-25 15:06:41 +00:00
|
|
|
<string>#{opt_prefix}/bin/mysqld_safe</string>
|
2011-09-02 16:08:18 +00:00
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>#{var}</string>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
2012-11-25 15:06:41 +00:00
|
|
|
EOS
|
2011-03-21 17:04:45 +00:00
|
|
|
end
|
|
|
|
end
|