Class: Vigil::VMBuilder
- Inherits:
-
Object
- Object
- Vigil::VMBuilder
- Defined in:
- lib/vigil/vmbuilder.rb
Instance Method Summary collapse
- #_build_basebox ⇒ Object
- #_build_complete_box ⇒ Object
- #_build_no_gems_box ⇒ Object
- #_build_vm ⇒ Object
- #_changes_relative_to_previous_revision_in?(files) ⇒ Boolean
- #_setup_basebox ⇒ Object
- #_setup_complete_box ⇒ Object
- #_setup_iso_cache ⇒ Object
- #_setup_no_gems_box ⇒ Object
- #_use_old_box(box) ⇒ Object
-
#initialize(revision) ⇒ VMBuilder
constructor
A new instance of VMBuilder.
- #run ⇒ Object
Constructor Details
Instance Method Details
#_build_basebox ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/vigil/vmbuilder.rb', line 42 def _build_basebox _setup_iso_cache Vagrant.run "basebox build --force --nogui '#{@revision.project_name}'" Vagrant.run "basebox validate '#{@revision.project_name}'" Vagrant.run "basebox export '#{@revision.project_name}'" @x._system "mv #{@revision.project_name}.box #{@revision.base_box_path}" Vagrant.run "basebox destroy #{@revision.project_name}" end |
#_build_complete_box ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/vigil/vmbuilder.rb', line 83 def _build_complete_box Vagrant.run "box add --force '#{@revision.no_gems_box_name}' '#{@revision.no_gems_box_path}'" Vagrant.use @revision.no_gems_box_name Vagrant.run "up" Vagrant.run "ssh -c 'sudo gem install bundler'" Vagrant.run "ssh -c 'cd /vagrant/; bundle install'" Vagrant.run "package --output #{@revision.complete_box_path}" Vagrant.run "box remove '#{@revision.no_gems_box_name}'" end |
#_build_no_gems_box ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/vigil/vmbuilder.rb', line 66 def _build_no_gems_box Vagrant.run "box add --force '#{@revision.base_box_name}' '#{@revision.base_box_path}'" Vagrant.use @revision.base_box_name Vagrant.run "up" Vagrant.run "package --output #{@revision.no_gems_box_path}" Vagrant.run "box remove #{@revision.base_box_name}" end |
#_build_vm ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/vigil/vmbuilder.rb', line 22 def _build_vm _setup_basebox @plugman.notify(:task_done, 'VM1') _setup_no_gems_box @plugman.notify(:task_done, 'VM2') _setup_complete_box @plugman.notify(:task_done, 'VM3') @rebuild = false end |
#_changes_relative_to_previous_revision_in?(files) ⇒ Boolean
97 98 99 |
# File 'lib/vigil/vmbuilder.rb', line 97 def _changes_relative_to_previous_revision_in?(files) Git.differs?(@previous_revision.sha, files) end |
#_setup_basebox ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/vigil/vmbuilder.rb', line 32 def _setup_basebox return if @x.exists? @revision.base_box_path if @x.exists?(@previous_revision.base_box_path) and !_changes_relative_to_previous_revision_in?('definitions') _use_old_box(:base_box_path) else _build_basebox @rebuild = true end end |
#_setup_complete_box ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/vigil/vmbuilder.rb', line 74 def _setup_complete_box if @rebuild or !@x.exists?(@previous_revision.complete_box_path) or _changes_relative_to_previous_revision_in?('Gemfile*') _build_complete_box else _use_old_box :complete_box_path end end |
#_setup_iso_cache ⇒ Object
51 52 53 |
# File 'lib/vigil/vmbuilder.rb', line 51 def _setup_iso_cache @x._system "ln -sf #{File.join(Vigil.run_dir, 'iso')}" end |
#_setup_no_gems_box ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/vigil/vmbuilder.rb', line 55 def _setup_no_gems_box return if @x.exists?(@revision.no_gems_box_path) if @rebuild or !@x.exists?(@previous_revision.no_gems_box_path) or _changes_relative_to_previous_revision_in?('manifests') _build_no_gems_box @rebuild = true else _use_old_box :no_gems_box_path end end |
#_use_old_box(box) ⇒ Object
93 94 95 |
# File 'lib/vigil/vmbuilder.rb', line 93 def _use_old_box(box) @x.ln @previous_revision.send(box), @revision.send(box) end |
#run ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/vigil/vmbuilder.rb', line 12 def run if @x.exists?(@revision.complete_box_path) @plugman.notify(:task_done, 'VM1') @plugman.notify(:task_done, 'VM2') @plugman.notify(:task_done, 'VM3') return end _build_vm end |