Brian Cain 73a5a5a8c9
(#9059) Convert to windows path if on WSL during vbox export
Prior to this commit, the incorrect path was used when determining where
to export an ovf file during the `vagrant package` step. This commit
updates that by checking if vagrant is within WSL, and if so, convert
the path to a proper windows path to be used during the export.

Fixes #9059
2018-02-27 16:02:25 -08:00

50 lines
1.2 KiB
Ruby

require "fileutils"
require 'vagrant/util/platform'
module VagrantPlugins
module ProviderVirtualBox
module Action
class Export
def initialize(app, env)
@app = app
end
def call(env)
@env = env
raise Vagrant::Errors::VMPowerOffToPackage if \
@env[:machine].state.id != :poweroff
export
@app.call(env)
end
def export
@env[:ui].info I18n.t("vagrant.actions.vm.export.exporting")
@env[:machine].provider.driver.export(ovf_path) do |progress|
@env[:ui].clear_line
@env[:ui].report_progress(progress.percent, 100, false)
end
# Clear the line a final time so the next data can appear
# alone on the line.
@env[:ui].clear_line
end
def ovf_path
path = File.join(@env["export.temp_dir"], "box.ovf")
# If we're within WSL, we should use the correct path rather than
# the mnt path. GH-9059
if Vagrant::Util::Platform.wsl?
path = Vagrant::Util::Platform.wsl_to_windows_path(path)
end
return path
end
end
end
end
end