lib/vagrant/bundler.rb in vagrant-unbundled-1.9.5.1 vs lib/vagrant/bundler.rb in vagrant-unbundled-1.9.7.1
- old
+ new
@@ -213,19 +213,25 @@
def internal_install(plugins, update, **extra)
update = {} if !update.is_a?(Hash)
skips = []
source_list = {}
+ system_plugins = plugins.map do |plugin_name, plugin_info|
+ plugin_name if plugin_info["system"]
+ end.compact
installer_set = VagrantSet.new(:both)
+ installer_set.system_plugins = system_plugins
# Generate all required plugin deps
plugin_deps = plugins.map do |name, info|
+ gem_version = info['gem_version'].to_s.empty? ? '> 0' : info['gem_version']
if update[:gems] == true || (update[:gems].respond_to?(:include?) && update[:gems].include?(name))
- gem_version = '> 0'
+ if Gem::Requirement.new(gem_version).exact?
+ gem_version = "> 0"
+ @logger.debug("Detected exact version match for `#{name}` plugin update. Reset to loose constraint #{gem_version.inspect}.")
+ end
skips << name
- else
- gem_version = info['gem_version'].to_s.empty? ? '> 0' : info['gem_version']
end
source_list[name] ||= []
if plugin_source = info.delete("local_source")
installer_set.add_local(plugin_source.spec.name, plugin_source.spec, plugin_source)
source_list[name] << plugin_source.path
@@ -237,12 +243,23 @@
source_list[name] << source
end
Gem::Dependency.new(name, gem_version)
end
- @logger.debug("Dependency list for installation: #{plugin_deps}")
+ if Vagrant.strict_dependency_enforcement
+ @logger.debug("Enabling strict dependency enforcement")
+ plugin_deps += vagrant_internal_specs.map do |spec|
+ next if system_plugins.include?(spec.name)
+ Gem::Dependency.new(spec.name, spec.version)
+ end.compact
+ else
+ @logger.debug("Disabling strict dependency enforcement")
+ end
+ @logger.debug("Dependency list for installation:\n - " \
+ "#{plugin_deps.map{|d| "#{d.name} #{d.requirement}"}.join("\n - ")}")
+
all_sources = source_list.values.flatten.uniq
default_sources = DEFAULT_GEM_SOURCES & all_sources
all_sources -= DEFAULT_GEM_SOURCES
# Only allow defined Gem sources
@@ -275,14 +292,13 @@
# Create the request set for the new plugins
request_set = Gem::RequestSet.new(*plugin_deps)
installer_set = Gem::Resolver.compose_sets(
installer_set,
- generate_builtin_set,
+ generate_builtin_set(system_plugins),
generate_plugin_set(skips)
)
-
@logger.debug("Generating solution set for installation.")
# Generate the required solution set for new plugins
solution = request_set.resolve(installer_set)
activate_solution(solution)
@@ -347,15 +363,17 @@
end
end
end
# Generate the builtin resolver set
- def generate_builtin_set
+ def generate_builtin_set(system_plugins=[])
builtin_set = BuiltinSet.new
@logger.debug("Generating new builtin set instance.")
vagrant_internal_specs.each do |spec|
- builtin_set.add_builtin_spec(spec)
+ if !system_plugins.include?(spec.name)
+ builtin_set.add_builtin_spec(spec)
+ end
end
builtin_set
end
# Generate the plugin resolver set. Optionally provide specification names (short or
@@ -426,19 +444,26 @@
# This is a custom Gem::Resolver::InstallerSet. It will prefer sources which are
# explicitly provided over default sources when matches are found. This is generally
# the entire set used for performing full resolutions on install.
class VagrantSet < Gem::Resolver::InstallerSet
attr_accessor :prefer_sources
+ attr_accessor :system_plugins
def initialize(domain, defined_sources={})
@prefer_sources = defined_sources
+ @system_plugins = []
super(domain)
end
# Allow InstallerSet to find matching specs, then filter
# for preferred sources
def find_all(req)
result = super
+ if system_plugins.include?(req.name)
+ result.delete_if do |spec|
+ spec.is_a?(Gem::Resolver::InstalledSpecification)
+ end
+ end
subset = result.find_all do |idx_spec|
preferred = false
if prefer_sources[req.name]
if idx_spec.source.respond_to?(:path)
preferred = prefer_sources[req.name].include?(idx_spec.source.path.to_s)