python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / tools / vagrant / 0004-Support-system-installed-plugins.patch
blobfa6555c594efa7d0e60eb25a0c52b5e8da56709b
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/9d86f222/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
8 following content:
11 "${PLUGINNAME}": {
12 "ruby_version":"$(ruby -e 'puts RUBY_VERSION')",
13 "vagrant_version":"$(cat /usr/share/vagrant/version.txt)",
14 "gem_version":"",
15 "require":"",
16 "sources":[]
19 ---
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 9058e68..2772131 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@'
34 return nil if !dir
35 Pathname.new(dir).join("plugins.json")
36 end
37 @@ -38,7 +38,7 @@ module Vagrant
39 system_path = self.class.system_plugins_file
40 @system_file = nil
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?
44 @local_file = nil
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
52 attr_reader :path
54 - def initialize(path)
55 + def initialize(path, system = false)
56 @path = path
57 + @system = system
59 @data = {}
60 if @path.exist?
61 @@ -28,6 +29,21 @@ module Vagrant
63 @data["version"] ||= "1"
64 @data["installed"] ||= {}
65 + load_extra_plugins
66 + end
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)
72 + begin
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
78 + end
79 + end
80 end
82 # Add a plugin that is installed to the state file.
83 @@ -107,6 +123,10 @@ module Vagrant
84 f.close
85 FileUtils.mv(f.path, @path)
86 end
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
91 end
93 protected