vagrant-bindfs 1.0.11 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ea2b8920c39f6a2706fb6961e59b10821986ef0
4
- data.tar.gz: d03fb93229d6e9bb52b261061a51d18b6a679246
3
+ metadata.gz: 8fc17d7b8bc6dadfe52d9b702d4761b473cbc388
4
+ data.tar.gz: 760d7bb79eb8ca7fa4efac3fe772672c6ea316f4
5
5
  SHA512:
6
- metadata.gz: fe917a556f92d71713ca398329d2bd54ff6c7e87023125f14641ac868448d34087dfd887c67b377e9753ca1a3bceacd52dc10484713f94bd869106b5ed17a693
7
- data.tar.gz: da6e2822e63a035c565f027247a7931f7b9424e25c365efd54db4ba531b5ae7f6b66b0081f6ef807c8ca03604269ce0d35e1fed421b46dba55d15c4289bde63d
6
+ metadata.gz: 1ecf98c2bf3ed2ab3c717223681a00392080fbd6277f9da19e9a939076cee4b7de69c230902f82fe1d7646de31e3e813b6944d26664c6ebf6124ae92aa5f6841
7
+ data.tar.gz: 0382d20c459d060917cfc7524b60c3e951f424869eab452210013280bf4ed7aa7f87e6543a4fcee41562e1b1970e9bb41cc6f58554c561f0c4be1a713b48cc2f
data/README.md CHANGED
@@ -101,7 +101,7 @@ The plugin will try to detect flag arguments values as true or false from common
101
101
  vagrant-bindfs detects installed version of bindfs, translate option names when needed and ignore an option if it is not supported.
102
102
  As we may have missed something, it will warn you when a binding command fail.
103
103
 
104
- On Debian (this includes Ubuntu), SUSE, Fedora, CentOS (5-6) and OS X guest systems, vagrant-bindfs will try to install bindfs automatically if it is not installed.
104
+ On Debian (this includes Ubuntu), SUSE, Fedora, CentOS (5-6), Gentoo and OS X guest systems, vagrant-bindfs will try to install bindfs automatically if it is not installed.
105
105
  On other system, you'll get warned.
106
106
 
107
107
  OS X guests may need some specific options. See [bindfs README](https://github.com/mpartel/bindfs#os-x-note) for details.
@@ -171,6 +171,34 @@ end
171
171
  **This feature only works with exact version match and does not try to resolve dependencies.**
172
172
  In particular, Fuse will always be installed from the latest version available in repositories (_via_ Homebrew Cask for OS X guests).
173
173
 
174
+ ### `force_empty_mountpoints`
175
+
176
+ By default, `vagrant-bindfs` won't try to empty an existing mount point before mount. Hence, if you try to bind a folder to a non-empty directory without explicitly allowing Fuse to do so (with the `nonempty` Fuse option), mount will fail.
177
+
178
+ You can ask `vagrant-bindfs` to make sure the mount points are empty with the `config.bindfs.force_empty_mountpoints` option.
179
+ Mount poitns will then be destroyed (with `rm -rf`) prior to mount, unless you allow Fuse to not mind (with the `nonempty` Fuse option).
180
+
181
+
182
+ ```ruby
183
+ Vagrant.configure("2") do |config|
184
+
185
+ config.bindfs.force_empty_mountpoint = true
186
+
187
+ # This exemple assume two directories exist in your VM:
188
+ # - `a/non/empty/mount/point/and/its/content`
189
+ # - `another/non/empty/mount/point/and/its/content`
190
+
191
+ # `a/non/empty/mount/point` will be destroyed before mount and
192
+ # all its content will be lost.
193
+ config.bindfs.bind_folder "/vagrant", "a/non/empty/mount/point"
194
+
195
+ # `a/non/empty/mount/point` will not be destroyed before mount
196
+ # but its content will not be accessible while in use by bindfs.
197
+ config.bindfs.bind_folder "/vagrant", "a/non/empty/mount/point", o: :nonempty
198
+
199
+ end
200
+ ```
201
+
174
202
  ## Contributing
175
203
 
176
204
  If you find this plugin useful, we could use a few enhancements!
data/Vagrantfile CHANGED
@@ -35,6 +35,7 @@ Vagrant.configure('2') do |config|
35
35
 
36
36
  # For a more detailled output when you test, set this to true.
37
37
  config.bindfs.debug = false
38
+ config.bindfs.force_empty_mountpoints = true
38
39
 
39
40
  test_machines.each do |distro, options|
40
41
  config.vm.define "vagrant-bindfs-test-#{distro}" do |machine|
@@ -2,7 +2,7 @@
2
2
 
3
3
  module VagrantBindfs
4
4
  module Bindfs
5
- SOURCE_VERSION = '1.13.9'.freeze
5
+ SOURCE_VERSION = '1.13.9'
6
6
  SOURCE_URLS = [
7
7
  'http://bindfs.org/downloads/bindfs-%<bindfs_version>.tar.gz',
8
8
  'http://bindfs.dy.fi/downloads/bindfs-%<bindfs_version>.tar.gz'
@@ -27,41 +27,75 @@ module VagrantBindfs
27
27
 
28
28
  def bind_folders!
29
29
  info I18n.t('vagrant-bindfs.actions.mounter.start', hook: hook)
30
+ binded_folders(hook).each_value do |folder|
31
+ bind_folder!(folder)
32
+ end
33
+ end
30
34
 
31
- bindfs_version = guest.capability(:bindfs_bindfs_version)
32
- bindfs_full_path = guest.capability(:bindfs_bindfs_full_path)
35
+ def bind_folder!(folder)
36
+ folder.reverse_merge!(config.default_options)
37
+ folder.to_version!(bindfs_version)
33
38
 
34
- binded_folders(hook).each_value do |folder|
35
- folder.reverse_merge!(config.default_options)
36
- folder.to_version!(bindfs_version)
37
-
38
- validator = VagrantBindfs::Bindfs::Validators::Runtime.new(folder, machine)
39
-
40
- unless validator.valid?
41
- error I18n.t(
42
- 'vagrant-bindfs.validations.errors_found',
43
- dest: folder.destination,
44
- source: folder.source,
45
- errors: validator.errors.join(' ')
46
- )
47
- next
48
- end
49
-
50
- command = VagrantBindfs::Bindfs::Command.new(folder)
51
-
52
- detail I18n.t(
53
- 'vagrant-bindfs.actions.mounter.entry',
54
- dest: folder.destination,
55
- source: folder.source
56
- )
57
-
58
- machine.communicate.tap do |comm|
59
- comm.sudo("mkdir -p #{folder.destination}")
60
- comm.sudo(command.to_s(bindfs_full_path), error_class: VagrantBindfs::Vagrant::Error, error_key: 'bindfs.mount_failed')
61
- debug(command.to_s(bindfs_full_path))
62
- end
39
+ return unless valid_folder?(folder)
40
+
41
+ machine.communicate.tap do |comm|
42
+ empty_mountpoint!(comm, folder) if empty_mountpoint?(folder)
43
+ ensure_mountpoint_exists!(comm, folder)
44
+ execute_bind_command!(comm, folder)
63
45
  end
64
46
  end
47
+
48
+ def valid_folder?(folder)
49
+ validator = VagrantBindfs::Bindfs::Validators::Runtime.new(folder, machine)
50
+ return true if validator.valid?
51
+
52
+ error I18n.t(
53
+ 'vagrant-bindfs.validations.errors_found',
54
+ dest: folder.destination,
55
+ source: folder.source,
56
+ errors: validator.errors.join(' ')
57
+ )
58
+ false
59
+ end
60
+
61
+ def empty_mountpoint?(folder)
62
+ return false unless config.force_empty_mountpoints
63
+ return false if folder.options.key?('o') && !folder.options['o'].match(/nonempty/).nil?
64
+ true
65
+ end
66
+
67
+ def empty_mountpoint!(comm, folder)
68
+ detail I18n.t(
69
+ 'vagrant-bindfs.actions.mounter.force_empty_mountpoints',
70
+ dest: folder.destination
71
+ )
72
+
73
+ comm.sudo("rm -rf #{folder.destination}")
74
+ end
75
+
76
+ def ensure_mountpoint_exists!(comm, folder)
77
+ comm.sudo("mkdir -p #{folder.destination}")
78
+ end
79
+
80
+ def execute_bind_command!(comm, folder)
81
+ detail I18n.t(
82
+ 'vagrant-bindfs.actions.mounter.entry',
83
+ dest: folder.destination,
84
+ source: folder.source
85
+ )
86
+
87
+ command = VagrantBindfs::Bindfs::Command.new(folder)
88
+ comm.sudo(command.to_s(bindfs_full_path), error_class: VagrantBindfs::Vagrant::Error, error_key: 'bindfs.mount_failed')
89
+ debug(command.to_s(bindfs_full_path))
90
+ end
91
+
92
+ def bindfs_version
93
+ @bindfs_version ||= guest.capability(:bindfs_bindfs_version)
94
+ end
95
+
96
+ def bindfs_full_path
97
+ @bindfs_full_path ||= guest.capability(:bindfs_bindfs_full_path)
98
+ end
65
99
  end
66
100
  end
67
101
  end
@@ -12,6 +12,7 @@ module VagrantBindfs
12
12
  attr_accessor :binded_folders
13
13
 
14
14
  attr_accessor :skip_validations
15
+ attr_reader :force_empty_mountpoints
15
16
 
16
17
  def initialize
17
18
  @debug = false
@@ -26,6 +27,7 @@ module VagrantBindfs
26
27
  'perms' => 'u=rwX:g=rD:o=rD')
27
28
 
28
29
  @skip_validations = []
30
+ @force_empty_mountpoints = false
29
31
  end
30
32
 
31
33
  def debug=(value)
@@ -44,6 +46,10 @@ module VagrantBindfs
44
46
  @default_options = Bindfs::OptionSet.new(nil, options)
45
47
  end
46
48
 
49
+ def force_empty_mountpoints=(value)
50
+ @force_empty_mountpoints = (value == true)
51
+ end
52
+
47
53
  def binded_folder=(*_any_variant)
48
54
  raise VagrantBindfs::Vagrant::ConfigError, :binded_folders
49
55
  end
@@ -66,6 +72,7 @@ module VagrantBindfs
66
72
  result.binded_folders = binded_folders.merge(other.binded_folders)
67
73
 
68
74
  result.skip_validations = (skip_validations + other.skip_validations).uniq
75
+ result.force_empty_mountpoints = (force_empty_mountpoints || other.force_empty_mountpoints)
69
76
  end
70
77
  end
71
78
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VagrantBindfs
4
- VERSION = '1.0.11'.freeze
4
+ VERSION = '1.1.0'
5
5
  end
data/locales/en.yml CHANGED
@@ -20,6 +20,7 @@ en:
20
20
  mounter:
21
21
  start: "Creating bind mounts after %{hook}..."
22
22
  entry: "%{source} => %{dest}"
23
+ force_empty_mountpoints: "All content in '%{dest}' as been removed before mount"
23
24
 
24
25
 
25
26
  validations:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-bindfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaël-Ian Havard
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-12-20 00:00:00.000000000 Z
13
+ date: 2018-01-30 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: " A Vagrant plugin to automate bindfs mount in the VM. This allow you
16
16
  to change owner, group and permissions on files and, for example, work around NFS