Skip to content

Instantly share code, notes, and snippets.

@slumos
Created September 18, 2009 18:22
Show Gist options
  • Save slumos/189209 to your computer and use it in GitHub Desktop.
Save slumos/189209 to your computer and use it in GitHub Desktop.
#!/bin/sh
export BUILD_ROOT=`pwd`/build
mkdir -p $BUILD_ROOT
export RUBY_VERSION=ruby-1.9.1-p243
export NGINX_VERSION=nginx-0.7.62
export PREFIX=/opt/ruby19
export PATH=$PREFIX/bin:$PATH
# ruby
export CFLAGS='-march=nocona -O3 -pipe -fomit-frame-pointer'
cd $BUILD_ROOT
if [ ! -f $RUBY_VERSION.tar.gz ]; then
echo 'Ruby tarball not found, downloading...'
curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.9/$RUBY_VERSION.tar.gz
fi
tar xzf $RUBY_VERSION.tar.gz
if [ ! -d $RUBY_VERSION ]; then
echo "Whoops, couldn't find the ruby source directory!"; exit 1
fi
cd $RUBY_VERSION
# lib/tempfile.rb bug patch in order to fix rack/passenger compat
cat <<END_DIFF > lib_tempfile_rb.patch
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 4d3a2f0..6c710d5 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -137,7 +137,6 @@ class Tempfile < DelegateClass(File)
# keep this order for thread safeness
begin
if File.exist?(@tmpname)
- closed? or close
File.unlink(@tmpname)
end
@@cleanlist.delete(@tmpname)
END_DIFF
patch -p1 < lib_tempfile_rb.patch
mkdir -p $PREFIX
if ! (./configure --prefix=$PREFIX && make && make install); then
echo 'Error compiling ruby!'; exit 2
fi
# gems
if ! (echo `gem sources` | grep -c github); then
echo 'http://gems.github.com added as a gem source.'
gem sources -a http://gems.github.com
fi
gem update --system && \
gem install mysql --no-rdoc --no-ri -- --with-mysql-config=`/usr/bin/which mysql_config || /usr/bin/which mysql_config5` && \
gem install ruby-debug19 --no-rdoc --no-ri && \
gem install hpricot --no-rdoc --no-ri && \
gem install json --no-rdoc --no-ri && \
#gem install unicorn --no-rdoc --no-ri && \
#gem install thin --no-rdoc --no-ri && \
gem install passenger --no-rdoc --no-ri
# end ruby
# nginx w/ passenger
cd $BUILD_ROOT
if [ ! -f $NGINX_VERSION.tar.gz ]; then
echo 'Nginx tarball not found, downloading...'
curl -O http://sysoev.ru/nginx/$NGINX_VERSION.tar.gz
fi
tar xzf $NGINX_VERSION.tar.gz
if [ ! -d $NGINX_VERSION ]; then
echo "Whoops, couldn't find the nginx source directory!"; exit 1
fi
mkdir -p $PREFIX
export NGINX_PREFIX=$PREFIX
export NGINX_CONFIGURE_ARGS="--pid-path=log/nginx.pid --lock-path=log/nginx.lock --error-log-path=log/nginx-error.log --http-log-path=log/nginx-access.log --without-http_memcached_module --without-http_fastcgi_module --without-http_proxy_module --without-http_autoindex_module --without-http_empty_gif_module"
export PASSENGER_INSTALLER_ARGS="--auto --prefix=$NGINX_PREFIX --nginx-source-dir=$BUILD_ROOT/$NGINX_VERSION"
if ! (passenger-install-nginx-module $PASSENGER_INSTALLER_ARGS --extra-configure-flags="$NGINX_CONFIGURE_ARGS"); then
echo 'Error compiling nginx!'; exit 2
fi
# end nginx w/ passenger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment