2
0
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-30 09:33:41 +00:00
nixpkgs/pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patch
Maximilian Bosch a26ffb006b
vagrant: 2.2.9 -> 2.2.10
ChangeLog: https://github.com/hashicorp/vagrant/blob/v2.2.10/CHANGELOG.md#2210-august-24-2020

Apart from the usual `gemset`-update the following patches were altered:

* Deprecation fix on ruby 2.6.5: was removed since the underlying issue
  was fixed upstream.
* 0004-Support-system-installed-plugins.patch: re-downloaded the rebased
  version from `salsa.debian.org`[1] where we originally obtained the patch
  from.
* use-system-bundler-version: re-applied on top of Vagrant 2.2.10.

[1] https://salsa.debian.org/ruby-team/vagrant/-/blob/9d86f222/debian/patches/0004-Support-system-installed-plugins.patch
2020-08-25 22:11:35 +02:00

94 lines
3.0 KiB
Diff

From: Antonio Terceiro <terceiro@debian.org>
Date: Wed, 27 May 2015 09:36:17 -0300
Subject: Support system-installed plugins
Source: https://salsa.debian.org/ruby-team/vagrant/-/blob/9d86f222/debian/patches/0004-Support-system-installed-plugins.patch
Plugins must be installed as regular Ruby libraries, and they must
contain /usr/share/vagrant-plugins/plugins.d/$PLUGINNAME.json with the
following content:
{
"${PLUGINNAME}": {
"ruby_version":"$(ruby -e 'puts RUBY_VERSION')",
"vagrant_version":"$(cat /usr/share/vagrant/version.txt)",
"gem_version":"",
"require":"",
"sources":[]
}
}
---
lib/vagrant/plugin/manager.rb | 4 ++--
lib/vagrant/plugin/state_file.rb | 22 +++++++++++++++++++++-
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb
index 9058e68..2772131 100644
--- a/lib/vagrant/plugin/manager.rb
+++ b/lib/vagrant/plugin/manager.rb
@@ -18,7 +18,7 @@ module Vagrant
# Returns the path to the [StateFile] for system plugins.
def self.system_plugins_file
- dir = Vagrant.installer_embedded_dir
+ dir = '@system_plugin_dir@'
return nil if !dir
Pathname.new(dir).join("plugins.json")
end
@@ -38,7 +38,7 @@ module Vagrant
system_path = self.class.system_plugins_file
@system_file = nil
- @system_file = StateFile.new(system_path) if system_path && system_path.file?
+ @system_file = StateFile.new(system_path, true) if system_path && system_path.file?
@local_file = nil
@globalized = @localized = false
diff --git a/lib/vagrant/plugin/state_file.rb b/lib/vagrant/plugin/state_file.rb
index c6872d4..935d431 100644
--- a/lib/vagrant/plugin/state_file.rb
+++ b/lib/vagrant/plugin/state_file.rb
@@ -11,8 +11,9 @@ module Vagrant
# @return [Pathname] path to file
attr_reader :path
- def initialize(path)
+ def initialize(path, system = false)
@path = path
+ @system = system
@data = {}
if @path.exist?
@@ -28,6 +29,21 @@ module Vagrant
@data["version"] ||= "1"
@data["installed"] ||= {}
+ load_extra_plugins
+ end
+
+ def load_extra_plugins
+ extra_plugins = Dir.glob(@path.dirname.join('plugins.d', '*.json'))
+ extra_plugins.each do |filename|
+ json = File.read(filename)
+ begin
+ plugin_data = JSON.parse(json)
+ @data["installed"].merge!(plugin_data)
+ rescue JSON::ParserError => e
+ raise Vagrant::Errors::PluginStateFileParseError,
+ path: filename, message: e.message
+ end
+ end
end
# Add a plugin that is installed to the state file.
@@ -107,6 +123,10 @@ module Vagrant
f.close
FileUtils.mv(f.path, @path)
end
+ rescue Errno::EACCES
+ # Ignore permission denied against system-installed plugins; regular
+ # users are not supposed to write there.
+ raise unless @system
end
protected