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,190 @@
|
|
1
|
+
module Bundler
|
2
|
+
class Source
|
3
|
+
class Git < Path
|
4
|
+
class GitNotInstalledError < GitError
|
5
|
+
def initialize
|
6
|
+
msg = "You need to install git to be able to use gems from git repositories. "
|
7
|
+
msg << "For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git"
|
8
|
+
super msg
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class GitNotAllowedError < GitError
|
13
|
+
def initialize(command)
|
14
|
+
msg = "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, "
|
15
|
+
msg << "this error message could probably be more useful. Please submit a ticket at http://github.com/bundler/bundler/issues "
|
16
|
+
msg << "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}"
|
17
|
+
super msg
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class GitCommandError < GitError
|
22
|
+
def initialize(command, path = nil, extra_info = nil)
|
23
|
+
msg = "Git error: command `git #{command}` in directory #{SharedHelpers.pwd} has failed."
|
24
|
+
msg << "\n#{extra_info}" if extra_info
|
25
|
+
msg << "\nIf this error persists you could try removing the cache directory '#{path}'" if path && path.exist?
|
26
|
+
super msg
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# The GitProxy is responsible to interact with git repositories.
|
31
|
+
# All actions required by the Git source is encapsulated in this
|
32
|
+
# object.
|
33
|
+
class GitProxy
|
34
|
+
attr_accessor :path, :uri, :ref
|
35
|
+
attr_writer :revision
|
36
|
+
|
37
|
+
def initialize(path, uri, ref, revision = nil, git = nil)
|
38
|
+
@path = path
|
39
|
+
@uri = uri
|
40
|
+
@ref = ref
|
41
|
+
@revision = revision
|
42
|
+
@git = git
|
43
|
+
raise GitNotInstalledError.new if allow? && !Bundler.git_present?
|
44
|
+
end
|
45
|
+
|
46
|
+
def revision
|
47
|
+
@revision ||= allowed_in_path do
|
48
|
+
msg = "Ref '#{ref}' was not found. Perhaps you mispelled it?"
|
49
|
+
git("rev-parse --verify #{ref}", true, msg).strip
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def branch
|
54
|
+
@branch ||= allowed_in_path do
|
55
|
+
git("branch") =~ /^\* (.*)$/ && $1.strip
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def contains?(commit)
|
60
|
+
allowed_in_path do
|
61
|
+
result = git_null("branch --contains #{commit}")
|
62
|
+
$? == 0 && result =~ /^\* (.*)$/
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def version
|
67
|
+
git("--version").sub("git version", "").strip
|
68
|
+
end
|
69
|
+
|
70
|
+
def checkout
|
71
|
+
if path.exist?
|
72
|
+
return if has_revision_cached?
|
73
|
+
Bundler.ui.info "Fetching #{uri}"
|
74
|
+
in_path do
|
75
|
+
git_retry %|fetch --force --quiet --tags #{uri_escaped_with_configured_credentials} "refs/heads/*:refs/heads/*"|
|
76
|
+
end
|
77
|
+
else
|
78
|
+
Bundler.ui.info "Fetching #{uri}"
|
79
|
+
SharedHelpers.filesystem_access(path.dirname) do |p|
|
80
|
+
FileUtils.mkdir_p(p)
|
81
|
+
end
|
82
|
+
git_retry %|clone #{uri_escaped_with_configured_credentials} "#{path}" --bare --no-hardlinks --quiet|
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def copy_to(destination, submodules = false)
|
87
|
+
# method 1
|
88
|
+
unless File.exist?(destination.join(".git"))
|
89
|
+
begin
|
90
|
+
SharedHelpers.filesystem_access(destination.dirname) do |p|
|
91
|
+
FileUtils.mkdir_p(p)
|
92
|
+
end
|
93
|
+
SharedHelpers.filesystem_access(destination) do |p|
|
94
|
+
FileUtils.rm_rf(p)
|
95
|
+
end
|
96
|
+
git_retry %|clone --no-checkout --quiet "#{path}" "#{destination}"|
|
97
|
+
File.chmod(((File.stat(destination).mode | 0777) & ~File.umask), destination)
|
98
|
+
rescue Errno::EEXIST => e
|
99
|
+
file_path = e.message[%r{.*?(/.*)}, 1]
|
100
|
+
raise GitError, "Bundler could not install a gem because it needs to " \
|
101
|
+
"create a directory, but a file exists - #{file_path}. Please delete " \
|
102
|
+
"this file and try again."
|
103
|
+
end
|
104
|
+
end
|
105
|
+
# method 2
|
106
|
+
SharedHelpers.chdir(destination) do
|
107
|
+
git_retry %|fetch --force --quiet --tags "#{path}"|
|
108
|
+
git "reset --hard #{@revision}"
|
109
|
+
|
110
|
+
if submodules
|
111
|
+
git_retry "submodule update --init --recursive"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
# TODO: Do not rely on /dev/null.
|
119
|
+
# Given that open3 is not cross platform until Ruby 1.9.3,
|
120
|
+
# the best solution is to pipe to /dev/null if it exists.
|
121
|
+
# If it doesn't, everything will work fine, but the user
|
122
|
+
# will get the $stderr messages as well.
|
123
|
+
def git_null(command)
|
124
|
+
git("#{command} 2>#{Bundler::NULL}", false)
|
125
|
+
end
|
126
|
+
|
127
|
+
def git_retry(command)
|
128
|
+
Bundler::Retry.new("git #{command}", GitNotAllowedError).attempts do
|
129
|
+
git(command)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def git(command, check_errors = true, error_msg = nil)
|
134
|
+
raise GitNotAllowedError.new(command) unless allow?
|
135
|
+
out = SharedHelpers.with_clean_git_env { `git #{command}` }
|
136
|
+
raise GitCommandError.new(command, path, error_msg) if check_errors && !$?.success?
|
137
|
+
out
|
138
|
+
end
|
139
|
+
|
140
|
+
def has_revision_cached?
|
141
|
+
return unless @revision
|
142
|
+
in_path { git("cat-file -e #{@revision}") }
|
143
|
+
true
|
144
|
+
rescue GitError
|
145
|
+
false
|
146
|
+
end
|
147
|
+
|
148
|
+
# Escape the URI for git commands
|
149
|
+
def uri_escaped_with_configured_credentials
|
150
|
+
remote = configured_uri_for(uri)
|
151
|
+
if Bundler::WINDOWS
|
152
|
+
# Windows quoting requires double quotes only, with double quotes
|
153
|
+
# inside the string escaped by being doubled.
|
154
|
+
'"' + remote.gsub('"') { '""' } + '"'
|
155
|
+
else
|
156
|
+
# Bash requires single quoted strings, with the single quotes escaped
|
157
|
+
# by ending the string, escaping the quote, and restarting the string.
|
158
|
+
"'" + remote.gsub("'") { "'\\''" } + "'"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Adds credentials to the URI as Fetcher#configured_uri_for does
|
163
|
+
def configured_uri_for(uri)
|
164
|
+
if /https?:/ =~ uri
|
165
|
+
remote = URI(uri)
|
166
|
+
config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
|
167
|
+
remote.userinfo ||= config_auth
|
168
|
+
remote.to_s
|
169
|
+
else
|
170
|
+
uri
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def allow?
|
175
|
+
@git ? @git.allow_git_ops? : true
|
176
|
+
end
|
177
|
+
|
178
|
+
def in_path(&blk)
|
179
|
+
checkout unless path.exist?
|
180
|
+
SharedHelpers.chdir(path, &blk)
|
181
|
+
end
|
182
|
+
|
183
|
+
def allowed_in_path
|
184
|
+
return in_path { yield } if allow?
|
185
|
+
raise GitError, "The git source #{uri} is not yet checked out. Please run `bundle install` before trying to start your application"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,224 @@
|
|
1
|
+
module Bundler
|
2
|
+
class Source
|
3
|
+
class Path < Source
|
4
|
+
autoload :Installer, "bundler/source/path/installer"
|
5
|
+
|
6
|
+
attr_reader :path, :options
|
7
|
+
attr_writer :name
|
8
|
+
attr_accessor :version
|
9
|
+
|
10
|
+
DEFAULT_GLOB = "{,*,*/*}.gemspec"
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
@options = options
|
14
|
+
@glob = options["glob"] || DEFAULT_GLOB
|
15
|
+
|
16
|
+
@allow_cached = false
|
17
|
+
@allow_remote = false
|
18
|
+
|
19
|
+
if options["path"]
|
20
|
+
@path = Pathname.new(options["path"])
|
21
|
+
@path = expand(@path) unless @path.relative?
|
22
|
+
end
|
23
|
+
|
24
|
+
@name = options["name"]
|
25
|
+
@version = options["version"]
|
26
|
+
|
27
|
+
# Stores the original path. If at any point we move to the
|
28
|
+
# cached directory, we still have the original path to copy from.
|
29
|
+
@original_path = @path
|
30
|
+
end
|
31
|
+
|
32
|
+
def remote!
|
33
|
+
@allow_remote = true
|
34
|
+
end
|
35
|
+
|
36
|
+
def cached!
|
37
|
+
@allow_cached = true
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.from_lock(options)
|
41
|
+
new(options.merge("path" => options.delete("remote")))
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_lock
|
45
|
+
out = "PATH\n"
|
46
|
+
out << " remote: #{relative_path}\n"
|
47
|
+
out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
|
48
|
+
out << " specs:\n"
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_s
|
52
|
+
"source at #{@path}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def hash
|
56
|
+
[self.class, expanded_path, version].hash
|
57
|
+
end
|
58
|
+
|
59
|
+
def eql?(other)
|
60
|
+
other.instance_of?(Path) &&
|
61
|
+
expanded_path == expand(other.path) &&
|
62
|
+
version == other.version
|
63
|
+
end
|
64
|
+
|
65
|
+
alias_method :==, :eql?
|
66
|
+
|
67
|
+
def name
|
68
|
+
File.basename(expanded_path.to_s)
|
69
|
+
end
|
70
|
+
|
71
|
+
def install(spec, force = false)
|
72
|
+
Bundler.ui.info "Using #{version_message(spec)} from #{self}"
|
73
|
+
generate_bin(spec, :disable_extensions)
|
74
|
+
nil # no post-install message
|
75
|
+
end
|
76
|
+
|
77
|
+
def cache(spec, custom_path = nil)
|
78
|
+
app_cache_path = app_cache_path(custom_path)
|
79
|
+
return unless Bundler.settings[:cache_all]
|
80
|
+
return if expand(@original_path).to_s.index(Bundler.root.to_s + "/") == 0
|
81
|
+
|
82
|
+
unless @original_path.exist?
|
83
|
+
raise GemNotFound, "Can't cache gem #{version_message(spec)} because #{self} is missing!"
|
84
|
+
end
|
85
|
+
|
86
|
+
FileUtils.rm_rf(app_cache_path)
|
87
|
+
FileUtils.cp_r("#{@original_path}/.", app_cache_path)
|
88
|
+
FileUtils.touch(app_cache_path.join(".bundlecache"))
|
89
|
+
end
|
90
|
+
|
91
|
+
def local_specs(*)
|
92
|
+
@local_specs ||= load_spec_files
|
93
|
+
end
|
94
|
+
|
95
|
+
def specs
|
96
|
+
if has_app_cache?
|
97
|
+
@path = app_cache_path
|
98
|
+
@expanded_path = nil # Invalidate
|
99
|
+
end
|
100
|
+
local_specs
|
101
|
+
end
|
102
|
+
|
103
|
+
def app_cache_dirname
|
104
|
+
name
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def expanded_path
|
110
|
+
@expanded_path ||= expand(path)
|
111
|
+
end
|
112
|
+
|
113
|
+
def expand(somepath)
|
114
|
+
somepath.expand_path(Bundler.root)
|
115
|
+
rescue ArgumentError => e
|
116
|
+
Bundler.ui.debug(e)
|
117
|
+
raise PathError, "There was an error while trying to use the path " \
|
118
|
+
"`#{somepath}`.\nThe error message was: #{e.message}."
|
119
|
+
end
|
120
|
+
|
121
|
+
def app_cache_path(custom_path = nil)
|
122
|
+
@app_cache_path ||= Bundler.app_cache(custom_path).join(app_cache_dirname)
|
123
|
+
end
|
124
|
+
|
125
|
+
def has_app_cache?
|
126
|
+
SharedHelpers.in_bundle? && app_cache_path.exist?
|
127
|
+
end
|
128
|
+
|
129
|
+
def load_spec_files
|
130
|
+
index = Index.new
|
131
|
+
|
132
|
+
if File.directory?(expanded_path)
|
133
|
+
# We sort depth-first since `<<` will override the earlier-found specs
|
134
|
+
Dir["#{expanded_path}/#{@glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
|
135
|
+
if spec = Bundler.load_gemspec(file, :validate)
|
136
|
+
spec.loaded_from = file.to_s
|
137
|
+
spec.source = self
|
138
|
+
index << spec
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
if index.empty? && @name && @version
|
143
|
+
index << Gem::Specification.new do |s|
|
144
|
+
s.name = @name
|
145
|
+
s.source = self
|
146
|
+
s.version = Gem::Version.new(@version)
|
147
|
+
s.platform = Gem::Platform::RUBY
|
148
|
+
s.summary = "Fake gemspec for #{@name}"
|
149
|
+
s.relative_loaded_from = "#{@name}.gemspec"
|
150
|
+
s.authors = ["no one"]
|
151
|
+
if expanded_path.join("bin").exist?
|
152
|
+
executables = expanded_path.join("bin").children
|
153
|
+
executables.reject! {|p| File.directory?(p) }
|
154
|
+
s.executables = executables.map {|c| c.basename.to_s }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
elsif File.exist?(expanded_path)
|
159
|
+
raise PathError, "The path `#{expanded_path}` is not a directory."
|
160
|
+
else
|
161
|
+
raise PathError, "The path `#{expanded_path}` does not exist."
|
162
|
+
end
|
163
|
+
|
164
|
+
index
|
165
|
+
end
|
166
|
+
|
167
|
+
def relative_path
|
168
|
+
if path.to_s.start_with?(Bundler.root.to_s)
|
169
|
+
return path.relative_path_from(Bundler.root)
|
170
|
+
end
|
171
|
+
path
|
172
|
+
end
|
173
|
+
|
174
|
+
def generate_bin(spec, disable_extensions = false)
|
175
|
+
gem_dir = Pathname.new(spec.full_gem_path)
|
176
|
+
|
177
|
+
# Some gem authors put absolute paths in their gemspec
|
178
|
+
# and we have to save them from themselves
|
179
|
+
spec.files = spec.files.map do |p|
|
180
|
+
next if File.directory?(p)
|
181
|
+
begin
|
182
|
+
Pathname.new(p).relative_path_from(gem_dir).to_s
|
183
|
+
rescue ArgumentError
|
184
|
+
p
|
185
|
+
end
|
186
|
+
end.compact
|
187
|
+
|
188
|
+
SharedHelpers.chdir(gem_dir) do
|
189
|
+
installer = Path::Installer.new(spec, :env_shebang => false)
|
190
|
+
run_hooks(:pre_install, installer)
|
191
|
+
installer.build_extensions unless disable_extensions
|
192
|
+
run_hooks(:post_build, installer)
|
193
|
+
installer.generate_bin
|
194
|
+
run_hooks(:post_install, installer)
|
195
|
+
end
|
196
|
+
rescue Gem::InvalidSpecificationException => e
|
197
|
+
Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" \
|
198
|
+
"This prevents bundler from installing bins or native extensions, but " \
|
199
|
+
"that may not affect its functionality."
|
200
|
+
|
201
|
+
if !spec.extensions.empty? && !spec.email.empty?
|
202
|
+
Bundler.ui.warn "If you need to use this package without installing it from a gem " \
|
203
|
+
"repository, please contact #{spec.email} and ask them " \
|
204
|
+
"to modify their .gemspec so it can work with `gem build`."
|
205
|
+
end
|
206
|
+
|
207
|
+
Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}"
|
208
|
+
end
|
209
|
+
|
210
|
+
def run_hooks(type, installer)
|
211
|
+
hooks_meth = "#{type}_hooks"
|
212
|
+
return unless Gem.respond_to?(hooks_meth)
|
213
|
+
Gem.send(hooks_meth).each do |hook|
|
214
|
+
result = hook.call(installer)
|
215
|
+
if result == false
|
216
|
+
location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
|
217
|
+
message = "#{type} hook#{location} failed for #{installer.spec.full_name}"
|
218
|
+
raise InstallHookError, message
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Bundler
|
2
|
+
class Source
|
3
|
+
class Path
|
4
|
+
class Installer < Bundler::GemInstaller
|
5
|
+
attr_reader :spec
|
6
|
+
|
7
|
+
def initialize(spec, options = {})
|
8
|
+
@spec = spec
|
9
|
+
@gem_dir = Bundler.rubygems.path(spec.full_gem_path)
|
10
|
+
@wrappers = true
|
11
|
+
@env_shebang = true
|
12
|
+
@format_executable = options[:format_executable] || false
|
13
|
+
@build_args = options[:build_args] || Bundler.rubygems.build_args
|
14
|
+
@gem_bin_dir = "#{Bundler.rubygems.gem_dir}/bin"
|
15
|
+
|
16
|
+
if Bundler.requires_sudo?
|
17
|
+
@tmp_dir = Bundler.tmp(spec.full_name).to_s
|
18
|
+
@bin_dir = "#{@tmp_dir}/bin"
|
19
|
+
else
|
20
|
+
@bin_dir = @gem_bin_dir
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def generate_bin
|
25
|
+
return if spec.executables.nil? || spec.executables.empty?
|
26
|
+
|
27
|
+
super
|
28
|
+
|
29
|
+
if Bundler.requires_sudo?
|
30
|
+
SharedHelpers.filesystem_access(@gem_bin_dir) do |p|
|
31
|
+
Bundler.mkdir_p(p)
|
32
|
+
end
|
33
|
+
spec.executables.each do |exe|
|
34
|
+
Bundler.sudo "cp -R #{@bin_dir}/#{exe} #{@gem_bin_dir}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
ensure
|
38
|
+
Bundler.rm_rf(@tmp_dir) if Bundler.requires_sudo?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|