driver: Use relative guest paths for synced folders

Closes GH-258
This commit is contained in:
Fabio Rehm 2014-05-04 20:51:53 -03:00
parent b17fb7baa8
commit 5eef1524d7
2 changed files with 9 additions and 7 deletions

View file

@ -67,11 +67,13 @@ module Vagrant
end
def share_folder(host_path, guest_path, mount_options = nil)
guest_path = rootfs_path.join(guest_path.gsub(/^\//, ''))
unless guest_path.directory?
guest_path = guest_path.gsub(/^\//, '')
guest_full_path = rootfs_path.join(guest_path)
unless guest_full_path.directory?
begin
@logger.debug("Guest path doesn't exist, creating: #{guest_path}")
@sudo_wrapper.run('mkdir', '-p', guest_path.to_s)
@logger.debug("Guest path doesn't exist, creating: #{guest_full_path}")
@sudo_wrapper.run('mkdir', '-p', guest_full_path.to_s)
rescue Errno::EACCES
raise Vagrant::Errors::SharedFolderCreateFailed, :path => guest_path.to_s
end

View file

@ -151,7 +151,7 @@ describe Vagrant::LXC::Driver do
let(:ro_rw_folder) { {guestpath: '/vagrant/ro_rw', hostpath: '/path/to/host/dir', mount_options: ['ro', 'rw']} }
let(:folders) { [shared_folder, ro_rw_folder] }
let(:rootfs_path) { Pathname('/path/to/rootfs') }
let(:expected_guest_path) { "#{rootfs_path}/vagrant" }
let(:expected_guest_path) { "vagrant" }
let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true) }
subject { described_class.new('name', sudo_wrapper) }
@ -162,7 +162,7 @@ describe Vagrant::LXC::Driver do
end
it "creates guest folder under container's rootfs" do
expect(sudo_wrapper).to have_received(:run).with("mkdir", "-p", expected_guest_path)
expect(sudo_wrapper).to have_received(:run).with("mkdir", "-p", "#{rootfs_path}/#{expected_guest_path}")
end
it 'adds a mount.entry to its local customizations' do
@ -175,7 +175,7 @@ describe Vagrant::LXC::Driver do
it 'supports additional mount options' do
expect(subject.customizations).to include [
'mount.entry',
"#{ro_rw_folder[:hostpath]} #{rootfs_path}/vagrant/ro_rw none ro,rw 0 0"
"#{ro_rw_folder[:hostpath]} vagrant/ro_rw none ro,rw 0 0"
]
end
end