rubygems-update 3.5.7 → 3.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/Manifest.txt +3 -0
- data/bundler/CHANGELOG.md +12 -0
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli/plugin.rb +2 -1
- data/bundler/lib/bundler/gem_version_promoter.rb +42 -38
- data/bundler/lib/bundler/man/bundle-add.1 +1 -1
- data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
- data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
- data/bundler/lib/bundler/man/bundle-check.1 +1 -1
- data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
- data/bundler/lib/bundler/man/bundle-config.1 +1 -1
- data/bundler/lib/bundler/man/bundle-console.1 +1 -1
- data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
- data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
- data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
- data/bundler/lib/bundler/man/bundle-help.1 +1 -1
- data/bundler/lib/bundler/man/bundle-info.1 +1 -1
- data/bundler/lib/bundler/man/bundle-init.1 +1 -1
- data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
- data/bundler/lib/bundler/man/bundle-install.1 +1 -1
- data/bundler/lib/bundler/man/bundle-list.1 +1 -1
- data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
- data/bundler/lib/bundler/man/bundle-open.1 +1 -1
- data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
- data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
- data/bundler/lib/bundler/man/bundle-plugin.1 +6 -3
- data/bundler/lib/bundler/man/bundle-plugin.1.ronn +6 -2
- data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
- data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
- data/bundler/lib/bundler/man/bundle-show.1 +1 -1
- data/bundler/lib/bundler/man/bundle-update.1 +1 -1
- data/bundler/lib/bundler/man/bundle-version.1 +1 -1
- data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
- data/bundler/lib/bundler/man/bundle.1 +1 -1
- data/bundler/lib/bundler/man/gemfile.5 +1 -1
- data/bundler/lib/bundler/plugin/installer/path.rb +18 -0
- data/bundler/lib/bundler/plugin/installer.rb +34 -10
- data/bundler/lib/bundler/plugin/source_list.rb +4 -4
- data/bundler/lib/bundler/resolver/candidate.rb +1 -1
- data/bundler/lib/bundler/resolver.rb +54 -24
- data/bundler/lib/bundler/self_manager.rb +1 -1
- data/bundler/lib/bundler/source/rubygems.rb +2 -2
- data/bundler/lib/bundler/source_list.rb +2 -2
- data/bundler/lib/bundler/version.rb +1 -1
- data/lib/rubygems/command_manager.rb +1 -0
- data/lib/rubygems/commands/build_command.rb +2 -11
- data/lib/rubygems/commands/rebuild_command.rb +264 -0
- data/lib/rubygems/config_file.rb +20 -8
- data/lib/rubygems/gemspec_helpers.rb +19 -0
- data/lib/rubygems/package.rb +2 -2
- data/lib/rubygems/resolver/spec_specification.rb +7 -0
- data/lib/rubygems.rb +1 -1
- data/rubygems-update.gemspec +1 -1
- metadata +6 -3
@@ -9,6 +9,10 @@ module Bundler
|
|
9
9
|
add_source_to_list Plugin::Installer::Git.new(options), git_sources
|
10
10
|
end
|
11
11
|
|
12
|
+
def add_path_source(options = {})
|
13
|
+
add_source_to_list Plugin::Installer::Path.new(options), path_sources
|
14
|
+
end
|
15
|
+
|
12
16
|
def add_rubygems_source(options = {})
|
13
17
|
add_source_to_list Plugin::Installer::Rubygems.new(options), @rubygems_sources
|
14
18
|
end
|
@@ -17,10 +21,6 @@ module Bundler
|
|
17
21
|
path_sources + git_sources + rubygems_sources + [metadata_source]
|
18
22
|
end
|
19
23
|
|
20
|
-
def default_source
|
21
|
-
git_sources.first || global_rubygems_source
|
22
|
-
end
|
23
|
-
|
24
24
|
private
|
25
25
|
|
26
26
|
def rubygems_aggregate_class
|
@@ -15,7 +15,7 @@ module Bundler
|
|
15
15
|
# considered separately.
|
16
16
|
#
|
17
17
|
# Some candidates may also keep some information explicitly about the
|
18
|
-
# package
|
18
|
+
# package they refer to. These candidates are referred to as "canonical" and
|
19
19
|
# are used when materializing resolution results back into RubyGems
|
20
20
|
# specifications that can be installed, written to lock files, and so on.
|
21
21
|
#
|
@@ -50,26 +50,26 @@ module Bundler
|
|
50
50
|
specs[name] = matches.sort_by {|s| [s.version, s.platform.to_s] }
|
51
51
|
end
|
52
52
|
|
53
|
+
@all_versions = Hash.new do |candidates, package|
|
54
|
+
candidates[package] = all_versions_for(package)
|
55
|
+
end
|
56
|
+
|
53
57
|
@sorted_versions = Hash.new do |candidates, package|
|
54
|
-
candidates[package] =
|
55
|
-
[root_version]
|
56
|
-
else
|
57
|
-
all_versions_for(package).sort
|
58
|
-
end
|
58
|
+
candidates[package] = filtered_versions_for(package).sort
|
59
59
|
end
|
60
60
|
|
61
|
+
@sorted_versions[root] = [root_version]
|
62
|
+
|
61
63
|
root_dependencies = prepare_dependencies(@requirements, @packages)
|
62
64
|
|
63
65
|
@cached_dependencies = Hash.new do |dependencies, package|
|
64
|
-
dependencies[package] =
|
65
|
-
{
|
66
|
-
else
|
67
|
-
Hash.new do |versions, version|
|
68
|
-
versions[version] = to_dependency_hash(version.dependencies.reject {|d| d.name == package.name }, @packages)
|
69
|
-
end
|
66
|
+
dependencies[package] = Hash.new do |versions, version|
|
67
|
+
versions[version] = to_dependency_hash(version.dependencies.reject {|d| d.name == package.name }, @packages)
|
70
68
|
end
|
71
69
|
end
|
72
70
|
|
71
|
+
@cached_dependencies[root] = { root_version => root_dependencies }
|
72
|
+
|
73
73
|
logger = Bundler::UI::Shell.new
|
74
74
|
logger.level = debug? ? "debug" : "warn"
|
75
75
|
|
@@ -156,9 +156,15 @@ module Bundler
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def versions_for(package, range=VersionRange.any)
|
159
|
-
versions =
|
159
|
+
versions = select_sorted_versions(package, range)
|
160
160
|
|
161
|
-
|
161
|
+
# Conditional avoids (among other things) calling
|
162
|
+
# sort_versions_by_preferred with the root package
|
163
|
+
if versions.size > 1
|
164
|
+
sort_versions_by_preferred(package, versions)
|
165
|
+
else
|
166
|
+
versions
|
167
|
+
end
|
162
168
|
end
|
163
169
|
|
164
170
|
def no_versions_incompatibility_for(package, unsatisfied_term)
|
@@ -247,7 +253,7 @@ module Bundler
|
|
247
253
|
locked_requirement = base_requirements[name]
|
248
254
|
results = filter_matching_specs(results, locked_requirement) if locked_requirement
|
249
255
|
|
250
|
-
|
256
|
+
results.group_by(&:version).reduce([]) do |groups, (version, specs)|
|
251
257
|
platform_specs = package.platforms.map {|platform| select_best_platform_match(specs, platform) }
|
252
258
|
|
253
259
|
# If package is a top-level dependency,
|
@@ -274,8 +280,6 @@ module Bundler
|
|
274
280
|
|
275
281
|
groups
|
276
282
|
end
|
277
|
-
|
278
|
-
sort_versions(package, versions)
|
279
283
|
end
|
280
284
|
|
281
285
|
def source_for(name)
|
@@ -334,6 +338,21 @@ module Bundler
|
|
334
338
|
|
335
339
|
private
|
336
340
|
|
341
|
+
def filtered_versions_for(package)
|
342
|
+
@gem_version_promoter.filter_versions(package, @all_versions[package])
|
343
|
+
end
|
344
|
+
|
345
|
+
def raise_all_versions_filtered_out!(package)
|
346
|
+
level = @gem_version_promoter.level
|
347
|
+
name = package.name
|
348
|
+
locked_version = package.locked_version
|
349
|
+
requirement = package.dependency
|
350
|
+
|
351
|
+
raise GemNotFound,
|
352
|
+
"#{name} is locked to #{locked_version}, while Gemfile is requesting #{requirement}. " \
|
353
|
+
"--strict --#{level} was specified, but there are no #{level} level upgrades from #{locked_version} satisfying #{requirement}, so version solving has failed"
|
354
|
+
end
|
355
|
+
|
337
356
|
def filter_matching_specs(specs, requirements)
|
338
357
|
Array(requirements).flat_map do |requirement|
|
339
358
|
specs.select {| spec| requirement_satisfied_by?(requirement, spec) }
|
@@ -357,12 +376,8 @@ module Bundler
|
|
357
376
|
requirement.satisfied_by?(spec.version) || spec.source.is_a?(Source::Gemspec)
|
358
377
|
end
|
359
378
|
|
360
|
-
def
|
361
|
-
|
362
|
-
@gem_version_promoter.sort_versions(package, versions).reverse
|
363
|
-
else
|
364
|
-
versions
|
365
|
-
end
|
379
|
+
def sort_versions_by_preferred(package, versions)
|
380
|
+
@gem_version_promoter.sort_versions(package, versions)
|
366
381
|
end
|
367
382
|
|
368
383
|
def repository_for(package)
|
@@ -379,12 +394,19 @@ module Bundler
|
|
379
394
|
|
380
395
|
next [dep_package, dep_constraint] if name == "bundler"
|
381
396
|
|
382
|
-
|
397
|
+
dep_range = dep_constraint.range
|
398
|
+
versions = select_sorted_versions(dep_package, dep_range)
|
383
399
|
if versions.empty? && dep_package.ignores_prereleases?
|
400
|
+
@all_versions.delete(dep_package)
|
384
401
|
@sorted_versions.delete(dep_package)
|
385
402
|
dep_package.consider_prereleases!
|
386
|
-
versions =
|
403
|
+
versions = select_sorted_versions(dep_package, dep_range)
|
387
404
|
end
|
405
|
+
|
406
|
+
if versions.empty? && select_all_versions(dep_package, dep_range).any?
|
407
|
+
raise_all_versions_filtered_out!(dep_package)
|
408
|
+
end
|
409
|
+
|
388
410
|
next [dep_package, dep_constraint] unless versions.empty?
|
389
411
|
|
390
412
|
next unless dep_package.current_platform?
|
@@ -393,6 +415,14 @@ module Bundler
|
|
393
415
|
end.compact.to_h
|
394
416
|
end
|
395
417
|
|
418
|
+
def select_sorted_versions(package, range)
|
419
|
+
range.select_versions(@sorted_versions[package])
|
420
|
+
end
|
421
|
+
|
422
|
+
def select_all_versions(package, range)
|
423
|
+
range.select_versions(@all_versions[package])
|
424
|
+
end
|
425
|
+
|
396
426
|
def other_specs_matching_message(specs, requirement)
|
397
427
|
message = String.new("The source contains the following gems matching '#{requirement}':\n")
|
398
428
|
message << specs.map {|s| " * #{s.full_name}" }.join("\n")
|
@@ -113,7 +113,7 @@ module Bundler
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def local_specs
|
116
|
-
@local_specs ||= Bundler::Source::Rubygems.new("allow_local" => true).specs.select {|spec| spec.name == "bundler" }
|
116
|
+
@local_specs ||= Bundler::Source::Rubygems.new("allow_local" => true, "allow_cached" => true).specs.select {|spec| spec.name == "bundler" }
|
117
117
|
end
|
118
118
|
|
119
119
|
def remote_specs
|
@@ -17,7 +17,7 @@ module Bundler
|
|
17
17
|
@remotes = []
|
18
18
|
@dependency_names = []
|
19
19
|
@allow_remote = false
|
20
|
-
@allow_cached = false
|
20
|
+
@allow_cached = options["allow_cached"] || false
|
21
21
|
@allow_local = options["allow_local"] || false
|
22
22
|
@checksum_store = Checksum::Store.new
|
23
23
|
|
@@ -133,7 +133,7 @@ module Bundler
|
|
133
133
|
# sources, and large_idx.merge! small_idx is way faster than
|
134
134
|
# small_idx.merge! large_idx.
|
135
135
|
index = @allow_remote ? remote_specs.dup : Index.new
|
136
|
-
index.merge!(cached_specs) if @allow_cached
|
136
|
+
index.merge!(cached_specs) if @allow_cached
|
137
137
|
index.merge!(installed_specs) if @allow_local
|
138
138
|
index
|
139
139
|
end
|
@@ -9,7 +9,7 @@ module Bundler
|
|
9
9
|
:metadata_source
|
10
10
|
|
11
11
|
def global_rubygems_source
|
12
|
-
@global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true)
|
12
|
+
@global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true, "allow_cached" => true)
|
13
13
|
end
|
14
14
|
|
15
15
|
def initialize
|
@@ -174,7 +174,7 @@ module Bundler
|
|
174
174
|
replacement_source = replacement_sources.find {|s| s == global_rubygems_source }
|
175
175
|
return global_rubygems_source unless replacement_source
|
176
176
|
|
177
|
-
replacement_source.
|
177
|
+
replacement_source.cached!
|
178
178
|
replacement_source
|
179
179
|
end
|
180
180
|
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "../command"
|
4
|
+
require_relative "../gemspec_helpers"
|
4
5
|
require_relative "../package"
|
5
6
|
require_relative "../version_option"
|
6
7
|
|
7
8
|
class Gem::Commands::BuildCommand < Gem::Command
|
8
9
|
include Gem::VersionOption
|
10
|
+
include Gem::GemspecHelpers
|
9
11
|
|
10
12
|
def initialize
|
11
13
|
super "build", "Build a gem from a gemspec"
|
@@ -75,17 +77,6 @@ Gems can be saved to a specified filename with the output option:
|
|
75
77
|
|
76
78
|
private
|
77
79
|
|
78
|
-
def find_gemspec(glob = "*.gemspec")
|
79
|
-
gemspecs = Dir.glob(glob).sort
|
80
|
-
|
81
|
-
if gemspecs.size > 1
|
82
|
-
alert_error "Multiple gemspecs found: #{gemspecs}, please specify one"
|
83
|
-
terminate_interaction(1)
|
84
|
-
end
|
85
|
-
|
86
|
-
gemspecs.first
|
87
|
-
end
|
88
|
-
|
89
80
|
def build_gem
|
90
81
|
gemspec = resolve_gem_name
|
91
82
|
|
@@ -0,0 +1,264 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "digest"
|
5
|
+
require "fileutils"
|
6
|
+
require "tmpdir"
|
7
|
+
require_relative "../gemspec_helpers"
|
8
|
+
require_relative "../package"
|
9
|
+
|
10
|
+
class Gem::Commands::RebuildCommand < Gem::Command
|
11
|
+
include Gem::GemspecHelpers
|
12
|
+
|
13
|
+
DATE_FORMAT = "%Y-%m-%d %H:%M:%S.%N Z"
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super "rebuild", "Attempt to reproduce a build of a gem."
|
17
|
+
|
18
|
+
add_option "--diff", "If the files don't match, compare them using diffoscope." do |_value, options|
|
19
|
+
options[:diff] = true
|
20
|
+
end
|
21
|
+
|
22
|
+
add_option "--force", "Skip validation of the spec." do |_value, options|
|
23
|
+
options[:force] = true
|
24
|
+
end
|
25
|
+
|
26
|
+
add_option "--strict", "Consider warnings as errors when validating the spec." do |_value, options|
|
27
|
+
options[:strict] = true
|
28
|
+
end
|
29
|
+
|
30
|
+
add_option "--source GEM_SOURCE", "Specify the source to download the gem from." do |value, options|
|
31
|
+
options[:source] = value
|
32
|
+
end
|
33
|
+
|
34
|
+
add_option "--original GEM_FILE", "Specify a local file to compare against (instead of downloading it)." do |value, options|
|
35
|
+
options[:original_gem_file] = value
|
36
|
+
end
|
37
|
+
|
38
|
+
add_option "--gemspec GEMSPEC_FILE", "Specify the name of the gemspec file." do |value, options|
|
39
|
+
options[:gemspec_file] = value
|
40
|
+
end
|
41
|
+
|
42
|
+
add_option "-C PATH", "Run as if gem build was started in <PATH> instead of the current working directory." do |value, options|
|
43
|
+
options[:build_path] = value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def arguments # :nodoc:
|
48
|
+
"GEM_NAME gem name on gem server\n" \
|
49
|
+
"GEM_VERSION gem version you are attempting to rebuild"
|
50
|
+
end
|
51
|
+
|
52
|
+
def description # :nodoc:
|
53
|
+
<<-EOF
|
54
|
+
The rebuild command allows you to (attempt to) reproduce a build of a gem
|
55
|
+
from a ruby gemspec.
|
56
|
+
|
57
|
+
This command assumes the gemspec can be built with the `gem build` command.
|
58
|
+
If you use any of `gem build`, `rake build`, or`rake release` in the
|
59
|
+
build/release process for a gem, it is a potential candidate.
|
60
|
+
|
61
|
+
You will need to match the RubyGems version used, since this is included in
|
62
|
+
the Gem metadata.
|
63
|
+
|
64
|
+
If the gem includes lockfiles (e.g. Gemfile.lock) and similar, it will
|
65
|
+
require more effort to reproduce a build. For example, it might require
|
66
|
+
more precisely matched versions of Ruby and/or Bundler to be used.
|
67
|
+
EOF
|
68
|
+
end
|
69
|
+
|
70
|
+
def usage # :nodoc:
|
71
|
+
"#{program_name} GEM_NAME GEM_VERSION"
|
72
|
+
end
|
73
|
+
|
74
|
+
def execute
|
75
|
+
gem_name, gem_version = get_gem_name_and_version
|
76
|
+
|
77
|
+
old_dir, new_dir = prep_dirs
|
78
|
+
|
79
|
+
gem_filename = "#{gem_name}-#{gem_version}.gem"
|
80
|
+
old_file = File.join(old_dir, gem_filename)
|
81
|
+
new_file = File.join(new_dir, gem_filename)
|
82
|
+
|
83
|
+
if options[:original_gem_file]
|
84
|
+
FileUtils.copy_file(options[:original_gem_file], old_file)
|
85
|
+
else
|
86
|
+
download_gem(gem_name, gem_version, old_file)
|
87
|
+
end
|
88
|
+
|
89
|
+
rg_version = rubygems_version(old_file)
|
90
|
+
unless rg_version == Gem::VERSION
|
91
|
+
alert_error <<-EOF
|
92
|
+
You need to use the same RubyGems version #{gem_name} v#{gem_version} was built with.
|
93
|
+
|
94
|
+
#{gem_name} v#{gem_version} was built using RubyGems v#{rg_version}.
|
95
|
+
Gem files include the version of RubyGems used to build them.
|
96
|
+
This means in order to reproduce #{gem_filename}, you must also use RubyGems v#{rg_version}.
|
97
|
+
|
98
|
+
You're using RubyGems v#{Gem::VERSION}.
|
99
|
+
|
100
|
+
Please install RubyGems v#{rg_version} and try again.
|
101
|
+
EOF
|
102
|
+
terminate_interaction 1
|
103
|
+
end
|
104
|
+
|
105
|
+
source_date_epoch = get_timestamp(old_file).to_s
|
106
|
+
|
107
|
+
if build_path = options[:build_path]
|
108
|
+
Dir.chdir(build_path) { build_gem(gem_name, source_date_epoch, new_file) }
|
109
|
+
else
|
110
|
+
build_gem(gem_name, source_date_epoch, new_file)
|
111
|
+
end
|
112
|
+
|
113
|
+
compare(source_date_epoch, old_file, new_file)
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def sha256(file)
|
119
|
+
Digest::SHA256.hexdigest(Gem.read_binary(file))
|
120
|
+
end
|
121
|
+
|
122
|
+
def get_timestamp(file)
|
123
|
+
mtime = nil
|
124
|
+
File.open(file, Gem.binary_mode) do |f|
|
125
|
+
Gem::Package::TarReader.new(f) do |tar|
|
126
|
+
mtime = tar.seek("metadata.gz") {|tf| tf.header.mtime }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
mtime
|
131
|
+
end
|
132
|
+
|
133
|
+
def compare(source_date_epoch, old_file, new_file)
|
134
|
+
date = Time.at(source_date_epoch.to_i).strftime("%F %T %Z")
|
135
|
+
|
136
|
+
old_hash = sha256(old_file)
|
137
|
+
new_hash = sha256(new_file)
|
138
|
+
|
139
|
+
say
|
140
|
+
say "Built at: #{date} (#{source_date_epoch})"
|
141
|
+
say "Original build saved to: #{old_file}"
|
142
|
+
say "Reproduced build saved to: #{new_file}"
|
143
|
+
say "Working directory: #{options[:build_path] || Dir.pwd}"
|
144
|
+
say
|
145
|
+
say "Hash comparison:"
|
146
|
+
say " #{old_hash}\t#{old_file}"
|
147
|
+
say " #{new_hash}\t#{new_file}"
|
148
|
+
say
|
149
|
+
|
150
|
+
if old_hash == new_hash
|
151
|
+
say "SUCCESS - original and rebuild hashes matched"
|
152
|
+
else
|
153
|
+
say "FAILURE - original and rebuild hashes did not match"
|
154
|
+
say
|
155
|
+
|
156
|
+
if options[:diff]
|
157
|
+
if system("diffoscope", old_file, new_file).nil?
|
158
|
+
alert_error "error: could not find `diffoscope` executable"
|
159
|
+
end
|
160
|
+
else
|
161
|
+
say "Pass --diff for more details (requires diffoscope to be installed)."
|
162
|
+
end
|
163
|
+
|
164
|
+
terminate_interaction 1
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def prep_dirs
|
169
|
+
rebuild_dir = Dir.mktmpdir("gem_rebuild")
|
170
|
+
old_dir = File.join(rebuild_dir, "old")
|
171
|
+
new_dir = File.join(rebuild_dir, "new")
|
172
|
+
|
173
|
+
FileUtils.mkdir_p(old_dir)
|
174
|
+
FileUtils.mkdir_p(new_dir)
|
175
|
+
|
176
|
+
[old_dir, new_dir]
|
177
|
+
end
|
178
|
+
|
179
|
+
def get_gem_name_and_version
|
180
|
+
args = options[:args] || []
|
181
|
+
if args.length == 2
|
182
|
+
gem_name, gem_version = args
|
183
|
+
elsif args.length > 2
|
184
|
+
raise Gem::CommandLineError, "Too many arguments"
|
185
|
+
else
|
186
|
+
raise Gem::CommandLineError, "Expected GEM_NAME and GEM_VERSION arguments (gem rebuild GEM_NAME GEM_VERSION)"
|
187
|
+
end
|
188
|
+
|
189
|
+
[gem_name, gem_version]
|
190
|
+
end
|
191
|
+
|
192
|
+
def build_gem(gem_name, source_date_epoch, output_file)
|
193
|
+
gemspec = options[:gemspec_file] || find_gemspec("#{gem_name}.gemspec")
|
194
|
+
|
195
|
+
if gemspec
|
196
|
+
build_package(gemspec, source_date_epoch, output_file)
|
197
|
+
else
|
198
|
+
alert_error error_message(gem_name)
|
199
|
+
terminate_interaction(1)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def build_package(gemspec, source_date_epoch, output_file)
|
204
|
+
with_source_date_epoch(source_date_epoch) do
|
205
|
+
spec = Gem::Specification.load(gemspec)
|
206
|
+
if spec
|
207
|
+
Gem::Package.build(
|
208
|
+
spec,
|
209
|
+
options[:force],
|
210
|
+
options[:strict],
|
211
|
+
output_file
|
212
|
+
)
|
213
|
+
else
|
214
|
+
alert_error "Error loading gemspec. Aborting."
|
215
|
+
terminate_interaction 1
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def with_source_date_epoch(source_date_epoch)
|
221
|
+
old_sde = ENV["SOURCE_DATE_EPOCH"]
|
222
|
+
ENV["SOURCE_DATE_EPOCH"] = source_date_epoch.to_s
|
223
|
+
|
224
|
+
yield
|
225
|
+
ensure
|
226
|
+
ENV["SOURCE_DATE_EPOCH"] = old_sde
|
227
|
+
end
|
228
|
+
|
229
|
+
def error_message(gem_name)
|
230
|
+
if gem_name
|
231
|
+
"Couldn't find a gemspec file matching '#{gem_name}' in #{Dir.pwd}"
|
232
|
+
else
|
233
|
+
"Couldn't find a gemspec file in #{Dir.pwd}"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def download_gem(gem_name, gem_version, old_file)
|
238
|
+
# This code was based loosely off the `gem fetch` command.
|
239
|
+
version = "= #{gem_version}"
|
240
|
+
dep = Gem::Dependency.new gem_name, version
|
241
|
+
|
242
|
+
specs_and_sources, errors =
|
243
|
+
Gem::SpecFetcher.fetcher.spec_for_dependency dep
|
244
|
+
|
245
|
+
# There should never be more than one item in specs_and_sources,
|
246
|
+
# since we search for an exact version.
|
247
|
+
spec, source = specs_and_sources[0]
|
248
|
+
|
249
|
+
if spec.nil?
|
250
|
+
show_lookup_failure gem_name, version, errors, options[:domain]
|
251
|
+
terminate_interaction 1
|
252
|
+
end
|
253
|
+
|
254
|
+
download_path = source.download spec
|
255
|
+
|
256
|
+
FileUtils.move(download_path, old_file)
|
257
|
+
|
258
|
+
say "Downloaded #{gem_name} version #{gem_version} as #{old_file}."
|
259
|
+
end
|
260
|
+
|
261
|
+
def rubygems_version(gem_file)
|
262
|
+
Gem::Package.new(gem_file).spec.rubygems_version
|
263
|
+
end
|
264
|
+
end
|
data/lib/rubygems/config_file.rb
CHANGED
@@ -202,21 +202,33 @@ class Gem::ConfigFile
|
|
202
202
|
@hash = @hash.merge environment_config
|
203
203
|
end
|
204
204
|
|
205
|
+
@hash.transform_keys! do |k|
|
206
|
+
# gemhome and gempath are not working with symbol keys
|
207
|
+
if %w[backtrace bulk_threshold verbose update_sources cert_expiration_length_days
|
208
|
+
install_extension_in_lib ipv4_fallback_enabled sources disable_default_gem_server
|
209
|
+
ssl_verify_mode ssl_ca_cert ssl_client_cert].include?(k)
|
210
|
+
k.to_sym
|
211
|
+
else
|
212
|
+
k
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
205
216
|
# HACK: these override command-line args, which is bad
|
206
217
|
@backtrace = @hash[:backtrace] if @hash.key? :backtrace
|
207
218
|
@bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
|
208
|
-
@home = @hash[:gemhome] if @hash.key? :gemhome
|
209
|
-
@path = @hash[:gempath] if @hash.key? :gempath
|
210
|
-
@update_sources = @hash[:update_sources] if @hash.key? :update_sources
|
211
219
|
@verbose = @hash[:verbose] if @hash.key? :verbose
|
212
|
-
@
|
213
|
-
|
220
|
+
@update_sources = @hash[:update_sources] if @hash.key? :update_sources
|
221
|
+
# TODO: We should handle concurrent_downloads same as other options
|
214
222
|
@cert_expiration_length_days = @hash[:cert_expiration_length_days] if @hash.key? :cert_expiration_length_days
|
215
223
|
@ipv4_fallback_enabled = @hash[:ipv4_fallback_enabled] if @hash.key? :ipv4_fallback_enabled
|
216
224
|
|
217
|
-
@
|
218
|
-
@
|
219
|
-
@
|
225
|
+
@home = @hash[:gemhome] if @hash.key? :gemhome
|
226
|
+
@path = @hash[:gempath] if @hash.key? :gempath
|
227
|
+
@sources = @hash[:sources] if @hash.key? :sources
|
228
|
+
@disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
|
229
|
+
@ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
|
230
|
+
@ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
|
231
|
+
@ssl_client_cert = @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert
|
220
232
|
|
221
233
|
@api_keys = nil
|
222
234
|
@rubygems_api_key = nil
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../rubygems"
|
4
|
+
|
5
|
+
##
|
6
|
+
# Mixin methods for commands that work with gemspecs.
|
7
|
+
|
8
|
+
module Gem::GemspecHelpers
|
9
|
+
def find_gemspec(glob = "*.gemspec")
|
10
|
+
gemspecs = Dir.glob(glob).sort
|
11
|
+
|
12
|
+
if gemspecs.size > 1
|
13
|
+
alert_error "Multiple gemspecs found: #{gemspecs}, please specify one"
|
14
|
+
terminate_interaction(1)
|
15
|
+
end
|
16
|
+
|
17
|
+
gemspecs.first
|
18
|
+
end
|
19
|
+
end
|
data/lib/rubygems/package.rb
CHANGED
@@ -59,7 +59,7 @@ class Gem::Package
|
|
59
59
|
|
60
60
|
def initialize(message, source = nil)
|
61
61
|
if source
|
62
|
-
@path = source.path
|
62
|
+
@path = source.is_a?(String) ? source : source.path
|
63
63
|
|
64
64
|
message += " in #{path}" if path
|
65
65
|
end
|
@@ -454,7 +454,7 @@ EOM
|
|
454
454
|
|
455
455
|
if entry.file?
|
456
456
|
File.open(destination, "wb") {|out| copy_stream(entry, out) }
|
457
|
-
FileUtils.chmod file_mode(entry.header.mode), destination
|
457
|
+
FileUtils.chmod file_mode(entry.header.mode) & ~File.umask, destination
|
458
458
|
end
|
459
459
|
|
460
460
|
verbose destination
|
data/lib/rubygems.rb
CHANGED
data/rubygems-update.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "rubygems-update"
|
5
|
-
s.version = "3.5.
|
5
|
+
s.version = "3.5.8"
|
6
6
|
s.authors = ["Jim Weirich", "Chad Fowler", "Eric Hodel", "Luis Lavena", "Aaron Patterson", "Samuel Giddins", "André Arko", "Evan Phoenix", "Hiroshi SHIBATA"]
|
7
7
|
s.email = ["", "", "drbrain@segment7.net", "luislavena@gmail.com", "aaron@tenderlovemaking.com", "segiddins@segiddins.me", "andre@arko.net", "evan@phx.io", "hsbt@ruby-lang.org"]
|
8
8
|
|