class PerconaServerAT55 < Formula desc "Drop-in MySQL replacement" homepage "https://www.percona.com/" url "https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-5.5.54-38.7/source/tarball/percona-server-5.5.54-38.7.tar.gz" version "5.5.54-38.7" sha256 "2c5f23a5bd41e36c681d882b94e021a2fe34acfb3951945146ee2ead2aeb7f1c" bottle do sha256 "122ac9f6d7d33fafed9927c8bccfd933f82df0e3b3a64a40733e86088e07647d" => :sierra sha256 "14dd4085444332e5f05fbcd0bb26e0fa8573ce9569e7817939e4b1e9a3018aad" => :el_capitan sha256 "cf5ff63513d937d546119e3da98e2ca54afab297f1c062dbcfc3221ab94ccb78" => :yosemite end keg_only :versioned_formula option "with-test", "Build with unit tests" option "with-embedded", "Build the embedded server" option "with-libedit", "Compile with editline wrapper instead of readline" option "with-local-infile", "Build with local infile loading support" deprecated_option "enable-local-infile" => "with-local-infile" deprecated_option "with-tests" => "with-test" depends_on "cmake" => :build depends_on "readline" depends_on "pidof" depends_on "openssl" # Where the database files should be located. Existing installs have them # under var/percona, but going forward they will be under var/mysql to be # shared with the mysql and mariadb formulae. def datadir @datadir ||= (var/"percona").directory? ? var/"percona" : var/"mysql" end pour_bottle? do reason "The bottle needs a var/mysql datadir (yours is var/percona)." satisfy { datadir == var/"mysql" } end def install args = std_cmake_args + %W[ -DMYSQL_DATADIR=#{datadir} -DSYSCONFDIR=#{etc} -DINSTALL_MANDIR=#{man} -DINSTALL_DOCDIR=#{doc} -DINSTALL_INFODIR=#{info} -DINSTALL_INCLUDEDIR=include/mysql -DINSTALL_MYSQLSHAREDIR=#{share.basename}/mysql -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DCOMPILATION_COMMENT=Homebrew -DWITH_EDITLINE=system ] # 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.with? "tests" args << "-DENABLE_DOWNLOADS=ON" else args << "-DWITH_UNIT_TESTS=OFF" end # Build the embedded server args << "-DWITH_EMBEDDED_SERVER=ON" if build.with? "embedded" # Compile with readline unless libedit is explicitly chosen args << "-DWITH_READLINE=yes" if build.without? "libedit" # Make universal for binding to universal applications if build.universal? ENV.universal_binary args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.universal_archs.as_cmake_arch_flags}" end # Build with local infile loading support args << "-DENABLED_LOCAL_INFILE=1" if build.include? "enable-local-infile" system "cmake", *args system "make" system "make", "install" # 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" # Fix up the control script and link into bin inreplace "#{prefix}/support-files/mysql.server", /^(PATH=".*)(")/, "\\1:#{HOMEBREW_PREFIX}/bin\\2" ln_s "#{prefix}/support-files/mysql.server", bin # Move mysqlaccess to libexec libexec.mkpath 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-server55)" --datadir=#{datadir} --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: * https://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html * https://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 plist_options :manual => "mysql.server start" def plist; <<-EOS.undent KeepAlive Label #{plist_name} Program #{opt_prefix}/bin/mysqld_safe RunAtLoad WorkingDirectory #{var} EOS end end