vagrant-vbguest 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,63 @@
1
+ ## 0.5.0 (2012-11-19)
2
+
3
+ - Box will be rebooted if the GuestAdditions installation
4
+ process does not load the kernel module [GH-25], [GH-24]
5
+ - Adds this Changelog
6
+
7
+ ## 0.4.0 (2012-10-21)
8
+
9
+ - Add global configuration options [GH-22]
10
+ - Add `iso_path` option `:auto` to rest a previously
11
+ configured path [GH-22]
12
+
13
+ ## 0.3.5
14
+
15
+ - Fix iso detection for windows hosts [GH-20]
16
+
17
+ ## 0.3.4
18
+
19
+ - Fix installer shell script invocation [GH-18]
20
+
21
+ ## 0.3.3
22
+
23
+ - Add Fedora to the list of supported plattforms [GH-17]
24
+ - Add system package update (`apt-get update`) to the
25
+ debian installer if package installation fails [GH-16]
26
+ - Drop dependency on `vagrant` gem [GH-15]
27
+
28
+ ## 0.3.2
29
+
30
+ - Stop GuestAdditions installation and fail with an error
31
+ when installation of dependency packes fails [GH-13]
32
+
33
+ ## 0.3.1
34
+
35
+ - Ruby 1.8.7 compatibility [GH-12]
36
+
37
+ ## 0.3.0
38
+
39
+ - Removed dependency to the `virtualbox` gem by using
40
+ `vagrant`s vm driver [GH-8]
41
+
42
+ ## 0.2.1
43
+
44
+ - Typo fixes in readme and internal renamings. [GH-9], [GH-7]
45
+
46
+ ## 0.2.0
47
+
48
+ - Makes a guess on where to look for a `VBoxGuestAdditions.iso` file
49
+ based on the host system (when VirtualBox does not tell). [GH-6]
50
+ - Adds command line options `--no-install`, `--no-remote`, `--iso`
51
+ - Requires vagrant v0.9.4 or later
52
+
53
+ ## 0.1.1
54
+
55
+ - Fix vagrant 0.9.4 compatibility [GH-4]
56
+
57
+ ## 0.1.0
58
+
59
+ - Vagrant 0.9 compatibility (drops 0.8 support) [GH-3]
60
+
61
+ ## Previous (≤ 0.0.3)
62
+
63
+ - Vagrant 0.8 support
data/Readme.md CHANGED
@@ -49,6 +49,7 @@ The `iso_path` may contain the optional placeholder `$VBOX_VERSION` for the dete
49
49
  The URI for the actual iso download reads: `http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso`<br/>
50
50
  vbguest will try to autodetect the best option for your system. WTF? see below.
51
51
  * `auto_update` (Boolean, default: `true`) : Whether to check the correct additions version on each start (where start is _not_ resuming a box).
52
+ * `auto_reboot` (Boolean, dafult: `true` when running as a middleware, `false` when running as a command) : Whether to reboot the box after GuestAdditions has been installed, but not loaded.
52
53
  * `no_install` (Boolean, default: `false`) : Whether to check the correct additions version only. This will warn you about version mis-matches, but will not try to install anything.
53
54
  * `no_remote` (Boolean, default: `false`) : Whether to _not_ download the iso file from a remote location. This includes any `http` location!
54
55
 
@@ -131,7 +132,7 @@ When everything is fine, and no update is needed, you see log like:
131
132
  When you switched off the middleware auto update, or you have a box up and running you may also run the installer manually.
132
133
 
133
134
  ```bash
134
- $ vagrant vbguest [vm-name] [-f|--force] [-I|--no-install] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]
135
+ $ vagrant vbguest [vm-name] [-f|--force] [--auto-reboot] [-I|--no-install] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]
135
136
  ```
136
137
 
137
138
  For example, when you just updated Virtual Box on your host system, you should update the gust additions right away. However, you may need to reload the box to get the guest additions working.
@@ -150,6 +151,14 @@ or a match:
150
151
 
151
152
  [default] Detected Virtualbox Guest Additions 4.1.14 --- OK
152
153
 
154
+
155
+ The `auto-reboot` is tured off by default, when running as a command. Vbguest will suggest you to reboot the box when needed. To turn it on simply pass the `--auto-reboot` parameter:
156
+
157
+ ```bash
158
+ $ vagrant vbguest --auto-reboot
159
+ ```
160
+
161
+
153
162
  ### ISO autodetection
154
163
 
155
164
  *vagrant-vbguest* will try to autodetect a VirtualBox GuestAdditions iso file on your system, which usually matches your installed version of VirtualBox. If it cannot find one, it downloads one from the web (virtualbox.org).
@@ -162,9 +171,16 @@ Those places will be checked in order:
162
171
  * for Windows : `%PROGRAMFILES%/Oracle/VirtualBox/VBoxGuestAdditions.iso`
163
172
 
164
173
 
174
+ ### Automatic reboot
175
+
176
+ The VirtualBox GuestAdditions Installer will try to load the newly build kernel module. However the installer my fail to do, just as it is happening when updating GuestAdditions from version 4.1 to 4.2.
177
+
178
+ Hency, vbguest will check for a loaded kernel module after the installation has finished and reboots the box, if it could not find one.
179
+
180
+
165
181
  ## Knows Issues
166
182
 
167
183
  * The installer script, which mounts and runs the GuestAdditions Installer Binary, works on linux only. Most likely it will run on most unix-like plattform.
168
184
  * The installer script requires a directory `/mnt` on the guest system
169
185
  * On multi vm boxes, the iso file will be downloaded for each vm
170
- * The plugin installation on Windows host systems my not work as expected (using `vagrant gem install vagrant-vbguest`). Try `C:\vagrant\vagrant\embedded\bin\gem.bat install vagrant-vbguest` instead. (See issue #5)
186
+ * The plugin installation on Windows host systems my not work as expected (using `vagrant gem install vagrant-vbguest`). Try `C:\vagrant\vagrant\embedded\bin\gem.bat install vagrant-vbguest` instead. (See [issue #19](https://github.com/dotless-de/vagrant-vbguest/issues/19#issuecomment-7040304))
@@ -1,7 +1,7 @@
1
1
  require 'vagrant'
2
2
  require "vagrant-vbguest/errors"
3
3
  require "vagrant-vbguest/config"
4
- require "vagrant-vbguest/detector"
4
+ require "vagrant-vbguest/helpers"
5
5
  require "vagrant-vbguest/download"
6
6
  require "vagrant-vbguest/installer"
7
7
  require 'vagrant-vbguest/command'
@@ -7,15 +7,21 @@ module VagrantVbguest
7
7
  # Runs the vbguest installer on the VMs that are represented
8
8
  # by this environment.
9
9
  def execute
10
- options = {}
10
+ options = {
11
+ :auto_reboot => false
12
+ }
11
13
  opts = OptionParser.new do |opts|
12
- opts.banner = "Usage: vagrant vbguest [vm-name] [-f|--force] [-I|--no-install] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]"
14
+ opts.banner = "Usage: vagrant vbguest [vm-name] [-f|--force] [--auto-reboot] [-I|--no-install] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]"
13
15
  opts.separator ""
14
16
 
15
17
  opts.on("-f", "--force", "Whether to force the installation") do
16
18
  options[:force] = true
17
19
  end
18
20
 
21
+ opts.on("--auto-reboot", "Reboot VM after installation") do
22
+ options[:auto_reboot] = true
23
+ end
24
+
19
25
  opts.on("--no-install", "-I", "Only check for the installed version. Do not attempt to install anything") do
20
26
  options[:no_install] = true
21
27
  end
@@ -3,13 +3,14 @@ module VagrantVbguest
3
3
  class Config < Vagrant::Config::Base
4
4
 
5
5
  module Attributes
6
- attr_accessor :iso_path, :auto_update, :no_install, :no_remote
6
+ attr_accessor :iso_path, :auto_update, :auto_reboot, :no_install, :no_remote
7
7
  end
8
8
 
9
9
  class << self
10
10
  include Attributes
11
11
 
12
12
  def auto_update; @auto_update.nil? ? true : @auto_update end
13
+ def auto_reboot; @auto_reboot.nil? ? true : @auto_reboot end
13
14
  def no_install; @no_install.nil? ? false : @no_install end
14
15
  def no_remote; @no_remote.nil? ? false : @no_remote end
15
16
 
@@ -22,6 +23,7 @@ module VagrantVbguest
22
23
  include Attributes
23
24
 
24
25
  def auto_update; @auto_update.nil? ? self.class.auto_update : @auto_update end
26
+ def auto_reboot; @auto_reboot.nil? ? self.class.auto_reboot : @auto_reboot end
25
27
  def no_install; @no_install.nil? ? self.class.no_install : @no_install end
26
28
  def no_remote; @no_remote.nil? ? self.class.no_remote : @no_remote end
27
29
 
@@ -35,6 +37,7 @@ module VagrantVbguest
35
37
  {
36
38
  :iso_path => iso_path,
37
39
  :auto_update => auto_update,
40
+ :auto_reboot => auto_reboot,
38
41
  :no_install => no_install,
39
42
  :no_remote => no_remote
40
43
  }
@@ -1,29 +1,23 @@
1
1
  module VagrantVbguest
2
+ module Helpers
3
+ class << self
2
4
 
3
- class Detector
4
-
5
- def initialize(vm, options)
6
- @vm = vm
7
- @options = options
8
- end
9
-
10
- def iso_path
11
- @iso_path ||= autodetect_iso
12
- end
13
-
14
- private
5
+ def local_iso_path_for(vm, options = nil)
6
+ options ||= {}
7
+ @local_iso_paths ||= Hash.new
8
+ @local_iso_paths[vm.uuid] ||= media_manager_iso(vm) || guess_iso(vm)
9
+ end
15
10
 
16
- def autodetect_iso
17
- path = media_manager_iso || guess_iso || web_iso
18
- raise VagrantVbguest::IsoPathAutodetectionError if !path || path.empty?
19
- path
11
+ def web_iso_path_for(vm, options = nil)
12
+ options ||= {}
13
+ "http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso"
20
14
  end
21
15
 
22
- def media_manager_iso
23
- (m = @vm.driver.execute('list', 'dvds').match(/^.+:\s+(.*VBoxGuestAdditions.iso)$/i)) && m[1]
16
+ def media_manager_iso(vm)
17
+ (m = vm.driver.execute('list', 'dvds').match(/^.+:\s+(.*VBoxGuestAdditions.iso)$/i)) && m[1]
24
18
  end
25
19
 
26
- def guess_iso
20
+ def guess_iso(vm)
27
21
  path_platform = if Vagrant::Util::Platform.linux?
28
22
  "/usr/share/virtualbox/VBoxGuestAdditions.iso"
29
23
  elsif Vagrant::Util::Platform.darwin?
@@ -38,9 +32,10 @@ module VagrantVbguest
38
32
  File.exists?(path_platform) ? path_platform : nil
39
33
  end
40
34
 
41
- def web_iso
42
- "http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso" unless @options[:no_remote]
35
+ def kernel_module_running?(vm, &block)
36
+ vm.channel.test('lsmod | grep vboxsf', :sudo => true, &block)
43
37
  end
44
38
 
39
+ end
45
40
  end
46
41
  end
@@ -3,6 +3,7 @@ module VagrantVbguest
3
3
  # Handles the guest addins installation process
4
4
 
5
5
  class Installer
6
+ @@rebooted = {}
6
7
 
7
8
  def initialize(vm, options = {})
8
9
  @env = {
@@ -31,35 +32,59 @@ module VagrantVbguest
31
32
  @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.check_failed", :host => vb_version, :guest => guest_version)) if @options[:no_install]
32
33
 
33
34
  if @options[:force] || (!@options[:no_install] && needs_update?)
34
- @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.installing#{@options[:force] ? '_forced' : ''}", :host => vb_version, :guest => guest_version))
35
+ if rebooted?
36
+ @vm.ui.error(I18n.t("vagrant.plugins.vbguest.restart_loop_guard_activated"))
37
+ else
38
+ @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.installing#{@options[:force] ? '_forced' : ''}", :host => vb_version, :guest => guest_version))
39
+ install
40
+ end
41
+ end
42
+ ensure
43
+ cleanup
44
+ end
45
+
46
+ def install
47
+ # :TODO:
48
+ # the whole installation process should be put into own classes
49
+ # like the vagrant system loading
50
+ if (i_script = installer_script)
51
+ @vm.ui.info(I18n.t("vagrant.plugins.vbguest.start_copy_iso", :from => iso_path, :to => iso_destination))
52
+ @vm.channel.upload(iso_path, iso_destination)
35
53
 
36
- # :TODO:
37
- # the whole installation process should be put into own classes
38
- # like the vagrant system loading
39
- if (i_script = installer_script)
40
- @options[:iso_path] ||= VagrantVbguest::Detector.new(@vm, @options).iso_path
54
+ @vm.ui.info(I18n.t("vagrant.plugins.vbguest.start_copy_script", :from => File.basename(i_script), :to => installer_destination))
55
+ @vm.channel.upload(i_script, installer_destination)
41
56
 
42
- @vm.ui.info(I18n.t("vagrant.plugins.vbguest.start_copy_iso", :from => iso_path, :to => iso_destination))
43
- @vm.channel.upload(iso_path, iso_destination)
57
+ @vm.channel.sudo("chmod 0755 #{installer_destination}") do |type, data|
58
+ @vm.ui.info(data, :prefix => false, :new_line => false)
59
+ end
44
60
 
45
- @vm.ui.info(I18n.t("vagrant.plugins.vbguest.start_copy_script", :from => File.basename(i_script), :to => installer_destination))
46
- @vm.channel.upload(i_script, installer_destination)
61
+ @vm.channel.sudo("#{installer_destination}") do |type, data|
62
+ @vm.ui.info(data, :prefix => false, :new_line => false)
63
+ end
47
64
 
48
- @vm.channel.sudo("chmod 0755 #{installer_destination}") do |type, data|
49
- @vm.ui.info(data, :prefix => false, :new_line => false)
50
- end
65
+ @vm.channel.execute("rm #{installer_destination} #{iso_destination}") do |type, data|
66
+ @vm.ui.error(data.chomp, :prefix => false)
67
+ end
51
68
 
52
- @vm.channel.sudo("#{installer_destination}") do |type, data|
53
- @vm.ui.info(data, :prefix => false, :new_line => false)
54
- end
69
+ cleanup
70
+ reboot
71
+ end
72
+ end
55
73
 
56
- @vm.channel.execute("rm #{installer_destination} #{iso_destination}") do |type, data|
57
- @vm.ui.error(data.chomp, :prefix => false)
58
- end
74
+ def reboot
75
+ if !VagrantVbguest::Helpers.kernel_module_running?(@vm)
76
+ if @options[:auto_reboot]
77
+ @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.restart_vm"))
78
+ @@rebooted[@vm.name] = true
79
+ @vm.reload(@options[:run_env])
80
+ else
81
+ @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.suggest_restart", :name => @vm.name))
59
82
  end
60
83
  end
61
- ensure
62
- cleanup
84
+ end
85
+
86
+ def rebooted?
87
+ !!@@rebooted[@vm.name]
63
88
  end
64
89
 
65
90
  def needs_update?
@@ -99,6 +124,11 @@ module VagrantVbguest
99
124
 
100
125
  def iso_path
101
126
  @iso_path ||= begin
127
+ @options[:iso_path] ||= VagrantVbguest::Helpers.local_iso_path_for @vm, @options
128
+ if !@options[:iso_path] || @options[:iso_path].empty? && !@options[:no_remote]
129
+ @options[:iso_path] = VagrantVbguest::Helpers.web_iso_path_for @vm, @options
130
+ end
131
+ raise VagrantVbguest::IsoPathAutodetectionError if !@options[:iso_path] || @options[:iso_path].empty?
102
132
  @env[:iso_url] ||= @options[:iso_path].gsub '$VBOX_VERSION', vb_version
103
133
 
104
134
  if local_iso?
@@ -13,9 +13,11 @@ module VagrantVbguest
13
13
 
14
14
  def call(env)
15
15
  options = @vm.config.vbguest.to_hash
16
+ options[:run_env] = env
16
17
  VagrantVbguest::Installer.new(@vm, options).run
18
+
17
19
  @app.call(env)
18
20
  end
19
- end
20
21
 
22
+ end
21
23
  end
@@ -1,3 +1,3 @@
1
1
  module VagrantVbguest
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/locales/en.yml CHANGED
@@ -8,6 +8,9 @@ en:
8
8
  installing_forced: "Forcing installation of Virtualbox Guest Additions %{host} - guest's version is %{guest}"
9
9
  start_copy_iso: "Copy iso file %{from} into the box %{to}"
10
10
  start_copy_script: "Copy installer file %{from} into the box %{to}"
11
+ restart_vm: "Restarting VM to apply changes..."
12
+ suggest_restart: "Guest Additions got installed. However, they seem not be loaded correctly. Please restart the box runing `vagrant reload %{name}`"
13
+ restart_loop_guard_activated: "Guest Additions will not load, even after reboot."
11
14
  no_install_script_for_platform: "Sorry, don't know how to install on a %{platform} system. Stopping installation."
12
15
  generic_install_script_for_platform: "%{platform} is currently not supported, will try generic Linux method..."
13
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vbguest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-21 00:00:00.000000000 Z
12
+ date: 2012-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -36,6 +36,7 @@ extensions: []
36
36
  extra_rdoc_files: []
37
37
  files:
38
38
  - .gitignore
39
+ - CHANGELOG.md
39
40
  - Gemfile
40
41
  - LICENSE
41
42
  - Rakefile
@@ -45,9 +46,9 @@ files:
45
46
  - lib/vagrant-vbguest.rb
46
47
  - lib/vagrant-vbguest/command.rb
47
48
  - lib/vagrant-vbguest/config.rb
48
- - lib/vagrant-vbguest/detector.rb
49
49
  - lib/vagrant-vbguest/download.rb
50
50
  - lib/vagrant-vbguest/errors.rb
51
+ - lib/vagrant-vbguest/helpers.rb
51
52
  - lib/vagrant-vbguest/installer.rb
52
53
  - lib/vagrant-vbguest/middleware.rb
53
54
  - lib/vagrant-vbguest/version.rb