git.iko.soy/typeable/nixpkgs
on master help sign in
vagrant: Support system-installed plugins
08488bcMatthew Harm Bekkema
pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patchnew file+97
@@ -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
5+
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:
9+
10+{
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":[]
17+ }
18+}
19+---
20+ lib/vagrant/plugin/manager.rb | 4 ++--
21+ lib/vagrant/plugin/state_file.rb | 22 +++++++++++++++++++++-
22+ 2 files changed, 23 insertions(+), 3 deletions(-)
23+
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
29+
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
38+
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?
43+
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
53+
54+- def initialize(path)
55++ def initialize(path, system = false)
56+ @path = path
57++ @system = system
58+
59+ @data = {}
60+ if @path.exist?
61+@@ -28,6 +29,21 @@ module Vagrant
62+
63+ @data["version"] ||= "1"
64+ @data["installed"] ||= {}
65++ load_extra_plugins
66++ end
67++
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
81+
82+ # Add a plugin that is installed to the state file.
83+@@ -107,6 +123,14 @@ 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++ rescue Errno::EROFS
92++ # Ignore read-only filesystem against system-installed plugins; regular
93++ # users are not supposed to write there.
94++ raise unless @system
95+ end
96+
97+ protected
pkgs/development/tools/vagrant/default.nix+9
@@ -40,8 +40,14 @@ in buildRubyGem rec {
40 patches = [
40 patches = [
41 ./unofficial-installation-nowarn.patch
41 ./unofficial-installation-nowarn.patch
42 ./use-system-bundler-version.patch
42 ./use-system-bundler-version.patch
43+ ./0004-Support-system-installed-plugins.patch
43 ];
44 ];
44
45
46+ postPatch = ''
47+ substituteInPlace lib/vagrant/plugin/manager.rb --subst-var-by \
48+ system_plugin_dir "$out/vagrant-plugins"
49+ '';
50+
45 # PATH additions:
51 # PATH additions:
46 # - libarchive: Make `bsdtar` available for extracting downloaded boxes
52 # - libarchive: Make `bsdtar` available for extracting downloaded boxes
47 postInstall = ''
53 postInstall = ''
@@ -53,6 +59,9 @@ in buildRubyGem rec {
53 --prefix PKG_CONFIG_PATH ':' \
59 --prefix PKG_CONFIG_PATH ':' \
54 "${lib.makeSearchPath "lib/pkgconfig" [ libvirt ]}"
60 "${lib.makeSearchPath "lib/pkgconfig" [ libvirt ]}"
55 ''}
61 ''}
62+
63+ mkdir -p "$out/vagrant-plugins/plugins.d"
64+ echo '{}' > "$out/vagrant-plugins/plugins.json"
56 '';
65 '';
57
66
58 installCheckPhase = ''
67 installCheckPhase = ''