vagrant-vbguest 0.7.0.pre0 → 0.7.0.pre1
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/.gitignore +14 -1
- data/CHANGELOG.md +23 -1
- data/Gemfile +10 -2
- data/Rakefile +11 -1
- data/Readme.md +19 -6
- data/lib/vagrant-vbguest.rb +35 -12
- data/lib/vagrant-vbguest/command.rb +37 -7
- data/lib/vagrant-vbguest/config.rb +1 -1
- data/lib/vagrant-vbguest/errors.rb +6 -2
- data/lib/vagrant-vbguest/helpers.rb +32 -3
- data/lib/vagrant-vbguest/installer.rb +7 -10
- data/lib/vagrant-vbguest/installers/base.rb +28 -23
- data/lib/vagrant-vbguest/installers/debian.rb +5 -5
- data/lib/vagrant-vbguest/installers/linux.rb +12 -12
- data/lib/vagrant-vbguest/installers/redhat.rb +1 -1
- data/lib/vagrant-vbguest/machine.rb +26 -21
- data/lib/vagrant-vbguest/middleware.rb +4 -3
- data/lib/vagrant-vbguest/version.rb +1 -1
- data/lib/vagrant_init.rb +37 -3
- data/locales/en.yml +3 -0
- metadata +5 -2
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
## 0.7.0
|
2
2
|
|
3
|
+
- When looking for a GuestAdditions iso file in media manager
|
4
|
+
allow version number in filename. [GH-48], [GH-49] /
|
5
|
+
(thanks @neerolyte)
|
6
|
+
- Support multiple locations to be searched while "guessing"
|
7
|
+
GuestAdditions iso file
|
8
|
+
- On Linux guests also search "$HOME/.VirtualBox" for
|
9
|
+
GuestAdditions iso file. [GH-48]
|
3
10
|
- Add support for redhat-based distributions (Scientific Linux and
|
4
11
|
presumably CentOS) [GH-47], [GH-46] / (thanks @neerolyte)
|
5
12
|
- Fix an issue with VirtualBox GuestAdditions 4.2.8 [GH-44] /
|
6
13
|
(thanks @jimmycuadra)
|
14
|
+
- Reworked bunch of internals, particularly how vagrants's
|
15
|
+
environemnt is passed arround
|
16
|
+
- Intodruce a vagrant 1.0 compatibility layer for Installers and
|
17
|
+
other vbguest internals
|
7
18
|
|
8
19
|
### heads-up
|
9
20
|
|
@@ -11,6 +22,17 @@
|
|
11
22
|
will no longer halt vagrant workflow if running the VirtualBox
|
12
23
|
GuestAdditions Installer returns an error-code.
|
13
24
|
Instead it will print a human readable waring message.
|
25
|
+
- The environment (`env`) in custom installers is no longer the
|
26
|
+
actions environment `Hash`, but the `Environment` instance.
|
27
|
+
Which has some implications on how you can access e.g. the `ui`:
|
28
|
+
instead of `env[:ui]` use `env.ui`
|
29
|
+
- To achieve compatibility to both vagrant 1.0 and 1.1, custom
|
30
|
+
Installers, when executing shell commands on the guest system,
|
31
|
+
should use vbguests `communicate` wrapper. e.g.:
|
32
|
+
A call like `vm.channel.sudo 'apt-get update'` should be
|
33
|
+
changed to `channel.sudo 'apt-get update'`
|
34
|
+
The old `vm.channel` syntax will continue to work on vagrant 1.0.x
|
35
|
+
but will fail on vagrant 1.1.x.
|
14
36
|
|
15
37
|
## 0.6.4 (2013-01-24)
|
16
38
|
|
@@ -121,4 +143,4 @@
|
|
121
143
|
|
122
144
|
## Previous (≤ 0.0.3)
|
123
145
|
|
124
|
-
- Vagrant 0.8 support
|
146
|
+
- Vagrant 0.8 support
|
data/Gemfile
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gemspec
|
3
|
+
# Specify your gem's dependencies in vagrant-vbguest.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
# We depend on Vagrant for development, but we don't add it as a
|
8
|
+
# gem dependency because we expect to be installed within the
|
9
|
+
# Vagrant environment itself using `vagrant plugin`.
|
10
|
+
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => 'v1.1.2'
|
11
|
+
end
|
data/Rakefile
CHANGED
@@ -1 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
# Immediately sync all stdout so that tools like buildbot can
|
5
|
+
# immediately load in the output.
|
6
|
+
$stdout.sync = true
|
7
|
+
$stderr.sync = true
|
8
|
+
|
9
|
+
# This installs the tasks that help with gem creation and
|
10
|
+
# publishing.
|
11
|
+
Bundler::GemHelper.install_tasks
|
data/Readme.md
CHANGED
@@ -4,8 +4,17 @@
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
Requires vagrant 0.9.4 or later (including 1.0)
|
8
|
-
|
7
|
+
Requires vagrant 0.9.4 or later (including 1.0 and 1.1)
|
8
|
+
|
9
|
+
On Vagrant 1.1.x use:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
$ vagrant plugin install vagrant-vbguest
|
13
|
+
```
|
14
|
+
|
15
|
+
### Vagrant 1.0 and older
|
16
|
+
|
17
|
+
Since vagrant v1.0.0 the preferred installation method for vagrant is using the provided packages or installers.
|
9
18
|
If you installed vagrant that way, you need to use vagrant's gem wrapper:
|
10
19
|
|
11
20
|
```bash
|
@@ -213,10 +222,6 @@ Installers take care of the whole installation process, that includes where to s
|
|
213
222
|
```ruby
|
214
223
|
class MyInstaller < VagrantVbguest::Installers::Linux
|
215
224
|
|
216
|
-
def self.match?(vm)
|
217
|
-
super && vm.channel.test("test -d /temp")
|
218
|
-
end
|
219
|
-
|
220
225
|
# use /temp instead of /tmp
|
221
226
|
def tmp_path
|
222
227
|
'/temp/VBoxGuestAdditions.iso'
|
@@ -226,6 +231,14 @@ class MyInstaller < VagrantVbguest::Installers::Linux
|
|
226
231
|
def mount_point
|
227
232
|
'/media'
|
228
233
|
end
|
234
|
+
|
235
|
+
def install(opts=nil, &block)
|
236
|
+
communicate.sudo('my_distos_way_of_preparing_guestadditions_installation', opts, &block)
|
237
|
+
# calling `super` will run the installation
|
238
|
+
# also it takes care of uploading the right iso file into the box
|
239
|
+
# and cleaning up afterward
|
240
|
+
super
|
241
|
+
end
|
229
242
|
end
|
230
243
|
|
231
244
|
Vagrant::Config.run do |config|
|
data/lib/vagrant-vbguest.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant VBGuest plugin must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
# Add our custom translations to the load path
|
8
|
+
I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
|
2
9
|
|
3
|
-
require 'vagrant'
|
4
10
|
require "vagrant-vbguest/errors"
|
5
11
|
require 'vagrant-vbguest/helpers'
|
6
12
|
|
@@ -13,17 +19,34 @@ require 'vagrant-vbguest/installers/debian'
|
|
13
19
|
require 'vagrant-vbguest/installers/ubuntu'
|
14
20
|
require 'vagrant-vbguest/installers/redhat'
|
15
21
|
|
16
|
-
require 'vagrant-vbguest/config'
|
17
|
-
require 'vagrant-vbguest/command'
|
18
22
|
require 'vagrant-vbguest/middleware'
|
19
23
|
|
20
24
|
require 'vagrant-vbguest/download'
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
Vagrant.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
module VagrantVbguest
|
27
|
+
|
28
|
+
class Plugin < Vagrant.plugin("2")
|
29
|
+
|
30
|
+
name "vbguest management"
|
31
|
+
description <<-DESC
|
32
|
+
Provides automatic and/or manual management of the
|
33
|
+
VirtualBox Guest Additions inside the Vagrant environment.
|
34
|
+
DESC
|
35
|
+
|
36
|
+
config('vbguest') do
|
37
|
+
require File.expand_path("../vagrant-vbguest/config", __FILE__)
|
38
|
+
Config
|
39
|
+
end
|
40
|
+
|
41
|
+
command('vbguest') do
|
42
|
+
require File.expand_path("../vagrant-vbguest/command", __FILE__)
|
43
|
+
Command
|
44
|
+
end
|
45
|
+
|
46
|
+
# hook after anything that boots:
|
47
|
+
# that's all middlewares which will run the buildin "VM::Boot" action
|
48
|
+
action_hook(self::ALL_ACTIONS) do |hook|
|
49
|
+
hook.after(VagrantPlugins::ProviderVirtualBox::Action::Boot, VagrantVbguest::Middleware)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
require 'optparse'
|
2
|
-
require 'vagrant/command/start_mixins'
|
3
2
|
|
4
3
|
module VagrantVbguest
|
5
4
|
|
6
|
-
|
7
|
-
include Vagrant::Command::StartMixins
|
5
|
+
module CommandCommons
|
8
6
|
include VagrantVbguest::Helpers::Rebootable
|
9
7
|
|
10
8
|
# Runs the vbguest installer on the VMs that are represented
|
@@ -66,9 +64,7 @@ module VagrantVbguest
|
|
66
64
|
|
67
65
|
# Executes a command on a specific VM.
|
68
66
|
def execute_on_vm(vm, options)
|
69
|
-
|
70
|
-
raise Vagrant::Errors::VMInaccessible if !vm.state == :inaccessible
|
71
|
-
raise Vagrant::Errors::VMNotRunningError if vm.state != :running
|
67
|
+
check_runable_on(vm)
|
72
68
|
|
73
69
|
options = options.clone
|
74
70
|
_method = options.delete(:_method)
|
@@ -77,7 +73,7 @@ module VagrantVbguest
|
|
77
73
|
options = vm.config.vbguest.to_hash.merge(options)
|
78
74
|
machine = VagrantVbguest::Machine.new(vm, options)
|
79
75
|
status = machine.state
|
80
|
-
vm.ui.send((:ok == status ? :success : :warn), I18n.t("vagrant.plugins.vbguest.status.#{status}", machine.info))
|
76
|
+
vm.env.ui.send((:ok == status ? :success : :warn), I18n.t("vagrant.plugins.vbguest.status.#{status}", machine.info))
|
81
77
|
|
82
78
|
if _method != :status
|
83
79
|
machine.send(_method)
|
@@ -91,6 +87,40 @@ module VagrantVbguest
|
|
91
87
|
vm.reload(options)
|
92
88
|
end
|
93
89
|
end
|
90
|
+
|
91
|
+
def check_runable_on(vm); end
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
if Vagrant::VERSION < "1.1.0"
|
96
|
+
require 'vagrant/command/start_mixins'
|
97
|
+
|
98
|
+
class Command < Vagrant::Command::Base
|
99
|
+
include CommandCommons
|
100
|
+
include Vagrant::Command::StartMixins
|
101
|
+
|
102
|
+
def check_runable_on(vm)
|
103
|
+
raise Vagrant::Errors::VMNotCreatedError if !vm.created?
|
104
|
+
raise Vagrant::Errors::VMInaccessible if !vm.state == :inaccessible
|
105
|
+
raise Vagrant::Errors::VMNotRunningError if vm.state != :running
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
else
|
110
|
+
require Vagrant.source_root.join("plugins/commands/up/start_mixins")
|
111
|
+
|
112
|
+
class Command < Vagrant.plugin("2", :command)
|
113
|
+
include CommandCommons
|
114
|
+
include VagrantPlugins::CommandUp::StartMixins
|
115
|
+
|
116
|
+
def check_runable_on(vm)
|
117
|
+
raise Vagrant::Errors::VMNotCreatedError if vm.state.id == :not_created
|
118
|
+
raise Vagrant::Errors::VMInaccessible if vm.state.id == :inaccessible
|
119
|
+
raise Vagrant::Errors::VMNotRunningError if vm.state.id != :running
|
120
|
+
raise VagrantVbguest::NoVirtualBoxMachineError if vm.provider.class != VagrantPlugins::ProviderVirtualBox::Provider
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
94
124
|
end
|
95
125
|
|
96
126
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module VagrantVbguest
|
2
2
|
|
3
|
-
class Config < Vagrant::Config::Base
|
3
|
+
class Config <( Vagrant::VERSION < "1.1.0" ? Vagrant::Config::Base : Vagrant.plugin("2", :config) )
|
4
4
|
|
5
5
|
module Attributes
|
6
6
|
attr_accessor :iso_path, :auto_update, :auto_reboot, :no_install, :no_remote, :installer
|
@@ -3,7 +3,7 @@ module VagrantVbguest
|
|
3
3
|
class VbguestError < Vagrant::Errors::VagrantError
|
4
4
|
def error_namespace; "vagrant.plugins.vbguest.errors"; end
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
class IsoPathAutodetectionError < VagrantVbguest::VbguestError
|
8
8
|
error_key :autodetect_iso_path
|
9
9
|
end
|
@@ -11,4 +11,8 @@ module VagrantVbguest
|
|
11
11
|
class DownloadingDisabledError < VagrantVbguest::VbguestError
|
12
12
|
error_key :downloading_disabled
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
|
+
class NoVirtualBoxMachineError < VagrantVbguest::VbguestError
|
16
|
+
error_key :no_virtualbox_machine
|
17
|
+
end
|
18
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module VagrantVbguest
|
2
2
|
module Helpers
|
3
|
+
|
3
4
|
module Rebootable
|
4
5
|
@@rebooted = {}
|
5
6
|
|
6
7
|
def rebooted?(vm)
|
7
|
-
!!@@rebooted[vm
|
8
|
+
!!@@rebooted[ VmCompatible.vm_id(vm) ]
|
8
9
|
end
|
9
10
|
|
10
11
|
def reboot(vm, options)
|
@@ -13,7 +14,7 @@ module VagrantVbguest
|
|
13
14
|
false
|
14
15
|
elsif options[:auto_reboot]
|
15
16
|
vm.ui.warn(I18n.t("vagrant.plugins.vbguest.restart_vm"))
|
16
|
-
@@rebooted[vm
|
17
|
+
@@rebooted[ VmCompatible.vm_id(vm) ] = true
|
17
18
|
else
|
18
19
|
vm.ui.warn(I18n.t("vagrant.plugins.vbguest.suggest_restart", :name => vm.name))
|
19
20
|
false
|
@@ -21,5 +22,33 @@ module VagrantVbguest
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
25
|
+
module VmCompatible
|
26
|
+
|
27
|
+
if Vagrant::VERSION < '1.1.0'
|
28
|
+
def communicate
|
29
|
+
vm.channel
|
30
|
+
end
|
31
|
+
|
32
|
+
def driver
|
33
|
+
vm.driver
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.vm_id(vm)
|
37
|
+
vm.uuid
|
38
|
+
end
|
39
|
+
else # Vagrant 1.1, and hopefully upwards
|
40
|
+
def communicate
|
41
|
+
vm.communicate
|
42
|
+
end
|
43
|
+
|
44
|
+
def driver
|
45
|
+
vm.provider.driver
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.vm_id(vm)
|
49
|
+
vm.id
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
24
53
|
end
|
25
|
-
end
|
54
|
+
end
|
@@ -35,12 +35,12 @@ module VagrantVbguest
|
|
35
35
|
end
|
36
36
|
|
37
37
|
##
|
38
|
-
# Returns
|
38
|
+
# Returns the class of the registrated Installer class which
|
39
39
|
# matches first (according to it's priority) or `nil` if none matches.
|
40
40
|
def detect(vm, options)
|
41
41
|
@installers.keys.sort.reverse.each do |prio|
|
42
42
|
klass = @installers[prio].detect { |k| k.match?(vm) }
|
43
|
-
return klass
|
43
|
+
return klass if klass
|
44
44
|
end
|
45
45
|
return nil
|
46
46
|
end
|
@@ -48,12 +48,9 @@ module VagrantVbguest
|
|
48
48
|
|
49
49
|
def initialize(vm, options = {})
|
50
50
|
@vm = vm
|
51
|
+
@env = vm.env
|
51
52
|
@options = options
|
52
53
|
@iso_path = nil
|
53
|
-
@env = {
|
54
|
-
:ui => vm.ui,
|
55
|
-
:tmp_path => vm.env.tmp_path
|
56
|
-
}
|
57
54
|
end
|
58
55
|
|
59
56
|
def install
|
@@ -61,7 +58,7 @@ module VagrantVbguest
|
|
61
58
|
raise NoInstallerFoundError, :method => 'install' if !installer
|
62
59
|
|
63
60
|
installer.install do |type, data|
|
64
|
-
@
|
61
|
+
@env.ui.info(data, :prefix => false, :new_line => false)
|
65
62
|
end
|
66
63
|
ensure
|
67
64
|
cleanup
|
@@ -72,7 +69,7 @@ module VagrantVbguest
|
|
72
69
|
raise NoInstallerFoundError, :method => 'rebuild' if !installer
|
73
70
|
|
74
71
|
installer.rebuild do |type, data|
|
75
|
-
@
|
72
|
+
@env.ui.info(data, :prefix => false, :new_line => false)
|
76
73
|
end
|
77
74
|
end
|
78
75
|
|
@@ -81,7 +78,7 @@ module VagrantVbguest
|
|
81
78
|
raise NoInstallerFoundError, :method => 'manual start' if !installer
|
82
79
|
|
83
80
|
installer.start do |type, data|
|
84
|
-
@
|
81
|
+
@env.ui.info(data, :prefix => false, :new_line => false)
|
85
82
|
end
|
86
83
|
end
|
87
84
|
|
@@ -112,7 +109,7 @@ module VagrantVbguest
|
|
112
109
|
@guest_installer ||= if @options[:installer].is_a? Class
|
113
110
|
@options[:installer].new(@vm, @options)
|
114
111
|
else
|
115
|
-
Installer.detect(@vm, @options)
|
112
|
+
installer_klass = Installer.detect(@vm, @options) and installer_klass.new(@vm, @options)
|
116
113
|
end
|
117
114
|
end
|
118
115
|
|
@@ -8,6 +8,7 @@ module VagrantVbguest
|
|
8
8
|
# It defines the basic structure of an Installer and should
|
9
9
|
# never be used directly
|
10
10
|
class Base
|
11
|
+
include VagrantVbguest::Helpers::VmCompatible
|
11
12
|
|
12
13
|
# Tests whether this installer class is applicable to the
|
13
14
|
# current environment. Usually, testing for a specific OS.
|
@@ -24,10 +25,11 @@ module VagrantVbguest
|
|
24
25
|
false
|
25
26
|
end
|
26
27
|
|
27
|
-
attr_reader :vm, :options
|
28
|
+
attr_reader :env, :vm, :options
|
28
29
|
|
29
30
|
def initialize(vm, options=nil)
|
30
31
|
@vm = vm
|
32
|
+
@env = vm.env
|
31
33
|
@options = options
|
32
34
|
end
|
33
35
|
|
@@ -42,7 +44,7 @@ module VagrantVbguest
|
|
42
44
|
# The mountpoint path
|
43
45
|
# Subclasses shall override this method, if they need to mount the uploaded file!
|
44
46
|
#
|
45
|
-
# @
|
47
|
+
# @return [String]
|
46
48
|
def mount_point
|
47
49
|
end
|
48
50
|
|
@@ -116,7 +118,7 @@ module VagrantVbguest
|
|
116
118
|
def guest_version(reload=false)
|
117
119
|
return @guest_version if @guest_version && !reload
|
118
120
|
|
119
|
-
guest_version =
|
121
|
+
guest_version = driver.read_guest_additions_version
|
120
122
|
guest_version = !guest_version ? nil : guest_version.gsub(/[-_]ose/i, '')
|
121
123
|
|
122
124
|
@guest_version = guest_version
|
@@ -126,7 +128,7 @@ module VagrantVbguest
|
|
126
128
|
#
|
127
129
|
# @return [String] The version code of the Virtual Box *host*
|
128
130
|
def host_version
|
129
|
-
|
131
|
+
driver.version
|
130
132
|
end
|
131
133
|
|
132
134
|
# Determinates the version of the GuestAdditions installer in use
|
@@ -134,7 +136,7 @@ module VagrantVbguest
|
|
134
136
|
# @return [String] The version code of the GuestAdditions installer
|
135
137
|
def installer_version(path_to_installer)
|
136
138
|
version = nil
|
137
|
-
|
139
|
+
communicate.sudo("#{path_to_installer} --info", :error_check => false) do |type, data|
|
138
140
|
if (v = data.to_s.match(/\AIdentification.*\s(\d+\.\d+.\d+)/i))
|
139
141
|
version = v[1]
|
140
142
|
end
|
@@ -146,7 +148,7 @@ module VagrantVbguest
|
|
146
148
|
# will start _now_.
|
147
149
|
# The message includes the host and installer version strings.
|
148
150
|
def yield_installation_waring(path_to_installer)
|
149
|
-
@
|
151
|
+
@env.ui.warn I18n.t("vagrant.plugins.vbguest.installing#{@options[:force] ? '_forced' : ''}",
|
150
152
|
:guest_version => guest_version,
|
151
153
|
:installer_version => installer_version(path_to_installer) || I18n.t("vagrant.plugins.vbguest.unknown"))
|
152
154
|
end
|
@@ -155,7 +157,7 @@ module VagrantVbguest
|
|
155
157
|
# will be rebuild using the installed GuestAdditions.
|
156
158
|
# The message includes the host and installer version strings.
|
157
159
|
def yield_rebuild_warning
|
158
|
-
@
|
160
|
+
@env.ui.warn I18n.t("vagrant.plugins.vbguest.rebuild#{@options[:force] ? '_forced' : ''}",
|
159
161
|
:guest_version => guest_version(true),
|
160
162
|
:host_version => host_version)
|
161
163
|
end
|
@@ -167,7 +169,7 @@ module VagrantVbguest
|
|
167
169
|
# knows there could be a problem. The message includles the installer
|
168
170
|
# version.
|
169
171
|
def yield_installation_error_warning(path_to_installer)
|
170
|
-
@
|
172
|
+
@env.ui.warn I18n.t("vagrant.plugins.vbguest.install_error",
|
171
173
|
:installer_version => installer_version(path_to_installer) || I18n.t("vagrant.plugins.vbguest.unknown"))
|
172
174
|
end
|
173
175
|
|
@@ -202,12 +204,12 @@ module VagrantVbguest
|
|
202
204
|
else
|
203
205
|
# :TODO: This will also raise, if the iso_url points to an invalid local path
|
204
206
|
raise VagrantVbguest::DownloadingDisabledError.new(:from => iso_path) if options[:no_remote]
|
205
|
-
|
206
|
-
:ui =>
|
207
|
-
:tmp_path =>
|
207
|
+
downloader_env = {
|
208
|
+
:ui => @env.ui,
|
209
|
+
:tmp_path => @env.tmp_path,
|
208
210
|
:iso_url => iso_path
|
209
211
|
}
|
210
|
-
@download = VagrantVbguest::Download.new(
|
212
|
+
@download = VagrantVbguest::Download.new(downloader_env)
|
211
213
|
@download.download
|
212
214
|
@download.temp_path
|
213
215
|
end
|
@@ -235,7 +237,7 @@ module VagrantVbguest
|
|
235
237
|
#
|
236
238
|
# @return [String] Absolute path to the local GuestAdditions iso file, or +nil+ if not found.
|
237
239
|
def media_manager_iso
|
238
|
-
(m =
|
240
|
+
(m = driver.execute('list', 'dvds').match(/^.+:\s+(.*VBoxGuestAdditions(?:_#{guest_version})?\.iso)$/i)) && m[1]
|
239
241
|
end
|
240
242
|
|
241
243
|
# Makes an educated guess where the GuestAdditions iso file
|
@@ -244,42 +246,45 @@ module VagrantVbguest
|
|
244
246
|
#
|
245
247
|
# @return [String] Absolute path to the local GuestAdditions iso file, or +nil+ if not found.
|
246
248
|
def guess_iso
|
247
|
-
|
248
|
-
|
249
|
+
paths = if Vagrant::Util::Platform.linux?
|
250
|
+
[
|
251
|
+
(File.join(ENV['HOME'], '.VirtualBox', "VBoxGuestAdditions_#{guest_version}.iso") if ENV['HOME']),
|
252
|
+
"/usr/share/virtualbox/VBoxGuestAdditions.iso"
|
253
|
+
]
|
249
254
|
elsif Vagrant::Util::Platform.darwin?
|
250
255
|
"/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso"
|
251
256
|
elsif Vagrant::Util::Platform.windows?
|
252
257
|
if (p = ENV["VBOX_INSTALL_PATH"]) && !p.empty?
|
253
258
|
File.join(p, "VBoxGuestAdditions.iso")
|
254
|
-
|
259
|
+
elsif ENV["PROGRAM_FILES"] || ENV["ProgramW6432"] || ENV["PROGRAMFILES"]
|
255
260
|
File.join((ENV["PROGRAM_FILES"] || ENV["ProgramW6432"] || ENV["PROGRAMFILES"]), "/Oracle/VirtualBox/VBoxGuestAdditions.iso")
|
256
261
|
end
|
257
262
|
end
|
258
|
-
File.exists?(
|
263
|
+
Array(paths).find { |path| path && File.exists?(path) }
|
259
264
|
end
|
260
265
|
|
261
266
|
# A helper method to handle the GuestAdditions iso file upload
|
262
267
|
# into the guest box.
|
263
|
-
# The file will uploaded to the location given by the +
|
268
|
+
# The file will uploaded to the location given by the +temp_path+ method.
|
264
269
|
#
|
265
270
|
# @example Default upload
|
266
271
|
# upload(iso_file)
|
267
272
|
#
|
268
273
|
# @param [String] Path of the file to upload to the +tmp_path*
|
269
274
|
def upload(file)
|
270
|
-
|
271
|
-
|
275
|
+
env.ui.info(I18n.t("vagrant.plugins.vbguest.start_copy_iso", :from => file, :to => tmp_path))
|
276
|
+
communicate.upload(file, tmp_path)
|
272
277
|
end
|
273
278
|
|
274
279
|
# A helper method to delete the uploaded GuestAdditions iso file
|
275
280
|
# from the guest box
|
276
281
|
def cleanup
|
277
282
|
@download.cleanup if @download
|
278
|
-
|
279
|
-
|
283
|
+
communicate.execute("test -f #{tmp_path} && rm #{tmp_path}", :error_check => false) do |type, data|
|
284
|
+
env.ui.error(data.chomp, :prefix => false)
|
280
285
|
end
|
281
286
|
end
|
282
287
|
|
283
288
|
end
|
284
289
|
end
|
285
|
-
end
|
290
|
+
end
|
@@ -14,10 +14,10 @@ module VagrantVbguest
|
|
14
14
|
# @yieldparam [String] data Data for the given output.
|
15
15
|
def install(opts=nil, &block)
|
16
16
|
begin
|
17
|
-
|
17
|
+
communicate.sudo(install_dependencies_cmd, opts, &block)
|
18
18
|
rescue
|
19
|
-
|
20
|
-
|
19
|
+
communicate.sudo('apt-get update', opts, &block)
|
20
|
+
communicate.sudo(install_dependencies_cmd, opts, &block)
|
21
21
|
end
|
22
22
|
super
|
23
23
|
end
|
@@ -31,10 +31,10 @@ module VagrantVbguest
|
|
31
31
|
packages = ['linux-headers-`uname -r`']
|
32
32
|
# some Debian system (lenny) dont come with a dkms packe so we neet to skip that.
|
33
33
|
# apt-cache search will exit with 0 even if nothing was found, so we need to grep.
|
34
|
-
packages << 'dkms' if
|
34
|
+
packages << 'dkms' if communicate.test('apt-cache search --names-only \'^dkms$\' | grep dkms')
|
35
35
|
packages.join ' '
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
-
VagrantVbguest::Installer.register(VagrantVbguest::Installers::Debian, 5)
|
40
|
+
VagrantVbguest::Installer.register(VagrantVbguest::Installers::Debian, 5)
|
@@ -13,7 +13,7 @@ module VagrantVbguest
|
|
13
13
|
# @return [Symbol] One of `:debian`, `:ubuntu`, `:gentoo`, `:fedora`, `:redhat`, `:suse`, `:arch`
|
14
14
|
def self.distro(vm)
|
15
15
|
@@ditro ||= {}
|
16
|
-
@@ditro[vm
|
16
|
+
@@ditro[ VagrantVbguest::Helpers::VmCompatible.vm_id(vm) ] ||= vm.guest.distro_dispatch
|
17
17
|
end
|
18
18
|
|
19
19
|
# Matches if the operating system name prints "Linux"
|
@@ -24,7 +24,7 @@ module VagrantVbguest
|
|
24
24
|
# therefore should do a more specific check.
|
25
25
|
def self.match?(vm)
|
26
26
|
raise Error, :_key => :do_not_inherit_match_method if self != Linux
|
27
|
-
|
27
|
+
communicate.test("uname | grep 'Linux'")
|
28
28
|
end
|
29
29
|
|
30
30
|
# defaults the temp path to "/tmp/VBoxGuestAdditions.iso" for all Linux based systems
|
@@ -44,7 +44,7 @@ module VagrantVbguest
|
|
44
44
|
# @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
|
45
45
|
# @yieldparam [String] data Data for the given output.
|
46
46
|
def install(opts=nil, &block)
|
47
|
-
|
47
|
+
env.ui.warn I18n.t("vagrant.plugins.vbguest.errors.installer.generic_linux_installer") if self.class == Linux
|
48
48
|
upload(iso_file)
|
49
49
|
mount_iso(opts, &block)
|
50
50
|
execute_installer(opts, &block)
|
@@ -59,7 +59,7 @@ module VagrantVbguest
|
|
59
59
|
opts = {
|
60
60
|
:sudo => true
|
61
61
|
}.merge(opts || {})
|
62
|
-
|
62
|
+
communicate.test('lsmod | grep vboxsf', opts, &block)
|
63
63
|
end
|
64
64
|
|
65
65
|
# This overrides {VagrantVbguest::Installers::Base#guest_version}
|
@@ -75,9 +75,9 @@ module VagrantVbguest
|
|
75
75
|
return @guest_version if @guest_version && !reload
|
76
76
|
driver_version = super
|
77
77
|
|
78
|
-
|
78
|
+
communicate.sudo('VBoxService --version', :error_check => false) do |type, data|
|
79
79
|
if (v = data.to_s.match(/^(\d+\.\d+.\d+)/)) && driver_version != v[1]
|
80
|
-
@
|
80
|
+
@env.ui.warn(I18n.t("vagrant.plugins.vbguest.guest_version_reports_differ", :driver => driver_version, :service => v[1]))
|
81
81
|
@guest_version = v[1]
|
82
82
|
end
|
83
83
|
end
|
@@ -89,7 +89,7 @@ module VagrantVbguest
|
|
89
89
|
# @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
|
90
90
|
# @yieldparam [String] data Data for the given output.
|
91
91
|
def rebuild(opts=nil, &block)
|
92
|
-
|
92
|
+
communicate.sudo('/etc/init.d/vboxadd setup', opts, &block)
|
93
93
|
end
|
94
94
|
|
95
95
|
# @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
|
@@ -98,7 +98,7 @@ module VagrantVbguest
|
|
98
98
|
# @yieldparam [String] data Data for the given output.
|
99
99
|
def start(opts=nil, &block)
|
100
100
|
opts = {:error_check => false}.merge(opts || {})
|
101
|
-
|
101
|
+
communicate.sudo('/etc/init.d/vboxadd start', opts, &block)
|
102
102
|
end
|
103
103
|
|
104
104
|
|
@@ -115,7 +115,7 @@ module VagrantVbguest
|
|
115
115
|
installer = File.join(mount_point, 'VBoxLinuxAdditions.run')
|
116
116
|
yield_installation_waring(installer)
|
117
117
|
opts = {:error_check => false}.merge(opts || {})
|
118
|
-
exit_status =
|
118
|
+
exit_status = communicate.sudo("#{installer} --nox11", opts, &block)
|
119
119
|
yield_installation_error_warning(installer) unless exit_status == 0
|
120
120
|
exit_status
|
121
121
|
end
|
@@ -129,7 +129,7 @@ module VagrantVbguest
|
|
129
129
|
# @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
|
130
130
|
# @yieldparam [String] data Data for the given output.
|
131
131
|
def mount_iso(opts=nil, &block)
|
132
|
-
|
132
|
+
communicate.sudo("mount #{tmp_path} -o loop #{mount_point}", opts, &block)
|
133
133
|
end
|
134
134
|
|
135
135
|
# A generic helper method for un-mounting the GuestAdditions iso file
|
@@ -141,9 +141,9 @@ module VagrantVbguest
|
|
141
141
|
# @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
|
142
142
|
# @yieldparam [String] data Data for the given output.
|
143
143
|
def unmount_iso(opts=nil, &block)
|
144
|
-
|
144
|
+
communicate.sudo("umount #{mount_point}", opts, &block)
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
149
|
-
VagrantVbguest::Installer.register(VagrantVbguest::Installers::Linux, 2)
|
149
|
+
VagrantVbguest::Installer.register(VagrantVbguest::Installers::Linux, 2)
|
@@ -10,7 +10,7 @@ module VagrantVbguest
|
|
10
10
|
|
11
11
|
# Install missing deps and yield up to regular linux installation
|
12
12
|
def install(opts=nil, &block)
|
13
|
-
|
13
|
+
communicate.sudo(install_dependencies_cmd, opts, &block)
|
14
14
|
super
|
15
15
|
end
|
16
16
|
|
@@ -3,26 +3,31 @@ module VagrantVbguest
|
|
3
3
|
|
4
4
|
require 'micromachine'
|
5
5
|
|
6
|
-
attr_reader :installer, :vm, :options
|
6
|
+
attr_reader :installer, :env, :vm, :options
|
7
7
|
|
8
8
|
def initialize vm, options
|
9
|
+
@vm = vm
|
10
|
+
@env = vm.env
|
11
|
+
@options = options
|
12
|
+
|
9
13
|
@logger = Log4r::Logger.new("vagrant::plugins::vbguest-machine")
|
10
|
-
@logger.debug("initialize vbguest machine for VM '#{vm.name}' (#{vm.
|
11
|
-
|
12
|
-
@
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@box_machine = MicroMachine.new
|
25
|
-
|
14
|
+
@logger.debug("initialize vbguest machine for VM '#{vm.name}' (#{vm.to_s})")
|
15
|
+
|
16
|
+
@installer = Installer.new vm, options
|
17
|
+
|
18
|
+
@ga_machine = MicroMachine.new(:pending).tap { |m|
|
19
|
+
m.when :install, :pending => :installed
|
20
|
+
m.when :start, :pending => :started
|
21
|
+
m.when :rebuild, :pending => :rebuilt, :started => :rebuilt
|
22
|
+
|
23
|
+
m.on(:installed) { installer.install }
|
24
|
+
m.on(:started) { installer.start }
|
25
|
+
m.on(:rebuilt) { installer.rebuild }
|
26
|
+
}
|
27
|
+
|
28
|
+
@box_machine = MicroMachine.new(:first_boot).tap { |m|
|
29
|
+
m.when :reboot, :first_boot => :rebooted
|
30
|
+
}
|
26
31
|
end
|
27
32
|
|
28
33
|
def run
|
@@ -32,7 +37,7 @@ module VagrantVbguest
|
|
32
37
|
while (command = runlist.shift)
|
33
38
|
@logger.debug("Running command #{command} from runlist")
|
34
39
|
if !self.send(command)
|
35
|
-
|
40
|
+
env.ui.error('vagrant.plugins.vbguest.machine_loop_guard', :command => command, :state => current_state)
|
36
41
|
return false
|
37
42
|
end
|
38
43
|
return run if current_state != state
|
@@ -41,12 +46,12 @@ module VagrantVbguest
|
|
41
46
|
end
|
42
47
|
|
43
48
|
def install
|
44
|
-
return
|
49
|
+
return env.ui.warn(I18n.t("vagrant.plugins.vbguest.skipped_installation")) if options[:no_install] && !options[:force]
|
45
50
|
@ga_machine.trigger :install
|
46
51
|
end
|
47
52
|
|
48
53
|
def rebuild
|
49
|
-
return
|
54
|
+
return env.ui.warn(I18n.t("vagrant.plugins.vbguest.skipped_rebuild")) if options[:no_install] && !options[:force]
|
50
55
|
@ga_machine.trigger :rebuild
|
51
56
|
end
|
52
57
|
|
@@ -91,4 +96,4 @@ module VagrantVbguest
|
|
91
96
|
}
|
92
97
|
end
|
93
98
|
end
|
94
|
-
end
|
99
|
+
end
|
@@ -14,13 +14,14 @@ module VagrantVbguest
|
|
14
14
|
|
15
15
|
def call(env)
|
16
16
|
@env = env
|
17
|
-
vm = env[:vm]
|
18
|
-
|
17
|
+
vm = env[:vm] || env[:machine]
|
18
|
+
|
19
|
+
options = vm.config.vbguest.to_hash.freeze
|
19
20
|
|
20
21
|
if options[:auto_update]
|
21
22
|
machine = VagrantVbguest::Machine.new vm, options
|
22
23
|
status = machine.state
|
23
|
-
vm.ui.send((:ok == status ? :success : :warn), I18n.t("vagrant.plugins.vbguest.status.#{status}", machine.info))
|
24
|
+
vm.env.ui.send((:ok == status ? :success : :warn), I18n.t("vagrant.plugins.vbguest.status.#{status}", machine.info))
|
24
25
|
machine.run
|
25
26
|
reboot(vm, options) if machine.reboot?
|
26
27
|
end
|
data/lib/vagrant_init.rb
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
-
# This file is automatically loaded by Vagrant
|
2
|
-
# plugins. This file kicks off this plugin.
|
3
|
-
|
1
|
+
# This file is automatically loaded by Vagrant < 1.1
|
2
|
+
# to load any plugins. This file kicks off this plugin.
|
3
|
+
begin
|
4
|
+
require "vagrant"
|
5
|
+
rescue LoadError
|
6
|
+
raise "The Vagrant VBGuest plugin must be run within Vagrant."
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'vagrant-vbguest/core_ext/string/interpolate'
|
10
|
+
|
11
|
+
require "vagrant-vbguest/errors"
|
12
|
+
require 'vagrant-vbguest/helpers'
|
13
|
+
|
14
|
+
require 'vagrant-vbguest/machine'
|
15
|
+
|
16
|
+
require 'vagrant-vbguest/installer'
|
17
|
+
require 'vagrant-vbguest/installers/base'
|
18
|
+
require 'vagrant-vbguest/installers/linux'
|
19
|
+
require 'vagrant-vbguest/installers/debian'
|
20
|
+
require 'vagrant-vbguest/installers/ubuntu'
|
21
|
+
require 'vagrant-vbguest/installers/redhat'
|
22
|
+
|
23
|
+
require 'vagrant-vbguest/config'
|
24
|
+
require 'vagrant-vbguest/command'
|
25
|
+
require 'vagrant-vbguest/middleware'
|
26
|
+
|
27
|
+
require 'vagrant-vbguest/download'
|
28
|
+
|
29
|
+
Vagrant.config_keys.register(:vbguest) { VagrantVbguest::Config }
|
30
|
+
|
31
|
+
Vagrant.commands.register(:vbguest) { VagrantVbguest::Command }
|
32
|
+
|
33
|
+
Vagrant.actions[:start].use VagrantVbguest::Middleware
|
34
|
+
|
35
|
+
# Add our custom translations to the load path
|
36
|
+
I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
|
37
|
+
|
data/locales/en.yml
CHANGED
@@ -42,6 +42,9 @@ en:
|
|
42
42
|
Please configure a local path to the iso using `config.vbguest.iso_path`
|
43
43
|
in your Vagrantfile or the `--iso` command line option.
|
44
44
|
|
45
|
+
no_virtualbox_machine: |-
|
46
|
+
The VBGuest plugin must be used with VirtualBox Machines only.
|
47
|
+
|
45
48
|
installer:
|
46
49
|
no_installer_for_platform: |-
|
47
50
|
Sorry, don't know how to %{method} Virtualbox Guest Additions on this platform. Stopping installation.
|
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.7.0.
|
4
|
+
version: 0.7.0.pre1
|
5
5
|
prerelease: 6
|
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: 2013-03-
|
12
|
+
date: 2013-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: micromachine
|
@@ -121,6 +121,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
121
|
- - ! '>='
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
hash: 1097977286854134739
|
124
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
128
|
none: false
|
126
129
|
requirements:
|