Skip to content

Instantly share code, notes, and snippets.

@tonyarnold
Created October 12, 2010 10:17
Show Gist options
  • Select an option

  • Save tonyarnold/621983 to your computer and use it in GitHub Desktop.

Select an option

Save tonyarnold/621983 to your computer and use it in GitHub Desktop.
require 'formula'
class Mysql <Formula
version '5.5.6-rc'
homepage 'http://dev.mysql.com/doc/refman/5.5/en/'
url 'http://mysql.mirrors.ilisys.com.au/Downloads/MySQL-5.5/mysql-5.5.6-rc.tar.gz'
md5 '25cbd495e3aa87b4eb741b213b6dd990'
depends_on 'readline'
def options
[
['--with-tests', "Keep tests when installing."],
['--with-bench', "Keep benchmark app when installing."],
['--client-only', "Only install client tools, not the server."],
['--universal', "Make mysql a universal binary"]
]
end
def install
fails_with_llvm "http://github.com/mxcl/homebrew/issues/issue/144"
# See: http://dev.mysql.com/doc/refman/5.1/en/configure-options.html
# These flags may not apply to gcc 4+
ENV['CC'] = "/usr/bin/gcc"
ENV['CXX'] = "/usr/bin/g++"
ENV['CXXFLAGS'] = ENV['CXXFLAGS'].gsub "-fomit-frame-pointer", ""
ENV['CXXFLAGS'] += " -fno-omit-frame-pointer -felide-constructors"
# Make universal for bindings to universal applications
ENV.universal_binary if ARGV.include? '--universal'
configure_args = [
"--without-docs",
"--without-debug",
"--disable-dependency-tracking",
"--prefix=#{prefix}",
"--localstatedir=#{var}/mysql",
"--sysconfdir=#{etc}",
"--with-plugins=innobase,myisam",
"--with-extra-charsets=complex",
"--with-ssl",
"--without-readline", # Confusingly, means "use detected readline instead of included readline"
"--enable-assembler",
"--enable-thread-safe-client",
"--enable-local-infile",
"--enable-shared"]
configure_args << "--without-server" if ARGV.include? '--client-only'
system "./configure", *configure_args
system "make install"
ln_s "#{libexec}/mysqld", bin
ln_s "#{share}/mysql/mysql.server", bin
(prefix+'mysql-test').rmtree unless ARGV.include? '--with-tests' # save 66MB!
(prefix+'sql-bench').rmtree unless ARGV.include? '--with-bench'
(prefix+'com.mysql.mysqld.plist').write startup_plist
end
def caveats; <<-EOS.undent
Set up databases with:
mysql_install_db
If this is your first install, automatically load on login with:
cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
If this is an upgrade and you already have the com.mysql.mysqld.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
Note on upgrading:
We overwrite any existing com.mysql.mysqld.plist in ~/Library/LaunchAgents
if we are upgrading because previous versions of this brew created the
plist with a version specific program argument.
Or start manually with:
mysql.server start
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>
<string>com.mysql.mysqld</string>
<key>Program</key>
<string>#{bin}/mysqld_safe</string>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>#{`whoami`.chomp}</string>
<key>WorkingDirectory</key>
<string>#{var}</string>
</dict>
</plist>
EOPLIST
end
end
@kristianmandrup
Copy link

Didn't work for me :(

==> Downloading http://mysql.mirrors.ilisys.com.au/Downloads/MySQL-5.5/mysql-5.5.6-rc.tar.gz

################################################################## 100.0%

==> ./configure --without-docs --without-debug --disable-dependency-tracking --prefix=/usr/local/Cellar/mysql/
==> make install
Error: undefined method length' for nil:NilClass Please report this bug at http://github.com/mxcl/homebrew/issues /usr/local/Library/Homebrew/extend/string.rb:3:inundent'
/usr/local/Library/Formula/mysql.rb:96:in startup_plist' /usr/local/Library/Formula/mysql.rb:60:ininstall'
/usr/local/Library/Homebrew/install.rb:96:in install' /usr/local/Library/Homebrew/formula.rb:190:inbrew'
/usr/local/Library/Homebrew/formula.rb:405:in stage' /usr/local/Library/Homebrew/formula.rb:364:inmktemp'
/usr/local/Library/Homebrew/formula.rb:403:in stage' /usr/local/Library/Homebrew/formula.rb:185:inbrew'
/usr/local/Library/Homebrew/install.rb:74:in `install'
/usr/local/Library/Homebrew/install.rb:39
/usr/local/Library/Formula/mysql.rb:86

@tonyarnold
Copy link
Author

That looks like a home brewerror as opposed to a compile error. I might be running homebrew HEAD. I'll have a look when I'm home from the conference I'm at right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment