vagrant-vbguest 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Readme.md +40 -8
- data/lib/vagrant-vbguest.rb +1 -0
- data/lib/vagrant-vbguest/command.rb +16 -3
- data/lib/vagrant-vbguest/config.rb +33 -10
- data/lib/vagrant-vbguest/download.rb +83 -0
- data/lib/vagrant-vbguest/installer.rb +37 -11
- data/lib/vagrant-vbguest/version.rb +1 -1
- data/locales/en.yml +15 -3
- data/vagrant-vbguest.gemspec +1 -1
- metadata +11 -10
data/Readme.md
CHANGED
@@ -4,31 +4,63 @@
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
Requires vagrant 0.9.
|
7
|
+
Requires vagrant 0.9.4 or later
|
8
8
|
|
9
9
|
gem install vagrant-vbguest
|
10
10
|
|
11
|
-
|
11
|
+
or, using vagrant's gem wrapper
|
12
|
+
|
13
|
+
vagrant gem install vagrant-vbguest
|
14
|
+
|
15
|
+
Compatibly for vagrant 0.8 is provided by version 0.0.3 (which lacks a bunch of new options)
|
12
16
|
|
13
17
|
## Configuration / Usage
|
14
18
|
|
15
|
-
|
19
|
+
If you're lucky, `vagrant-vbguest` does not require any configurations.
|
20
|
+
Hoever, here is an example for your `Vagrantfile`:
|
16
21
|
|
17
22
|
Vagrant::Config.run do |config|
|
18
23
|
# we will try to autodetect this path.
|
19
|
-
# However, if we cannot or you have a special one you may pass it
|
20
|
-
config.vbguest.iso_path = '/
|
24
|
+
# However, if we cannot or you have a special one you may pass it like:
|
25
|
+
# config.vbguest.iso_path = "#{ENV['HOME']}/Downloads/VBoxGuestAdditions.iso"
|
26
|
+
# or
|
27
|
+
# config.vbguest.iso_path = "http://company.server/VirtualBox/$VBOX_VERSION/VBoxGuestAdditions.iso"
|
21
28
|
|
22
29
|
# set auto_update to false, if do NOT want to check the correct additions
|
23
|
-
# version
|
30
|
+
# version when booting this machine
|
24
31
|
config.vbguest.auto_update = false
|
32
|
+
|
33
|
+
# do NOT download the iso file from a webserver
|
34
|
+
config.vbguest.no_remote = true
|
25
35
|
end
|
26
36
|
|
37
|
+
### Config options
|
38
|
+
|
39
|
+
* `iso_path` : The full path or URL to the VBoxGuestAdditions.iso file. <br/>
|
40
|
+
The `iso_path` may contain the optional placeholder `$VBOX_VERSION` for the detected version (e.g. `4.1.8`).
|
41
|
+
The URI for the actual iso download reads: `http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso`<br/>
|
42
|
+
vbguest will try to autodetect the best option for your system. WTF? see below.
|
43
|
+
* `auto_update` (Boolean, dafault: `true`) : Whether to check the correct additions version on each start (where start is _not_ resuming a box).
|
44
|
+
* `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.
|
45
|
+
* `no_remote` (Boolean, default: `false`) : Whether to _not_ download the iso file from a remote location. This includes any `http` location!
|
46
|
+
|
47
|
+
### ISO autodetection
|
48
|
+
|
49
|
+
`vagrant-vbguest` will try to autodetect a VirtualBox GuestAdditions iso file on your system, which usually matches your installed version of VirtualBox.
|
50
|
+
If it cannot find one, it downloads one from the web (virtualbox.org). Those places will be checked in order:
|
51
|
+
|
52
|
+
1. Checks your VirualBox "Virtual Media Maganger" for a DVD called "VBoxGuestAdditions.iso"
|
53
|
+
2. Guess by your operating system:
|
54
|
+
* for linux : `/usr/share/virtualbox/VBoxGuestAdditions.iso`
|
55
|
+
* for Mac : `/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso`
|
56
|
+
* for Windows : `%PROGRAMFILES%/Oracle/VirtualBox/VBoxGuestAdditions.iso`
|
57
|
+
|
27
58
|
You may also run the installer manually:
|
28
59
|
|
29
|
-
$ vagrant vbguest [vm-name] [-f|--force]
|
60
|
+
$ vagrant vbguest [vm-name] [-f|--force] [-I|--no-install] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]
|
30
61
|
|
31
62
|
## Knows Issues
|
32
63
|
|
33
64
|
* 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.
|
34
|
-
* The installer script requires a directory `/mnt` on the host system
|
65
|
+
* The installer script requires a directory `/mnt` on the host system
|
66
|
+
* On multi vm boxes, the iso file will be downloaded for each vm
|
data/lib/vagrant-vbguest.rb
CHANGED
@@ -9,11 +9,24 @@ module VagrantVbguest
|
|
9
9
|
def execute
|
10
10
|
options = {}
|
11
11
|
opts = OptionParser.new do |opts|
|
12
|
-
opts.
|
12
|
+
puts opts.inspect
|
13
|
+
opts.banner = "Usage: vagrant vbguest [vm-name] [-f|--force] [-I|--no-install] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]"
|
13
14
|
opts.separator ""
|
14
15
|
|
15
|
-
opts.on("-f", "--force", "Whether to force the installation") do
|
16
|
-
options[:force] =
|
16
|
+
opts.on("-f", "--force", "Whether to force the installation") do
|
17
|
+
options[:force] = true
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on("--no-install", "-I", "Only check for the installed version. Do not attempt to install anything") do
|
21
|
+
options[:no_install] = true
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on("--no-remote", "-R", "Do not attempt do download the iso file from a webserver") do
|
25
|
+
options[:no_remote] = true
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("--iso file_or_uri", "Full path or URI to the VBoxGuestAdditions.iso") do |file_or_uri|
|
29
|
+
options[:iso_path] = file_or_uri
|
17
30
|
end
|
18
31
|
end
|
19
32
|
|
@@ -5,32 +5,55 @@ module VagrantVbguest
|
|
5
5
|
class Config < Vagrant::Config::Base
|
6
6
|
attr_accessor :iso_path
|
7
7
|
attr_accessor :auto_update
|
8
|
+
attr_accessor :no_install
|
9
|
+
attr_accessor :no_remote
|
8
10
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def iso_path; @iso_path ||= autodetect_iso; end
|
12
|
+
def auto_update; @auto_update.nil? ? (@auto_update = true) : @auto_update; end
|
13
|
+
def no_remote; @no_remote.nil? ? (@no_remote = false) : @no_remote; end
|
14
|
+
def no_install; @no_install.nil? ? (@no_install = false): @no_install; end
|
15
|
+
|
15
16
|
def validate(env, errors)
|
16
|
-
errors.add(I18n.t("vagrant.plugins.vbguest.missing_iso_path")) unless iso_path && iso_path.is_a?(String)
|
17
|
+
errors.add(I18n.t("vagrant.plugins.vbguest.missing_iso_path")) unless iso_path && iso_path.is_a?(String)
|
17
18
|
end
|
18
19
|
|
19
20
|
# explicit hash, to get symbols in hash keys
|
20
21
|
def to_hash
|
21
22
|
{
|
22
23
|
:iso_path => iso_path,
|
23
|
-
:auto_update => auto_update
|
24
|
+
:auto_update => auto_update,
|
25
|
+
:no_install => no_install,
|
26
|
+
:no_remote => no_remote
|
24
27
|
}
|
25
28
|
end
|
26
29
|
|
27
30
|
protected
|
28
31
|
|
29
|
-
def autodetect_iso
|
32
|
+
def autodetect_iso
|
33
|
+
media_magager_iso || guess_iso || web_iso
|
34
|
+
end
|
35
|
+
|
36
|
+
def media_magager_iso
|
30
37
|
dvd = VirtualBox::DVD.all.find do |d|
|
31
38
|
!!(d.location =~ /VBoxGuestAdditions.iso$/)
|
32
39
|
end
|
33
|
-
|
40
|
+
dvd ? dvd.location : nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def guess_iso
|
44
|
+
guess_path = if Vagrant::Util::Platform.linux?
|
45
|
+
"/usr/share/virtualbox/VBoxGuestAdditions.iso"
|
46
|
+
elsif Vagrant::Util::Platform.darwin?
|
47
|
+
"/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso"
|
48
|
+
elsif Vagrant::Util::Platform.windows?
|
49
|
+
File.join((ENV["PROGRAM_FILES"] || ENV["PROGRAMFILES"]), "/Oracle/VirtualBox/VBoxGuestAdditions.iso")
|
50
|
+
end
|
51
|
+
File.exists?(guess_path) ? guess_path : nil
|
34
52
|
end
|
53
|
+
|
54
|
+
def web_iso
|
55
|
+
"http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso" unless !no_remote
|
56
|
+
end
|
57
|
+
|
35
58
|
end
|
36
59
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module VagrantVbguest
|
2
|
+
|
3
|
+
# This implementation is based on Action::Box::Download by vagrant
|
4
|
+
#
|
5
|
+
# This adoption does not run as a action/middleware, but is called manually
|
6
|
+
#
|
7
|
+
# MIT License - Mitchell Hashimoto and John Bender - https://github.com/mitchellh/vagrant
|
8
|
+
#
|
9
|
+
#
|
10
|
+
#
|
11
|
+
class Download
|
12
|
+
|
13
|
+
BASENAME = "vbguest"
|
14
|
+
|
15
|
+
include Vagrant::Util
|
16
|
+
|
17
|
+
attr_reader :temp_path
|
18
|
+
|
19
|
+
def initialize(env)
|
20
|
+
@env = env
|
21
|
+
@env["download.classes"] ||= []
|
22
|
+
@env["download.classes"] += [Vagrant::Downloaders::HTTP, Vagrant::Downloaders::File]
|
23
|
+
@downloader = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def instantiate_downloader
|
27
|
+
# Assign to a temporary variable since this is easier to type out,
|
28
|
+
# since it is used so many times.
|
29
|
+
classes = @env["download.classes"]
|
30
|
+
|
31
|
+
# Find the class to use.
|
32
|
+
classes.each_index do |i|
|
33
|
+
klass = classes[i]
|
34
|
+
|
35
|
+
# Use the class if it matches the given URI or if this
|
36
|
+
# is the last class...
|
37
|
+
if classes.length == (i + 1) || klass.match?(@env[:iso_url])
|
38
|
+
@env[:ui].info I18n.t("vagrant.plugins.vbguest.download.with", :class => klass.to_s)
|
39
|
+
@downloader = klass.new(@env[:ui])
|
40
|
+
break
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# This line should never be reached, but we'll keep this here
|
45
|
+
# just in case for now.
|
46
|
+
raise Errors::BoxDownloadUnknownType if !@downloader
|
47
|
+
|
48
|
+
@downloader.prepare(@env[:iso_url])
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
def download
|
53
|
+
if instantiate_downloader
|
54
|
+
with_tempfile do |tempfile|
|
55
|
+
download_to(tempfile)
|
56
|
+
@temp_path = @env["download.temp_path"] = tempfile.path
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def cleanup
|
62
|
+
if temp_path && File.exist?(temp_path)
|
63
|
+
@env[:ui].info I18n.t("vagrant.plugins.vbguest.download.cleaning")
|
64
|
+
File.unlink(temp_path)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def with_tempfile
|
69
|
+
File.open(iso_temp_path, Platform.tar_file_options) do |tempfile|
|
70
|
+
yield tempfile
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def iso_temp_path
|
75
|
+
@env[:tmp_path].join(BASENAME + Time.now.to_i.to_s)
|
76
|
+
end
|
77
|
+
|
78
|
+
def download_to(f)
|
79
|
+
@downloader.download!(@env[:iso_url], f)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -5,8 +5,13 @@ module VagrantVbguest
|
|
5
5
|
class Installer
|
6
6
|
|
7
7
|
def initialize(vm, options = {})
|
8
|
+
@env = {
|
9
|
+
:ui => vm.ui,
|
10
|
+
:tmp_path => vm.env.tmp_path
|
11
|
+
}
|
8
12
|
@vm = vm
|
9
13
|
@options = options
|
14
|
+
@iso_path = nil
|
10
15
|
end
|
11
16
|
|
12
17
|
def run!
|
@@ -20,15 +25,17 @@ module VagrantVbguest
|
|
20
25
|
raise Vagrant::Errors::VMNotRunningError if @vm.state != :running
|
21
26
|
|
22
27
|
if @options[:auto_update]
|
28
|
+
|
23
29
|
@vm.ui.success(I18n.t("vagrant.plugins.vbguest.guest_ok", :version => guest_version)) unless needs_update?
|
30
|
+
@vm.ui.warn(I18n.t("vagrant.plugins.vbguest.check_failed", :host => vb_version, :guest => guest_version)) if @options[:no_install]
|
24
31
|
|
25
|
-
if @options[:force] || needs_update?
|
32
|
+
if @options[:force] || (!@options[:no_install] && needs_update?)
|
26
33
|
@vm.ui.warn(I18n.t("vagrant.plugins.vbguest.installing#{@options[:force] ? '_forced' : ''}", :host => vb_version, :guest => guest_version))
|
27
34
|
|
28
35
|
# :TODO:
|
29
36
|
# the whole installation process should be put into own classes
|
30
37
|
# like the vagrant system loading
|
31
|
-
if i_script = installer_script
|
38
|
+
if (i_script = installer_script)
|
32
39
|
@vm.ui.info(I18n.t("vagrant.plugins.vbguest.start_copy_iso", :from => iso_path, :to => iso_destination))
|
33
40
|
@vm.channel.upload(iso_path, iso_destination)
|
34
41
|
|
@@ -52,8 +59,9 @@ module VagrantVbguest
|
|
52
59
|
$stdout.puts
|
53
60
|
end
|
54
61
|
end
|
55
|
-
|
56
62
|
end
|
63
|
+
ensure
|
64
|
+
cleanup
|
57
65
|
end
|
58
66
|
|
59
67
|
def needs_update?
|
@@ -73,14 +81,14 @@ module VagrantVbguest
|
|
73
81
|
plattform = @vm.guest.distro_dispatch
|
74
82
|
case plattform
|
75
83
|
when :debian, :ubuntu
|
76
|
-
|
84
|
+
File.expand_path("../../../files/setup_debian.sh", __FILE__)
|
77
85
|
when :gentoo, :redhat, :suse, :arch, :linux
|
78
86
|
@vm.ui.warn(I18n.t("vagrant.plugins.vbguest.generic_install_script_for_plattform", :plattform => plattform.to_s))
|
79
|
-
|
87
|
+
File.expand_path("../../../files/setup_linux.sh", __FILE__)
|
88
|
+
else
|
89
|
+
@vm.ui.error(I18n.t("vagrant.plugins.vbguest.no_install_script_for_plattform", :plattform => plattform.to_s))
|
90
|
+
nil
|
80
91
|
end
|
81
|
-
@vm.ui.error(I18n.t("vagrant.plugins.vbguest.no_install_script_for_plattform", :plattform => plattform.to_s))
|
82
|
-
|
83
|
-
nil
|
84
92
|
end
|
85
93
|
|
86
94
|
def installer_destination
|
@@ -92,8 +100,26 @@ module VagrantVbguest
|
|
92
100
|
end
|
93
101
|
|
94
102
|
def iso_path
|
95
|
-
@
|
103
|
+
@iso_path ||= begin
|
104
|
+
@env[:iso_url] ||= @options[:iso_path].gsub '$VBOX_VERSION', vb_version
|
105
|
+
|
106
|
+
if local_iso?
|
107
|
+
@env[:iso_url]
|
108
|
+
else
|
109
|
+
@download = VagrantVbguest::Download.new(@env)
|
110
|
+
@download.download
|
111
|
+
@download.temp_path
|
112
|
+
end
|
113
|
+
end
|
96
114
|
end
|
97
|
-
end
|
98
115
|
|
99
|
-
|
116
|
+
def local_iso?
|
117
|
+
::File.file?(@env[:iso_url])
|
118
|
+
end
|
119
|
+
|
120
|
+
def cleanup
|
121
|
+
@download.cleanup if @download
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
data/locales/en.yml
CHANGED
@@ -3,10 +3,22 @@ en:
|
|
3
3
|
plugins:
|
4
4
|
vbguest:
|
5
5
|
guest_ok: "Detected Virtualbox Guest Additions %{version} --- OK."
|
6
|
+
check_failed: "Virtualbox Guest Additions on host: %{host} - guest's version is %{guest}"
|
6
7
|
installing: "Installing Virtualbox Guest Additions %{host} - guest's version is %{guest}"
|
7
8
|
installing_forced: "Forcing installation of Virtualbox Guest Additions %{host} - guest's version is %{guest}"
|
8
|
-
missing_iso_path: "Could not autodetect the correct location of the Virtualbox Guest Additions ISO File. Or the Path provided is not correct. \nPlease configure using `config.vbguest.iso_path`. \nOn Mac this is most likely: '/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso' "
|
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
|
-
no_install_script_for_plattform: "Sorry,
|
12
|
-
generic_install_script_for_plattform: "%{plattform} is currently not supported, but i'll try generic linux way ... "
|
11
|
+
no_install_script_for_plattform: "Sorry, don't know how to install on a %{plattform} system. Stopping installation."
|
12
|
+
generic_install_script_for_plattform: "%{plattform} is currently not supported, but i'll try generic linux way ... "
|
13
|
+
|
14
|
+
validation_errors:
|
15
|
+
missing_iso_path: |-
|
16
|
+
Could not autodetect the correct location of the Virtualbox Guest Additions
|
17
|
+
ISO File. Please correct or configure using `config.vbguest.iso_path`.
|
18
|
+
If you think this is a bug in vbguest and we could guessed the iso_path,
|
19
|
+
please file a bug: https://github.com/dotless-de/vagrant-vbguest/issues
|
20
|
+
|
21
|
+
download:
|
22
|
+
with: "Downloading VirtualBox Guest Additions ISO with %{class}..."
|
23
|
+
cleaning: "Cleaning up downloaded VirtualBox Guest Additions ISO..."
|
24
|
+
unknown_type: "Unknown or unsupported URI type given for VirtualBox Guest Additions ISO download."
|
data/vagrant-vbguest.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
# s.add_runtime_dependency "rest-client"
|
22
22
|
|
23
23
|
s.add_dependency "virtualbox", "~> 0.9.1"
|
24
|
-
s.add_dependency "vagrant", "
|
24
|
+
s.add_dependency "vagrant", ">= 0.9.4"
|
25
25
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
26
26
|
|
27
27
|
s.files = `git ls-files`.split("\n")
|
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
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-05 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: virtualbox
|
16
|
-
requirement: &
|
16
|
+
requirement: &70295089810860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: 0.9.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70295089810860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vagrant
|
27
|
-
requirement: &
|
27
|
+
requirement: &70295089810380 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.9.
|
32
|
+
version: 0.9.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70295089810380
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70295089809920 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70295089809920
|
47
47
|
description: A Vagrant plugin wich automatically installs the host's VirtualBox Guest
|
48
48
|
Additions on the guest system.
|
49
49
|
email:
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/vagrant-vbguest.rb
|
63
63
|
- lib/vagrant-vbguest/command.rb
|
64
64
|
- lib/vagrant-vbguest/config.rb
|
65
|
+
- lib/vagrant-vbguest/download.rb
|
65
66
|
- lib/vagrant-vbguest/installer.rb
|
66
67
|
- lib/vagrant-vbguest/middleware.rb
|
67
68
|
- lib/vagrant-vbguest/version.rb
|