Mount vmware synced folders for big sur guests

This commit is contained in:
sophia 2020-11-17 11:49:32 -06:00
parent 84ea86a7cd
commit 8eea6a2301
4 changed files with 80 additions and 2 deletions

View File

@ -0,0 +1,24 @@
module VagrantPlugins
module GuestDarwin
module Cap
class Flavor
def self.flavor(machine)
# Read the version file
output = ""
machine.communicate.sudo("sw_vers -productVersion", error_check: false) do |_, data|
output = data
end
# Detect various flavors we care about
if output =~ /10.15.\d+/
return :catalina
elsif output =~ /11.0.?\d*/
return :big_sur
else
return :darwin
end
end
end
end
end
end

View File

@ -81,9 +81,15 @@ module VagrantPlugins
content = @apply_firmlinks[machine.id][:content].join("\n")
# Write out the synthetic file
comm.sudo("echo -e #{content.inspect} > /etc/synthetic.conf")
if @apply_firmlinks[:bootstrap]
if @apply_firmlinks[machine.id][:bootstrap]
case machine.guest.capability("flavor")
when :big_sur
apfs_bootstrap_flag = "-t"
else
apfs_bootstrap_flag = "-B"
end
# Re-bootstrap the root container to pick up firmlink updates
comm.sudo("/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B")
comm.sudo("/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util #{apfs_bootstrap_flag}", good_exit: [0, 253])
end
end
end

View File

@ -31,6 +31,11 @@ module VagrantPlugins
Cap::ConfigureNetworks
end
guest_capability(:darwin, :flavor) do
require_relative "cap/flavor"
Cap::Flavor
end
guest_capability(:darwin, :halt) do
require_relative "cap/halt"
Cap::Halt

View File

@ -0,0 +1,43 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestDarwin::Cap::Flavor" do
let(:caps) do
VagrantPlugins::GuestDarwin::Plugin
.components
.guest_capabilities[:darwin]
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 ".flavor" do
let(:cap) { caps.get(:flavor) }
{
"11.0.1" => :big_sur,
"11.0.11" => :big_sur,
"11.0" => :big_sur,
"10.15.123" => :catalina,
"" => :darwin,
"10.14.1" => :darwin,
}.each do |str, expected|
it "returns #{expected} for #{str}" do
comm.stub_command("sw_vers -productVersion", stdout: str)
expect(cap.flavor(machine)).to be(expected)
end
end
it "contines if sw_vers is not available" do
comm.stub_command("sw_vers -productVersion", stdout: "something!")
expect(cap.flavor(machine)).to be(:darwin)
end
end
end