2011-03-21 17:04:45 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class PerconaServer < Formula
|
|
|
|
homepage 'http://www.percona.com'
|
2012-10-27 09:41:54 +00:00
|
|
|
url 'http://www.percona.com/redir/downloads/Percona-Server-5.5/Percona-Server-5.5.28-29.1/source/Percona-Server-5.5.28-rel29.1.tar.gz'
|
|
|
|
version '5.5.28-29.1'
|
|
|
|
sha1 'c7b2803c440564beff124c9a5641daa643b9f909'
|
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-07-28 16:02:46 +00:00
|
|
|
conflicts_with 'mysql',
|
|
|
|
:because => "percona-server and mysql install the same binaries."
|
2012-10-23 22:37:28 +00:00
|
|
|
|
2012-07-28 16:02:46 +00:00
|
|
|
conflicts_with 'mariadb',
|
|
|
|
:because => "percona-server and mariadb install the same binaries."
|
|
|
|
|
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
|
2012-08-13 20:40:26 +00:00
|
|
|
args << "-DCMAKE_OSX_ARCHITECTURES='i386;x86_64'" 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"
|
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
|
|
|
|
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...
|
|
|
|
|
|
|
|
Start mysqld manually with:
|
|
|
|
mysql.server start
|
|
|
|
|
|
|
|
Note: if this fails, you probably forgot to run the first two steps up above
|
|
|
|
|
|
|
|
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
|
|
|
|
server starting up correctly.
|
|
|
|
|
|
|
|
To connect:
|
|
|
|
mysql -uroot
|
|
|
|
|
|
|
|
To launch on startup:
|
|
|
|
* if this is your first install:
|
|
|
|
mkdir -p ~/Library/LaunchAgents
|
2011-12-31 05:56:52 +00:00
|
|
|
cp #{plist_path} ~/Library/LaunchAgents/
|
|
|
|
launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
|
2011-09-02 16:08:18 +00:00
|
|
|
|
2012-02-04 14:57:53 +00:00
|
|
|
* if this is an upgrade and you already have the #{plist_path.basename} loaded:
|
2011-12-31 05:56:52 +00:00
|
|
|
launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
|
|
|
|
cp #{plist_path} ~/Library/LaunchAgents/
|
|
|
|
launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
|
2011-09-02 16:08:18 +00:00
|
|
|
|
|
|
|
You may also need to edit the plist to use the correct "UserName".
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def startup_plist; <<-EOPLIST.undent
|
|
|
|
<?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>
|
2011-12-31 22:13:31 +00:00
|
|
|
<string>#{HOMEBREW_PREFIX}/bin/mysqld_safe</string>
|
2011-09-02 16:08:18 +00:00
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>UserName</key>
|
|
|
|
<string>#{`whoami`.chomp}</string>
|
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>#{var}</string>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOPLIST
|
2011-03-21 17:04:45 +00:00
|
|
|
end
|
|
|
|
end
|