diff options
author | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-01 09:41:32 +0000 |
---|---|---|
committer | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-01 09:41:32 +0000 |
commit | 25a9b62d45ddd60a231272567c7dda9337da9b62 (patch) | |
tree | e72ba4c9c01cba5fb510eb1eafaba76d998baf4c /lib/rubygems/dependency_installer.rb | |
parent | 86bb0af7ea3b50f72e6845a6f5f64cb1b23fd279 (diff) | |
download | ruby-25a9b62d45ddd60a231272567c7dda9337da9b62.tar.gz |
Import rubygems 1.6.0 (released version @ 58d8a0b9)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/dependency_installer.rb')
-rw-r--r-- | lib/rubygems/dependency_installer.rb | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb index 23462fbe33..46ec63f14f 100644 --- a/lib/rubygems/dependency_installer.rb +++ b/lib/rubygems/dependency_installer.rb @@ -74,7 +74,7 @@ class Gem::DependencyInstaller @installed_gems = [] @install_dir = options[:install_dir] || Gem.dir - @cache_dir = options[:cache_dir] || @install_dir + @cache_dir = options[:cache_dir] || Gem.cache_dir(@install_dir) # Set with any errors that SpecFetcher finds while search through # gemspecs for a dep @@ -136,17 +136,33 @@ class Gem::DependencyInstaller def gather_dependencies specs = @specs_and_sources.map { |spec,_| spec } + # these gems were listed by the user, always install them + keep_names = specs.map { |spec| spec.full_name } + dependency_list = Gem::DependencyList.new @development dependency_list.add(*specs) to_do = specs.dup add_found_dependencies to_do, dependency_list unless @ignore_dependencies + dependency_list.specs.reject! { |spec| + ! keep_names.include? spec.full_name and + @source_index.any? { |n,_| n == spec.full_name } + } + + unless dependency_list.ok? or @ignore_dependencies or @force then + reason = dependency_list.why_not_ok?.map { |k,v| + "#{k} requires #{v.join(", ")}" + }.join("; ") + raise Gem::DependencyError, "Unable to resolve dependencies: #{reason}" + end + @gems_to_install = dependency_list.dependency_order.reverse end def add_found_dependencies to_do, dependency_list seen = {} + dependencies = Hash.new { |h, name| h[name] = Gem::Dependency.new name } until to_do.empty? do spec = to_do.shift @@ -157,10 +173,10 @@ class Gem::DependencyInstaller deps |= spec.development_dependencies if @development deps.each do |dep| + dependencies[dep.name] = dependencies[dep.name].merge dep + results = find_gems_with_sources(dep).reverse - # FIX: throw in everything that satisfies, and let - # FIX: dependencylist reduce to the chosen few results.reject! do |dep_spec,| to_do.push dep_spec @@ -172,14 +188,14 @@ class Gem::DependencyInstaller end results.each do |dep_spec, source_uri| - next if seen[dep_spec.name] @specs_and_sources << [dep_spec, source_uri] - # FIX: this is the bug dependency_list.add dep_spec end end end + + dependency_list.remove_specs_unsatisfied_by dependencies end ## @@ -259,7 +275,6 @@ class Gem::DependencyInstaller @gems_to_install.each do |spec| last = spec == @gems_to_install.last - # HACK is this test for full_name acceptable? next if @source_index.any? { |n,_| n == spec.full_name } and not last # TODO: make this sorta_verbose so other users can benefit from it |