vagrant-vbguest 0.10.1 → 0.11.0.beta0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13084bb868cab9e4f72ffe2736fc19431766c040
4
- data.tar.gz: 2c741a74f26808fe8b7982d9bbc969e155e399b0
3
+ metadata.gz: 48daaa682d1954afa47077d851e909ee59f4de16
4
+ data.tar.gz: e0463a03f2399f33f936c78a7d7a85fc28a2ea10
5
5
  SHA512:
6
- metadata.gz: 0aa5063d60c8593ebdc717f2b317c84e4a513c5c6bb5535401d98613ab58c0773f388253cd6d4e64a3da312ccd54c0441aecfd663ceb282be013f196aef9551f
7
- data.tar.gz: 05ccc67697bde6ccf34c92eed2a8d1124dc1934a026dccc0a372021ffa187494385f29f6b4e9e0c09464563d87013b5d293eaf0ca599562d1bad74b5530cc87f
6
+ metadata.gz: fa1f488dcb5c2260dfc377aa2e6b789bcdc14355d3b0a5522dee7cb75a479d7592bf05f7898e5e371629479132e3c572724760f0877586a6d7723c7a414a7c4f
7
+ data.tar.gz: 81abe6a1a27e15588257a30890bb8628480ad92306eb53c88f47b9fc0f27427d1e758ea58662a31798d3ff54af115231c75ffe602d13302aca044d3adc943a1e
data/.gitignore CHANGED
@@ -15,3 +15,6 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+
19
+ testdrive/.vagrant/
20
+ testdrive/.vagrant.d/
@@ -1,3 +1,13 @@
1
+ ## 0.11.0 (unreleased)
2
+
3
+ - Add installer for opensuse. Thanks @darnells for [GH-163]
4
+ - Add installer for fedora. Thanks @jamesgecko and @PatrickCoffey for [GH-158]
5
+ - Add redhat installer support for centos7. Thanks @roidelapluie for [GH-162]
6
+ - Add debian installer support for debian8. Thanks @ubermuda for [GH-171]
7
+ - Add ISO autodetection on Archlinux hosts. [GH-135]
8
+ - Add configuration options for iso upload path and mount point.
9
+ - Add a `--no-cleanup` command-line switch to make debugging a bit more convenient.
10
+
1
11
  ## 0.10.1 (2015-10-08)
2
12
 
3
13
  - Make sure our log message strings are loaded [GH-107]
data/Gemfile CHANGED
@@ -1,11 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in vagrant-vbguest.gemspec
4
- gemspec
5
-
6
3
  group :development do
7
4
  # We depend on Vagrant for development, but we don't add it as a
8
5
  # gem dependency because we expect to be installed within the
9
6
  # Vagrant environment itself using `vagrant plugin`.
10
7
  gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
11
8
  end
9
+
10
+ group :plugins do
11
+ gem "vagrant-vbguest", path: "."
12
+ end
data/Readme.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  *vagrant-vbguest* is a [Vagrant](http://vagrantup.com) plugin which automatically installs the host's VirtualBox Guest Additions on the guest system.
4
4
 
5
- [![Code Climate](https://codeclimate.com/github/dotless-de/vagrant-vbguest.png)](https://codeclimate.com/github/dotless-de/vagrant-vbguest) [![Dependency Status](https://gemnasium.com/dotless-de/vagrant-vbguest.png)](https://gemnasium.com/dotless-de/vagrant-vbguest)
5
+ [![Code Climate](https://codeclimate.com/github/dotless-de/vagrant-vbguest.png)](https://codeclimate.com/github/dotless-de/vagrant-vbguest) [![Dependency Status](https://gemnasium.com/dotless-de/vagrant-vbguest.png)](https://gemnasium.com/dotless-de/vagrant-vbguest) [![Inline docs](http://inch-ci.org/github/dotless-de/vagrant-vbguest.svg?branch=master)](http://inch-ci.org/github/dotless-de/vagrant-vbguest)
6
+
6
7
 
7
8
  ## Installation
8
9
 
@@ -59,11 +60,14 @@ end
59
60
  The `iso_path` may contain the optional placeholder `%{version}` replaced with detected VirtualBox version (e.g. `4.1.8`).
60
61
  The default URI for the actual iso download is: `http://download.virtualbox.org/virtualbox/%{version}/VBoxGuestAdditions_%{version}.iso`<br/>
61
62
  vbguest will try to autodetect the best option for your system. WTF? see below.
63
+ * `iso_upload_path` (String, default: `/tmp`): A writeable directory where to put the VBoxGuestAdditions.iso file on the guest system.
64
+ * `iso_mount_point` (String, default: `/mnt`): Where to mount the VBoxGuestAdditions.iso file on the guest system.
62
65
  * `auto_update` (Boolean, default: `true`) : Whether to check the correct additions version on each start (where start is _not_ resuming a box).
63
66
  * `auto_reboot` (Boolean, default: `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.
64
67
  * `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.
65
68
  * `no_remote` (Boolean, default: `false`) : Whether to _not_ download the iso file from a remote location. This includes any `http` location!
66
69
  * `installer` (`VagrantVbguest::Installers::Base`, optional) : Reference to a (custom) installer class
70
+ * `installer_arguments` (Array, default: `['--nox11']`) : List of additional arguments to pass to the installer. eg: `%w{--nox11 --force}` would execute `VBoxLinuxAdditions.run install --nox11 --force`
67
71
 
68
72
  #### Global Configuration
69
73
 
@@ -173,7 +177,7 @@ When everything is fine, and no update is needed, you see log like:
173
177
  When you switched off the middleware auto update, or you have a box up and running you may also run the installer manually.
174
178
 
175
179
  ```bash
176
- $ vagrant vbguest [vm-name] [--do start|rebuild|install] [--status] [-f|--force] [-b|--auto-reboot] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]
180
+ $ vagrant vbguest [vm-name] [--do start|rebuild|install] [--status] [-f|--force] [-b|--auto-reboot] [-R|--no-remote] [--iso VBoxGuestAdditions.iso] [--no-cleanup]
177
181
  ```
178
182
 
179
183
  For example, when you just updated VirtualBox on your host system, you should update the guest additions right away. However, you may need to reload the box to get the guest additions working.
@@ -205,7 +209,7 @@ You can also pass vagrant's `reload` options like:
205
209
  $ vagrant vbguest --auto-reboot --no-provision
206
210
  ```
207
211
 
208
-
212
+ When running the install step manually like this: `vagrant vbguest --do install`, adding `--no-cleanup` keeps the downloaded, uploaded files and mounted iso in their place. Happy debugging ;)
209
213
 
210
214
  ### ISO autodetection
211
215
 
@@ -262,6 +266,7 @@ end
262
266
  ## Known Issues
263
267
 
264
268
  * The installer script, which mounts and runs the GuestAdditions Installer Binary, works on Linux only. Most likely it will run on most Unix-like platforms.
265
- * The installer script requires a directory `/mnt` on the guest system
266
- * On multi vm boxes, the iso file will be downloaded for each vm
269
+ * The installer script requires a writeable upload directory on the guest system. This defaults to `/tmp` but can be overwritten with the `iso_upload_path` option.
270
+ * The installer script requires a valid mount point on the guest system. This defaults to `/mnt` but can be overwritten with the `iso_mount_point` option.
271
+ * On multi vm boxes, the iso file will be downloaded for each vm.
267
272
  * The plugin installation on Windows host systems may 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))
@@ -22,6 +22,9 @@ require 'vagrant-vbguest/installers/linux'
22
22
  require 'vagrant-vbguest/installers/debian'
23
23
  require 'vagrant-vbguest/installers/ubuntu'
24
24
  require 'vagrant-vbguest/installers/redhat'
25
+ require 'vagrant-vbguest/installers/oracle'
26
+ require 'vagrant-vbguest/installers/fedora'
27
+ require 'vagrant-vbguest/installers/opensuse'
25
28
 
26
29
  require 'vagrant-vbguest/middleware'
27
30
 
@@ -17,7 +17,15 @@ module VagrantVbguest
17
17
  :auto_reboot => false
18
18
  }
19
19
  opts = OptionParser.new do |opts|
20
- opts.banner = "Usage: vagrant vbguest [vm-name] [--do start|rebuild|install] [--status] [-f|--force] [-b|--auto-reboot] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]"
20
+ opts.banner = "Usage: vagrant vbguest [vm-name] "\
21
+ "[--do start|rebuild|install] "\
22
+ "[--status] "\
23
+ "[-f|--force] "\
24
+ "[-b|--auto-reboot] "\
25
+ "[-R|--no-remote] "\
26
+ "[--iso VBoxGuestAdditions.iso] "\
27
+ "[--no-cleanup]"
28
+
21
29
  opts.separator ""
22
30
 
23
31
  opts.on("--do COMMAND", [:start, :rebuild, :install], "Manually `start`, `rebuild` or `install` GuestAdditions.") do |command|
@@ -46,6 +54,10 @@ module VagrantVbguest
46
54
  options[:iso_path] = file_or_uri
47
55
  end
48
56
 
57
+ opts.on("--no-cleanup", "Do not run cleanup tasks after installation. (for debugging)") do
58
+ options[:no_cleanup] = true
59
+ end
60
+
49
61
  build_start_options(opts, options)
50
62
  end
51
63
 
@@ -65,7 +77,10 @@ module VagrantVbguest
65
77
 
66
78
  protected
67
79
 
68
- # Executes a command on a specific VM.
80
+ # Executes a task on a specific VM.
81
+ #
82
+ # @param vm [Vagrant::VM]
83
+ # @param options [Hash] Parsed options from the command line
69
84
  def execute_on_vm(vm, options)
70
85
  check_runable_on(vm)
71
86
 
@@ -3,7 +3,9 @@ module VagrantVbguest
3
3
  class Config <( Vagrant::VERSION < "1.1.0" ? Vagrant::Config::Base : Vagrant.plugin("2", :config) )
4
4
 
5
5
  module Attributes
6
- attr_accessor :iso_path, :auto_update, :auto_reboot, :no_install, :no_remote, :installer, :installer_arguments
6
+ attr_accessor :auto_update, :auto_reboot, :no_install, :no_remote,
7
+ :installer, :installer_arguments,
8
+ :iso_path, :iso_upload_path, :iso_mount_point
7
9
  end
8
10
 
9
11
  class << self
@@ -40,6 +42,8 @@ module VagrantVbguest
40
42
  :installer => installer,
41
43
  :installer_arguments => installer_arguments,
42
44
  :iso_path => iso_path,
45
+ :iso_upload_path => iso_upload_path,
46
+ :iso_mount_point => iso_mount_point,
43
47
  :auto_update => auto_update,
44
48
  :auto_reboot => auto_reboot,
45
49
  :no_install => no_install,
@@ -91,9 +91,9 @@ module VagrantVbguest
91
91
  # replaces the veriosn placeholder with the additions
92
92
  # version string
93
93
  #
94
- # @param [String] A path or URL (or any other String)
94
+ # @param path [String] A path or URL (or any other String)
95
95
  #
96
- # @retrun [String] A copy of the passed string, with verision
96
+ # @return [String] A copy of the passed string, with verision
97
97
  # placeholder replaced
98
98
  def versionize(path)
99
99
  path % {:version => version}
@@ -104,7 +104,7 @@ module VagrantVbguest
104
104
  #
105
105
  # To remove the created tempfile call +cleanup+
106
106
  #
107
- # @param [String] The path or URI to download
107
+ # @param path [String] The path or URI to download
108
108
  #
109
109
  # @return [String] The path to the downloaded file
110
110
  def download(path)
@@ -25,7 +25,7 @@ module VagrantVbguest
25
25
  #
26
26
  # To remove the created tempfile call +cleanup+
27
27
  #
28
- # @param [String] The path or URI to download
28
+ # @param path [String] The path or URI to download
29
29
  #
30
30
  # @return [String] The path to the downloaded file
31
31
  def download(path)
@@ -70,7 +70,10 @@ module VagrantVbguest
70
70
  # Makes an educated guess where the GuestAdditions iso file
71
71
  # on linux based systems
72
72
  def linux_path
73
- paths = ["/usr/share/virtualbox/VBoxGuestAdditions.iso"]
73
+ paths = [
74
+ "/usr/share/virtualbox/VBoxGuestAdditions.iso",
75
+ "/usr/lib/virtualbox/additions/VBoxGuestAdditions.iso"
76
+ ]
74
77
  paths.unshift(File.join(ENV['HOME'], '.VirtualBox', "VBoxGuestAdditions_#{version}.iso")) if ENV['HOME']
75
78
  paths
76
79
  end
@@ -26,8 +26,8 @@ module VagrantVbguest
26
26
  # specific version of a distribution should use heigher
27
27
  # priority numbers.
28
28
  #
29
- # @param [Class] installer_class A reference to the Installer class.
30
- # @param [Fixnum] prio Priority describing how specific the Installer matches. (default: `5`)
29
+ # @param installer_class [Class] A reference to the Installer class.
30
+ # @param prio [Fixnum] Priority describing how specific the Installer matches. (default: `5`)
31
31
  def register(installer_class, prio = 5)
32
32
  @installers ||= {}
33
33
  @installers[prio] ||= []
@@ -35,8 +35,11 @@ module VagrantVbguest
35
35
  end
36
36
 
37
37
  ##
38
- # Returns the class of the registrated Installer class which
38
+ # Returns the class of the registered Installer class which
39
39
  # matches first (according to it's priority) or `nil` if none matches.
40
+ #
41
+ # @param vm [Vagrant::VM]
42
+ # @param options [Hash]
40
43
  def detect(vm, options)
41
44
  @installers.keys.sort.reverse.each do |prio|
42
45
  klass = @installers[prio].detect { |k| k.match?(vm) }
@@ -19,7 +19,7 @@ module VagrantVbguest
19
19
  # is run. It is ignored, when passing an Installer class
20
20
  # directly as an config (`installer`) option.
21
21
  #
22
- # @param [Vagrant::VM]
22
+ # @param vm [Vagrant::VM]
23
23
  # @return [Boolean]
24
24
  def self.match?(vm)
25
25
  false
@@ -57,7 +57,7 @@ module VagrantVbguest
57
57
  # The path to the local iso file should be obtained by calling +iso_file+
58
58
  # Subclasses must override this method!
59
59
  #
60
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
60
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
61
61
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
62
62
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
63
63
  # @yieldparam [String] data Data for the given output.
@@ -74,7 +74,7 @@ module VagrantVbguest
74
74
  # empty.
75
75
  # Subclasses should override this method.
76
76
  #
77
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
77
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
78
78
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
79
79
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
80
80
  # @yieldparam [String] data Data for the given output.
@@ -90,7 +90,7 @@ module VagrantVbguest
90
90
  # this method should left empty.
91
91
  # Subclasses should override this method.
92
92
  #
93
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
93
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
94
94
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
95
95
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
96
96
  # @yieldparam [String] data Data for the given output.
@@ -113,7 +113,7 @@ module VagrantVbguest
113
113
  # Determinates the GuestAdditions version installed on the
114
114
  # guest system.
115
115
  #
116
- # @param [Boolean] reload Whether to read the value again or use
116
+ # @param reload [Boolean] Whether to read the value again or use
117
117
  # the cached value form an erlier call.
118
118
  # @return [String] The version code of the VirtualBox Guest Additions
119
119
  # available on the guest, or `nil` if none installed.
@@ -145,7 +145,7 @@ module VagrantVbguest
145
145
  # The message includes the host and installer version strings.
146
146
  def yield_installation_waring(path_to_installer)
147
147
  @env.ui.warn I18n.t("vagrant_vbguest.installing#{@options[:force] ? '_forced' : ''}",
148
- :guest_version => guest_version,
148
+ :guest_version => (guest_version || I18n.t("vagrant_vbguest.unknown")),
149
149
  :installer_version => installer_version(path_to_installer) || I18n.t("vagrant_vbguest.unknown"))
150
150
  end
151
151
 
@@ -181,7 +181,7 @@ module VagrantVbguest
181
181
  # @example Default upload
182
182
  # upload(file)
183
183
  #
184
- # @param [String] Path of the file to upload to the +tmp_path*
184
+ # @param file [String] Path of the file to upload to the +tmp_path*
185
185
  def upload(file)
186
186
  env.ui.info(I18n.t("vagrant_vbguest.start_copy_iso", :from => file, :to => tmp_path))
187
187
  communicate.upload(file, tmp_path)
@@ -190,9 +190,11 @@ module VagrantVbguest
190
190
  # A helper method to delete the uploaded GuestAdditions iso file
191
191
  # from the guest box
192
192
  def cleanup
193
- @host.cleanup
194
- communicate.execute("test -f #{tmp_path} && rm #{tmp_path}", :error_check => false) do |type, data|
195
- env.ui.error(data.chomp, :prefix => false)
193
+ unless options[:no_cleanup]
194
+ @host.cleanup
195
+ communicate.execute("test -f #{tmp_path} && rm #{tmp_path}", :error_check => false) do |type, data|
196
+ env.ui.error(data.chomp, :prefix => false)
197
+ end
196
198
  end
197
199
  end
198
200
 
@@ -3,12 +3,12 @@ module VagrantVbguest
3
3
  class Debian < Linux
4
4
 
5
5
  def self.match?(vm)
6
- :debian == self.distro(vm)
6
+ /\Adebian\d*\Z/ =~ self.distro(vm)
7
7
  end
8
8
 
9
9
  # installes the correct linux-headers package
10
10
  # installes `dkms` package for dynamic kernel module loading
11
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
11
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
12
12
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
13
13
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
14
14
  # @yieldparam [String] data Data for the given output.
@@ -0,0 +1,28 @@
1
+ module VagrantVbguest
2
+ module Installers
3
+ class Fedora < Linux
4
+
5
+ def self.match?(vm)
6
+ :fedora == self.distro(vm)
7
+ end
8
+
9
+ # Install missing deps and yield up to regular linux installation
10
+ def install(opts=nil, &block)
11
+ communicate.sudo(install_dependencies_cmd, opts, &block)
12
+ super
13
+ end
14
+
15
+ protected
16
+
17
+ def install_dependencies_cmd
18
+ "`which dnf || which yum` install -y #{dependencies}"
19
+ end
20
+
21
+ def dependencies
22
+ packages = ['kernel-devel-`uname -r`', 'gcc', 'dkms', 'make', 'perl', 'bzip2']
23
+ packages.join ' '
24
+ end
25
+ end
26
+ end
27
+ end
28
+ VagrantVbguest::Installer.register(VagrantVbguest::Installers::Fedora, 5)
@@ -27,31 +27,37 @@ module VagrantVbguest
27
27
  communicate_to(vm).test("uname | grep 'Linux'")
28
28
  end
29
29
 
30
- # defaults the temp path to "/tmp/VBoxGuestAdditions.iso" for all Linux based systems
30
+ # The temporary path where to upload the iso file to.
31
+ # Configurable via `config.vbguest.iso_upload_path`.
32
+ # Defaults the temp path to `/tmp/VBoxGuestAdditions.iso" for
33
+ # all Linux based systems
31
34
  def tmp_path
32
- '/tmp/VBoxGuestAdditions.iso'
35
+ options[:iso_upload_path] || '/tmp/VBoxGuestAdditions.iso'
33
36
  end
34
37
 
35
- # defaults the mount point to "/mnt" for all Linux based systems
38
+ # Mount point for the iso file.
39
+ # Configurable via `config.vbguest.iso_mount_point`.
40
+ #Ddefaults to "/mnt" for all Linux based systems.
36
41
  def mount_point
37
- '/mnt'
42
+ options[:iso_mount_point] || '/mnt'
38
43
  end
39
44
 
40
45
  # a generic way of installing GuestAdditions assuming all
41
46
  # dependencies on the guest are installed
42
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
47
+ #
48
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
43
49
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
44
50
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
45
51
  # @yieldparam [String] data Data for the given output.
46
52
  def install(opts=nil, &block)
47
- env.ui.warn I18n.t("vagrant_vbguest.errors.installer.generic_linux_installer") if self.class == Linux
53
+ env.ui.warn I18n.t("vagrant_vbguest.errors.installer.generic_linux_installer", distro: self.class.distro(vm)) if self.class == Linux
48
54
  upload(iso_file)
49
55
  mount_iso(opts, &block)
50
56
  execute_installer(opts, &block)
51
- unmount_iso(opts, &block)
57
+ unmount_iso(opts, &block) unless options[:no_cleanup]
52
58
  end
53
59
 
54
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
60
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
55
61
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
56
62
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
57
63
  # @yieldparam [String] data Data for the given output.
@@ -84,29 +90,87 @@ module VagrantVbguest
84
90
  @guest_version
85
91
  end
86
92
 
87
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
93
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
88
94
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
89
95
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
90
96
  # @yieldparam [String] data Data for the given output.
91
97
  def rebuild(opts=nil, &block)
92
- communicate.sudo('/etc/init.d/vboxadd setup', opts, &block)
98
+ communicate.sudo("#{vboxadd_tool} setup", opts, &block)
93
99
  end
94
100
 
95
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
101
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
96
102
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
97
103
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
98
104
  # @yieldparam [String] data Data for the given output.
99
105
  def start(opts=nil, &block)
100
106
  opts = {:error_check => false}.merge(opts || {})
101
- communicate.sudo('/etc/init.d/vboxadd start', opts, &block)
107
+ systemd = systemd_tool
108
+ if systemd
109
+ communicate.sudo("#{systemd[:path]} vboxadd #{systemd[:up]}", opts, &block)
110
+ else
111
+ communicate.sudo("#{vboxadd_tool} start", opts, &block)
112
+ end
102
113
  end
103
114
 
115
+ # Check for the presence of 'systemd' chkconfg or service command.
116
+ #
117
+ # systemd_tool # => {:path=>"/usr/sbin/service", :up=>"start"}
118
+ #
119
+ # @return [Hash|nil] Hash with an absolute +path+ to the tool and the
120
+ # command string for starting.
121
+ # +nil* if neither was found.
122
+ def systemd_tool
123
+ result = nil
124
+ communicate.sudo('(which chkconfg || which service) 2>/dev/null', {:error_check => false}) do |type, data|
125
+ path = data.to_s
126
+ case path
127
+ when /\bservice\b/
128
+ result = { path: path, up: "start" }
129
+ when /\chkconfg\b/
130
+ result = { path: path, up: "on" }
131
+ end
132
+ end
133
+ result
134
+ end
135
+
136
+ # Checks for the correct location of the 'vboxadd' tool.
137
+ # It checks for a given list of possible locations. This list got
138
+ # extracted from the 'VBoxLinuxAdditions.run' script.
139
+ #
140
+ # @return [String|nil] Absolute path to the +vboxadd+ tool,
141
+ # or +nil+ if none found.
142
+ def vboxadd_tool
143
+ candidates = [
144
+ "/usr/lib/i386-linux-gnu/VBoxGuestAdditions/vboxadd",
145
+ "/usr/lib/x86_64-linux-gnu/VBoxGuestAdditions/vboxadd",
146
+ "/usr/lib64/VBoxGuestAdditions/vboxadd",
147
+ "/usr/lib/VBoxGuestAdditions/vboxadd",
148
+ "/lib64/VBoxGuestAdditions/vboxadd",
149
+ "/lib/VBoxGuestAdditions/vboxadd",
150
+ "/etc/init.d/vboxadd",
151
+ ]
152
+ bin_path = ""
153
+ cmd = <<-SHELL
154
+ for c in #{candidates.join(" ")}; do
155
+ if test -x "$c"; then
156
+ echo $c
157
+ break
158
+ fi
159
+ done
160
+ SHELL
161
+
162
+ path = nil
163
+ communicate.sudo(cmd, {:error_check => false}) do |type, data|
164
+ path = data.strip unless data.empty?
165
+ end
166
+ path
167
+ end
104
168
 
105
169
  # A generic helper method to execute the installer.
106
170
  # This also yields a installation warning to the user, and an error
107
171
  # warning in the event that the installer returns a non-zero exit status.
108
172
  #
109
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
173
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
110
174
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
111
175
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
112
176
  # @yieldparam [String] data Data for the given output.
@@ -133,7 +197,7 @@ module VagrantVbguest
133
197
  # on most linux system.
134
198
  # Mounts the given uploaded file from +tmp_path+ on +mount_point+.
135
199
  #
136
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
200
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
137
201
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
138
202
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
139
203
  # @yieldparam [String] data Data for the given output.
@@ -145,7 +209,7 @@ module VagrantVbguest
145
209
  # on most linux system
146
210
  # Unmounts the +mount_point+.
147
211
  #
148
- # @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
212
+ # @param opts [Hash] Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
149
213
  # @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
150
214
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
151
215
  # @yieldparam [String] data Data for the given output.
@@ -0,0 +1,32 @@
1
+ module VagrantVbguest
2
+ module Installers
3
+ class OpenSuse < Linux
4
+ # OpenSuse shows up as "suse", check for presence of the zypper
5
+ # package manager as well.
6
+ def self.match?(vm)
7
+ :suse == self.distro(vm) && has_zypper?(vm)
8
+ end
9
+
10
+ # Install missing deps and yield up to regular linux installation
11
+ def install(opts=nil, &block)
12
+ communicate.sudo(install_dependencies_cmd, opts, &block)
13
+ super
14
+ end
15
+
16
+ protected
17
+ def self.has_zypper?(vm)
18
+ communicate_to(vm).test "which zypper"
19
+ end
20
+
21
+ def install_dependencies_cmd
22
+ "zypper --non-interactive install #{dependencies}"
23
+ end
24
+
25
+ def dependencies
26
+ packages = ['kernel-devel', 'gcc', 'make', 'tar']
27
+ packages.join ' '
28
+ end
29
+ end
30
+ end
31
+ end
32
+ VagrantVbguest::Installer.register(VagrantVbguest::Installers::OpenSuse, 5)
@@ -0,0 +1,19 @@
1
+ module VagrantVbguest
2
+ module Installers
3
+ class Oracle < RedHat
4
+
5
+ def self.match?(vm)
6
+ :redhat == self.distro(vm) &&
7
+ communicate_to(vm).test('test -f /etc/oracle-release')
8
+ end
9
+
10
+ protected
11
+
12
+ def dependencies
13
+ packages = ['kernel-uek-devel-`uname -r`', 'gcc', 'make', 'perl', 'bzip2']
14
+ packages.join ' '
15
+ end
16
+ end
17
+ end
18
+ end
19
+ VagrantVbguest::Installer.register(VagrantVbguest::Installers::Oracle, 6)
@@ -1,11 +1,11 @@
1
1
  module VagrantVbguest
2
2
  module Installers
3
3
  class RedHat < Linux
4
- # Scientific Linux (and probably CentOS) both show up as :redhat
4
+ # Scientific Linux and CentOS show up as :redhat (or "centos7")
5
5
  # fortunately they're probably both similar enough to RHEL
6
6
  # (RedHat Enterprise Linux) not to matter.
7
7
  def self.match?(vm)
8
- :redhat == self.distro(vm)
8
+ /\A(redhat|centos)\d*\Z/ =~ self.distro(vm)
9
9
  end
10
10
 
11
11
  # Install missing deps and yield up to regular linux installation
@@ -1,3 +1,3 @@
1
1
  module VagrantVbguest
2
- VERSION = "0.10.1"
2
+ VERSION = "0.11.0.beta0"
3
3
  end
@@ -52,7 +52,7 @@ en:
52
52
  no_installer_for_platform: |-
53
53
  Sorry, don't know how to %{method} Virtualbox Guest Additions on this platform. Stopping installation.
54
54
  generic_linux_installer: |-
55
- The guest's platform is currently not supported, will try generic Linux method...
55
+ The guest's platform ("%{distro}") is currently not supported, will try generic Linux method...
56
56
  do_not_inherit_match_method: |-
57
57
  Installer classes must provide their own `match?` method.
58
58
 
@@ -0,0 +1,76 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ require 'ipaddr'
5
+
6
+ class NextIP
7
+ def initialize(start_ip)
8
+ @ip_addr = IPAddr.new start_ip
9
+ end
10
+
11
+ def get
12
+ @ip_addr = @ip_addr.succ
13
+ @ip_addr
14
+ end
15
+
16
+ def box vagrant_config, name, box, &block
17
+ ip_addr = get
18
+
19
+ vagrant_config.vm.define name do |config|
20
+ config.vm.box = box
21
+ config.vm.hostname = name
22
+ config.vm.network :private_network, ip: ip_addr.to_s
23
+
24
+ config.vm.provider "virtualbox" do |vb, override|
25
+ # Display the VirtualBox GUI when booting the machine
26
+ vb.gui = false
27
+
28
+ # Customize the amount of memory on the VM:
29
+ vb.memory = "512"
30
+ vb.cpus = "4"
31
+
32
+ # Specify default provider configuration
33
+ # - give the VM a name - can be better localized in the VirtualBox GUI
34
+ # - make the DNS resolution faster
35
+ vb.customize [
36
+ "modifyvm", :id,
37
+ "--name", "vbguest_testdrive-#{name}",
38
+ "--natdnshostresolver1", "on",
39
+ "--natdnshostresolver2", "on"
40
+ ]
41
+ end
42
+
43
+ yield(config) if block
44
+ end
45
+ end
46
+ end
47
+
48
+ Vagrant.configure("2") do |config|
49
+ next_ip = NextIP.new("44.44.0.10/24")
50
+
51
+ next_ip.box config, "debian8", "oar-team/debian8"
52
+ next_ip.box config, "opensuse13", "bento/opensuse-13.2"
53
+ next_ip.box config, "ubuntu1404", "ubuntu/trusty64"
54
+ next_ip.box config, "centos7", "centos/7"
55
+ next_ip.box config, "oracle65", "tobyhferguson_oracle-65-x64" do |cfg|
56
+ cfg.vm.box_url = "http://tobyhferguson.org/boxes/oracle-6-5-x64-virtualbox.box"
57
+ end
58
+ next_ip.box config, "fedora22", "Fedora-Cloud-Base-Virtualbox-22" do |cfg|
59
+ cfg.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-22-20150521.x86_64.vagrant-virtualbox.box"
60
+ end
61
+
62
+ config.vm.provider "virtualbox" do |v|
63
+ # v.gui = true
64
+ end
65
+
66
+ # config.vbguest.installer_arguments = "--nox11 -- --force"
67
+ # config.vbguest.auto_update = false
68
+ # config.vbguest.iso_path = '/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso'
69
+ # config.vbguest.iso_path = 'http://download.virtualbox.org/virtualbox/%{version}/VBoxGuestAdditions_%{version}.iso' #% {version: '4.2.12'}
70
+ # config.vbguest.iso_path = "#{ENV["HOME"]}/Downloads/VBoxGuestAdditions_4.2.12.iso"
71
+ # config.vbguest.installer = My_Installer
72
+
73
+ # require 'Date'
74
+ # config.vm.provision :shell, :inline => "touch /vagrant/testrun-#{DateTime.now.strftime '%FT%T.%S%L'}"
75
+
76
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ TESTDRIVE=${VAGRANT_DEV:-$(dirname "$(cd "$(dirname "$0")" && pwd)")}
3
+
4
+ VAGRANT_DEFAULT_PROVIDER=virtualbox \
5
+ VAGRANT_HOME=${TESTDRIVE}/.vagrant.d \
6
+ bundle exec vagrant $@
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vbguest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0.beta0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Schulze
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-08 00:00:00.000000000 Z
11
+ date: 2015-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: micromachine
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.2.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: i18n
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: log4r
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: A Vagrant plugin which automatically installs the host's VirtualBox Guest
@@ -88,7 +88,7 @@ executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
- - ".gitignore"
91
+ - .gitignore
92
92
  - CHANGELOG.md
93
93
  - Gemfile
94
94
  - LICENSE
@@ -105,7 +105,10 @@ files:
105
105
  - lib/vagrant-vbguest/installer.rb
106
106
  - lib/vagrant-vbguest/installers/base.rb
107
107
  - lib/vagrant-vbguest/installers/debian.rb
108
+ - lib/vagrant-vbguest/installers/fedora.rb
108
109
  - lib/vagrant-vbguest/installers/linux.rb
110
+ - lib/vagrant-vbguest/installers/opensuse.rb
111
+ - lib/vagrant-vbguest/installers/oracle.rb
109
112
  - lib/vagrant-vbguest/installers/redhat.rb
110
113
  - lib/vagrant-vbguest/installers/ubuntu.rb
111
114
  - lib/vagrant-vbguest/machine.rb
@@ -131,6 +134,8 @@ files:
131
134
  - lib/vagrant-vbguest/version.rb
132
135
  - lib/vagrant_init.rb
133
136
  - locales/en.yml
137
+ - testdrive/Vagrantfile
138
+ - testdrive/bin/vagrant
134
139
  - vagrant-vbguest.gemspec
135
140
  homepage: https://github.com/dotless-de/vagrant-vbguest
136
141
  licenses:
@@ -142,17 +147,17 @@ require_paths:
142
147
  - lib
143
148
  required_ruby_version: !ruby/object:Gem::Requirement
144
149
  requirements:
145
- - - ">="
150
+ - - '>='
146
151
  - !ruby/object:Gem::Version
147
152
  version: '0'
148
153
  required_rubygems_version: !ruby/object:Gem::Requirement
149
154
  requirements:
150
- - - ">="
155
+ - - '>='
151
156
  - !ruby/object:Gem::Version
152
157
  version: 1.3.6
153
158
  requirements: []
154
159
  rubyforge_project:
155
- rubygems_version: 2.4.5.1
160
+ rubygems_version: 2.0.14
156
161
  signing_key:
157
162
  specification_version: 4
158
163
  summary: A Vagrant plugin to install the VirtualBoxAdditions into the guest VM