diff options
author | Matthew Harm Bekkema <mbekkema97@gmail.com> | 2018-12-17 10:51:30 +1100 |
---|---|---|
committer | Matthew Harm Bekkema <mbekkema97@gmail.com> | 2018-12-17 21:53:23 +1100 |
commit | 08488bcf946ed7bfa004d0c6fb128c3622493beb (patch) | |
tree | ae1773cdf5cd92b159d84dbb81b2e4c21466b3e5 /pkgs/development/tools/vagrant | |
parent | 1183ee645df7fb0a8e3b9411201c62ba6033675b (diff) | |
download | nixlib-08488bcf946ed7bfa004d0c6fb128c3622493beb.tar nixlib-08488bcf946ed7bfa004d0c6fb128c3622493beb.tar.gz nixlib-08488bcf946ed7bfa004d0c6fb128c3622493beb.tar.bz2 nixlib-08488bcf946ed7bfa004d0c6fb128c3622493beb.tar.lz nixlib-08488bcf946ed7bfa004d0c6fb128c3622493beb.tar.xz nixlib-08488bcf946ed7bfa004d0c6fb128c3622493beb.tar.zst nixlib-08488bcf946ed7bfa004d0c6fb128c3622493beb.zip |
vagrant: Support system-installed plugins
Patch taken from Debian
Diffstat (limited to 'pkgs/development/tools/vagrant')
-rw-r--r-- | pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patch | 97 | ||||
-rw-r--r-- | pkgs/development/tools/vagrant/default.nix | 9 |
2 files changed, 106 insertions, 0 deletions
diff --git a/pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patch b/pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patch new file mode 100644 index 000000000000..f87ff5135b3f --- /dev/null +++ b/pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patch @@ -0,0 +1,97 @@ +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/cb672c6dc0c63f6552c5ec4d6d7d22929d353503/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 567347d..d9d76a0 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,14 @@ 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 ++ rescue Errno::EROFS ++ # Ignore read-only filesystem against system-installed plugins; regular ++ # users are not supposed to write there. ++ raise unless @system + end + + protected diff --git a/pkgs/development/tools/vagrant/default.nix b/pkgs/development/tools/vagrant/default.nix index 74992560f3fc..cdfdb9077a37 100644 --- a/pkgs/development/tools/vagrant/default.nix +++ b/pkgs/development/tools/vagrant/default.nix @@ -40,8 +40,14 @@ in buildRubyGem rec { patches = [ ./unofficial-installation-nowarn.patch ./use-system-bundler-version.patch + ./0004-Support-system-installed-plugins.patch ]; + postPatch = '' + substituteInPlace lib/vagrant/plugin/manager.rb --subst-var-by \ + system_plugin_dir "$out/vagrant-plugins" + ''; + # PATH additions: # - libarchive: Make `bsdtar` available for extracting downloaded boxes postInstall = '' @@ -53,6 +59,9 @@ in buildRubyGem rec { --prefix PKG_CONFIG_PATH ':' \ "${lib.makeSearchPath "lib/pkgconfig" [ libvirt ]}" ''} + + mkdir -p "$out/vagrant-plugins/plugins.d" + echo '{}' > "$out/vagrant-plugins/plugins.json" ''; installCheckPhase = '' |