vagrant-bindfs 0.4.14 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +66 -4
  3. data/Rakefile +11 -7
  4. data/Vagrantfile +10 -8
  5. data/lib/vagrant-bindfs.rb +10 -16
  6. data/lib/vagrant-bindfs/bindfs.rb +15 -0
  7. data/lib/vagrant-bindfs/bindfs/command.rb +47 -0
  8. data/lib/vagrant-bindfs/bindfs/folder.rb +38 -0
  9. data/lib/vagrant-bindfs/bindfs/option_definitions.json +67 -0
  10. data/lib/vagrant-bindfs/bindfs/option_set.rb +105 -0
  11. data/lib/vagrant-bindfs/bindfs/validators.rb +9 -0
  12. data/lib/vagrant-bindfs/bindfs/validators/config.rb +58 -0
  13. data/lib/vagrant-bindfs/bindfs/validators/runtime.rb +56 -0
  14. data/lib/vagrant-bindfs/vagrant.rb +12 -0
  15. data/lib/vagrant-bindfs/vagrant/actions.rb +11 -0
  16. data/lib/vagrant-bindfs/vagrant/actions/concerns.rb +11 -0
  17. data/lib/vagrant-bindfs/vagrant/actions/concerns/log.rb +34 -0
  18. data/lib/vagrant-bindfs/vagrant/actions/concerns/machine.rb +31 -0
  19. data/lib/vagrant-bindfs/vagrant/actions/installer.rb +99 -0
  20. data/lib/vagrant-bindfs/vagrant/actions/mounter.rb +65 -0
  21. data/lib/vagrant-bindfs/vagrant/capabilities.rb +108 -0
  22. data/lib/vagrant-bindfs/vagrant/capabilities/all.rb +12 -0
  23. data/lib/vagrant-bindfs/vagrant/capabilities/all/bindfs.rb +53 -0
  24. data/lib/vagrant-bindfs/vagrant/capabilities/all/package_manager.rb +17 -0
  25. data/lib/vagrant-bindfs/vagrant/capabilities/all/system_checks.rb +20 -0
  26. data/lib/vagrant-bindfs/vagrant/capabilities/darwin.rb +13 -0
  27. data/lib/vagrant-bindfs/vagrant/capabilities/darwin/bindfs.rb +33 -0
  28. data/lib/vagrant-bindfs/vagrant/capabilities/darwin/fuse.rb +32 -0
  29. data/lib/vagrant-bindfs/vagrant/capabilities/darwin/package_manager.rb +24 -0
  30. data/lib/vagrant-bindfs/{cap/darwin/checks.rb → vagrant/capabilities/darwin/system_checks.rb} +7 -8
  31. data/lib/vagrant-bindfs/vagrant/capabilities/debian.rb +12 -0
  32. data/lib/vagrant-bindfs/vagrant/capabilities/debian/bindfs.rb +39 -0
  33. data/lib/vagrant-bindfs/vagrant/capabilities/debian/fuse.rb +16 -0
  34. data/lib/vagrant-bindfs/vagrant/capabilities/debian/package_manager.rb +20 -0
  35. data/lib/vagrant-bindfs/vagrant/capabilities/linux.rb +12 -0
  36. data/lib/vagrant-bindfs/vagrant/capabilities/linux/fuse.rb +24 -0
  37. data/lib/vagrant-bindfs/vagrant/capabilities/linux/package_manager.rb +16 -0
  38. data/lib/vagrant-bindfs/vagrant/capabilities/linux/system_checks.rb +26 -0
  39. data/lib/vagrant-bindfs/vagrant/capabilities/redhat.rb +12 -0
  40. data/lib/vagrant-bindfs/vagrant/capabilities/redhat/bindfs.rb +39 -0
  41. data/lib/vagrant-bindfs/vagrant/capabilities/redhat/fuse.rb +17 -0
  42. data/lib/vagrant-bindfs/vagrant/capabilities/redhat/package_manager.rb +20 -0
  43. data/lib/vagrant-bindfs/vagrant/capabilities/suse.rb +12 -0
  44. data/lib/vagrant-bindfs/vagrant/capabilities/suse/bindfs.rb +41 -0
  45. data/lib/vagrant-bindfs/vagrant/capabilities/suse/fuse.rb +17 -0
  46. data/lib/vagrant-bindfs/vagrant/capabilities/suse/package_manager.rb +20 -0
  47. data/lib/vagrant-bindfs/vagrant/capabilities/ubuntu.rb +10 -0
  48. data/lib/vagrant-bindfs/vagrant/capabilities/ubuntu/fuse.rb +23 -0
  49. data/lib/vagrant-bindfs/vagrant/config.rb +86 -0
  50. data/lib/vagrant-bindfs/vagrant/errors.rb +12 -0
  51. data/lib/vagrant-bindfs/vagrant/plugin.rb +43 -0
  52. data/lib/vagrant-bindfs/version.rb +3 -12
  53. data/locales/en.yml +71 -26
  54. metadata +48 -23
  55. data/lib/vagrant-bindfs/bind.rb +0 -109
  56. data/lib/vagrant-bindfs/cap/all/bindfs_installed.rb +0 -17
  57. data/lib/vagrant-bindfs/cap/all/checks.rb +0 -17
  58. data/lib/vagrant-bindfs/cap/darwin/fuse_loaded.rb +0 -19
  59. data/lib/vagrant-bindfs/cap/darwin/install_bindfs.rb +0 -61
  60. data/lib/vagrant-bindfs/cap/debian/install_bindfs.rb +0 -17
  61. data/lib/vagrant-bindfs/cap/fedora/install_bindfs.rb +0 -17
  62. data/lib/vagrant-bindfs/cap/linux/bindfs_installed.rb +0 -17
  63. data/lib/vagrant-bindfs/cap/linux/checks.rb +0 -21
  64. data/lib/vagrant-bindfs/cap/linux/enable_fuse.rb +0 -17
  65. data/lib/vagrant-bindfs/cap/linux/fuse_loaded.rb +0 -17
  66. data/lib/vagrant-bindfs/cap/redhat/install_bindfs.rb +0 -52
  67. data/lib/vagrant-bindfs/cap/suse/install_bindfs.rb +0 -17
  68. data/lib/vagrant-bindfs/cap/ubuntu/fuse_loaded.rb +0 -19
  69. data/lib/vagrant-bindfs/command.rb +0 -212
  70. data/lib/vagrant-bindfs/config.rb +0 -119
  71. data/lib/vagrant-bindfs/errors.rb +0 -7
  72. data/lib/vagrant-bindfs/plugin.rb +0 -145
  73. data/test/test_helper.rb +0 -20
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ module Capabilities
5
+ module RedHat
6
+ module Bindfs
7
+ class << self
8
+ def bindfs_bindfs_install(machine)
9
+ machine.guest.capability(:bindfs_package_manager_update)
10
+ machine.communicate.sudo('yum -y install bindfs')
11
+ end
12
+
13
+ def bindfs_bindfs_search_version(machine, version)
14
+ machine.guest.capability(:bindfs_package_manager_update)
15
+ machine.communicate.tap do |comm|
16
+ comm.sudo('yum -y install yum-utils')
17
+ comm.execute("repoquery --show-duplicates bindfs-#{version}* 2>/dev/null | head -n1") do |_, output|
18
+ package_name = output.strip
19
+ return package_name unless package_name.empty?
20
+ end
21
+ end
22
+ false
23
+ end
24
+
25
+ def bindfs_bindfs_install_version(machine, version)
26
+ machine.guest.capability(:bindfs_package_manager_update)
27
+ package_name = machine.guest.capability(:bindfs_bindfs_search_version, version)
28
+ machine.communicate.sudo("yum -y install #{package_name.shellescape}")
29
+ end
30
+
31
+ def bindfs_bindfs_install_compilation_requirements(machine)
32
+ machine.communicate.sudo('yum -y install make automake gcc gcc-c++ kernel-devel wget tar fuse-devel')
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ module Capabilities
5
+ module RedHat
6
+ module Fuse
7
+ class << self
8
+ def bindfs_fuse_install(machine)
9
+ machine.guest.capability(:bindfs_package_manager_update)
10
+ machine.communicate.sudo('yum -y install fuse')
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ module Capabilities
5
+ module RedHat
6
+ module PackageManager
7
+ class << self
8
+ def bindfs_package_manager_name(_machine)
9
+ 'yum'
10
+ end
11
+
12
+ def bindfs_package_manager_update(machine)
13
+ machine.communicate.sudo('yum clean expire-cache')
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ module Capabilities
5
+ module Suse
6
+ autoload :PackageManager, 'vagrant-bindfs/vagrant/capabilities/suse/package_manager'
7
+ autoload :Fuse, 'vagrant-bindfs/vagrant/capabilities/suse/fuse'
8
+ autoload :Bindfs, 'vagrant-bindfs/vagrant/capabilities/suse/bindfs'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ module Capabilities
5
+ module Suse
6
+ module Bindfs
7
+ class << self
8
+ def bindfs_bindfs_install(machine)
9
+ machine.guest.capability(:bindfs_package_manager_update)
10
+ machine.communicate.sudo('zypper -n install bindfs')
11
+ end
12
+
13
+ def bindfs_bindfs_search_version(machine, version)
14
+ machine.guest.capability(:bindfs_package_manager_update)
15
+ machine.communicate.tap do |comm|
16
+ comm.sudo("zypper se -s bindfs | sed -n '/bindfs/,${p}' | cut -d'|' -f2,4 --output-delimiter='-'") do |_, output|
17
+ package_name = output.strip
18
+ return package_name if !package_name.empty? && !package_name.match(/^bindfs-#{version}/).nil?
19
+ end
20
+ end
21
+ false
22
+ end
23
+
24
+ def bindfs_bindfs_install_version(machine, version)
25
+ machine.guest.capability(:bindfs_package_manager_update)
26
+ package_name = machine.guest.capability(:bindfs_bindfs_search_version, version)
27
+ machine.communicate.sudo("zypper -n in -f #{package_name.shellescape}")
28
+ end
29
+
30
+ def bindfs_bindfs_install_compilation_requirements(machine)
31
+ machine.guest.capability(:bindfs_package_manager_update)
32
+ machine.communicate.tap do |comm|
33
+ comm.sudo('zypper -n install make automake gcc gcc-c++ kernel-devel wget tar fuse-devel')
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ module Capabilities
5
+ module Suse
6
+ module Fuse
7
+ class << self
8
+ def bindfs_fuse_install(machine)
9
+ machine.guest.capability(:bindfs_package_manager_update)
10
+ machine.communicate.sudo('zypper -n install fuse')
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ module Capabilities
5
+ module Suse
6
+ module PackageManager
7
+ class << self
8
+ def bindfs_package_manager_name(_machine)
9
+ 'zypper'
10
+ end
11
+
12
+ def bindfs_package_manager_update(machine)
13
+ machine.communicate.sudo('zypper ref -s')
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ module Capabilities
5
+ module Ubuntu
6
+ autoload :Fuse, 'vagrant-bindfs/vagrant/capabilities/ubuntu/fuse'
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ module Capabilities
5
+ module Ubuntu
6
+ module Fuse
7
+ class << self
8
+ # Ubuntu 6.10 and after automatically load fuse.
9
+ # Just check if it is installed
10
+
11
+ def bindfs_fuse_loaded(machine)
12
+ machine.guest.capability(:bindfs_fuse_installed)
13
+ end
14
+
15
+ def bindfs_fuse_load(machine)
16
+ machine.guest.capability(:bindfs_fuse_installed)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ class Config < ::Vagrant.plugin('2', :config)
5
+ attr_accessor :debug
6
+
7
+ attr_accessor :bindfs_version
8
+ attr_accessor :install_bindfs_from_source
9
+
10
+ attr_accessor :default_options
11
+ attr_accessor :binded_folders
12
+
13
+ attr_accessor :skip_validations
14
+
15
+ def initialize
16
+ @debug = false
17
+
18
+ @bindfs_version = UNSET_VALUE
19
+ @install_bindfs_from_source = false
20
+
21
+ @binded_folders = {}
22
+ @default_options = Bindfs::OptionSet.new(nil, 'force-user' => 'vagrant',
23
+ 'force-group' => 'vagrant',
24
+ 'perms' => 'u=rwX:g=rD:o=rD')
25
+
26
+ @skip_validations = []
27
+ end
28
+
29
+ def debug=(value)
30
+ @debug = (value == true)
31
+ end
32
+
33
+ def source_version=(value)
34
+ @bindfs_version = Gem::Version.new(value.to_s)
35
+ end
36
+
37
+ def install_bindfs_from_source=(value)
38
+ @install_bindfs_from_source = (value == true)
39
+ end
40
+
41
+ def default_options=(options = {})
42
+ @default_options = Bindfs::OptionSet.new(nil, options)
43
+ end
44
+
45
+ def binded_folder=(*_any_variant)
46
+ raise VagrantBindfs::Vagrant::ConfigError, :binded_folders
47
+ end
48
+
49
+ def bind_folder(source, destination, options = {})
50
+ hook = options.delete(:after) || :synced_folders
51
+ folder = Bindfs::Folder.new(hook, source, destination, options)
52
+ @binded_folders[folder.id] = folder
53
+ end
54
+
55
+ def merge(other)
56
+ super.tap do |result|
57
+ result.debug = (debug || other.debug)
58
+
59
+ result_bindfs_version = [bindfs_version, other.bindfs_version].select { |v| v != UNSET_VALUE }.min
60
+ result.bindfs_version = result_bindfs_version unless result_bindfs_version.nil?
61
+ result.install_bindfs_from_source = (install_bindfs_from_source || other.install_bindfs_from_source)
62
+
63
+ result.default_options = default_options.merge(other.default_options)
64
+ result.binded_folders = binded_folders.merge(other.binded_folders)
65
+
66
+ result.skip_validations = (skip_validations + other.skip_validations).uniq
67
+ end
68
+ end
69
+
70
+ def finalize!
71
+ @bindfs_version = :latest if @bindfs_version == UNSET_VALUE
72
+ end
73
+
74
+ def validate(_machine)
75
+ errors = _detected_errors
76
+
77
+ binded_folders.each do |_, folder|
78
+ validator = Bindfs::Validators::Config.new(folder)
79
+ errors << validator.errors unless validator.valid?
80
+ end
81
+
82
+ { 'vagrant-bindfs' => errors.flatten }
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ class Error < ::Vagrant::Errors::VagrantError
5
+ error_namespace('vagrant-bindfs.errors')
6
+ end
7
+
8
+ class ConfigError < Error
9
+ error_namespace('vagrant-bindfs.errors.config')
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ module Vagrant
4
+ class Plugin < ::Vagrant.plugin('2')
5
+ name 'bindfs'
6
+ description <<-DESC
7
+ A Vagrant plugin to automate bindfs mount in the VM. This allow you to change owner, group and permissions on files and, for example, work around NFS share permissions issues.
8
+ DESC
9
+
10
+ config(:bindfs) do
11
+ Config
12
+ end
13
+
14
+ include Capabilities
15
+
16
+ %w(up reload).each do |action|
17
+ action_hook(:bindfs, "machine_action_#{action}".to_sym) do |hook|
18
+ hooks.each do |(name, middleware)|
19
+ hook.before(middleware, Actions::Mounter, name)
20
+ end
21
+ hook.before(hooks[hooks.keys.first], Actions::Installer)
22
+ end
23
+ end
24
+
25
+ class << self
26
+ def hooks
27
+ @hooks ||= begin
28
+ synced_folders = if ::Vagrant::Action::Builtin.const_defined? :NFS
29
+ ::Vagrant::Action::Builtin::NFS
30
+ else
31
+ ::Vagrant::Action::Builtin::SyncedFolders
32
+ end
33
+
34
+ {
35
+ synced_folders: synced_folders,
36
+ provision: ::Vagrant::Action::Builtin::Provision
37
+ }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,13 +1,4 @@
1
- module VagrantPlugins
2
- module Bindfs
3
-
4
- VERSION = "0.4.14"
5
-
6
- SOURCE_VERSION = "1.13.4"
7
- SOURCE_URLS = [
8
- "http://bindfs.org/downloads/bindfs-%{source_version}.tar.gz",
9
- "http://bindfs.dnsalias.net/downloads/bindfs-%{source_version}.tar.gz"
10
- ]
11
-
12
- end
1
+ # frozen_string_literal: true
2
+ module VagrantBindfs
3
+ VERSION = '1.0.0'
13
4
  end
data/locales/en.yml CHANGED
@@ -1,29 +1,74 @@
1
1
  en:
2
- vagrant:
3
- config:
2
+ vagrant-bindfs:
3
+
4
+ actions:
5
+ installer:
6
+ start: "Checking for bindfs in VM..."
7
+ end: "Machine is ready to use bindfs!"
8
+ package_manager:
9
+ not_installed: "Package manager seems to not be installed on the virtual machine, installing now"
10
+ installed: "Package manager detected: %{name}"
11
+ fuse:
12
+ not_installed: "Fuse seems to not be installed on the virtual machine, installing now"
13
+ installed: "Fuse kernel module is installed"
14
+ not_loaded: "Fuse kernel module seems to be not loaded, trying to load it"
15
+ loaded: "Fuse kernel module is loaded"
4
16
  bindfs:
5
- homebrew_not_installed: "Homebrew seems to not be installed on the virtual machine, installing now"
6
- osxfuse_not_installed: "OSXFuse seems to not be installed on the virtual machine, installing now"
7
17
  not_installed: "Bindfs seems to not be installed on the virtual machine, installing now"
8
- not_loaded: "Fuse kernel module seems to be not loaded, trying to load it"
9
- already_mounted: "There's already a bindfs mount to destination %{dest}"
10
- status:
11
- binding_all: "Creating bind mounts for selected devices"
12
- binding_entry: "Creating bind mount from %{source} to %{dest}"
13
- errors:
14
- invalid_hook: "Invalid hook specified. Must use one of %{hooks}"
15
- no_path_supplied: "You must pass a destination and a source path as arguments"
16
- destination_path_relative: "Destination path %{path} is relative for bind whatever"
17
- destination_path_reserved: "Destination path %{path} is part of a reserved subtree for Vagrant use"
18
- source_path_relative: "Source path %{path} is relative for bind whatever"
19
- source_path_not_exist: "Cannot bind source path %{path} because it doesn't exist"
20
- user_not_exist: "Cannot bind to user '%{user}' because it doesn't exist"
21
- group_not_exist: "Cannot bind to group '%{group}' because it doesn't exist"
22
- cannot_enable_fuse: "The fuse kernel module seems to not be loadable on the virtual machine"
23
- binding_failed: |-
24
- The bind command `%{command}` failed to run!
25
-
26
- Please check options values and compatibility. For a complete documentation,
27
- run `sudo bindfs --help` on the VM.
28
-
29
- You can see it online at http://bindfs.org/docs/bindfs.1.html
18
+ not_found_in_repository: "Bindfs %{version} can not be found in any of the repositories, installing now from sources"
19
+ detected: "Bindfs %{version} is installed"
20
+ mounter:
21
+ start: "Creating bind mounts after %{hook}..."
22
+ entry: "%{source} => %{dest}"
23
+
24
+
25
+ validations:
26
+ source_path_required: "A source path is required as argument to bind_folder"
27
+ source_path_does_not_exist: "Source path '%{path}' doesn't exist"
28
+
29
+ destination_path_required: "A destination path is required as argument to bind_folder"
30
+ destination_path_reserved: "Destination path '%{path}' is part of a reserved subtree for Vagrant use"
31
+ destination_already_mounted: "Destination path '%{dest}' is already a bindfs mount"
32
+
33
+ path_must_be_absolute: "Path '%{path}' is relative but an absolute path is attended"
34
+ user_does_not_exist: "User '%{user}' doesn't exist"
35
+ group_does_not_exist: "Group '%{group}' doesn't exist"
36
+
37
+ invalid_hook: "Invalid hook specified. Must use one of %{hooks}"
38
+
39
+ errors_found: "Cannot create bind mount from '%{source}' to '%{dest}': %{errors}"
40
+
41
+
42
+ errors:
43
+ package_manager_missing: "No package manager found on the virtual machine. You may use an unsupported flavour of Linux."
44
+ config:
45
+ binded_folders: "config.bindfs.binded_folders= must no be called. Use config.bindfs.bind_folders instead."
46
+ conflicting_options: "Another option has already been set for the canonical name '%{name}'"
47
+
48
+ bindfs:
49
+ mount_failed: |-
50
+ The following bindfs command failed to run!
51
+
52
+ `%{command}`
53
+
54
+ Please check options values and compatibility. For a complete
55
+ documentation, run `sudo bindfs --help` on the VM. You can see
56
+ it online at http://bindfs.org/docs/bindfs.1.html
57
+
58
+ deprecations:
59
+ disabled: |-
60
+ ':disabled' option is not supported anymore.
61
+ Please comment or remove the line in your Vagrantfile instead.
62
+ skip_verify_user: |-
63
+ ':skip_verify_user' option is not supported anymore via bind_folder.
64
+ If you need vagrant-bindfs to not check user existence, use the 'skip_validations' configuration options:
65
+
66
+ config.bindfs.skip_validations << :user
67
+ skip_verify_group: |-
68
+ ':skip_verify_group' option is not supported anymore via bind_folder.
69
+ If you need vagrant-bindfs to not check user existence, use the 'skip_validations' configuration options:
70
+
71
+ config.bindfs.skip_validations << :group
72
+ hook: |-
73
+ ':hook' option is not supported anymore.
74
+ Please use ':after' instead.