Fixes #11218: Update apk cache when installing rsync (#11220)

This ensures that rsync can be installed on an Alpine Linux machine where the
apk cache may not be current.

Display a warning if the vagrant-alpine plugin is installed, since Alpine guest
support has been merged into Vagrant core.
This commit is contained in:
Jeff Bonhag 2019-12-17 12:34:53 -05:00 committed by GitHub
parent 55994824a4
commit 2fa44f5b8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 3 deletions

View File

@ -8,7 +8,7 @@ module VagrantPlugins
def self.rsync_install(machine)
machine.communicate.tap do |comm|
comm.sudo('apk add rsync')
comm.sudo('apk add --update-cache rsync')
end
end
end

View File

@ -45,6 +45,22 @@ module VagrantPlugins
require_relative 'cap/smb'
Cap::SMB
end
def self.check_community_plugin
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
if plugins.keys.include?("vagrant-alpine")
$stderr.puts <<-EOF
WARNING: Vagrant has detected the `vagrant-alpine` plugin. This plugin's
functionality has been merged into the main Vagrant project and should be
considered deprecated. To uninstall the plugin, run the command shown below:
vagrant plugin uninstall vagrant-alpine
EOF
end
end
self.check_community_plugin
end
end
end

View File

@ -16,9 +16,9 @@ describe 'VagrantPlugins::GuestAlpine::Cap::RSync' do
VagrantPlugins::GuestAlpine::Plugin.components.guest_capabilities[:alpine].get(:rsync_install)
end
it 'should install rsync' do
it 'should install rsync with --update-cache flag' do
# communicator.should_receive(:sudo).with('apk add rsync')
expect(communicator).to receive(:sudo).with('apk add rsync')
expect(communicator).to receive(:sudo).with('apk add --update-cache rsync')
allow_message_expectations_on_nil
described_class.rsync_install(machine)
end

View File

@ -0,0 +1,32 @@
require File.expand_path("../../../../base", __FILE__)
describe VagrantPlugins::GuestAlpine::Plugin do
let(:manager) { double("manager") }
before do
allow(Vagrant::Plugin::Manager).to receive(:instance).and_return(manager)
end
context "when vagrant-alpine plugin is not installed" do
before do
allow(manager).to receive(:installed_plugins).and_return({})
end
it "should not display a warning" do
expect($stderr).to_not receive(:puts)
VagrantPlugins::GuestAlpine::Plugin.check_community_plugin
end
end
context "when vagrant-alpine plugin is installed" do
before do
allow(manager).to receive(:installed_plugins).and_return({ "vagrant-alpine" => {} })
end
it "should display a warning" do
expect($stderr).to receive(:puts).with(/vagrant plugin uninstall vagrant-alpine/)
VagrantPlugins::GuestAlpine::Plugin.check_community_plugin
end
end
end