# -*- mode: ruby -*-
# vi: set ft=ruby :

# This Vagrantfile sets up a CentOS VM, for the purpose of RPM development.

ROOT = File.expand_path(File.dirname(__FILE__) + "/..")

# 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|
  config.vm.box = "centos-6.4-x86_64"
  config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box"
  config.vm.synced_folder ROOT, "/vagrant"
  config.ssh.forward_agent = true

  config.vm.provider :vmware_fusion do |f, override|
    override.vm.box_url = "https://dl.dropbox.com/u/5721940/vagrant-boxes/vagrant-centos-6.4-x86_64-vmware_fusion.box"
  end

  pkg_cmd = %Q{
    echo "exclude = kernel*" >> /etc/yum.conf
    rpm -Uvh http://mirror.overthewire.com.au/pub/epel/6/i386/epel-release-6-8.noarch.rpm &&
    yum update -y &&
    yum install -y @development-tools fedora-packager git sudo nano &&
    yum install -y gcc gcc-c++ ccache curl-devel openssl-devel zlib-devel &&
    yum install -y ruby ruby-devel rubygems rubygem-rake httpd httpd-devel apr-devel apr-util-devel &&
    usermod -a -G mock vagrant &&
    sed -i 's/Defaults    requiretty//' /etc/sudoers &&
    sudo -u vagrant -H rpmdev-setuptree
  }
  config.vm.provision :shell, :inline => pkg_cmd
end
