From a4a0034b29a7c6490b42900d568ef487377ad875 Mon Sep 17 00:00:00 2001 From: George Brocklehurst Date: Wed, 16 Jan 2013 23:05:58 +0100 Subject: [PATCH] Add Vagrant configuration. capybara-webkit has various development dependencies which can be a little cumbersome to manage. With vagrant they can all be nicely bundled up in a VM and installed automatically. --- .gitignore | 1 + CONTRIBUTING.md | 17 +++++++++++--- Vagrantfile | 7 ++++++ vagrant_setup.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 Vagrantfile create mode 100644 vagrant_setup.sh diff --git a/.gitignore b/.gitignore index ca52833..6a783f8 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ tmp .rvmrc src/debug webkit_server.pro.user +.vagrant diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index da49fa1..976c18e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,13 +1,24 @@ We love pull requests. Here's a quick guide: -Dependencies +## Dependencies Some of the tests depend on the `identify` command that comes with Imagemagick. -Imagemagick can be installed via [homebrew](http://mxcl.github.com/homebrew/). +Imagemagick can be installed via [homebrew](http://mxcl.github.com/homebrew/) on +Mac OS X: brew install imagemagick -Contributing +If you prefer, you can use a [Vagrant](http://www.vagrantup.com/) virtual +machine. The Vagrantfile in the capybara-webkit repository will get you up and +running with all the development dependencies: + + gem install vagrant + vagrant up + vagrant ssh + cd /vagrant + rake + +## Contributing 1. Fork the repo. diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..e01d4e8 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,7 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant::Config.run do |config| + config.vm.box = "precise32" + config.vm.provision :shell, :path => 'vagrant_setup.sh' +end diff --git a/vagrant_setup.sh b/vagrant_setup.sh new file mode 100644 index 0000000..1dc51f5 --- /dev/null +++ b/vagrant_setup.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +export DISPLAY=:99 + +apt-get -y update +apt-get -y install ruby1.9.1-dev + +if [ -z `which make` ]; then apt-get -y install build-essential; fi +if [ -z `which qmake` ]; then apt-get -y install libqt4-dev libicu48; fi +if [ -z `which git` ]; then apt-get -y install git-core; fi +if [ -z `which xml2-config` ]; then apt-get -y install libxml2-dev; fi +if [ -z `which xslt-config` ]; then apt-get -y install libxslt-dev; fi +if [ -z `which convert` ]; then apt-get -y install imagemagick; fi +if [ -z `which firefox` ]; then apt-get -y install firefox; fi + +if [ -z `which bundle` ]; +then + gem install bundler + cd /vagrant + bundle +fi + +if [ ! -f /etc/init.d/xvfb ]; +then + apt-get -y install xvfb + echo "export DISPLAY=${DISPLAY}" >> /home/vagrant/.bashrc + tee /etc/init.d/xvfb <<-EOF + #!/bin/bash + + XVFB=/usr/bin/Xvfb + XVFBARGS="\$DISPLAY -ac -screen 0 1024x768x16" + PIDFILE=\${HOME}/xvfb_\${DISPLAY:1}.pid + case "\$1" in + start) + echo -n "Starting virtual X frame buffer: Xvfb" + /sbin/start-stop-daemon --start --quiet --pidfile \$PIDFILE --make-pidfile --background --exec \$XVFB -- \$XVFBARGS + echo "." + ;; + stop) + echo -n "Stopping virtual X frame buffer: Xvfb" + /sbin/start-stop-daemon --stop --quiet --pidfile \$PIDFILE + echo "." + ;; + restart) + \$0 stop + \$0 start + ;; + *) + echo "Usage: /etc/init.d/xvfb {start|stop|restart}" + exit 1 + esac + exit 0 +EOF + + chmod +x /etc/init.d/xvfb +fi + +/etc/init.d/xvfb start