Project

General

Profile

Misc #10757 ยป vagrant.patch

anthonycrumley (Anthony Crumley), 01/18/2015 03:43 AM

View differences:

.gitignore
22 22
.pc
23 23
.ppack
24 24
.svn
25
.vagrant
25 26
Makefile
26 27
Makefile.old
27 28
extconf.h
Vagrantfile
1
# -*- mode: ruby -*-
2
# vi: set ft=ruby :
3

  
4
# Vagrant configuration for an MRI Ruby contributor environment.
5
Vagrant.configure(2) do |config|
6
  config.vm.box = "hashicorp/precise64"
7

  
8
  # Create a private network, which allows host-only access to the machine
9
  # using a specific IP.
10
  config.vm.network "private_network", ip: "192.168.33.10"
11

  
12
  # Maps the /vagrant VM folder to the Ruby source folder.  NFS is used for 
13
  # better performance and may require configuration on the host machine.
14
  config.vm.synced_folder '.', '/vagrant', nfs: true
15

  
16
  # Configure the virtual machine with enough access to processors and memory
17
  # that it will not be sluggish.
18
  config.vm.provider "virtualbox" do |v|
19
    host = RbConfig::CONFIG['host_os']
20

  
21
    # Give VM 1/4 system memory & access to all cpu cores on the host
22
    if host =~ /darwin/
23
      cpus = `sysctl -n hw.ncpu`.to_i
24
      # sysctl returns Bytes and we need to convert to MB
25
      mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
26
    elsif host =~ /linux/
27
      cpus = `nproc`.to_i
28
      # meminfo shows KB and we need to convert to MB
29
      mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
30
    else # sorry Windows folks, I can't help you
31
      cpus = 2
32
      mem = 1024
33
    end
34

  
35
    v.customize ["modifyvm", :id, "--memory", mem]
36
    v.customize ["modifyvm", :id, "--cpus", cpus]
37
  end
38

  
39
  # Provision the Ruby development environment with a shell script.
40
  config.vm.provision "shell", inline: <<-SHELL
41
    # The following allows openssl to be upgraded unattended.
42
    unset UCF_FORCE_CONFFOLD
43
    export UCF_FORCE_CONFFNEW=YES
44
    ucf --purge /boot/grub/menu.lst
45
    export DEBIAN_FRONTEND=noninteractive
46

  
47
    apt-get update
48
    # Upgrade openssl unattended.
49
    apt-get -o Dpkg::Options::="--force-confnew" --force-yes -fuy upgrade openssl
50
    apt-get install -y git
51
    apt-get install -y autoconf
52
    apt-get install -y make
53
    apt-get install -y bison
54
    apt-get install -y gdb
55
    aptitude build-dep -y ruby1.9.1
56
    su - vagrant -c "mkdir ~/build"
57
    su - vagrant -c "cd /vagrant && autoconf"
58
    su - vagrant -c "cd ~/build && /vagrant/configure"
59
  SHELL
60

  
61
  # Usage instructions that will be displayed whenever 'vagrant up' completes.
62
  config.vm.post_up_message = <<-USAGE_INSTRUCTIONS
63
  To access the MRI Ruby development virtual machine:
64

  
65
    $ vagrant ssh
66
    vagrant@precise64:~$
67

  
68
  To build ruby:
69

  
70
    vagrant@precise64:~$ cd ~/build
71
    vagrant@precise64:~$ make
72

  
73
  To run MRI tests:
74

  
75
    vagrant@precise64:~$ cd ~/build
76
    vagrant@precise64:~$ make test-all
77

  
78
  To update RubySpec tests:
79

  
80
    vagrant@precise64:~$ cd ~/build
81
    vagrant@precise64:~$ make update-rubyspec
82
     
83
  To run RubySpec tests:
84

  
85
    vagrant@precise64:~$ cd ~/build
86
    vagrant@precise64:~$ make test-rubyspec
87

  
88
  USAGE_INSTRUCTIONS
89
end
vagrant.md
1
# Ruby Contributor Vagrant Guide
2

  
3
The following instructions will help you quickly get an MRI Ruby development environment ready for contributing in short order.
4

  
5
### Getting Started
6

  
7
1. Install Git: http://git-scm.com/downloads (or [GitHub for Windows](http://windows.github.com/) if you want a GUI)
8
2. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads
9
3. Install Vagrant: http://www.vagrantup.com/
10
4. Open a terminal
11
5. Clone the project: `git clone https://github.com/ruby/ruby.git`
12
6. Enter the project directory: `cd ruby`
13

  
14
### Setting Up Vagrant
15

  
16
Build the Vagrant development environment by entering the following command:
17
```
18
vagrant up
19
```
20

  
21
The first time this command is ran will take a while because the VM image will need to download.
22

  
23
Follow the directions at the end of the installation to begin contributing.