2012-08-15 05:38:41 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module ProviderVirtualBox
|
|
|
|
module Action
|
|
|
|
class CheckGuestAdditions
|
|
|
|
def initialize(app, env)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
# Use the raw interface for now, while the virtualbox gem
|
|
|
|
# doesn't support guest properties (due to cross platform issues)
|
|
|
|
version = env[:machine].provider.driver.read_guest_additions_version
|
|
|
|
if !version
|
|
|
|
env[:ui].warn I18n.t("vagrant.actions.vm.check_guest_additions.not_detected")
|
|
|
|
else
|
2013-02-28 03:10:49 +00:00
|
|
|
# Read the versions
|
|
|
|
versions = [version, env[:machine].provider.driver.version]
|
|
|
|
|
|
|
|
# Strip of any -OSE or _OSE and read only the first two parts
|
|
|
|
# of the version such as "4.2" in "4.2.0"
|
|
|
|
versions.map! do |v|
|
2013-02-28 03:12:45 +00:00
|
|
|
v = v.gsub(/[-_]ose/i, '')
|
2013-02-28 03:10:49 +00:00
|
|
|
match = /^(\d+\.\d+)\.(\d+)/.match(v)
|
2013-02-28 03:12:45 +00:00
|
|
|
v = match[1] if match
|
2013-02-28 03:10:49 +00:00
|
|
|
v
|
2012-08-15 05:38:41 +00:00
|
|
|
end
|
|
|
|
|
2013-02-28 03:10:49 +00:00
|
|
|
guest_version = versions[0]
|
|
|
|
vb_version = versions[1]
|
|
|
|
|
2012-08-15 05:38:41 +00:00
|
|
|
if guest_version != vb_version
|
|
|
|
env[:ui].warn(I18n.t("vagrant.actions.vm.check_guest_additions.version_mismatch",
|
|
|
|
:guest_version => version,
|
|
|
|
:virtualbox_version => vb_version))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Continue
|
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|