@@ -0,0 +1,97 @@
1+From: Antonio Terceiro <terceiro@debian.org>
2+Date: Wed, 27 May 2015 09:36:17 -0300
3+Subject: Support system-installed plugins
4+Source: https://salsa.debian.org/ruby-team/vagrant/blob/cb672c6dc0c63f6552c5ec4d6d7d22929d353503/debian/patches/0004-Support-system-installed-plugins.patch
6+Plugins must be installed as regular Ruby libraries, and they must
7+contain /usr/share/vagrant-plugins/plugins.d/$PLUGINNAME.json with the
12+ "ruby_version":"$(ruby -e 'puts RUBY_VERSION')",
13+ "vagrant_version":"$(cat /usr/share/vagrant/version.txt)",
20+ lib/vagrant/plugin/manager.rb | 4 ++--
21+ lib/vagrant/plugin/state_file.rb | 22 +++++++++++++++++++++-
22+ 2 files changed, 23 insertions(+), 3 deletions(-)
24+diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb
25+index 567347d..d9d76a0 100644
26+--- a/lib/vagrant/plugin/manager.rb
27++++ b/lib/vagrant/plugin/manager.rb
28+@@ -18,7 +18,7 @@ module Vagrant
30+ # Returns the path to the [StateFile] for system plugins.
31+ def self.system_plugins_file
32+- dir = Vagrant.installer_embedded_dir
33++ dir = '@system_plugin_dir@'
35+ Pathname.new(dir).join("plugins.json")
37+@@ -38,7 +38,7 @@ module Vagrant
39+ system_path = self.class.system_plugins_file
41+- @system_file = StateFile.new(system_path) if system_path && system_path.file?
42++ @system_file = StateFile.new(system_path, true) if system_path && system_path.file?
45+ @globalized = @localized = false
46+diff --git a/lib/vagrant/plugin/state_file.rb b/lib/vagrant/plugin/state_file.rb
47+index c6872d4..935d431 100644
48+--- a/lib/vagrant/plugin/state_file.rb
49++++ b/lib/vagrant/plugin/state_file.rb
50+@@ -11,8 +11,9 @@ module Vagrant
51+ # @return [Pathname] path to file
54+- def initialize(path)
55++ def initialize(path, system = false)
61+@@ -28,6 +29,21 @@ module Vagrant
63+ @data["version"] ||= "1"
64+ @data["installed"] ||= {}
68++ def load_extra_plugins
69++ extra_plugins = Dir.glob(@path.dirname.join('plugins.d', '*.json'))
70++ extra_plugins.each do |filename|
71++ json = File.read(filename)
73++ plugin_data = JSON.parse(json)
74++ @data["installed"].merge!(plugin_data)
75++ rescue JSON::ParserError => e
76++ raise Vagrant::Errors::PluginStateFileParseError,
77++ path: filename, message: e.message
82+ # Add a plugin that is installed to the state file.
83+@@ -107,6 +123,14 @@ module Vagrant
85+ FileUtils.mv(f.path, @path)
87++ rescue Errno::EACCES
88++ # Ignore permission denied against system-installed plugins; regular
89++ # users are not supposed to write there.
90++ raise unless @system
92++ # Ignore read-only filesystem against system-installed plugins; regular
93++ # users are not supposed to write there.
94++ raise unless @system