Project

General

Profile

Misc #10757 ยป vagrant_v2.patch

anthonycrumley (Anthony Crumley), 01/20/2015 03:59 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

  
38
    # Fix problem with time on VM getting out of sync with host.
39
    v.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000 ]
40
  end
41

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

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

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

  
68
    $ vagrant ssh
69
    vagrant@precise64:~$
70

  
71
  To build ruby:
72

  
73
    vagrant@precise64:~$ cd ~/build
74
    vagrant@precise64:~$ make
75

  
76
  To run MRI tests:
77

  
78
    vagrant@precise64:~$ cd ~/build
79
    vagrant@precise64:~$ make test-all
80

  
81
  To update RubySpec tests:
82

  
83
    vagrant@precise64:~$ cd ~/build
84
    vagrant@precise64:~$ make update-rubyspec
85
     
86
  To run RubySpec tests:
87

  
88
    vagrant@precise64:~$ cd ~/build
89
    vagrant@precise64:~$ make test-rubyspec
90

  
91
  USAGE_INSTRUCTIONS
92
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.