gel 0.3.0 → 0.8.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -3
- data/RELEASING.md +12 -0
- data/exe/gel +4 -2
- data/gemlib/gel/stub.rb +20 -0
- data/lib/gel/catalog/common.rb +4 -2
- data/lib/gel/catalog/compact_index.rb +6 -10
- data/lib/gel/catalog/dependency_index.rb +10 -10
- data/lib/gel/catalog/legacy_index.rb +4 -6
- data/lib/gel/catalog/marshal_hacks.rb +2 -0
- data/lib/gel/catalog.rb +33 -52
- data/lib/gel/catalog_set.rb +100 -0
- data/lib/gel/command/help.rb +13 -2
- data/lib/gel/command/lock.rb +3 -3
- data/lib/gel/command/open.rb +24 -0
- data/lib/gel/command/shell_setup.rb +11 -8
- data/lib/gel/command/stub.rb +45 -2
- data/lib/gel/command/version.rb +7 -0
- data/lib/gel/command.rb +43 -6
- data/lib/gel/compatibility/rubygems.rb +10 -197
- data/lib/gel/compatibility.rb +2 -2
- data/lib/gel/config.rb +41 -7
- data/lib/gel/db.rb +93 -83
- data/lib/gel/direct_gem.rb +16 -4
- data/lib/gel/environment.rb +542 -249
- data/lib/gel/error.rb +156 -24
- data/lib/gel/gemfile_parser.rb +74 -12
- data/lib/gel/gemspec_parser.rb +26 -7
- data/lib/gel/git_catalog.rb +15 -3
- data/lib/gel/git_depot.rb +62 -28
- data/lib/gel/httpool.rb +5 -2
- data/lib/gel/installer.rb +61 -23
- data/lib/gel/lock_loader.rb +87 -112
- data/lib/gel/lock_parser.rb +23 -31
- data/lib/gel/locked_store.rb +30 -21
- data/lib/gel/multi_store.rb +13 -4
- data/lib/gel/null_solver.rb +67 -0
- data/lib/gel/package/abortable.rb +18 -0
- data/lib/gel/package/installer.rb +124 -49
- data/lib/gel/package.rb +21 -4
- data/lib/gel/path_catalog.rb +1 -1
- data/lib/gel/pinboard.rb +4 -2
- data/lib/gel/platform.rb +38 -0
- data/lib/gel/pub_grub/package.rb +67 -0
- data/lib/gel/pub_grub/preference_strategy.rb +10 -6
- data/lib/gel/pub_grub/solver.rb +37 -0
- data/lib/gel/pub_grub/source.rb +64 -92
- data/lib/gel/resolved_gem_set.rb +234 -0
- data/lib/gel/runtime.rb +3 -3
- data/lib/gel/set.rb +62 -0
- data/lib/gel/stdlib.rb +83 -0
- data/lib/gel/store.rb +94 -25
- data/lib/gel/store_catalog.rb +2 -2
- data/lib/gel/store_gem.rb +54 -6
- data/lib/gel/stub_set.rb +32 -2
- data/lib/gel/support/cgi_escape.rb +34 -0
- data/lib/gel/support/gem_platform.rb +0 -2
- data/lib/gel/support/sha512.rb +142 -0
- data/lib/gel/support/tar/tar_writer.rb +2 -2
- data/lib/gel/tail_file.rb +2 -1
- data/lib/gel/util.rb +108 -0
- data/lib/gel/vendor/pstore.rb +3 -0
- data/lib/gel/vendor/pub_grub.rb +3 -0
- data/lib/gel/vendor/ruby_digest.rb +3 -0
- data/lib/gel/vendor_catalog.rb +38 -0
- data/lib/gel/version.rb +1 -1
- data/lib/gel.rb +15 -0
- data/man/man1/gel-exec.1 +1 -1
- data/man/man1/gel-install.1 +1 -1
- data/man/man1/gel.1 +14 -1
- data/{lib/gel/compatibility → slib}/bundler/cli.rb +0 -0
- data/{lib/gel/compatibility → slib}/bundler/friendly_errors.rb +0 -0
- data/{lib/gel/compatibility/rubygems/dependency_installer.rb → slib/bundler/gem_helper.rb} +0 -0
- data/slib/bundler/gem_tasks.rb +0 -0
- data/{lib/gel/compatibility → slib}/bundler/setup.rb +0 -0
- data/{lib/gel/compatibility → slib}/bundler.rb +39 -3
- data/{lib/gel/compatibility → slib}/rubygems/command.rb +0 -0
- data/slib/rubygems/dependency_installer.rb +12 -0
- data/{lib/gel/compatibility → slib}/rubygems/gem_runner.rb +0 -0
- data/slib/rubygems/package.rb +6 -0
- data/slib/rubygems/package_task.rb +7 -0
- data/slib/rubygems/specification.rb +0 -0
- data/slib/rubygems/version.rb +0 -0
- data/slib/rubygems.rb +297 -0
- data/vendor/pstore/LICENSE.txt +22 -0
- data/vendor/pstore/lib/pstore.rb +488 -0
- data/vendor/pub_grub/LICENSE.txt +21 -0
- data/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
- data/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +183 -0
- data/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
- data/vendor/pub_grub/lib/pub_grub/incompatibility.rb +143 -0
- data/vendor/pub_grub/lib/pub_grub/package.rb +35 -0
- data/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
- data/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
- data/vendor/pub_grub/lib/pub_grub/solve_failure.rb +17 -0
- data/vendor/pub_grub/lib/pub_grub/static_package_source.rb +53 -0
- data/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
- data/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
- data/vendor/pub_grub/lib/pub_grub/version_constraint.rb +124 -0
- data/vendor/pub_grub/lib/pub_grub/version_range.rb +399 -0
- data/vendor/pub_grub/lib/pub_grub/version_solver.rb +247 -0
- data/vendor/pub_grub/lib/pub_grub/version_union.rb +174 -0
- data/vendor/pub_grub/lib/pub_grub.rb +31 -0
- data/vendor/ruby-digest/UNLICENSE +24 -0
- data/vendor/ruby-digest/lib/ruby_digest.rb +812 -0
- metadata +95 -19
@@ -0,0 +1,124 @@
|
|
1
|
+
require_relative '../pub_grub/version_range'
|
2
|
+
|
3
|
+
module Gel::Vendor::PubGrub
|
4
|
+
class VersionConstraint
|
5
|
+
attr_reader :package, :range
|
6
|
+
|
7
|
+
# @param package [Gel::Vendor::PubGrub::Package]
|
8
|
+
# @param range [Gel::Vendor::PubGrub::VersionRange]
|
9
|
+
def initialize(package, range: nil)
|
10
|
+
@package = package
|
11
|
+
@range = range
|
12
|
+
end
|
13
|
+
|
14
|
+
def hash
|
15
|
+
package.hash ^ range.hash
|
16
|
+
end
|
17
|
+
|
18
|
+
def eql?(other)
|
19
|
+
package.eql?(other.package) &&
|
20
|
+
range.eql?(other.range)
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
def exact(package, version)
|
25
|
+
range = VersionRange.new(min: version, max: version, include_min: true, include_max: true)
|
26
|
+
new(package, range: range)
|
27
|
+
end
|
28
|
+
|
29
|
+
def any(package)
|
30
|
+
new(package, range: VersionRange.any)
|
31
|
+
end
|
32
|
+
|
33
|
+
def empty(package)
|
34
|
+
new(package, range: VersionRange.empty)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def intersect(other)
|
39
|
+
unless package == other.package
|
40
|
+
raise ArgumentError, "Can only intersect between VersionConstraint of the same package"
|
41
|
+
end
|
42
|
+
|
43
|
+
self.class.new(package, range: range.intersect(other.range))
|
44
|
+
end
|
45
|
+
|
46
|
+
def union(other)
|
47
|
+
unless package == other.package
|
48
|
+
raise ArgumentError, "Can only intersect between VersionConstraint of the same package"
|
49
|
+
end
|
50
|
+
|
51
|
+
self.class.new(package, range: range.union(other.range))
|
52
|
+
end
|
53
|
+
|
54
|
+
def invert
|
55
|
+
new_range = range.invert
|
56
|
+
self.class.new(package, range: new_range)
|
57
|
+
end
|
58
|
+
|
59
|
+
def difference(other)
|
60
|
+
intersect(other.invert)
|
61
|
+
end
|
62
|
+
|
63
|
+
def allows_all?(other)
|
64
|
+
range.allows_all?(other.range)
|
65
|
+
end
|
66
|
+
|
67
|
+
def allows_any?(other)
|
68
|
+
range.intersects?(other.range)
|
69
|
+
end
|
70
|
+
|
71
|
+
def subset?(other)
|
72
|
+
other.allows_all?(self)
|
73
|
+
end
|
74
|
+
|
75
|
+
def overlap?(other)
|
76
|
+
other.allows_any?(self)
|
77
|
+
end
|
78
|
+
|
79
|
+
def disjoint?(other)
|
80
|
+
!overlap?(other)
|
81
|
+
end
|
82
|
+
|
83
|
+
def relation(other)
|
84
|
+
if subset?(other)
|
85
|
+
:subset
|
86
|
+
elsif overlap?(other)
|
87
|
+
:overlap
|
88
|
+
else
|
89
|
+
:disjoint
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def to_s(allow_every: false)
|
94
|
+
if package == Package.root
|
95
|
+
"root"
|
96
|
+
elsif allow_every && any?
|
97
|
+
"every version of #{package}"
|
98
|
+
else
|
99
|
+
"#{package} #{constraint_string}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def constraint_string
|
104
|
+
if any?
|
105
|
+
">= 0"
|
106
|
+
else
|
107
|
+
range.to_s
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def empty?
|
112
|
+
range.empty?
|
113
|
+
end
|
114
|
+
|
115
|
+
# Does this match every version of the package
|
116
|
+
def any?
|
117
|
+
range.any?
|
118
|
+
end
|
119
|
+
|
120
|
+
def inspect
|
121
|
+
"#<#{self.class} #{self}>"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,399 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gel::Vendor::PubGrub
|
4
|
+
class VersionRange
|
5
|
+
attr_reader :min, :max, :include_min, :include_max
|
6
|
+
|
7
|
+
alias_method :include_min?, :include_min
|
8
|
+
alias_method :include_max?, :include_max
|
9
|
+
|
10
|
+
class Empty < VersionRange
|
11
|
+
undef_method :min, :max
|
12
|
+
undef_method :include_min, :include_min?
|
13
|
+
undef_method :include_max, :include_max?
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
end
|
17
|
+
|
18
|
+
def empty?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def eql?
|
23
|
+
other.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
def intersects?(_)
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
def intersect(other)
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def allows_all?(other)
|
35
|
+
other.empty?
|
36
|
+
end
|
37
|
+
|
38
|
+
def include?(_)
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
42
|
+
def any?
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
"(no versions)"
|
48
|
+
end
|
49
|
+
|
50
|
+
def ==(other)
|
51
|
+
other.class == self.class
|
52
|
+
end
|
53
|
+
|
54
|
+
def invert
|
55
|
+
VersionRange.any
|
56
|
+
end
|
57
|
+
|
58
|
+
def select_versions(_)
|
59
|
+
[]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
EMPTY = Empty.new
|
64
|
+
|
65
|
+
def self.empty
|
66
|
+
EMPTY
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.any
|
70
|
+
new
|
71
|
+
end
|
72
|
+
|
73
|
+
def initialize(min: nil, max: nil, include_min: false, include_max: false, name: nil)
|
74
|
+
@min = min
|
75
|
+
@max = max
|
76
|
+
@include_min = include_min
|
77
|
+
@include_max = include_max
|
78
|
+
@name = name
|
79
|
+
end
|
80
|
+
|
81
|
+
def hash
|
82
|
+
@hash ||= min.hash ^ max.hash ^ include_min.hash ^ include_max.hash
|
83
|
+
end
|
84
|
+
|
85
|
+
def eql?(other)
|
86
|
+
if other.is_a?(VersionRange)
|
87
|
+
min.eql?(other.min) &&
|
88
|
+
max.eql?(other.max) &&
|
89
|
+
include_min.eql?(other.include_min) &&
|
90
|
+
include_max.eql?(other.include_max)
|
91
|
+
else
|
92
|
+
ranges.eql?(other.ranges)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def ranges
|
97
|
+
[self]
|
98
|
+
end
|
99
|
+
|
100
|
+
def include?(version)
|
101
|
+
compare_version(version) == 0
|
102
|
+
end
|
103
|
+
|
104
|
+
# Partitions passed versions into [lower, within, higher]
|
105
|
+
#
|
106
|
+
# versions must be sorted
|
107
|
+
def partition_versions(versions)
|
108
|
+
min_index =
|
109
|
+
if !min || versions.empty?
|
110
|
+
0
|
111
|
+
elsif include_min?
|
112
|
+
(0..versions.size).bsearch { |i| versions[i].nil? || versions[i] >= min }
|
113
|
+
else
|
114
|
+
(0..versions.size).bsearch { |i| versions[i].nil? || versions[i] > min }
|
115
|
+
end
|
116
|
+
|
117
|
+
lower = versions.slice(0, min_index)
|
118
|
+
versions = versions.slice(min_index, versions.size)
|
119
|
+
|
120
|
+
max_index =
|
121
|
+
if !max || versions.empty?
|
122
|
+
versions.size
|
123
|
+
elsif include_max?
|
124
|
+
(0..versions.size).bsearch { |i| versions[i].nil? || versions[i] > max }
|
125
|
+
else
|
126
|
+
(0..versions.size).bsearch { |i| versions[i].nil? || versions[i] >= max }
|
127
|
+
end
|
128
|
+
|
129
|
+
[
|
130
|
+
lower,
|
131
|
+
versions.slice(0, max_index),
|
132
|
+
versions.slice(max_index, versions.size)
|
133
|
+
]
|
134
|
+
end
|
135
|
+
|
136
|
+
# Returns verisons which are included by this range.
|
137
|
+
#
|
138
|
+
# versions must be sorted
|
139
|
+
def select_versions(versions)
|
140
|
+
return versions if any?
|
141
|
+
|
142
|
+
partition_versions(versions)[1]
|
143
|
+
end
|
144
|
+
|
145
|
+
def compare_version(version)
|
146
|
+
if min
|
147
|
+
case version <=> min
|
148
|
+
when -1
|
149
|
+
return -1
|
150
|
+
when 0
|
151
|
+
return -1 if !include_min
|
152
|
+
when 1
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
if max
|
157
|
+
case version <=> max
|
158
|
+
when -1
|
159
|
+
when 0
|
160
|
+
return 1 if !include_max
|
161
|
+
when 1
|
162
|
+
return 1
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
0
|
167
|
+
end
|
168
|
+
|
169
|
+
def strictly_lower?(other)
|
170
|
+
return false if !max || !other.min
|
171
|
+
|
172
|
+
case max <=> other.min
|
173
|
+
when 0
|
174
|
+
!include_max || !other.include_min
|
175
|
+
when -1
|
176
|
+
true
|
177
|
+
when 1
|
178
|
+
false
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def strictly_higher?(other)
|
183
|
+
other.strictly_lower?(self)
|
184
|
+
end
|
185
|
+
|
186
|
+
def intersects?(other)
|
187
|
+
return false if other.empty?
|
188
|
+
return other.intersects?(self) if other.is_a?(VersionUnion)
|
189
|
+
!strictly_lower?(other) && !strictly_higher?(other)
|
190
|
+
end
|
191
|
+
alias_method :allows_any?, :intersects?
|
192
|
+
|
193
|
+
def intersect(other)
|
194
|
+
return other if other.empty?
|
195
|
+
return other.intersect(self) if other.is_a?(VersionUnion)
|
196
|
+
|
197
|
+
min_range =
|
198
|
+
if !min
|
199
|
+
other
|
200
|
+
elsif !other.min
|
201
|
+
self
|
202
|
+
else
|
203
|
+
case min <=> other.min
|
204
|
+
when 0
|
205
|
+
include_min ? other : self
|
206
|
+
when -1
|
207
|
+
other
|
208
|
+
when 1
|
209
|
+
self
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
max_range =
|
214
|
+
if !max
|
215
|
+
other
|
216
|
+
elsif !other.max
|
217
|
+
self
|
218
|
+
else
|
219
|
+
case max <=> other.max
|
220
|
+
when 0
|
221
|
+
include_max ? other : self
|
222
|
+
when -1
|
223
|
+
self
|
224
|
+
when 1
|
225
|
+
other
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
if !min_range.equal?(max_range) && min_range.min && max_range.max
|
230
|
+
case min_range.min <=> max_range.max
|
231
|
+
when -1
|
232
|
+
when 0
|
233
|
+
if !min_range.include_min || !max_range.include_max
|
234
|
+
return EMPTY
|
235
|
+
end
|
236
|
+
when 1
|
237
|
+
return EMPTY
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
VersionRange.new(
|
242
|
+
min: min_range.min,
|
243
|
+
include_min: min_range.include_min,
|
244
|
+
max: max_range.max,
|
245
|
+
include_max: max_range.include_max
|
246
|
+
)
|
247
|
+
end
|
248
|
+
|
249
|
+
# The span covered by two ranges
|
250
|
+
#
|
251
|
+
# If self and other are contiguous, this builds a union of the two ranges.
|
252
|
+
# (if they aren't you are probably calling the wrong method)
|
253
|
+
def span(other)
|
254
|
+
return self if other.empty?
|
255
|
+
|
256
|
+
min_range =
|
257
|
+
if !min
|
258
|
+
self
|
259
|
+
elsif !other.min
|
260
|
+
other
|
261
|
+
else
|
262
|
+
case min <=> other.min
|
263
|
+
when 0
|
264
|
+
include_min ? self : other
|
265
|
+
when -1
|
266
|
+
self
|
267
|
+
when 1
|
268
|
+
other
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
max_range =
|
273
|
+
if !max
|
274
|
+
self
|
275
|
+
elsif !other.max
|
276
|
+
other
|
277
|
+
else
|
278
|
+
case max <=> other.max
|
279
|
+
when 0
|
280
|
+
include_max ? self : other
|
281
|
+
when -1
|
282
|
+
other
|
283
|
+
when 1
|
284
|
+
self
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
VersionRange.new(
|
289
|
+
min: min_range.min,
|
290
|
+
include_min: min_range.include_min,
|
291
|
+
max: max_range.max,
|
292
|
+
include_max: max_range.include_max
|
293
|
+
)
|
294
|
+
end
|
295
|
+
|
296
|
+
def union(other)
|
297
|
+
return other.union(self) if other.is_a?(VersionUnion)
|
298
|
+
|
299
|
+
if contiguous_to?(other)
|
300
|
+
span(other)
|
301
|
+
else
|
302
|
+
VersionUnion.union([self, other])
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
def contiguous_to?(other)
|
307
|
+
return false if other.empty?
|
308
|
+
|
309
|
+
intersects?(other) ||
|
310
|
+
(min == other.max && (include_min || other.include_max)) ||
|
311
|
+
(max == other.min && (include_max || other.include_min))
|
312
|
+
end
|
313
|
+
|
314
|
+
def allows_all?(other)
|
315
|
+
return true if other.empty?
|
316
|
+
|
317
|
+
if other.is_a?(VersionUnion)
|
318
|
+
return VersionUnion.new([self]).allows_all?(other)
|
319
|
+
end
|
320
|
+
|
321
|
+
return false if max && !other.max
|
322
|
+
return false if min && !other.min
|
323
|
+
|
324
|
+
if min
|
325
|
+
case min <=> other.min
|
326
|
+
when -1
|
327
|
+
when 0
|
328
|
+
return false if !include_min && other.include_min
|
329
|
+
when 1
|
330
|
+
return false
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
if max
|
335
|
+
case max <=> other.max
|
336
|
+
when -1
|
337
|
+
return false
|
338
|
+
when 0
|
339
|
+
return false if !include_max && other.include_max
|
340
|
+
when 1
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
true
|
345
|
+
end
|
346
|
+
|
347
|
+
def any?
|
348
|
+
!min && !max
|
349
|
+
end
|
350
|
+
|
351
|
+
def empty?
|
352
|
+
false
|
353
|
+
end
|
354
|
+
|
355
|
+
def to_s
|
356
|
+
@name ||= constraints.join(", ")
|
357
|
+
end
|
358
|
+
|
359
|
+
def inspect
|
360
|
+
"#<#{self.class} #{to_s}>"
|
361
|
+
end
|
362
|
+
|
363
|
+
def invert
|
364
|
+
return self.class.empty if any?
|
365
|
+
|
366
|
+
low = VersionRange.new(max: min, include_max: !include_min)
|
367
|
+
high = VersionRange.new(min: max, include_min: !include_max)
|
368
|
+
|
369
|
+
if !min
|
370
|
+
high
|
371
|
+
elsif !max
|
372
|
+
low
|
373
|
+
else
|
374
|
+
low.union(high)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
def ==(other)
|
379
|
+
self.class == other.class &&
|
380
|
+
min == other.min &&
|
381
|
+
max == other.max &&
|
382
|
+
include_min == other.include_min &&
|
383
|
+
include_max == other.include_max
|
384
|
+
end
|
385
|
+
|
386
|
+
private
|
387
|
+
|
388
|
+
def constraints
|
389
|
+
return ["any"] if any?
|
390
|
+
return ["= #{min}"] if min == max
|
391
|
+
|
392
|
+
c = []
|
393
|
+
c << "#{include_min ? ">=" : ">"} #{min}" if min
|
394
|
+
c << "#{include_max ? "<=" : "<"} #{max}" if max
|
395
|
+
c
|
396
|
+
end
|
397
|
+
|
398
|
+
end
|
399
|
+
end
|