vagrant-bindfs 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/vagrant-bindfs/bindfs/command.rb +2 -2
- data/lib/vagrant-bindfs/bindfs/option_set.rb +23 -0
- data/lib/vagrant-bindfs/vagrant/actions/installer.rb +23 -16
- data/lib/vagrant-bindfs/vagrant/actions/mounter.rb +5 -3
- data/lib/vagrant-bindfs/vagrant/capabilities.rb +8 -0
- data/lib/vagrant-bindfs/vagrant/capabilities/all/bindfs.rb +12 -2
- data/lib/vagrant-bindfs/vagrant/capabilities/darwin/bindfs.rb +5 -0
- data/lib/vagrant-bindfs/vagrant/capabilities/debian/bindfs.rb +7 -0
- data/lib/vagrant-bindfs/vagrant/capabilities/redhat/bindfs.rb +5 -0
- data/lib/vagrant-bindfs/vagrant/capabilities/suse/bindfs.rb +5 -0
- data/lib/vagrant-bindfs/version.rb +1 -1
- data/locales/en.yml +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7592d35f88e63f1ffdb5b8af8f2d8b099ece93db
|
4
|
+
data.tar.gz: 89fffbd06beab56ba0259242cda9f447a62fba37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea36b98e9874197f57ec1b627c1035472acf6a129c087ce8758bb87b99e0212bd47b5dca53d3070e03e8b361f4e5373e3fdf9d47c49d80132104519f9cb650e6
|
7
|
+
data.tar.gz: fa7efd228f4afac3514cd096f4c93113de7d3f3b682c59fc0f1e2c9cd1670ce0a05737ad2424a977e1eac0dce72e2acb961e0de5a8fa80147996879d345a2f54
|
data/README.md
CHANGED
@@ -95,6 +95,9 @@ Both long arguments and shorthand are supported.
|
|
95
95
|
If you set both, shorthand will prevail.
|
96
96
|
Long arguments can be written indifferently with underscore ('force_user') or dash ('force-user') and as strings (:'force-user') or symbols (:force_user).
|
97
97
|
|
98
|
+
Option arguments values can be anything that can be casted to a string _via_ `to_s`.
|
99
|
+
The plugin will try to detect flag arguments values as true or false from common notations.
|
100
|
+
|
98
101
|
vagrant-bindfs detects installed version of bindfs, translate option names when needed and ignore an option if it is not supported.
|
99
102
|
As we may have missed something, it will warn you when a binding command fail.
|
100
103
|
|
@@ -8,8 +8,8 @@ module VagrantBindfs
|
|
8
8
|
@folder = folder
|
9
9
|
end
|
10
10
|
|
11
|
-
def to_s
|
12
|
-
[
|
11
|
+
def to_s(bindfs_command = 'bindfs')
|
12
|
+
[bindfs_command, arguments_for(folder.options).join(' '), folder.source, folder.destination].compact.join(' ')
|
13
13
|
end
|
14
14
|
|
15
15
|
protected
|
@@ -23,13 +23,16 @@ module VagrantBindfs
|
|
23
23
|
|
24
24
|
extract_invalid_options!
|
25
25
|
extract_unsupported_options!
|
26
|
+
cast_option_values!
|
26
27
|
end
|
27
28
|
|
28
29
|
def merge!(other)
|
29
30
|
other = other.to_version(version) if other.respond_to?(:to_version)
|
30
31
|
@options.merge!(normalize_option_names(other))
|
32
|
+
|
31
33
|
extract_invalid_options!
|
32
34
|
extract_unsupported_options!
|
35
|
+
cast_option_values!
|
33
36
|
end
|
34
37
|
|
35
38
|
def merge(other)
|
@@ -77,6 +80,26 @@ module VagrantBindfs
|
|
77
80
|
names.each { |name| to[name] = @options.delete(name) }
|
78
81
|
end
|
79
82
|
|
83
|
+
def cast_option_values!
|
84
|
+
@options = options.each_with_object({}) do |(key, value), normalized|
|
85
|
+
normalized[key] = case self.class.bindfs_options[key]['type']
|
86
|
+
when 'option' then cast_value_as_option(value)
|
87
|
+
when 'flag' then cast_value_as_flag(value)
|
88
|
+
end
|
89
|
+
normalized
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def cast_value_as_option(value)
|
94
|
+
(value.respond_to?(:to_s) ? value.to_s : value)
|
95
|
+
end
|
96
|
+
|
97
|
+
def cast_value_as_flag(value)
|
98
|
+
return true if [true, 'true', 'True', 'yes', 'Yes', 'y', 'Y', 'on', 'On', 1].include?(value)
|
99
|
+
return false if [false, 'false', 'False', 'no', 'No', 'n', 'N', 'off', 'Off', 0].include?(value)
|
100
|
+
!!value
|
101
|
+
end
|
102
|
+
|
80
103
|
class << self
|
81
104
|
def bindfs_options
|
82
105
|
@bindfs_options ||= JSON.parse(File.read(File.expand_path('../option_definitions.json', __FILE__)))
|
@@ -66,33 +66,40 @@ module VagrantBindfs
|
|
66
66
|
def ensure_bindfs_is_installed!
|
67
67
|
unless guest.capability(:bindfs_bindfs_installed)
|
68
68
|
warn(I18n.t('vagrant-bindfs.actions.bindfs.not_installed'))
|
69
|
-
|
70
|
-
case true
|
71
|
-
when config.install_bindfs_from_source
|
72
|
-
install_bindfs_from_source!
|
73
|
-
|
74
|
-
when config.bindfs_version == :latest
|
75
|
-
guest.capability(:bindfs_bindfs_install)
|
76
|
-
|
77
|
-
when config.bindfs_version != :latest && guest.capability(:bindfs_bindfs_search_version, config.bindfs_version)
|
78
|
-
guest.capability(:bindfs_bindfs_install_version, config.bindfs_version)
|
79
|
-
|
80
|
-
else
|
81
|
-
warn(I18n.t('vagrant-bindfs.actions.bindfs.not_found_in_repository',
|
82
|
-
version: config.bindfs_version))
|
83
|
-
install_bindfs_from_source!
|
84
|
-
end
|
69
|
+
install_bindfs!
|
85
70
|
end
|
86
71
|
|
87
72
|
detail(I18n.t('vagrant-bindfs.actions.bindfs.detected',
|
88
73
|
version: guest.capability(:bindfs_bindfs_version)))
|
89
74
|
end
|
90
75
|
|
76
|
+
def install_bindfs!
|
77
|
+
return install_bindfs_from_source! if install_from_source?
|
78
|
+
return guest.capability(:bindfs_bindfs_install) if install_latest_from_repositories?
|
79
|
+
return guest.capability(:bindfs_bindfs_install_version, config.bindfs_version) if install_version_from_repositories?
|
80
|
+
|
81
|
+
warn(I18n.t('vagrant-bindfs.actions.bindfs.not_found_in_repository',
|
82
|
+
version: config.bindfs_version))
|
83
|
+
install_bindfs_from_source!
|
84
|
+
end
|
85
|
+
|
91
86
|
def install_bindfs_from_source!
|
92
87
|
version = (config.bindfs_version == :latest ? VagrantBindfs::Bindfs::SOURCE_VERSION : config.bindfs_version.to_s)
|
93
88
|
guest.capability(:bindfs_bindfs_install_compilation_requirements)
|
94
89
|
guest.capability(:bindfs_bindfs_install_from_source, version)
|
95
90
|
end
|
91
|
+
|
92
|
+
def install_from_source?
|
93
|
+
config.install_bindfs_from_source
|
94
|
+
end
|
95
|
+
|
96
|
+
def install_latest_from_repositories?
|
97
|
+
config.bindfs_version == :latest && guest.capability(:bindfs_bindfs_search)
|
98
|
+
end
|
99
|
+
|
100
|
+
def install_version_from_repositories?
|
101
|
+
config.bindfs_version != :latest && guest.capability(:bindfs_bindfs_search_version, config.bindfs_version)
|
102
|
+
end
|
96
103
|
end
|
97
104
|
end
|
98
105
|
end
|
@@ -26,7 +26,9 @@ module VagrantBindfs
|
|
26
26
|
|
27
27
|
def bind_folders!
|
28
28
|
info I18n.t('vagrant-bindfs.actions.mounter.start', hook: hook)
|
29
|
-
|
29
|
+
|
30
|
+
bindfs_version = guest.capability(:bindfs_bindfs_version)
|
31
|
+
bindfs_full_path = guest.capability(:bindfs_bindfs_full_path)
|
30
32
|
|
31
33
|
binded_folders(hook).each do |_, folder|
|
32
34
|
folder.reverse_merge!(config.default_options)
|
@@ -54,8 +56,8 @@ module VagrantBindfs
|
|
54
56
|
|
55
57
|
machine.communicate.tap do |comm|
|
56
58
|
comm.sudo("mkdir -p #{folder.destination}")
|
57
|
-
comm.sudo(command.to_s, error_class: VagrantBindfs::Vagrant::Error, error_key: 'bindfs.mount_failed')
|
58
|
-
debug(command.to_s)
|
59
|
+
comm.sudo(command.to_s(bindfs_full_path), error_class: VagrantBindfs::Vagrant::Error, error_key: 'bindfs.mount_failed')
|
60
|
+
debug(command.to_s(bindfs_full_path))
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
@@ -73,12 +73,20 @@ module VagrantBindfs
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def declare_capabilities_for_bindfs!(base)
|
76
|
+
base.guest_capability('darwin', 'bindfs_bindfs_full_path') { Capabilities::All::Bindfs }
|
77
|
+
base.guest_capability('linux', 'bindfs_bindfs_full_path') { Capabilities::All::Bindfs }
|
78
|
+
|
76
79
|
base.guest_capability('darwin', 'bindfs_bindfs_installed') { Capabilities::All::Bindfs }
|
77
80
|
base.guest_capability('linux', 'bindfs_bindfs_installed') { Capabilities::All::Bindfs }
|
78
81
|
|
79
82
|
base.guest_capability('darwin', 'bindfs_bindfs_version') { Capabilities::All::Bindfs }
|
80
83
|
base.guest_capability('linux', 'bindfs_bindfs_version') { Capabilities::All::Bindfs }
|
81
84
|
|
85
|
+
base.guest_capability('darwin', 'bindfs_bindfs_search') { Capabilities::Darwin::Bindfs }
|
86
|
+
base.guest_capability('debian', 'bindfs_bindfs_search') { Capabilities::Debian::Bindfs }
|
87
|
+
base.guest_capability('redhat', 'bindfs_bindfs_search') { Capabilities::RedHat::Bindfs }
|
88
|
+
base.guest_capability('suse', 'bindfs_bindfs_search') { Capabilities::Suse::Bindfs }
|
89
|
+
|
82
90
|
base.guest_capability('darwin', 'bindfs_bindfs_install') { Capabilities::Darwin::Bindfs }
|
83
91
|
base.guest_capability('debian', 'bindfs_bindfs_install') { Capabilities::Debian::Bindfs }
|
84
92
|
base.guest_capability('redhat', 'bindfs_bindfs_install') { Capabilities::RedHat::Bindfs }
|
@@ -5,12 +5,22 @@ module VagrantBindfs
|
|
5
5
|
module All
|
6
6
|
module Bindfs
|
7
7
|
class << self
|
8
|
+
def bindfs_bindfs_full_path(machine)
|
9
|
+
machine.communicate.execute('type bindfs | cut -d" " -f3') do |_, output|
|
10
|
+
path = output.strip
|
11
|
+
return path unless path.empty?
|
12
|
+
end
|
13
|
+
'bindfs'
|
14
|
+
end
|
15
|
+
|
8
16
|
def bindfs_bindfs_installed(machine)
|
9
|
-
machine.
|
17
|
+
bindfs_full_path = machine.guest.capability(:bindfs_bindfs_full_path)
|
18
|
+
machine.communicate.test("#{bindfs_full_path} --help")
|
10
19
|
end
|
11
20
|
|
12
21
|
def bindfs_bindfs_version(machine)
|
13
|
-
|
22
|
+
bindfs_full_path = machine.guest.capability(:bindfs_bindfs_full_path)
|
23
|
+
[%(sudo #{bindfs_full_path} --version | cut -d" " -f2), %(sudo -i #{bindfs_full_path} --version | cut -d" " -f2)].each do |command|
|
14
24
|
machine.communicate.execute(command) do |_, output|
|
15
25
|
version = output.strip
|
16
26
|
return Gem::Version.new(version) if !version.empty? && Gem::Version.correct?(version)
|
@@ -5,6 +5,11 @@ module VagrantBindfs
|
|
5
5
|
module Darwin
|
6
6
|
module Bindfs
|
7
7
|
class << self
|
8
|
+
# Homebrew only use its own github repositories
|
9
|
+
def bindfs_bindfs_search(_machine)
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
8
13
|
def bindfs_bindfs_install(machine)
|
9
14
|
machine.guest.capability(:bindfs_package_manager_update)
|
10
15
|
machine.communicate.execute('brew install homebrew/fuse/bindfs')
|
@@ -5,6 +5,11 @@ module VagrantBindfs
|
|
5
5
|
module Debian
|
6
6
|
module Bindfs
|
7
7
|
class << self
|
8
|
+
def bindfs_bindfs_search(machine)
|
9
|
+
machine.guest.capability(:bindfs_package_manager_update)
|
10
|
+
machine.communicate.test('[[ $(sudo apt-cache search bindfs | egrep "^bindfs - " | wc -l) != 0 ]]')
|
11
|
+
end
|
12
|
+
|
8
13
|
def bindfs_bindfs_install(machine)
|
9
14
|
machine.guest.capability(:bindfs_package_manager_update)
|
10
15
|
machine.communicate.sudo('apt-get install -y bindfs')
|
@@ -13,6 +18,8 @@ module VagrantBindfs
|
|
13
18
|
def bindfs_bindfs_search_version(machine, version)
|
14
19
|
machine.guest.capability(:bindfs_package_manager_update)
|
15
20
|
machine.communicate.tap do |comm|
|
21
|
+
# Ensure aptitude is installed as Ubuntu removed it
|
22
|
+
comm.sudo('apt-get install aptitude')
|
16
23
|
comm.sudo("aptitude versions bindfs | sed -n '/p/,${p}' | sed 's/\s\+/ /g' | cut -d' ' -f2") do |_, output|
|
17
24
|
package_version = output.strip
|
18
25
|
return "bindfs-#{package_version}" if !package_version.empty? && !package_version.match(/^#{version}/).nil?
|
@@ -5,6 +5,11 @@ module VagrantBindfs
|
|
5
5
|
module RedHat
|
6
6
|
module Bindfs
|
7
7
|
class << self
|
8
|
+
def bindfs_bindfs_search(machine)
|
9
|
+
machine.guest.capability(:bindfs_package_manager_update)
|
10
|
+
machine.communicate.test('[[ $(yum search bindfs 2>/dev/null | tail -n1) != "No matches found" ]]')
|
11
|
+
end
|
12
|
+
|
8
13
|
def bindfs_bindfs_install(machine)
|
9
14
|
machine.guest.capability(:bindfs_package_manager_update)
|
10
15
|
machine.communicate.sudo('yum -y install bindfs')
|
@@ -5,6 +5,11 @@ module VagrantBindfs
|
|
5
5
|
module Suse
|
6
6
|
module Bindfs
|
7
7
|
class << self
|
8
|
+
def bindfs_bindfs_search(machine)
|
9
|
+
machine.guest.capability(:bindfs_package_manager_update)
|
10
|
+
machine.communicate.test('zypper se -s bindfs')
|
11
|
+
end
|
12
|
+
|
8
13
|
def bindfs_bindfs_install(machine)
|
9
14
|
machine.guest.capability(:bindfs_package_manager_update)
|
10
15
|
machine.communicate.sudo('zypper -n install bindfs')
|
data/locales/en.yml
CHANGED
@@ -11,7 +11,7 @@ en:
|
|
11
11
|
fuse:
|
12
12
|
not_installed: "Fuse seems to not be installed on the virtual machine, installing now"
|
13
13
|
installed: "Fuse kernel module is installed"
|
14
|
-
not_loaded: "Fuse kernel module seems to be not loaded
|
14
|
+
not_loaded: "Fuse kernel module seems to be not loaded on the virtual machine, loading now"
|
15
15
|
loaded: "Fuse kernel module is loaded"
|
16
16
|
bindfs:
|
17
17
|
not_installed: "Bindfs seems to not be installed on the virtual machine, installing now"
|
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.
|
4
|
+
version: 1.0.2
|
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: 2016-12-
|
13
|
+
date: 2016-12-16 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
|