2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2010-01-16 19:25:49 +00:00
|
|
|
require 'hardware'
|
2009-09-01 01:22:29 +00:00
|
|
|
|
|
|
|
class Postgresql <Formula
|
2010-04-04 18:09:09 +00:00
|
|
|
homepage 'http://www.postgresql.org/'
|
|
|
|
url 'http://ftp2.uk.postgresql.org/sites/ftp.postgresql.org/source/v8.4.3/postgresql-8.4.3.tar.bz2'
|
|
|
|
md5 '7f70e7b140fb190f268837255582b07e'
|
2009-10-29 19:47:57 +00:00
|
|
|
|
2009-10-05 20:27:37 +00:00
|
|
|
depends_on 'readline'
|
2010-01-13 05:15:58 +00:00
|
|
|
depends_on 'libxml2' if MACOS_VERSION < 10.6 #system libxml is too old
|
2009-09-01 01:22:29 +00:00
|
|
|
|
2009-12-04 10:48:21 +00:00
|
|
|
aka 'postgres'
|
|
|
|
|
2010-03-29 19:46:53 +00:00
|
|
|
def options
|
|
|
|
[
|
|
|
|
['--no-python', 'Build without Python support.'],
|
|
|
|
['--no-perl', 'Build without Perl support.']
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2009-09-01 01:22:29 +00:00
|
|
|
def install
|
2009-12-05 18:39:13 +00:00
|
|
|
ENV.libxml2 # wouldn't compile for justinlilly otherwise
|
|
|
|
|
2009-09-01 01:22:29 +00:00
|
|
|
configure_args = [
|
2009-09-23 18:00:02 +00:00
|
|
|
"--enable-thread-safety",
|
2009-09-01 01:22:29 +00:00
|
|
|
"--with-bonjour",
|
|
|
|
"--with-gssapi",
|
|
|
|
"--with-krb5",
|
|
|
|
"--with-openssl",
|
|
|
|
"--with-libxml",
|
|
|
|
"--with-libxslt",
|
|
|
|
"--prefix=#{prefix}",
|
2010-03-29 19:46:53 +00:00
|
|
|
"--disable-debug"
|
2009-09-01 01:22:29 +00:00
|
|
|
]
|
|
|
|
|
2010-03-29 19:46:53 +00:00
|
|
|
configure_args << "--with-python" unless ARGV.include? '--no-python'
|
|
|
|
configure_args << "--with-perl" unless ARGV.include? '--no-perl'
|
|
|
|
|
|
|
|
if bits_64? and not ARGV.include? '--no-python'
|
|
|
|
configure_args << "ARCHFLAGS='-arch x86_64'"
|
|
|
|
|
2010-05-05 04:24:32 +00:00
|
|
|
# On 64-bit systems, we need to look for a 32-bit Framework Python.
|
|
|
|
# The configure script prefers this Python version, and if it doesn't
|
|
|
|
# have 64-bit support then linking will fail.
|
|
|
|
|
2010-03-29 19:46:53 +00:00
|
|
|
framework_python = Pathname.new "/Library/Frameworks/Python.framework/Versions/Current/Python"
|
|
|
|
if framework_python.exist? and not (archs_for_command framework_python).include? :x86_64
|
2010-05-05 04:24:32 +00:00
|
|
|
opoo "Detected a framework Python that does not have 64-bit support in:"
|
|
|
|
puts <<-EOS.undent
|
|
|
|
#{framework_python}
|
|
|
|
|
|
|
|
The configure script seems to prefer this version of Python over any others,
|
|
|
|
so you may experience linker problems as described in:
|
|
|
|
http://osdir.com/ml/pgsql-general/2009-09/msg00160.html
|
|
|
|
|
|
|
|
To fix this issue, you may need to either delete the version of Python
|
|
|
|
shown above, or move it out of the way before brewing PostgreSQL.
|
|
|
|
|
|
|
|
Note that a framework Python in /Library/Frameworks/Python.framework is
|
|
|
|
the "MacPython" verison, and not the system-provided version which is in:
|
|
|
|
/System/Library/Frameworks/Python.framework
|
|
|
|
EOS
|
2010-03-29 19:46:53 +00:00
|
|
|
end
|
|
|
|
end
|
2009-10-02 22:46:27 +00:00
|
|
|
|
|
|
|
# Fails on Core Duo with O4 and O3
|
2010-03-13 06:44:50 +00:00
|
|
|
ENV.O2 if Hardware.intel_family == :core
|
2009-09-23 18:00:02 +00:00
|
|
|
|
2009-09-01 01:22:29 +00:00
|
|
|
system "./configure", *configure_args
|
|
|
|
system "make install"
|
|
|
|
|
2009-10-01 04:49:34 +00:00
|
|
|
(prefix+'org.postgresql.postgres.plist').write startup_plist
|
2009-09-01 01:22:29 +00:00
|
|
|
end
|
|
|
|
|
2009-09-23 18:00:02 +00:00
|
|
|
def skip_clean? path
|
|
|
|
# NOTE at some point someone should tweak this so it only skips clean
|
|
|
|
# for the bits that break the build otherwise
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2010-01-13 05:15:58 +00:00
|
|
|
def bits_64?
|
|
|
|
MACOS_VERSION >= 10.6 && Hardware.is_64_bit?
|
|
|
|
end
|
|
|
|
|
|
|
|
def caveats
|
|
|
|
caveats = <<-EOS
|
2010-04-14 16:43:06 +00:00
|
|
|
To build plpython against a specific Python, set PYTHON prior to brewing:
|
|
|
|
PYTHON=/usr/local/bin/python brew install postgresql
|
|
|
|
See:
|
|
|
|
http://www.postgresql.org/docs/8.4/static/install-procedure.html
|
|
|
|
|
|
|
|
|
2009-10-01 04:49:34 +00:00
|
|
|
If this is your first install, create a database with:
|
2010-03-13 06:44:50 +00:00
|
|
|
initdb #{var}/postgres
|
2009-09-26 05:49:03 +00:00
|
|
|
|
2009-10-01 04:49:34 +00:00
|
|
|
Automatically load on login with:
|
|
|
|
launchctl load -w #{prefix}/org.postgresql.postgres.plist
|
2009-09-01 01:22:29 +00:00
|
|
|
|
2009-10-01 04:49:34 +00:00
|
|
|
Or start manually with:
|
2010-03-13 06:44:50 +00:00
|
|
|
pg_ctl -D #{var}/postgres -l #{var}/postgres/server.log start
|
2009-09-01 01:22:29 +00:00
|
|
|
|
2009-10-01 04:49:34 +00:00
|
|
|
And stop with:
|
2010-03-13 06:44:50 +00:00
|
|
|
pg_ctl -D #{var}/postgres stop -s -m fast
|
2010-01-13 05:15:58 +00:00
|
|
|
EOS
|
|
|
|
|
|
|
|
if bits_64? then
|
|
|
|
caveats << <<-EOS
|
2009-09-01 01:22:29 +00:00
|
|
|
|
2010-01-13 05:15:58 +00:00
|
|
|
If you want to install the postgres gem, including ARCHFLAGS is recommended:
|
2009-10-01 04:49:34 +00:00
|
|
|
env ARCHFLAGS="-arch x86_64" gem install postgres
|
2009-09-01 01:22:29 +00:00
|
|
|
|
2009-10-01 04:49:34 +00:00
|
|
|
To install gems without sudo, see the Homebrew wiki.
|
2010-01-13 05:15:58 +00:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
caveats
|
2009-09-01 01:22:29 +00:00
|
|
|
end
|
2009-10-01 04:49:34 +00:00
|
|
|
|
|
|
|
def startup_plist
|
|
|
|
return <<-EOPLIST
|
|
|
|
<?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>org.postgresql.postgres</string>
|
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
2010-03-13 06:44:50 +00:00
|
|
|
<string>#{bin}/postgres</string>
|
2009-10-01 04:49:34 +00:00
|
|
|
<string>-D</string>
|
2010-03-13 06:44:50 +00:00
|
|
|
<string>#{var}/postgres</string>
|
2009-10-01 04:49:34 +00:00
|
|
|
<string>-r</string>
|
2010-03-13 06:44:50 +00:00
|
|
|
<string>#{var}/postgres/server.log</string>
|
2009-10-01 04:49:34 +00:00
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>UserName</key>
|
2010-01-16 15:48:56 +00:00
|
|
|
<string>#{`whoami`.chomp}</string>
|
2009-10-01 04:49:34 +00:00
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>#{HOMEBREW_PREFIX}</string>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOPLIST
|
|
|
|
end
|
2009-09-01 01:22:29 +00:00
|
|
|
end
|