shopify-bundler 1.10.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +96 -0
- data/.rubocop_todo.yml +177 -0
- data/.travis.yml +104 -0
- data/CHANGELOG.md +2131 -0
- data/CODE_OF_CONDUCT.md +42 -0
- data/CONTRIBUTING.md +32 -0
- data/DEVELOPMENT.md +118 -0
- data/ISSUES.md +96 -0
- data/LICENSE.md +23 -0
- data/README.md +40 -0
- data/Rakefile +309 -0
- data/bin/rake +14 -0
- data/bin/rspec +10 -0
- data/bin/rubocop +11 -0
- data/bundler.gemspec +34 -0
- data/exe/bundle +21 -0
- data/exe/bundle_ruby +60 -0
- data/exe/bundler +21 -0
- data/lib/bundler.rb +499 -0
- data/lib/bundler/capistrano.rb +16 -0
- data/lib/bundler/cli.rb +435 -0
- data/lib/bundler/cli/binstubs.rb +37 -0
- data/lib/bundler/cli/cache.rb +34 -0
- data/lib/bundler/cli/check.rb +37 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +56 -0
- data/lib/bundler/cli/config.rb +88 -0
- data/lib/bundler/cli/console.rb +37 -0
- data/lib/bundler/cli/exec.rb +51 -0
- data/lib/bundler/cli/gem.rb +208 -0
- data/lib/bundler/cli/init.rb +32 -0
- data/lib/bundler/cli/inject.rb +32 -0
- data/lib/bundler/cli/install.rb +188 -0
- data/lib/bundler/cli/lock.rb +35 -0
- data/lib/bundler/cli/open.rb +22 -0
- data/lib/bundler/cli/outdated.rb +86 -0
- data/lib/bundler/cli/package.rb +45 -0
- data/lib/bundler/cli/platform.rb +42 -0
- data/lib/bundler/cli/show.rb +74 -0
- data/lib/bundler/cli/update.rb +72 -0
- data/lib/bundler/cli/viz.rb +26 -0
- data/lib/bundler/constants.rb +5 -0
- data/lib/bundler/current_ruby.rb +218 -0
- data/lib/bundler/definition.rb +675 -0
- data/lib/bundler/dep_proxy.rb +45 -0
- data/lib/bundler/dependency.rb +119 -0
- data/lib/bundler/deployment.rb +62 -0
- data/lib/bundler/deprecate.rb +17 -0
- data/lib/bundler/dsl.rb +478 -0
- data/lib/bundler/endpoint_specification.rb +100 -0
- data/lib/bundler/env.rb +82 -0
- data/lib/bundler/environment.rb +41 -0
- data/lib/bundler/fetcher.rb +288 -0
- data/lib/bundler/fetcher/base.rb +26 -0
- data/lib/bundler/fetcher/dependency.rb +88 -0
- data/lib/bundler/fetcher/downloader.rb +60 -0
- data/lib/bundler/fetcher/index.rb +32 -0
- data/lib/bundler/friendly_errors.rb +92 -0
- data/lib/bundler/gem_helper.rb +191 -0
- data/lib/bundler/gem_helpers.rb +26 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_path_manipulation.rb +8 -0
- data/lib/bundler/gem_tasks.rb +5 -0
- data/lib/bundler/graph.rb +173 -0
- data/lib/bundler/index.rb +199 -0
- data/lib/bundler/injector.rb +62 -0
- data/lib/bundler/inline.rb +58 -0
- data/lib/bundler/installer.rb +242 -0
- data/lib/bundler/installer/parallel_installer.rb +122 -0
- data/lib/bundler/installer/standalone.rb +48 -0
- data/lib/bundler/lazy_specification.rb +82 -0
- data/lib/bundler/lockfile_parser.rb +199 -0
- data/lib/bundler/match_platform.rb +13 -0
- data/lib/bundler/psyched_yaml.rb +26 -0
- data/lib/bundler/remote_specification.rb +82 -0
- data/lib/bundler/resolver.rb +350 -0
- data/lib/bundler/retry.rb +60 -0
- data/lib/bundler/ruby_dsl.rb +11 -0
- data/lib/bundler/ruby_version.rb +116 -0
- data/lib/bundler/rubygems_ext.rb +175 -0
- data/lib/bundler/rubygems_integration.rb +674 -0
- data/lib/bundler/runtime.rb +285 -0
- data/lib/bundler/settings.rb +263 -0
- data/lib/bundler/setup.rb +26 -0
- data/lib/bundler/shared_helpers.rb +176 -0
- data/lib/bundler/similarity_detector.rb +61 -0
- data/lib/bundler/source.rb +35 -0
- data/lib/bundler/source/git.rb +286 -0
- data/lib/bundler/source/git/git_proxy.rb +190 -0
- data/lib/bundler/source/path.rb +224 -0
- data/lib/bundler/source/path/installer.rb +43 -0
- data/lib/bundler/source/rubygems.rb +436 -0
- data/lib/bundler/source/rubygems/remote.rb +38 -0
- data/lib/bundler/source_list.rb +101 -0
- data/lib/bundler/spec_set.rb +156 -0
- data/lib/bundler/ssl_certs/.document +1 -0
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot-2048.pem +25 -0
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot.pem +32 -0
- data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +14 -0
- data/lib/bundler/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +28 -0
- data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +20 -0
- data/lib/bundler/ssl_certs/certificate_manager.rb +64 -0
- data/lib/bundler/stub_specification.rb +23 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Executable.standalone +12 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/.travis.yml.tt +4 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +22 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
- data/lib/bundler/templates/newgem/README.md.tt +41 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +29 -0
- data/lib/bundler/templates/newgem/bin/console.tt +14 -0
- data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
- data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
- data/lib/bundler/templates/newgem/gitignore.tt +16 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +12 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +43 -0
- data/lib/bundler/templates/newgem/rspec.tt +2 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +4 -0
- data/lib/bundler/ui.rb +7 -0
- data/lib/bundler/ui/rg_proxy.rb +17 -0
- data/lib/bundler/ui/shell.rb +108 -0
- data/lib/bundler/ui/silent.rb +44 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +5 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +277 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +69 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +3 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +99 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +434 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +43 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +51 -0
- data/lib/bundler/vendor/net/http/faster.rb +26 -0
- data/lib/bundler/vendor/net/http/persistent.rb +1230 -0
- data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +128 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +484 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +319 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +59 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +656 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +133 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +32 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +73 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +125 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +218 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +322 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +421 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/lib/bundler/vendor/thor/lib/thor/util.rb +267 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_molinillo.rb +2 -0
- data/lib/bundler/vendored_persistent.rb +11 -0
- data/lib/bundler/vendored_thor.rb +3 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +11 -0
- data/lib/bundler/worker.rb +72 -0
- data/man/bundle-config.ronn +187 -0
- data/man/bundle-exec.ronn +136 -0
- data/man/bundle-gem.ronn +77 -0
- data/man/bundle-install.ronn +398 -0
- data/man/bundle-package.ronn +66 -0
- data/man/bundle-platform.ronn +42 -0
- data/man/bundle-update.ronn +188 -0
- data/man/bundle.ronn +98 -0
- data/man/gemfile.5.ronn +495 -0
- data/man/index.txt +8 -0
- metadata +346 -0
@@ -0,0 +1,436 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "rubygems/user_interaction"
|
3
|
+
require "rubygems/spec_fetcher"
|
4
|
+
|
5
|
+
module Bundler
|
6
|
+
class Source
|
7
|
+
class Rubygems < Source
|
8
|
+
autoload :Remote, "bundler/source/rubygems/remote"
|
9
|
+
|
10
|
+
# Use the API when installing less than X gems
|
11
|
+
API_REQUEST_LIMIT = 500
|
12
|
+
# Ask for X gems per API request
|
13
|
+
API_REQUEST_SIZE = 50
|
14
|
+
|
15
|
+
attr_reader :remotes, :caches
|
16
|
+
|
17
|
+
def initialize(options = {})
|
18
|
+
@options = options
|
19
|
+
@remotes = []
|
20
|
+
@dependency_names = []
|
21
|
+
@allow_remote = false
|
22
|
+
@allow_cached = false
|
23
|
+
@caches = [Bundler.app_cache, *Bundler.rubygems.gem_cache]
|
24
|
+
|
25
|
+
Array(options["remotes"] || []).reverse_each {|r| add_remote(r) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def remote!
|
29
|
+
@allow_remote = true
|
30
|
+
end
|
31
|
+
|
32
|
+
def cached!
|
33
|
+
@allow_cached = true
|
34
|
+
end
|
35
|
+
|
36
|
+
def hash
|
37
|
+
@remotes.hash
|
38
|
+
end
|
39
|
+
|
40
|
+
def eql?(other)
|
41
|
+
other.is_a?(Rubygems) && other.credless_remotes == credless_remotes
|
42
|
+
end
|
43
|
+
|
44
|
+
alias_method :==, :eql?
|
45
|
+
|
46
|
+
def include?(o)
|
47
|
+
o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty?
|
48
|
+
end
|
49
|
+
|
50
|
+
def can_lock?(spec)
|
51
|
+
spec.source.is_a?(Rubygems)
|
52
|
+
end
|
53
|
+
|
54
|
+
def options
|
55
|
+
{ "remotes" => @remotes.map(&:to_s) }
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.from_lock(options)
|
59
|
+
new(options)
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_lock
|
63
|
+
out = "GEM\n"
|
64
|
+
remotes.reverse_each do |remote|
|
65
|
+
out << " remote: #{suppress_configured_credentials remote}\n"
|
66
|
+
end
|
67
|
+
out << " specs:\n"
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_s
|
71
|
+
remote_names = self.remotes.map(&:to_s).join(", ")
|
72
|
+
"rubygems repository #{remote_names}"
|
73
|
+
end
|
74
|
+
alias_method :name, :to_s
|
75
|
+
|
76
|
+
def specs
|
77
|
+
@specs ||= begin
|
78
|
+
# remote_specs usually generates a way larger Index than the other
|
79
|
+
# sources, and large_idx.use small_idx is way faster than
|
80
|
+
# small_idx.use large_idx.
|
81
|
+
idx = @allow_remote ? remote_specs.dup : Index.new
|
82
|
+
idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
|
83
|
+
idx.use(installed_specs, :override_dupes)
|
84
|
+
idx
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def install(spec, opts = {})
|
89
|
+
force = opts[:force]
|
90
|
+
ensure_builtin_gems_cached = opts[:ensure_builtin_gems_cached]
|
91
|
+
|
92
|
+
if ensure_builtin_gems_cached && builtin_gem?(spec)
|
93
|
+
if !cached_path(spec)
|
94
|
+
cached_built_in_gem(spec) unless spec.remote
|
95
|
+
force = true
|
96
|
+
else
|
97
|
+
spec.loaded_from = loaded_from(spec)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
if installed?(spec) && (!force || spec.name.eql?("bundler"))
|
102
|
+
Bundler.ui.info "Using #{version_message(spec)}"
|
103
|
+
return nil # no post-install message
|
104
|
+
end
|
105
|
+
|
106
|
+
# Download the gem to get the spec, because some specs that are returned
|
107
|
+
# by rubygems.org are broken and wrong.
|
108
|
+
if spec.remote
|
109
|
+
# Check for this spec from other sources
|
110
|
+
uris = [spec.remote.anonymized_uri]
|
111
|
+
uris += remotes_for_spec(spec).map(&:anonymized_uri)
|
112
|
+
uris.uniq!
|
113
|
+
Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1
|
114
|
+
|
115
|
+
s = Bundler.rubygems.spec_from_gem(fetch_gem(spec), Bundler.settings["trust-policy"])
|
116
|
+
spec.__swap__(s)
|
117
|
+
end
|
118
|
+
|
119
|
+
unless Bundler.settings[:no_install]
|
120
|
+
message = "Installing #{version_message(spec)}"
|
121
|
+
message << " with native extensions" if spec.extensions.any?
|
122
|
+
Bundler.ui.confirm message
|
123
|
+
|
124
|
+
path = cached_gem(spec)
|
125
|
+
if Bundler.requires_sudo?
|
126
|
+
install_path = Bundler.tmp(spec.full_name)
|
127
|
+
bin_path = install_path.join("bin")
|
128
|
+
else
|
129
|
+
install_path = Bundler.rubygems.gem_dir
|
130
|
+
bin_path = Bundler.system_bindir
|
131
|
+
end
|
132
|
+
|
133
|
+
installed_spec = nil
|
134
|
+
Bundler.rubygems.preserve_paths do
|
135
|
+
installed_spec = Bundler::GemInstaller.new(
|
136
|
+
path,
|
137
|
+
:install_dir => install_path.to_s,
|
138
|
+
:bin_dir => bin_path.to_s,
|
139
|
+
:ignore_dependencies => true,
|
140
|
+
:wrappers => true,
|
141
|
+
:env_shebang => true
|
142
|
+
).install
|
143
|
+
end
|
144
|
+
|
145
|
+
# SUDO HAX
|
146
|
+
if Bundler.requires_sudo?
|
147
|
+
Bundler.rubygems.repository_subdirectories.each do |name|
|
148
|
+
src = File.join(install_path, name, "*")
|
149
|
+
dst = File.join(Bundler.rubygems.gem_dir, name)
|
150
|
+
if name == "extensions" && Dir.glob(src).any?
|
151
|
+
src = File.join(src, "*/*")
|
152
|
+
ext_src = Dir.glob(src).first
|
153
|
+
ext_src.gsub!(src[0..-6], "")
|
154
|
+
dst = File.dirname(File.join(dst, ext_src))
|
155
|
+
end
|
156
|
+
SharedHelpers.filesystem_access(dst) do |p|
|
157
|
+
Bundler.mkdir_p(p)
|
158
|
+
end
|
159
|
+
Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
|
160
|
+
end
|
161
|
+
|
162
|
+
spec.executables.each do |exe|
|
163
|
+
SharedHelpers.filesystem_access(Bundler.system_bindir) do |p|
|
164
|
+
Bundler.mkdir_p(p)
|
165
|
+
end
|
166
|
+
Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
installed_spec.loaded_from = loaded_from(spec)
|
170
|
+
end
|
171
|
+
spec.loaded_from = loaded_from(spec)
|
172
|
+
|
173
|
+
spec.post_install_message
|
174
|
+
ensure
|
175
|
+
Bundler.rm_rf(install_path) if Bundler.requires_sudo?
|
176
|
+
end
|
177
|
+
|
178
|
+
def cache(spec, custom_path = nil)
|
179
|
+
if builtin_gem?(spec)
|
180
|
+
cached_path = cached_built_in_gem(spec)
|
181
|
+
else
|
182
|
+
cached_path = cached_gem(spec)
|
183
|
+
end
|
184
|
+
raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path
|
185
|
+
return if File.dirname(cached_path) == Bundler.app_cache.to_s
|
186
|
+
Bundler.ui.info " * #{File.basename(cached_path)}"
|
187
|
+
FileUtils.cp(cached_path, Bundler.app_cache(custom_path))
|
188
|
+
rescue Errno::EACCES => e
|
189
|
+
Bundler.ui.debug(e)
|
190
|
+
raise InstallError, e.message
|
191
|
+
end
|
192
|
+
|
193
|
+
def cached_built_in_gem(spec)
|
194
|
+
cached_path = cached_path(spec)
|
195
|
+
if cached_path.nil?
|
196
|
+
remote_spec = remote_specs.search(spec).first
|
197
|
+
if remote_spec
|
198
|
+
cached_path = fetch_gem(remote_spec)
|
199
|
+
else
|
200
|
+
Bundler.ui.warn "#{spec.full_name} is built in to Ruby, and can't be cached because your Gemfile doesn't have any sources that contain it."
|
201
|
+
end
|
202
|
+
end
|
203
|
+
cached_path
|
204
|
+
end
|
205
|
+
|
206
|
+
def add_remote(source)
|
207
|
+
uri = normalize_uri(source)
|
208
|
+
@remotes.unshift(uri) unless @remotes.include?(uri)
|
209
|
+
end
|
210
|
+
|
211
|
+
def replace_remotes(other_remotes)
|
212
|
+
return false if other_remotes == @remotes
|
213
|
+
|
214
|
+
@remotes = []
|
215
|
+
other_remotes.reverse_each do |r|
|
216
|
+
add_remote r.to_s
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def unmet_deps
|
221
|
+
if @allow_remote && api_fetchers.any?
|
222
|
+
remote_specs.unmet_dependency_names
|
223
|
+
else
|
224
|
+
[]
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def fetchers
|
229
|
+
@fetchers ||= remotes.map do |uri|
|
230
|
+
remote = Source::Rubygems::Remote.new(uri)
|
231
|
+
Bundler::Fetcher.new(remote)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
protected
|
236
|
+
|
237
|
+
def credless_remotes
|
238
|
+
remotes.map(&method(:suppress_configured_credentials))
|
239
|
+
end
|
240
|
+
|
241
|
+
def remotes_for_spec(spec)
|
242
|
+
specs.search_all(spec.name).inject([]) do |uris, s|
|
243
|
+
uris << s.remote if s.remote
|
244
|
+
uris
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def loaded_from(spec)
|
249
|
+
"#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
|
250
|
+
end
|
251
|
+
|
252
|
+
def cached_gem(spec)
|
253
|
+
cached_gem = cached_path(spec)
|
254
|
+
unless cached_gem
|
255
|
+
raise Bundler::GemNotFound, "Could not find #{spec.file_name} for installation"
|
256
|
+
end
|
257
|
+
cached_gem
|
258
|
+
end
|
259
|
+
|
260
|
+
def cached_path(spec)
|
261
|
+
possibilities = @caches.map {|p| "#{p}/#{spec.file_name}" }
|
262
|
+
possibilities.find {|p| File.exist?(p) }
|
263
|
+
end
|
264
|
+
|
265
|
+
def normalize_uri(uri)
|
266
|
+
uri = uri.to_s
|
267
|
+
uri = "#{uri}/" unless uri =~ %r'/$'
|
268
|
+
uri = URI(uri)
|
269
|
+
raise ArgumentError, "The source must be an absolute URI. For example:\n" \
|
270
|
+
"source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(URI::HTTP) && uri.host.nil?)
|
271
|
+
uri
|
272
|
+
end
|
273
|
+
|
274
|
+
def suppress_configured_credentials(remote)
|
275
|
+
remote_nouser = remote.dup.tap {|uri| uri.user = uri.password = nil }.to_s
|
276
|
+
if remote.userinfo && remote.userinfo == Bundler.settings[remote_nouser]
|
277
|
+
remote_nouser
|
278
|
+
else
|
279
|
+
remote
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def installed_specs
|
284
|
+
@installed_specs ||= begin
|
285
|
+
idx = Index.new
|
286
|
+
have_bundler = false
|
287
|
+
Bundler.rubygems.all_specs.reverse_each do |spec|
|
288
|
+
next if spec.name == "bundler" && spec.version.to_s != VERSION
|
289
|
+
have_bundler = true if spec.name == "bundler"
|
290
|
+
spec.source = self
|
291
|
+
idx << spec
|
292
|
+
end
|
293
|
+
|
294
|
+
# Always have bundler locally
|
295
|
+
unless have_bundler
|
296
|
+
# We're running bundler directly from the source
|
297
|
+
# so, let's create a fake gemspec for it (it's a path)
|
298
|
+
# gemspec
|
299
|
+
bundler = Gem::Specification.new do |s|
|
300
|
+
s.name = "bundler"
|
301
|
+
s.version = VERSION
|
302
|
+
s.platform = Gem::Platform::RUBY
|
303
|
+
s.source = self
|
304
|
+
s.authors = ["bundler team"]
|
305
|
+
s.loaded_from = File.expand_path("..", __FILE__)
|
306
|
+
end
|
307
|
+
idx << bundler
|
308
|
+
end
|
309
|
+
idx
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
def cached_specs
|
314
|
+
@cached_specs ||= begin
|
315
|
+
idx = installed_specs.dup
|
316
|
+
|
317
|
+
path = Bundler.app_cache
|
318
|
+
Dir["#{path}/*.gem"].each do |gemfile|
|
319
|
+
next if gemfile =~ /^bundler\-[\d\.]+?\.gem/
|
320
|
+
s ||= Bundler.rubygems.spec_from_gem(gemfile)
|
321
|
+
s.source = self
|
322
|
+
idx << s
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
idx
|
327
|
+
end
|
328
|
+
|
329
|
+
def api_fetchers
|
330
|
+
fetchers.select(&:use_api)
|
331
|
+
end
|
332
|
+
|
333
|
+
def remote_specs
|
334
|
+
@remote_specs ||= Index.build do |idx|
|
335
|
+
index_fetchers = fetchers - api_fetchers
|
336
|
+
|
337
|
+
# gather lists from non-api sites
|
338
|
+
index_fetchers.each do |f|
|
339
|
+
Bundler.ui.info "Fetching source index from #{f.uri}"
|
340
|
+
idx.use f.specs(nil, self)
|
341
|
+
end
|
342
|
+
|
343
|
+
# because ensuring we have all the gems we need involves downloading
|
344
|
+
# the gemspecs of those gems, if the non-api sites contain more than
|
345
|
+
# about 100 gems, we just treat all sites as non-api for speed.
|
346
|
+
allow_api = idx.size < API_REQUEST_LIMIT && dependency_names.size < API_REQUEST_LIMIT
|
347
|
+
Bundler.ui.debug "Need to query more than #{API_REQUEST_LIMIT} gems." \
|
348
|
+
" Downloading full index instead..." unless allow_api
|
349
|
+
|
350
|
+
if allow_api
|
351
|
+
api_fetchers.each do |f|
|
352
|
+
Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug?
|
353
|
+
idx.use f.specs(dependency_names, self)
|
354
|
+
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
|
355
|
+
end
|
356
|
+
|
357
|
+
# Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
|
358
|
+
# sources A and B. At this point, the API request will have found all the versions of Bar in source A,
|
359
|
+
# but will not have found any versions of Bar from source B, which is a problem if the requested version
|
360
|
+
# of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
|
361
|
+
# each spec we found, we add all possible versions from all sources to the index.
|
362
|
+
loop do
|
363
|
+
idxcount = idx.size
|
364
|
+
api_fetchers.each do |f|
|
365
|
+
Bundler.ui.info "Fetching version metadata from #{f.uri}", Bundler.ui.debug?
|
366
|
+
idx.use f.specs(idx.dependency_names, self), true
|
367
|
+
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
|
368
|
+
end
|
369
|
+
break if idxcount == idx.size
|
370
|
+
end
|
371
|
+
|
372
|
+
if api_fetchers.any?
|
373
|
+
# it's possible that gems from one source depend on gems from some
|
374
|
+
# other source, so now we download gemspecs and iterate over those
|
375
|
+
# dependencies, looking for gems we don't have info on yet.
|
376
|
+
unmet = idx.unmet_dependency_names
|
377
|
+
|
378
|
+
# if there are any cross-site gems we missed, get them now
|
379
|
+
api_fetchers.each do |f|
|
380
|
+
Bundler.ui.info "Fetching dependency metadata from #{f.uri}", Bundler.ui.debug?
|
381
|
+
idx.use f.specs(unmet, self)
|
382
|
+
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
|
383
|
+
end if unmet.any?
|
384
|
+
else
|
385
|
+
allow_api = false
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
unless allow_api
|
390
|
+
api_fetchers.each do |f|
|
391
|
+
Bundler.ui.info "Fetching source index from #{f.uri}"
|
392
|
+
idx.use f.specs(nil, self)
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
def fetch_gem(spec)
|
399
|
+
return false unless spec.remote
|
400
|
+
uri = spec.remote.uri
|
401
|
+
spec.fetch_platform
|
402
|
+
|
403
|
+
download_path = Bundler.requires_sudo? ? Bundler.tmp(spec.full_name) : Bundler.rubygems.gem_dir
|
404
|
+
gem_path = "#{Bundler.rubygems.gem_dir}/cache/#{spec.full_name}.gem"
|
405
|
+
|
406
|
+
SharedHelpers.filesystem_access("#{download_path}/cache") do |p|
|
407
|
+
FileUtils.mkdir_p(p)
|
408
|
+
end
|
409
|
+
Bundler.rubygems.download_gem(spec, uri, download_path)
|
410
|
+
|
411
|
+
if Bundler.requires_sudo?
|
412
|
+
SharedHelpers.filesystem_access("#{Bundler.rubygems.gem_dir}/cache") do |p|
|
413
|
+
Bundler.mkdir_p(p)
|
414
|
+
end
|
415
|
+
Bundler.sudo "mv #{download_path}/cache/#{spec.full_name}.gem #{gem_path}"
|
416
|
+
end
|
417
|
+
|
418
|
+
gem_path
|
419
|
+
ensure
|
420
|
+
Bundler.rm_rf(download_path) if Bundler.requires_sudo?
|
421
|
+
end
|
422
|
+
|
423
|
+
def builtin_gem?(spec)
|
424
|
+
# Ruby 2.1, where all included gems have this summary
|
425
|
+
return true if spec.summary =~ /is bundled with Ruby/
|
426
|
+
|
427
|
+
# Ruby 2.0, where gemspecs are stored in specifications/default/
|
428
|
+
spec.loaded_from && spec.loaded_from.include?("specifications/default/")
|
429
|
+
end
|
430
|
+
|
431
|
+
def installed?(spec)
|
432
|
+
installed_specs[spec].any?
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Bundler
|
2
|
+
class Source
|
3
|
+
class Rubygems
|
4
|
+
class Remote
|
5
|
+
attr_reader :uri,
|
6
|
+
:anonymized_uri
|
7
|
+
|
8
|
+
def initialize(uri)
|
9
|
+
uri = Bundler.settings.mirror_for(uri)
|
10
|
+
fallback_auth = Bundler.settings.credentials_for(uri)
|
11
|
+
|
12
|
+
@uri = apply_auth(uri, fallback_auth).freeze
|
13
|
+
@anonymized_uri = remove_auth(@uri).freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def apply_auth(uri, auth)
|
19
|
+
if auth && uri.userinfo.nil?
|
20
|
+
uri = uri.dup
|
21
|
+
uri.userinfo = auth
|
22
|
+
end
|
23
|
+
|
24
|
+
uri
|
25
|
+
end
|
26
|
+
|
27
|
+
def remove_auth(uri)
|
28
|
+
if uri.userinfo
|
29
|
+
uri = uri.dup
|
30
|
+
uri.user = uri.password = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
uri
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|