From a50432cf165acd0c356dd0d94e102bea01636cd0 Mon Sep 17 00:00:00 2001 From: Jeff Bonhag Date: Mon, 11 May 2020 12:09:03 -0400 Subject: [PATCH 1/2] Install rsync on Haiku --- plugins/guests/haiku/cap/rsync.rb | 15 ++++++++ plugins/guests/haiku/plugin.rb | 10 +++++ .../plugins/guests/haiku/cap/rsync_test.rb | 38 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 plugins/guests/haiku/cap/rsync.rb create mode 100644 test/unit/plugins/guests/haiku/cap/rsync_test.rb diff --git a/plugins/guests/haiku/cap/rsync.rb b/plugins/guests/haiku/cap/rsync.rb new file mode 100644 index 000000000..e465c3800 --- /dev/null +++ b/plugins/guests/haiku/cap/rsync.rb @@ -0,0 +1,15 @@ +module VagrantPlugins + module GuestHaiku + module Cap + class RSync + def self.rsync_installed(machine) + machine.communicate.test("test -f /bin/rsync") + end + + def self.rsync_install(machine) + machine.communicate.execute("pkgman install -y rsync") + end + end + end + end +end diff --git a/plugins/guests/haiku/plugin.rb b/plugins/guests/haiku/plugin.rb index 4654d3b75..55fa93b75 100644 --- a/plugins/guests/haiku/plugin.rb +++ b/plugins/guests/haiku/plugin.rb @@ -30,6 +30,16 @@ module VagrantPlugins require_relative "cap/remove_public_key" Cap::RemovePublicKey end + + guest_capability(:haiku, :rsync_install) do + require_relative "cap/rsync" + Cap::RSync + end + + guest_capability(:haiku, :rsync_installed) do + require_relative "cap/rsync" + Cap::RSync + end end end end diff --git a/test/unit/plugins/guests/haiku/cap/rsync_test.rb b/test/unit/plugins/guests/haiku/cap/rsync_test.rb new file mode 100644 index 000000000..60330521b --- /dev/null +++ b/test/unit/plugins/guests/haiku/cap/rsync_test.rb @@ -0,0 +1,38 @@ +require_relative "../../../../base" + +describe "VagrantPlugins::GuestHaiku::Cap::RSync" do + let(:caps) do + VagrantPlugins::GuestHaiku::Plugin + .components + .guest_capabilities[:haiku] + 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 + let(:cap) { caps.get(:rsync_install) } + + it "installs rsync" do + comm.expect_command("pkgman install -y rsync") + cap.rsync_install(machine) + end + end + + describe ".rsync_installed" do + let(:cap) { caps.get(:rsync_installed) } + + it "checks if rsync is installed" do + comm.expect_command("test -f /bin/rsync") + cap.rsync_installed(machine) + end + end +end From 2d4ecfbd230e42ea519f98bc5733da9d3d7093b9 Mon Sep 17 00:00:00 2001 From: Jeff Bonhag Date: Mon, 11 May 2020 12:38:41 -0400 Subject: [PATCH 2/2] Set rsync_command for Haiku guests At the time of writing, the Haiku rsync lacks old-style --compress due to its external zlib. Pass `-zz` to the guest rsync. This works with or without the `--compress` flag in the host's `rsync__args`. --- plugins/guests/haiku/cap/rsync.rb | 4 ++++ plugins/guests/haiku/plugin.rb | 5 +++++ test/unit/plugins/guests/haiku/cap/rsync_test.rb | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/plugins/guests/haiku/cap/rsync.rb b/plugins/guests/haiku/cap/rsync.rb index e465c3800..e0c2112f7 100644 --- a/plugins/guests/haiku/cap/rsync.rb +++ b/plugins/guests/haiku/cap/rsync.rb @@ -9,6 +9,10 @@ module VagrantPlugins def self.rsync_install(machine) machine.communicate.execute("pkgman install -y rsync") end + + def self.rsync_command(machine) + "rsync -zz" + end end end end diff --git a/plugins/guests/haiku/plugin.rb b/plugins/guests/haiku/plugin.rb index 55fa93b75..b000bb616 100644 --- a/plugins/guests/haiku/plugin.rb +++ b/plugins/guests/haiku/plugin.rb @@ -40,6 +40,11 @@ module VagrantPlugins require_relative "cap/rsync" Cap::RSync end + + guest_capability(:haiku, :rsync_command) do + require_relative "cap/rsync" + Cap::RSync + end end end end diff --git a/test/unit/plugins/guests/haiku/cap/rsync_test.rb b/test/unit/plugins/guests/haiku/cap/rsync_test.rb index 60330521b..b278b3909 100644 --- a/test/unit/plugins/guests/haiku/cap/rsync_test.rb +++ b/test/unit/plugins/guests/haiku/cap/rsync_test.rb @@ -35,4 +35,12 @@ describe "VagrantPlugins::GuestHaiku::Cap::RSync" do cap.rsync_installed(machine) end end + + describe ".rsync_command" do + let(:cap) { caps.get(:rsync_command) } + + it "defaults to 'rsync -zz'" do + expect(cap.rsync_command(machine)).to eq("rsync -zz") + end + end end