Last active
August 29, 2015 14:17
-
-
Save jerrykan/1737fca39ee0124ef8af to your computer and use it in GitHub Desktop.
Vagrantfile for running roundup tests
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
$script = <<SCRIPT | |
## init the environment | |
echo "deb http://http.debian.net/debian squeeze main" > /etc/apt/sources.list.d/squeeze.list | |
# Set MySQL root password | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password password ""' | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password ""' | |
# set up local environment customisations | |
# (eg. local debian mirror, web proxies, pypi mirror, etc.) | |
test -f /vagrant/vagrant.env && source /vagrant/vagrant.env | |
# Update/Upgrade packages | |
apt-get update | |
apt-get upgrade -q -y | |
# Install required packages | |
apt-get install -q -y \ | |
python2.5 python2.5-dev \ | |
python2.6 python2.6-dev \ | |
python2.7 python2.7-dev \ | |
python-virtualenv \ | |
mysql-server libmysqlclient-dev \ | |
postgresql libpq-dev \ | |
uuid-dev \ | |
libgpgme11-dev swig \ | |
git | |
# set up mysql database | |
mysql --defaults-file=/etc/mysql/debian.cnf -e 'CREATE DATABASE rounduptest;' | |
mysql --defaults-file=/etc/mysql/debian.cnf -e 'GRANT ALL ON rounduptest.* TO rounduptest@localhost IDENTIFIED BY "rounduptest";' | |
# set up postgresql database | |
sed -i "s/^\\(local\\s\\+all\\s\\+postgres\\s\\+\\)peer/\\1trust/" /etc/postgresql/9.1/main/pg_hba.conf | |
/etc/init.d/postgresql restart | |
psql -c "CREATE ROLE rounduptest WITH CREATEDB LOGIN PASSWORD 'rounduptest';" -U postgres | |
# Install external dependencies | |
cd /usr/local/src | |
wget -q http://oligarchy.co.uk/xapian/1.2.8/xapian-core-1.2.8.tar.gz | |
wget -q http://oligarchy.co.uk/xapian/1.2.8/xapian-bindings-1.2.8.tar.gz | |
tar -zxf xapian-core-1.2.8.tar.gz | |
tar -zxf xapian-bindings-1.2.8.tar.gz | |
# Set up virtual envs | |
for PY in 2.{5..7}; do | |
virtualenv -p python${PY} /opt/venv${PY} | |
source /opt/venv${PY}/bin/activate | |
cd /usr/local/src/xapian-core-1.2.8/ | |
./configure --prefix=$VIRTUAL_ENV && make && make install | |
cd /usr/local/src/xapian-bindings-1.2.8/ | |
./configure --prefix=$VIRTUAL_ENV --with-python && make && make install | |
pip install MySQL-python psycopg2 | |
if [ $PY != "2.5" ]; then | |
# broken for 2.5 | |
pip install git+https://bitbucket.org/malb/pyme.git@459f3eca65#egg=pyme | |
fi | |
deactivate | |
done | |
chown -R vagrant:vagrant /opt/venv2.* | |
# setup some aliases | |
cat <<EOT >> /home/vagrant/.bashrc | |
alias runtests="cd /vagrant/; python run_tests.py --dir /vagrant/./test" | |
alias v25="source /opt/venv2.5/bin/activate; cd /vagrant/" | |
alias v26="source /opt/venv2.6/bin/activate; cd /vagrant/" | |
alias v27="source /opt/venv2.7/bin/activate; cd /vagrant/" | |
EOT | |
SCRIPT | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. | |
config.vm.box = 'debian-wheezy-64' | |
config.vm.box_url = 'http://basebox.libera.cc/debian-wheezy-64.box' | |
config.vm.box_download_checksum = 'http://basebox.libera.cc/MD5SUM' | |
config.vm.box_download_checksum_type = 'md5' | |
config.vm.host_name = 'roundup.example.com' | |
config.vm.provision "shell", inline: $script | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment