1- require 'formula'
2-
31class Postgresql < Formula
4- homepage 'http://www.postgresql.org/'
5- url 'http://ftp.postgresql.org/pub/source/v9.4.1/postgresql-9.4.1.tar.bz2'
6- sha256 '29ddb77c820095b8f52e5455e9c6c6c20cf979b0834ed1986a8857b84888c3a6'
7- version '9.4.1-boxen'
2+ homepage "http://www.postgresql.org/"
3+
4+ stable do
5+ url "http://ftp.postgresql.org/pub/source/v9.4.1/postgresql-9.4.1.tar.bz2"
6+ sha256 "29ddb77c820095b8f52e5455e9c6c6c20cf979b0834ed1986a8857b84888c3a6"
7+ end
8+
9+ version "9.4.1-boxen2"
10+
11+ bottle do
12+ revision 1
13+ sha1 "4b5a1f7ebe10ec5aba088459a4faa2ba7c13a691" => :yosemite
14+ sha1 "e7844fc53d1ffef1cb809332d88b5bb777927176" => :mavericks
15+ sha1 "a5e70e04dba89fee99bb5fb7dae74e4a849813c4" => :mountain_lion
16+ end
817
9- option ' 32-bit'
10- option 'no -perl' , ' Build without Perl support'
11- option 'no -tcl' , ' Build without Tcl support'
12- option 'enable -dtrace' , ' Build with DTrace support'
18+ option " 32-bit"
19+ option "without -perl" , " Build without Perl support"
20+ option "without -tcl" , " Build without Tcl support"
21+ option "with -dtrace" , " Build with DTrace support"
1322
14- depends_on 'readline'
15- depends_on 'ossp-uuid' => :recommended
23+ deprecated_option "no-perl" => "without-perl"
24+ deprecated_option "no-tcl" => "without-tcl"
25+ deprecated_option "enable-dtrace" => "with-dtrace"
1626
17- conflicts_with 'postgres-xc' ,
18- :because => 'postgresql and postgres-xc install the same binaries.'
27+ depends_on "openssl"
28+ depends_on "readline"
29+ depends_on "libxml2" if MacOS . version <= :leopard # Leopard libxml is too old
30+ depends_on :python => :optional
31+
32+ conflicts_with "postgres-xc" ,
33+ :because => "postgresql and postgres-xc install the same binaries."
1934
2035 fails_with :clang do
2136 build 211
22- cause 'Miscompilation resulting in segfault on queries'
23- end
24-
25- # Fix uuid-ossp build issues: http://archives.postgresql.org/pgsql-general/2012-07/msg00654.php
26- def patches
27- DATA
37+ cause "Miscompilation resulting in segfault on queries"
2838 end
2939
3040 def install
@@ -38,44 +48,84 @@ def install
3848 --enable-thread-safety
3949 --with-bonjour
4050 --with-gssapi
41- --with-krb5
4251 --with-ldap
4352 --with-openssl
4453 --with-pam
4554 --with-libxml
4655 --with-libxslt
4756 ]
4857
49- args << "--with-ossp-uuid" if build . with? 'ossp-uuid'
50- args << "--with-perl" unless build . include? 'no-perl'
51- args << "--with-tcl" unless build . include? 'no-tcl'
52- args << "--enable-dtrace" if build . include? 'enable-dtrace'
58+ args << "--with-python" if build . with? "python"
59+ args << "--with-perl" if build . with? "perl"
5360
54- if build . with? 'ossp-uuid'
55- ENV . append 'CFLAGS' , `uuid-config --cflags` . strip
56- ENV . append 'LDFLAGS' , `uuid-config --ldflags` . strip
57- ENV . append 'LIBS' , `uuid-config --libs` . strip
61+ # The CLT is required to build tcl support on 10.7 and 10.8 because
62+ # tclConfig.sh is not part of the SDK
63+ if build . with? ( "tcl" ) && ( MacOS . version >= :mavericks || MacOS ::CLT . installed? )
64+ args << "--with-tcl"
65+
66+ if File . exist? ( "#{ MacOS . sdk_path } /usr/lib/tclConfig.sh" )
67+ args << "--with-tclconfig=#{ MacOS . sdk_path } /usr/lib"
68+ end
5869 end
5970
71+ args << "--enable-dtrace" if build . with? "dtrace"
72+ args << "--with-uuid=e2fs"
73+
6074 if build . build_32_bit?
61- ENV . append 'CFLAGS' , "-arch #{ MacOS . preferred_arch } "
62- ENV . append 'LDFLAGS' , "-arch #{ MacOS . preferred_arch } "
75+ ENV . append %w{ CFLAGS LDFLAGS } , "-arch #{ Hardware ::CPU . arch_32_bit } "
6376 end
6477
6578 system "./configure" , *args
66- system "make install-world"
79+ system "make" , " install-world"
6780 end
68- end
6981
70- __END__
71- --- a/contrib/uuid-ossp/uuid-ossp.c 2012-07-30 18:34:53.000000000 -0700
72- +++ b/contrib/uuid-ossp/uuid-ossp.c 2012-07-30 18:35:03.000000000 -0700
73- @@ -9,6 +9,8 @@
74- *-------------------------------------------------------------------------
75- */
76-
77- +#define _XOPEN_SOURCE
78- +
79- #include "postgres.h"
80- #include "fmgr.h"
81- #include "utils/builtins.h"
82+ def post_install
83+ unless File . exist? "#{ var } /postgres"
84+ system "#{ bin } /initdb" , "#{ var } /postgres"
85+ end
86+ end
87+
88+ def caveats ; <<-EOS . undent
89+ If builds of PostgreSQL 9 are failing and you have version 8.x installed,
90+ you may need to remove the previous version first. See:
91+ https://github.com/Homebrew/homebrew/issues/2510
92+
93+ To migrate existing data from a previous major version (pre-9.4) of PostgreSQL, see:
94+ http://www.postgresql.org/docs/9.4/static/upgrading.html
95+ EOS
96+ end
97+
98+ plist_options :manual => "postgres -D #{ HOMEBREW_PREFIX } /var/postgres"
99+
100+ def plist ; <<-EOS . undent
101+ <?xml version="1.0" encoding="UTF-8"?>
102+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
103+ <plist version="1.0">
104+ <dict>
105+ <key>KeepAlive</key>
106+ <true/>
107+ <key>Label</key>
108+ <string>#{ plist_name } </string>
109+ <key>ProgramArguments</key>
110+ <array>
111+ <string>#{ opt_bin } /postgres</string>
112+ <string>-D</string>
113+ <string>#{ var } /postgres</string>
114+ <string>-r</string>
115+ <string>#{ var } /postgres/server.log</string>
116+ </array>
117+ <key>RunAtLoad</key>
118+ <true/>
119+ <key>WorkingDirectory</key>
120+ <string>#{ HOMEBREW_PREFIX } </string>
121+ <key>StandardErrorPath</key>
122+ <string>#{ var } /postgres/server.log</string>
123+ </dict>
124+ </plist>
125+ EOS
126+ end
127+
128+ test do
129+ system "#{ bin } /initdb" , testpath /"test"
130+ end
131+ end
0 commit comments