aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/percona-server.rb
diff options
context:
space:
mode:
authorJack Nagel2013-11-15 16:37:22 -0600
committerJack Nagel2013-11-15 16:37:22 -0600
commitc5b4a826a67f1f02f22b8a4fcf7e63da765236c3 (patch)
tree134c41260fac600f85c1d89ae4c2ce074bba5d11 /Library/Formula/percona-server.rb
parent49a42018493582788c56a7888156f4d90ec9dbb1 (diff)
downloadhomebrew-c5b4a826a67f1f02f22b8a4fcf7e63da765236c3.tar.bz2
percona-server: port changes from mysql formula and modernize style
Diffstat (limited to 'Library/Formula/percona-server.rb')
-rw-r--r--Library/Formula/percona-server.rb90
1 files changed, 48 insertions, 42 deletions
diff --git a/Library/Formula/percona-server.rb b/Library/Formula/percona-server.rb
index 9a822156d..d619205b5 100644
--- a/Library/Formula/percona-server.rb
+++ b/Library/Formula/percona-server.rb
@@ -8,7 +8,7 @@ class PerconaServer < Formula
depends_on 'cmake' => :build
depends_on 'readline'
- depends_on 'pidof'
+ depends_on 'pidof' unless MacOS.version >= :mountain_lion
option :universal
option 'with-tests', 'Build with unit tests'
@@ -30,8 +30,8 @@ class PerconaServer < Formula
# 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'
+ def datadir
+ @datadir ||= (var/'percona').directory? ? var/'percona' : var/'mysql'
end
def patches
@@ -42,45 +42,53 @@ class PerconaServer < Formula
end
def install
+ # Don't hard-code the libtool path. See:
+ # https://github.com/mxcl/homebrew/issues/20185
+ inreplace "cmake/libutils.cmake",
+ "COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION}",
+ "COMMAND libtool -static -o ${TARGET_LOCATION}"
+
# Build without compiler or CPU specific optimization flags to facilitate
# compilation of gems and other software that queries `mysql-config`.
ENV.minimal_optimization
- # Make sure that data directory exists
- (var/destination).mkpath
-
- args = [
- ".",
- "-DCMAKE_INSTALL_PREFIX=#{prefix}",
- "-DMYSQL_DATADIR=#{var}/#{destination}",
- "-DINSTALL_MANDIR=#{man}",
- "-DINSTALL_DOCDIR=#{doc}",
- "-DINSTALL_INFODIR=#{info}",
- # CMake prepends prefix, so use share.basename
- "-DINSTALL_MYSQLSHAREDIR=#{share.basename}/mysql",
- "-DWITH_SSL=yes",
- "-DDEFAULT_CHARSET=utf8",
- "-DDEFAULT_COLLATION=utf8_general_ci",
- "-DSYSCONFDIR=#{etc}",
- "-DCMAKE_BUILD_TYPE=RelWithDebInfo",
- # PAM plugin is Linux-only at the moment
- "-DWITHOUT_AUTH_PAM=1",
- "-DWITHOUT_AUTH_PAM_COMPAT=1",
- "-DWITHOUT_DIALOG=1"
+ args = %W[
+ -DCMAKE_INSTALL_PREFIX=#{prefix}
+ -DCMAKE_FIND_FRAMEWORK=LAST
+ -DCMAKE_VERBOSE_MAKEFILE=ON
+ -DMYSQL_DATADIR=#{datadir}
+ -DINSTALL_INCLUDEDIR=include/mysql
+ -DINSTALL_MANDIR=share/man
+ -DINSTALL_DOCDIR=share/doc/#{name}
+ -DINSTALL_INFODIR=share/info
+ -DINSTALL_MYSQLSHAREDIR=share/mysql
+ -DWITH_SSL=yes
+ -DDEFAULT_CHARSET=utf8
+ -DDEFAULT_COLLATION=utf8_general_ci
+ -DSYSCONFDIR=#{etc}
+ -DCOMPILATION_COMMENT=Homebrew
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo
+ ]
+
+ # PAM plugin is Linux-only at the moment
+ args.concat %W[
+ -DWITHOUT_AUTH_PAM=1
+ -DWITHOUT_AUTH_PAM_COMPAT=1
+ -DWITHOUT_DIALOG=1
]
# To enable unit testing at build, we need to download the unit testing suite
- if build.include? 'with-tests'
+ if build.with? 'tests'
args << "-DENABLE_DOWNLOADS=ON"
else
args << "-DWITH_UNIT_TESTS=OFF"
end
# Build the embedded server
- args << "-DWITH_EMBEDDED_SERVER=ON" if build.include? 'with-embedded'
+ args << "-DWITH_EMBEDDED_SERVER=ON" if build.with? 'embedded'
# Compile with readline unless libedit is explicitly chosen
- args << "-DWITH_READLINE=yes" unless build.include? 'with-libedit'
+ args << "-DWITH_READLINE=yes" unless build.with? 'libedit'
# Make universal for binding to universal applications
args << "-DCMAKE_OSX_ARCHITECTURES='#{Hardware::CPU.universal_archs.as_cmake_arch_flags}'" if build.universal?
@@ -105,6 +113,8 @@ class PerconaServer < Formula
# 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")
+ # pidof can be replaced with pgrep from proctools on Mountain Lion
+ s.gsub!(/pidof/, 'pgrep') if MacOS.version >= :mountain_lion
end
ln_s "#{prefix}/support-files/mysql.server", bin
@@ -112,24 +122,20 @@ class PerconaServer < Formula
# Move mysqlaccess to libexec
mv "#{bin}/mysqlaccess", libexec
mv "#{bin}/mysqlaccess.conf", libexec
- end
-
- def caveats; <<-EOS.undent
- Set up databases to run AS YOUR USER ACCOUNT with:
- unset TMPDIR
- mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix percona-server)" --datadir=#{var}/#{destination} --tmpdir=/tmp
- 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
+ # Make sure that data directory exists
+ datadir.mkpath
+ end
- To run as, for instance, user "mysql", you may need to `sudo`:
- sudo mysql_install_db ...options...
+ def post_install
+ unless File.exist? "#{datadir}/mysql/user.frm"
+ ENV['TMPDIR'] = nil
+ system "#{bin}/mysql_install_db", "--verbose", "--user=#{ENV["USER"]}",
+ "--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
+ end
+ end
+ def caveats; <<-EOS.undent
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.