diff --git a/plugins/guests/arch/cap/rsync.rb b/plugins/guests/arch/cap/rsync.rb new file mode 100644 index 000000000..99aefa208 --- /dev/null +++ b/plugins/guests/arch/cap/rsync.rb @@ -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 diff --git a/plugins/guests/arch/cap/smb.rb b/plugins/guests/arch/cap/smb.rb new file mode 100644 index 000000000..88c65acd6 --- /dev/null +++ b/plugins/guests/arch/cap/smb.rb @@ -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 diff --git a/plugins/guests/arch/plugin.rb b/plugins/guests/arch/plugin.rb index 440917754..d35bb84f3 100644 --- a/plugins/guests/arch/plugin.rb +++ b/plugins/guests/arch/plugin.rb @@ -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 diff --git a/test/unit/plugins/guests/arch/cap/rsync_test.rb b/test/unit/plugins/guests/arch/cap/rsync_test.rb new file mode 100644 index 000000000..4cd7e0e8b --- /dev/null +++ b/test/unit/plugins/guests/arch/cap/rsync_test.rb @@ -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 diff --git a/test/unit/plugins/guests/arch/cap/smb_test.rb b/test/unit/plugins/guests/arch/cap/smb_test.rb new file mode 100644 index 000000000..bd817d21d --- /dev/null +++ b/test/unit/plugins/guests/arch/cap/smb_test.rb @@ -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