require 'formula' class Pgbouncer < Formula homepage 'http://wiki.postgresql.org/wiki/PgBouncer' url 'http://pgfoundry.org/frs/download.php/3369/pgbouncer-1.5.3.tar.gz' sha1 '2811d32d39cb87a64e278d985178258072c5c8ef' depends_on 'asciidoc' => :build depends_on 'xmlto' => :build depends_on 'libevent' def install ENV['XML_CATALOG_FILES'] = "#{etc}/xml/catalog" system "./configure", "--disable-debug", "--with-libevent=#{HOMEBREW_PREFIX}", "--prefix=#{prefix}" ln_s "../install-sh", "doc/install-sh" system "make install" bin.install "etc/mkauth.py" etc.install %w(etc/pgbouncer.ini etc/userlist.txt) end def caveats s = <<-EOS The config file: #{etc}/pgbouncer.ini is in the "ini" format and you will need to edit it for your particular setup. See: http://pgbouncer.projects.postgresql.org/doc/config.html The auth_file option should point to the #{etc}/userlist.txt file which can be populated by the #{bin}/mkauth.py script. If this is your first install, automatically load on login with: mkdir -p ~/Library/LaunchAgents cp #{plist_path} ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename} If this is an upgrade and you already have the #{plist_path.basename} loaded: launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename} cp #{plist_path} ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename} Or start manually with: pgbouncer -q #{etc}/pgbouncer.ini EOS end def startup_plist return <<-EOPLIST KeepAlive Label #{plist_name} ProgramArguments #{HOMEBREW_PREFIX}/bin/pgbouncer -d -q #{etc}/pgbouncer.ini RunAtLoad UserName #{`whoami`.chomp} WorkingDirectory #{HOMEBREW_PREFIX} EOPLIST end end