Support installing synced folder clients on arch

This commit is contained in:
Colin Shea 2016-07-18 22:32:55 -04:00 committed by Seth Vargo
parent 7ed6bb5bef
commit b31b240c8c
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
5 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,16 @@
module VagrantPlugins
module GuestArch
module Cap
class RSync
def self.rsync_install(machine)
comm = machine.communicate
comm.sudo <<-EOH.gsub(/^ {12}/, '')
set -e
pacman -Sy --noconfirm
pacman -S --noconfirm rsync
EOH
end
end
end
end
end

View File

@ -0,0 +1,17 @@
module VagrantPlugins
module GuestArch
module Cap
class SMB
def self.smb_install(machine)
comm = machine.communicate
if !comm.test("test -f /usr/bin/mount.cifs")
comm.sudo <<-EOH.gsub(/^ {14}/, '')
pacman -Sy --noconfirm
pacman -S --noconfirm cifs-utils
EOH
end
end
end
end
end
end

View File

@ -35,6 +35,16 @@ module VagrantPlugins
require_relative "cap/nfs"
Cap::NFS
end
guest_capability(:arch, :rsync_install) do
require_relative "cap/rsync"
Cap::RSync
end
guest_capability(:arch, :smb_install) do
require_relative "cap/smb"
Cap::SMB
end
end
end
end

View File

@ -0,0 +1,30 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestArch::Cap:RSync" do
let(:described_class) do
VagrantPlugins::GuestArch::Plugin
.components
.guest_capabilities[:arch]
.get(:rsync_install)
end
let(:machine) { double("machine") }
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
before do
allow(machine).to receive(:communicate).and_return(comm)
end
after do
comm.verify_expectations!
end
describe ".rsync_install" do
it "installs rsync=" do
described_class.rsync_install(machine)
expect(comm.received_commands[0]).to match(/pacman -Sy --noconfirm/)
expect(comm.received_commands[0]).to match(/pacman -S --noconfirm rsync/)
end
end
end

View File

@ -0,0 +1,38 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestArch::Cap::SMB" do
let(:described_class) do
VagrantPlugins::GuestArch::Plugin
.components
.guest_capabilities[:arch]
.get(:smb_install)
end
let(:machine) { double("machine") }
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
before do
allow(machine).to receive(:communicate).and_return(comm)
end
after do
comm.verify_expectations!
end
describe ".smb_install" do
it "installs smb when /usr/bin/mount.cifs does not exist" do
comm.stub_command("test -f /usr/bin/mount.cifs", exit_code: 1)
described_class.smb_install(machine)
expect(comm.received_commands[1]).to match(/pacman -Sy --noconfirm/)
expect(comm.received_commands[1]).to match(/pacman -S --noconfirm cifs-utils/)
end
it "does not install smb when /usr/bin/mount.cifs exists" do
comm.stub_command("test -f /usr/bin/mount.cifs", exit_code: 0)
described_class.smb_install(machine)
expect(comm.received_commands.join("")).to_not match(/-S/)
end
end
end