Created
July 27, 2011 09:49
-
-
Save gerhard/1109029 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
def mysql_installed? | |
`which mysql_config`.length > 0 | |
end | |
class Php <Formula | |
url 'http://www.php.net/get/php-5.3.3.tar.gz/from/this/mirror' | |
homepage 'http://php.net/' | |
md5 '5adf1a537895c2ec933fddd48e78d8a2' | |
version '5.3.3' | |
# So PHP extensions don't report missing symbols | |
skip_clean 'bin' | |
depends_on 'libxml2' | |
depends_on 'jpeg' | |
depends_on 'libpng' | |
depends_on 'mcrypt' | |
depends_on 'gettext' | |
if ARGV.include? '--with-mysql' | |
depends_on 'mysql' => :recommended unless mysql_installed? | |
end | |
if ARGV.include? '--with-fpm' | |
depends_on 'libevent' | |
end | |
def options | |
[ | |
['--with-mysql', 'Build with MySQL support'], | |
['--with-fpm', 'Enable building of the fpm SAPI executable'], | |
['--with-apache', 'Build shared Apache 2.0 Handler module'] | |
] | |
end | |
def patches | |
DATA | |
end | |
def configure_args | |
args = [ | |
"--prefix=#{prefix}", | |
"--disable-debug", | |
"--disable-dependency-tracking", | |
"--with-config-file-path=#{prefix}/etc", | |
"--with-iconv-dir=/usr", | |
"--enable-exif", | |
"--enable-soap", | |
"--enable-sqlite-utf8", | |
"--enable-wddx", | |
"--enable-ftp", | |
"--enable-sockets", | |
"--enable-zip", | |
"--enable-pcntl", | |
"--enable-shmop", | |
"--enable-sysvsem", | |
"--enable-sysvshm", | |
"--enable-sysvmsg", | |
"--enable-memory-limit", | |
"--enable-mbstring", | |
"--enable-bcmath", | |
"--enable-calendar", | |
"--enable-memcache", | |
"--with-openssl=/usr", | |
"--with-zlib=/usr", | |
"--with-bz2=/usr", | |
"--with-ldap", | |
"--with-ldap-sasl=/usr", | |
"--with-xmlrpc", | |
"--with-iodbc", | |
"--with-kerberos=/usr", | |
"--with-libxml-dir=#{Formula.factory('libxml2').prefix}", | |
"--with-xsl=/usr", | |
"--with-curl=/usr", | |
"--with-gd", | |
"--enable-gd-native-ttf", | |
"--with-mcrypt=#{Formula.factory('mcrypt').prefix}", | |
"--with-jpeg-dir=#{Formula.factory('jpeg').prefix}", | |
"--with-png-dir=#{Formula.factory('libpng').prefix}", | |
"--with-gettext=#{Formula.factory('gettext').prefix}", | |
"--with-tidy", | |
"--mandir=#{man}" | |
] | |
# Bail if both php-fpm and apxs are enabled | |
# http://bugs.php.net/bug.php?id=52419 | |
if (ARGV.include? '--with-fpm') && (ARGV.include? '--with-apache') | |
onoe "You can only enable PHP FPM or Apache, not both" | |
puts "For more information:" | |
puts "http://bugs.php.net/bug.php?id=52419" | |
exit 99 | |
end | |
# Enable PHP FPM | |
if ARGV.include? '--with-fpm' | |
args.push "--enable-fpm" | |
end | |
# Build Apache module | |
if ARGV.include? '--with-apache' | |
args.push "--with-apxs2=/usr/sbin/apxs" | |
args.push "--libexecdir=#{prefix}/libexec" | |
end | |
if ARGV.include? '--with-mysql' | |
if mysql_installed? | |
args.push "--with-mysql-sock=/tmp/mysql.sock" | |
args.push "--with-mysqli=mysqlnd" | |
args.push "--with-mysql=mysqlnd" | |
args.push "--with-pdo-mysql=mysqlnd" | |
else | |
args.push "--with-mysqli=#{Formula.factory('mysql').bin}/mysql_config}" | |
args.push "--with-mysql=#{Formula.factory('mysql').prefix}" | |
args.push "--with-pdo-mysql=#{Formula.factory('mysql').prefix}" | |
end | |
end | |
return args | |
end | |
def install | |
ENV.O3 # Speed things up | |
system "./configure", *configure_args | |
if ARGV.include? '--with-apache' | |
# Use Homebrew prefix for the Apache libexec folder | |
inreplace "Makefile", | |
"INSTALL_IT = $(mkinstalldirs) '$(INSTALL_ROOT)/usr/libexec/apache2' && $(mkinstalldirs) '$(INSTALL_ROOT)/private/etc/apache2' && /usr/sbin/apxs -S LIBEXECDIR='$(INSTALL_ROOT)/usr/libexec/apache2' -S SYSCONFDIR='$(INSTALL_ROOT)/private/etc/apache2' -i -a -n php5 libs/libphp5.so", | |
"INSTALL_IT = $(mkinstalldirs) '#{prefix}/libexec/apache2' && $(mkinstalldirs) '$(INSTALL_ROOT)/private/etc/apache2' && /usr/sbin/apxs -S LIBEXECDIR='#{prefix}/libexec/apache2' -S SYSCONFDIR='$(INSTALL_ROOT)/private/etc/apache2' -i -a -n php5 libs/libphp5.so" | |
end | |
system "make" | |
system "make install" | |
system "cp ./php.ini-production #{prefix}/etc/php.ini" | |
end | |
def caveats; <<-EOS | |
For 10.5 and Apache: | |
Apache needs to run in 32-bit mode. You can either force Apache to start | |
in 32-bit mode or you can thin the Apache executable. | |
To enable PHP in Apache add the following to httpd.conf and restart Apache: | |
LoadModule php5_module #{prefix}/libexec/apache2/libphp5.so | |
The php.ini file can be found in: | |
#{prefix}/etc/php.ini | |
EOS | |
end | |
end | |
__END__ | |
diff -Naur php-5.3.2/ext/tidy/tidy.c php/ext/tidy/tidy.c | |
--- php-5.3.2/ext/tidy/tidy.c 2010-02-12 04:36:40.000000000 +1100 | |
+++ php/ext/tidy/tidy.c 2010-05-23 19:49:47.000000000 +1000 | |
@@ -22,6 +22,8 @@ | |
#include "config.h" | |
#endif | |
+#include "tidy.h" | |
+ | |
#include "php.h" | |
#include "php_tidy.h" | |
@@ -31,7 +33,6 @@ | |
#include "ext/standard/info.h" | |
#include "safe_mode.h" | |
-#include "tidy.h" | |
#include "buffio.h" | |
/* compatibility with older versions of libtidy */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "fileutils" | |
module Tty extend self | |
def blue; bold 34; end | |
def white; bold 39; end | |
def red; underline 31; end | |
def green; bold 32; end | |
def reset; escape 0; end | |
def bold n; escape "1;#{n}" end | |
def underline n; escape "4;#{n}" end | |
def escape n; "\033[#{n}m" if STDOUT.tty? end | |
end | |
class Array | |
def shell_s | |
cp = dup | |
first = cp.shift | |
cp.map{ |arg| arg.gsub " ", "\\ " }.unshift(first) * " " | |
end | |
end | |
def ohai *args | |
puts "#{Tty.blue}==>#{Tty.white} #{args.shell_s}#{Tty.reset}" | |
end | |
def warn warning | |
puts "#{Tty.red}Warning#{Tty.reset}: #{warning.chomp}" | |
end | |
def error message | |
puts "#{Tty.red}ERROR#{Tty.reset}: #{message.chomp}" | |
end | |
def abort message | |
error message | |
Kernel.exit 1 | |
end | |
def system *args | |
abort "Failed during: #{args.shell_s}" unless Kernel.system *args | |
end | |
def success message | |
puts "#{Tty.green}#{message}#{Tty.reset}" | |
end | |
def installed? bin | |
`brew list`.include?(bin) || %x{which #{bin}}.include?("/") | |
end | |
def running? app | |
%x{ps aux | grep #{app}}.split("\n").count > 1 | |
end | |
abort "brew must be installed first!" unless installed? "brew" | |
%w(git ack mongodb redis mysql postgresql tree htop parallel unrar pbzip2 pigz ec2-api-tools git-extras wget ctags tmux libffi).each do |package| | |
unless installed? package | |
ohai "Installing #{package}" | |
system "brew install #{package}" | |
end | |
end | |
if ARGV.include?("--php") && !installed?("php") | |
puts "Adding php formula to brew" | |
%x{mv #{File.expand_path(File.dirname(__FILE__) + "/php.brew.rb")} `brew --prefix`/Library/Formula/} | |
ohai "Installing php" | |
system "brew install php" | |
end | |
abort "I'm assuming you're keeping all your system config files in #{ENV['HOME']}/Dropbox/system" unless File.exists? "#{ENV['HOME']}/Dropbox/system" | |
%w(ackrc autotest chef editrc gitconfig irbrc rdebugrc oh-my-zsh rspec rvmrc screenrc zshrc ssh tmux.conf relish gitignore).each do |config| | |
original_file = "#{ENV['HOME']}/Dropbox/system/#{config}" | |
symlink = "#{ENV['HOME']}/.#{config}" | |
unless File.symlink?(symlink) | |
puts "Symlinking #{original_file} > #{symlink}" | |
FileUtils.ln_sf("#{original_file}", "#{symlink}") | |
end | |
end | |
# VIM | |
if ARGV.include? "--vim" | |
unless installed? "macvim" | |
ohai "Installing macvim" | |
system "brew install macvim" | |
end | |
if ARGV.include? "--losh" | |
# Steve Losh's config | |
vim_original = "#{ENV['HOME']}/Dropbox/system/vim" | |
vim_symlink = "#{ENV['HOME']}/.vim" | |
ohai "Setting up vim-fu" | |
FileUtils.ln_sf("#{vim_original}", "#{vim_symlink}") | |
FileUtils.ln_sf("#{vim_original}/.vimrc", "#{ENV['HOME']}/.vimrc") | |
else | |
ohai "Setting up Vim Janus" | |
vim_original = "#{ENV['HOME']}/Dropbox/system/janus" | |
vim_symlink = "#{ENV['HOME']}/.vim" | |
ohai "Setting up vim-fu" | |
FileUtils.ln_sf("#{vim_original}", "#{vim_symlink}") | |
system "cd #{ENV['HOME']}/.vim && rake --silent" | |
# vimrc = "#{ENV['HOME']}/.vimrc" | |
# system %{ | |
# if ( grep 'mapleader' #{vimrc} ); then | |
# sed -i 's/mapleader.+","/mapleader=","/g' #{vimrc} | |
# else | |
# echo '" Leader\nlet mapleader=","\n'|cat - #{vimrc} > /tmp/vimrc && mv /tmp/vimrc #{vimrc} | |
# fi | |
# } | |
# system %{ | |
# echo '" Leader\nlet mapleader=","\n'|cat - #{vimrc} > /tmp/vimrc && mv /tmp/vimrc #{vimrc} | |
# } | |
%w(vimrc.local gvimrc.local).each do |config| | |
original_file = "#{ENV['HOME']}/Dropbox/system/#{config}" | |
symlink = "#{ENV['HOME']}/.#{config}" | |
puts "Symlinking #{original_file} > #{symlink}" | |
FileUtils.ln_sf("#{original_file}", "#{symlink}") | |
end | |
end | |
end | |
# RVM with Ruby REE & 1.9.2 | |
if ARGV.include? "--rvm" | |
default_gems = %w(bundler awesome_print heroku hirb httparty map_by_method net-http-spy sketches wirble gem-release vagrant pg) | |
unless installed? "rvm" | |
puts "Installing rvm" | |
system "gem install rvm" | |
system "rvm-install" | |
end | |
unless `rvm list`.include? "ree" | |
puts "Installing REE as the default Ruby" | |
system "rvm install ree; rvm default" | |
puts "Installing bundler in the global gemset" | |
system "rvm --create ree@global; env ARCHFLAGS='-arch x86_64' rvm ree@global gem install #{default_gems}" | |
end | |
unless `rvm list`.include? "ruby-1.9.2-p180-patched" | |
puts "Installing Ruby 1.9.2-p180-patched" | |
system "rvm install 1.9.2-p180-patched" | |
puts "Installing bundler in the global gemset" | |
system "rvm --create 1.9.2-p180-patched@global; env ARCHFLAGS='-arch x86_64' rvm 1.9.2-p180-patched@global gem install #{default_gems}" | |
end | |
unless `rvm list`.include? "jruby" | |
puts "Installing jRuby" | |
system "rvm install jruby" | |
puts "Installing bundler in the global gemset" | |
system "rvm --create jruby@global; env ARCHFLAGS='-arch x86_64' rvm jruby@global gem install #{default_gems}" | |
end | |
end | |
# GOTCHAS | |
warn "Run #{Tty.white}mysql_install_db#{Tty.reset} to finish setting up MySQL" if !running?("mysql") | |
success "All set up!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment