librarian 0.0.16 → 0.0.17
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.
- data/CHANGELOG.md +14 -0
- data/README.md +33 -2
- data/lib/librarian/chef/source/site.rb +14 -15
- data/lib/librarian/resolver.rb +26 -0
- data/lib/librarian/resolver/implementation.rb +21 -21
- data/lib/librarian/version.rb +1 -1
- data/librarian.gemspec +1 -0
- metadata +29 -18
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.17
|
4
|
+
|
5
|
+
* Use a pure-Ruby implementation of tar/gz. Helps with Windows support, since
|
6
|
+
Windows boxes are less likely than *NIX boxes to have the `tar` executable.
|
7
|
+
|
8
|
+
* Fix an issue where the chef site source considers uncached manifests to be
|
9
|
+
cached, and skips caching them, causing the install action to fail.
|
10
|
+
|
11
|
+
* Fail fast if the resolver produces an inconsistent resolution. It is a known
|
12
|
+
issue that the resolver will sometimes (deterministically, not randomly)
|
13
|
+
produce an inconsistent resolution when performing an update action (#57).
|
14
|
+
Start debugging this by failing fast at this point and spitting out gobs of
|
15
|
+
debug-level log details.
|
16
|
+
|
3
17
|
## 0.0.16
|
4
18
|
|
5
19
|
* Recache site-sourced dependency metadata per each run.
|
data/README.md
CHANGED
@@ -258,8 +258,39 @@ When you use this integration, any changes you make to anything in the
|
|
258
258
|
`cookbooks/` directory will be ignored by Knife, because Knife won't look in
|
259
259
|
that directory for your cookbooks.
|
260
260
|
|
261
|
-
|
262
|
-
|
261
|
+
How to Contribute
|
262
|
+
-----------------
|
263
|
+
|
264
|
+
### Running the tests
|
265
|
+
|
266
|
+
# Either
|
267
|
+
$ rspec spec
|
268
|
+
$ cucumber
|
269
|
+
|
270
|
+
# Or
|
271
|
+
$ rake
|
272
|
+
|
273
|
+
You will probably need some way to isolate gems. Librarian provides a `Gemfile`,
|
274
|
+
so if you want to use bundler, you can prepare the directory with the usual
|
275
|
+
`bundle install` and run each command prefixed with the usual `bundle exec`, as:
|
276
|
+
|
277
|
+
$ bundle install
|
278
|
+
$ bundle exec rspec spec
|
279
|
+
$ bundle exec cucumber
|
280
|
+
$ bundle exec rake
|
281
|
+
|
282
|
+
### Installing locally
|
283
|
+
|
284
|
+
$ rake install
|
285
|
+
|
286
|
+
You should typically not need to install locally, if you are simply trying to
|
287
|
+
patch a bug and test the result on a test case. Instead of installing locally,
|
288
|
+
you are probably better served by:
|
289
|
+
|
290
|
+
$ cd $PATH_TO_INFRASTRUCTURE_REPO
|
291
|
+
$ $PATH_TO_LIBRARIAN_CHECKOUT/bin/librarian-chef install [--verbose]
|
292
|
+
|
293
|
+
### Reporting Issues
|
263
294
|
|
264
295
|
Please include relevant `Cheffile` and `Cheffile.lock` files. Please run the
|
265
296
|
`librarian-chef` commands in verbose mode by using the `--verbose` flag, and
|
@@ -4,6 +4,8 @@ require 'uri'
|
|
4
4
|
require 'net/http'
|
5
5
|
require 'json'
|
6
6
|
require 'digest'
|
7
|
+
require 'zlib'
|
8
|
+
require 'archive/tar/minitar'
|
7
9
|
|
8
10
|
require 'librarian/helpers/debug'
|
9
11
|
|
@@ -30,10 +32,14 @@ module Librarian
|
|
30
32
|
private :environment=
|
31
33
|
attr_reader :uri
|
32
34
|
|
35
|
+
attr_accessor :_metadata_cache
|
36
|
+
private :_metadata_cache, :_metadata_cache=
|
37
|
+
|
33
38
|
def initialize(environment, uri, options = {})
|
34
39
|
self.environment = environment
|
35
40
|
@uri = uri
|
36
41
|
@cache_path = nil
|
42
|
+
self._metadata_cache = { }
|
37
43
|
end
|
38
44
|
|
39
45
|
def to_s
|
@@ -145,7 +151,7 @@ module Librarian
|
|
145
151
|
dependency_cache_path.mkpath
|
146
152
|
metadata_cache_path = metadata_cache_path(dependency)
|
147
153
|
|
148
|
-
caching_metadata do
|
154
|
+
caching_metadata(dependency.name) do
|
149
155
|
dep_uri = URI.parse(dependency_uri(dependency))
|
150
156
|
debug { "Caching #{dep_uri}" }
|
151
157
|
http = Net::HTTP.new(dep_uri.host, dep_uri.port)
|
@@ -162,11 +168,9 @@ module Librarian
|
|
162
168
|
end
|
163
169
|
end
|
164
170
|
|
165
|
-
def caching_metadata
|
166
|
-
|
167
|
-
|
168
|
-
@_metadata_cached = true
|
169
|
-
result
|
171
|
+
def caching_metadata(name)
|
172
|
+
_metadata_cache[name] = yield unless _metadata_cache.include?(name)
|
173
|
+
_metadata_cache[name]
|
170
174
|
end
|
171
175
|
|
172
176
|
def cache_version_metadata!(dependency, version_uri)
|
@@ -192,16 +196,11 @@ module Librarian
|
|
192
196
|
version_package_cache_path = version_package_cache_path(dependency, version_uri)
|
193
197
|
unless version_package_cache_path.exist?
|
194
198
|
dependency_cache_path = dependency_cache_path(dependency)
|
195
|
-
Process.waitpid2(fork do
|
196
|
-
$stdin.reopen("/dev/null")
|
197
|
-
$stdout.reopen("/dev/null")
|
198
|
-
$stderr.reopen("/dev/null")
|
199
|
-
Dir.chdir(dependency_cache_path)
|
200
|
-
exec("tar", "-xzf", version_archive_cache_path.to_s)
|
201
|
-
end)
|
202
|
-
raise StandardError, "Caching #{version_uri} failed with #{$?.inspect}!" unless $?.success?
|
203
199
|
version_unpacked_temp_path = dependency_cache_path.join(dependency.name)
|
204
|
-
|
200
|
+
Zlib::GzipReader.open(version_archive_cache_path) do |input|
|
201
|
+
Archive::Tar::Minitar.unpack(input, version_unpacked_temp_path.to_s)
|
202
|
+
end
|
203
|
+
FileUtils.move(version_unpacked_temp_path.join(dependency.name), version_package_cache_path)
|
205
204
|
end
|
206
205
|
end
|
207
206
|
|
data/lib/librarian/resolver.rb
CHANGED
@@ -4,6 +4,7 @@ require 'librarian/resolution'
|
|
4
4
|
|
5
5
|
module Librarian
|
6
6
|
class Resolver
|
7
|
+
include Helpers::Debug
|
7
8
|
|
8
9
|
attr_accessor :environment
|
9
10
|
private :environment=
|
@@ -16,10 +17,35 @@ module Librarian
|
|
16
17
|
implementation = Implementation.new(self, spec)
|
17
18
|
partial_manifests_index = Hash[partial_manifests.map{|m| [m.name, m]}]
|
18
19
|
manifests = implementation.resolve(spec.dependencies, partial_manifests_index)
|
20
|
+
enforce_consistency!(manifests) if manifests
|
19
21
|
manifests = sort(manifests) if manifests
|
20
22
|
Resolution.new(spec.dependencies, manifests)
|
21
23
|
end
|
22
24
|
|
25
|
+
def enforce_consistency!(manifests)
|
26
|
+
return if ManifestSet.new(manifests).consistent?
|
27
|
+
|
28
|
+
debug { "Resolver Malfunctioned!" }
|
29
|
+
manifests.values.sort_by(&:name).each do |manifest|
|
30
|
+
errors = []
|
31
|
+
manifest.dependencies.sort_by(&:name).each do |d|
|
32
|
+
if !manifests[d]
|
33
|
+
errors << ["Depends on: #{d}", "Missing!"]
|
34
|
+
elsif !manifests[d].satisfies?(d)
|
35
|
+
errors << ["Depends on: #{d}", "Found: #{manifests[d]}"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
unless errors.empty?
|
39
|
+
debug { " #{manifest}" }
|
40
|
+
errors.each do |a, b|
|
41
|
+
debug { " #{a}" }
|
42
|
+
debug { " #{b}" }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
raise Error, "Resolver Malfunctioned!"
|
47
|
+
end
|
48
|
+
|
23
49
|
def sort(manifests)
|
24
50
|
ManifestSet.sort(manifests)
|
25
51
|
end
|
@@ -52,28 +52,28 @@ module Librarian
|
|
52
52
|
debug { "Checking manifests" }
|
53
53
|
scope do
|
54
54
|
dependency.manifests.each do |manifest|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
q = queue + a
|
70
|
-
resolution = recursive_resolve(dependencies.dup, m, q)
|
71
|
-
end
|
72
|
-
if resolution
|
73
|
-
debug { "Resolved #{dependency} at #{manifest}" }
|
74
|
-
else
|
75
|
-
debug { "Backtracking from #{manifest}" }
|
55
|
+
break if resolution
|
56
|
+
|
57
|
+
debug { "Checking #{manifest}" }
|
58
|
+
scope do
|
59
|
+
if related_dependencies.all?{|d| d.satisfied_by?(manifest)}
|
60
|
+
m = manifests.merge(dependency.name => manifest)
|
61
|
+
a = manifest.dependencies.map { |d|
|
62
|
+
d.source ? d :
|
63
|
+
!dependency_source_map.key?(d.name) ?
|
64
|
+
Dependency.new(d.name, d.requirement, source) :
|
65
|
+
Dependency.new(d.name, d.requirement, dependency_source_map[d.name])
|
66
|
+
}
|
67
|
+
a.each do |d|
|
68
|
+
debug { "Scheduling #{d}" }
|
76
69
|
end
|
70
|
+
q = queue + a
|
71
|
+
resolution = recursive_resolve(dependencies.dup, m, q)
|
72
|
+
end
|
73
|
+
if resolution
|
74
|
+
debug { "Resolved #{dependency} at #{manifest}" }
|
75
|
+
else
|
76
|
+
debug { "Backtracking from #{manifest}" }
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/lib/librarian/version.rb
CHANGED
data/librarian.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librarian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &7439800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *7439800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &7439140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *7439140
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &7438460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *7438460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: cucumber
|
49
|
-
requirement: &
|
49
|
+
requirement: &7471000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *7471000
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: aruba
|
60
|
-
requirement: &
|
60
|
+
requirement: &7470560 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *7470560
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
|
-
requirement: &
|
71
|
+
requirement: &7470120 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *7470120
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: chef
|
82
|
-
requirement: &
|
82
|
+
requirement: &7469600 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0.10'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *7469600
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: highline
|
93
|
-
requirement: &
|
93
|
+
requirement: &7469180 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,18 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *7469180
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: archive-tar-minitar
|
104
|
+
requirement: &7468640 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.5.2
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *7468640
|
102
113
|
description: Librarian
|
103
114
|
email:
|
104
115
|
- y_feldblum@yahoo.com
|