berkshelf 3.0.0.rc1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90ffa4862aad42150a8e4a7386f48a3495f0f7ef
4
- data.tar.gz: 215b5e4128bc085893ee1740e8d02d73a6fdbd90
3
+ metadata.gz: 1a8c63c90d30c802ffb17a2789a8cbe9587419bc
4
+ data.tar.gz: d47fcfb52f9ac8c1013775d16ed3e7cff157f578
5
5
  SHA512:
6
- metadata.gz: 5725f1b7ca2b51b17cbfdad97727f06548ae6445b90646f2c85293fcec6f5f160eaf36c0a7ccef26efc6333902e6d3885190a6a1b4033d0c8e87fd7ae8eb4d14
7
- data.tar.gz: 814b494a2a9f5c92df52effecc0208938ff6829a22d5c21ee1f6a00526826df3c978f87cf2b9ff2dab9905ae854d438be00b20263c67cd1b011a2b24b31286c0
6
+ metadata.gz: 1ea86f4683a43f628c45451fc8dedded9da3958bd44a8f2d670e7c0f2b3659ab82db4199f5e96ab46c040b1e956d74792bb3f2956dd450764240a7480f9e10b4
7
+ data.tar.gz: 2830ea0960dfc0219cecc3af858c1fe420ad4402a1415cdcbdf7027dcc4c2dcb2c757a3e193b1ec138048826a044b1611eeab9a7489b331e6cd6c87feb7a2749
data/Gemfile CHANGED
@@ -31,5 +31,5 @@ group :guard do
31
31
  end
32
32
 
33
33
  group :test do
34
- gem 'berkshelf-api', github: "berkshelf/berkshelf-api"
34
+ gem 'berkshelf-api', "~> 1.2"
35
35
  end
data/README.md CHANGED
@@ -11,34 +11,6 @@ Manage a Cookbook or an Application's Cookbook dependencies
11
11
 
12
12
  **WARNING:** It is advised at this time that you [use Berkshelf 3](https://github.com/berkshelf/berkshelf/wiki/Howto:-Use-the-bleeding-edge). Berkshelf 2 is no longer being actively developed and has a number of significant issues related to dependency resolution that Berkshelf 3 fixes.
13
13
 
14
- ### Manually install Gecode (temporary)
15
-
16
- The current release candidate of Vagrant Berkshelf requires you to have Gecode installed on your machine. In the future this process will be provided in an easy and automated fashion.
17
-
18
- #### OSX
19
-
20
- $ cd $( brew --prefix )
21
- $ git checkout 3c5ca25 Library/Formula/gecode.rb
22
- $ brew install gecode
23
-
24
- #### Debian and Ubuntu
25
-
26
- $ sudo apt-get install libgecode-dev
27
-
28
- ##### Source
29
-
30
- $ curl -O http://www.gecode.org/download/gecode-3.7.3.tar.gz
31
- $ tar zxvf gecode-3.7.3.tar.gz
32
- $ ./configure --disable-doc-dot \
33
- --disable-doc-search \
34
- --disable-doc-tagfile \
35
- --disable-doc-chm \
36
- --disable-doc-docset \
37
- --disable-qt \
38
- --disable-examples
39
- $ make
40
- $ (sudo) make install
41
-
42
14
  ### Gem Installation
43
15
 
44
16
  Add Berkshelf to your repository's `Gemfile`:
@@ -126,11 +98,7 @@ If you need to disable SSL, you can in `~/.berkshelf/config.json` like so:
126
98
 
127
99
  ## Authors
128
100
 
129
- - Jamie Winsor (<jamie@vialstudios.com>)
130
- - Josiah Kiehl (<jkiehl@riotgames.com>)
131
- - Michael Ivey (<michael.ivey@riotgames.com>)
132
- - Justin Campbell (<justin@justincampbell.me>)
133
- - Seth Vargo (<sethvargo@gmail.com>)
101
+ [The Berkshelf Core Team](https://github.com/berkshelf/berkshelf/wiki/Core-Team)
134
102
 
135
103
  Thank you to all of our [Contributors](https://github.com/berkshelf/berkshelf/graphs/contributors), testers, and users.
136
104
 
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.required_rubygems_version = '>= 1.8.0'
32
32
 
33
33
  s.add_dependency 'addressable', '~> 2.3.4'
34
- s.add_dependency 'berkshelf-api-client', '~> 1.2.0.rc2'
34
+ s.add_dependency 'berkshelf-api-client', '~> 1.2'
35
35
  s.add_dependency 'buff-config', '~> 0.2'
36
36
  s.add_dependency 'buff-extensions', '~> 0.4'
37
37
  s.add_dependency 'buff-shell_out', '~> 0.1'
@@ -39,9 +39,11 @@ Gem::Specification.new do |s|
39
39
  s.add_dependency 'minitar', '~> 0.5.4'
40
40
  s.add_dependency 'retryable', '~> 1.3.3'
41
41
  s.add_dependency 'ridley', '~> 3.0'
42
- s.add_dependency 'solve', '~> 1.0.0.rc3'
42
+ s.add_dependency 'solve', '~> 1.1'
43
43
  s.add_dependency 'thor', '~> 0.18'
44
44
  s.add_dependency 'octokit', '~> 2.6'
45
+ s.add_dependency 'celluloid', '~> 0.16.0.pre'
46
+ s.add_dependency 'celluloid-io', '~> 0.16.0.pre'
45
47
 
46
48
  s.add_development_dependency 'aruba', '~> 0.5'
47
49
  s.add_development_dependency 'chef-zero', '~> 1.5.0'
@@ -250,7 +250,7 @@ Feature: Lifecycle commands
250
250
  """
251
251
  DEPENDENCIES
252
252
  fake
253
- path: ./fake
253
+ path: fake
254
254
  transitive
255
255
  path: .
256
256
  metadata: true
@@ -369,7 +369,7 @@ Feature: Lifecycle commands
369
369
  """
370
370
  DEPENDENCIES
371
371
  fake
372
- path: ./fake
372
+ path: fake
373
373
 
374
374
  GRAPH
375
375
  fake (2.0.0)
@@ -268,7 +268,7 @@ Feature: Creating and reading the Berkshelf lockfile
268
268
  """
269
269
  DEPENDENCIES
270
270
  fake
271
- path: ./fake
271
+ path: fake
272
272
 
273
273
  GRAPH
274
274
  fake (0.0.0)
@@ -9,6 +9,7 @@ require 'solve'
9
9
  require 'thor'
10
10
  require 'tmpdir'
11
11
  require 'uri'
12
+ require 'celluloid'
12
13
 
13
14
  JSON.create_id = nil
14
15
 
@@ -217,5 +218,6 @@ require_relative 'berkshelf/source'
217
218
  require_relative 'berkshelf/source_uri'
218
219
  require_relative 'berkshelf/ui'
219
220
 
220
- Ridley.logger = Berkshelf.logger
221
+ Ridley.logger = Berkshelf.logger
221
222
  Berkshelf.logger.level = Logger::WARN
223
+ Celluloid.logger.level = Logger::ERROR
@@ -8,6 +8,7 @@ module Berkshelf
8
8
  #
9
9
  # @param (see Berksfile#initialize)
10
10
  def from_options(options = {})
11
+ options[:berksfile] ||= File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME)
11
12
  from_file(options[:berksfile], options.slice(:except, :only))
12
13
  end
13
14
 
@@ -56,7 +57,7 @@ module Berkshelf
56
57
  # Group(s) to include which will cause any dependencies marked as a member of the
57
58
  # group to be installed and all others to be ignored
58
59
  def initialize(path, options = {})
59
- @filepath = path
60
+ @filepath = File.expand_path(path)
60
61
  @dependencies = Hash.new
61
62
  @sources = Hash.new
62
63
 
@@ -159,14 +160,11 @@ module Berkshelf
159
160
  # @option options [String] :path
160
161
  # path to the metadata file
161
162
  def metadata(options = {})
162
- path = options[:path] || File.dirname(filepath)
163
-
163
+ path = options[:path] || File.dirname(filepath)
164
164
  metadata_path = File.expand_path(File.join(path, 'metadata.rb'))
165
- metadata = Ridley::Chef::Cookbook::Metadata.from_file(metadata_path)
166
-
167
- name = metadata.name.presence || File.basename(File.expand_path(path))
165
+ metadata = Ridley::Chef::Cookbook::Metadata.from_file(metadata_path)
168
166
 
169
- add_dependency(name, nil, path: path, metadata: true)
167
+ add_dependency(metadata.name, nil, path: path, metadata: true)
170
168
  end
171
169
 
172
170
  # Add a Berkshelf API source to use when building the index of known cookbooks. The indexes will be
@@ -122,7 +122,7 @@ module Berkshelf
122
122
  aliases: '-o'
123
123
  method_option :berksfile,
124
124
  type: :string,
125
- default: Berkshelf::DEFAULT_FILENAME,
125
+ default: nil,
126
126
  desc: 'Path to a Berksfile to operate off of.',
127
127
  aliases: '-b',
128
128
  banner: 'PATH'
@@ -145,7 +145,7 @@ module Berkshelf
145
145
 
146
146
  method_option :berksfile,
147
147
  type: :string,
148
- default: Berkshelf::DEFAULT_FILENAME,
148
+ default: nil,
149
149
  desc: 'Path to a Berksfile to operate off of.',
150
150
  aliases: '-b',
151
151
  banner: 'PATH'
@@ -165,7 +165,7 @@ module Berkshelf
165
165
 
166
166
  method_option :berksfile,
167
167
  type: :string,
168
- default: Berkshelf::DEFAULT_FILENAME,
168
+ default: nil,
169
169
  desc: 'Path to a Berksfile to operate off of.',
170
170
  aliases: '-b',
171
171
  banner: 'PATH'
@@ -232,7 +232,7 @@ module Berkshelf
232
232
 
233
233
  method_option :berksfile,
234
234
  type: :string,
235
- default: Berkshelf::DEFAULT_FILENAME,
235
+ default: nil,
236
236
  desc: 'Path to a Berksfile to operate off of.',
237
237
  aliases: '-b',
238
238
  banner: 'PATH'
@@ -283,7 +283,7 @@ module Berkshelf
283
283
 
284
284
  method_option :berksfile,
285
285
  type: :string,
286
- default: Berkshelf::DEFAULT_FILENAME,
286
+ default: nil,
287
287
  desc: 'Path to a Berksfile to operate off of.',
288
288
  aliases: '-b',
289
289
  banner: 'PATH'
@@ -303,7 +303,7 @@ module Berkshelf
303
303
 
304
304
  method_option :berksfile,
305
305
  type: :string,
306
- default: Berkshelf::DEFAULT_FILENAME,
306
+ default: nil,
307
307
  desc: "Path to a Berksfile to operate off of.",
308
308
  aliases: "-b",
309
309
  banner: "PATH"
@@ -316,7 +316,7 @@ module Berkshelf
316
316
 
317
317
  method_option :berksfile,
318
318
  type: :string,
319
- default: Berkshelf::DEFAULT_FILENAME,
319
+ default: nil,
320
320
  desc: 'Path to a Berksfile to operate off of.',
321
321
  aliases: '-b',
322
322
  banner: 'PATH'
@@ -337,7 +337,7 @@ module Berkshelf
337
337
 
338
338
  method_option :berksfile,
339
339
  type: :string,
340
- default: Berkshelf::DEFAULT_FILENAME,
340
+ default: nil,
341
341
  desc: 'Path to a Berksfile to operate off of.',
342
342
  aliases: '-b',
343
343
  banner: 'PATH'
@@ -371,7 +371,7 @@ module Berkshelf
371
371
  aliases: '-o'
372
372
  method_option :berksfile,
373
373
  type: :string,
374
- default: Berkshelf::DEFAULT_FILENAME,
374
+ default: nil,
375
375
  desc: 'Path to a Berksfile to operate off of.',
376
376
  aliases: '-b',
377
377
  banner: 'PATH'
@@ -86,14 +86,27 @@ module Berkshelf
86
86
  super(api_uri, options)
87
87
  end
88
88
 
89
+ # Download and extract target cookbook archive to the local file system,
90
+ # returning its filepath.
91
+ #
89
92
  # @param [String] name
93
+ # the name of the cookbook
90
94
  # @param [String] version
95
+ # the targeted version of the cookbook
91
96
  #
92
- # @return [String]
97
+ # @return [String, nil]
98
+ # cookbook filepath, or nil if archive does not contain a cookbook
93
99
  def download(name, version)
94
100
  archive = stream(find(name, version)[:file])
95
101
  extracted = self.class.unpack(archive.path)
96
- Dir.glob(File.join(extracted, "*")).first
102
+
103
+ if File.cookbook?(extracted)
104
+ extracted
105
+ else
106
+ Dir.glob(File.join(extracted, '*')).find do |dir|
107
+ File.cookbook?(dir)
108
+ end
109
+ end
97
110
  ensure
98
111
  archive.unlink unless archive.nil?
99
112
  end
@@ -10,7 +10,7 @@ module Berkshelf
10
10
  def initialize(berksfile)
11
11
  @berksfile = berksfile
12
12
  @lockfile = berksfile.lockfile
13
- @downloader = Downloader.new(berksfile)
13
+ @worker = Worker.pool(size: [(Celluloid.cores - 1), 1].max, args: [berksfile])
14
14
  end
15
15
 
16
16
  def build_universe
@@ -34,10 +34,10 @@ module Berkshelf
34
34
  Berkshelf.formatter.msg('Resolving cookbook dependencies...')
35
35
 
36
36
  dependencies, cookbooks = if lockfile.trusted?
37
- install_from_lockfile
38
- else
39
- install_from_universe
40
- end
37
+ install_from_lockfile
38
+ else
39
+ install_from_universe
40
+ end
41
41
 
42
42
  Berkshelf.log.debug " Finished resolving, calculating locks"
43
43
 
@@ -59,34 +59,48 @@ module Berkshelf
59
59
 
60
60
  private
61
61
 
62
- # Install a specific dependency.
63
- #
64
- # @param [Dependency]
65
- # the dependency to install
66
- # @return [CachedCookbook]
67
- # the installed cookbook
68
- def install(dependency)
69
- Berkshelf.log.info "Installing #{dependency}"
62
+ attr_reader :worker
63
+
64
+ class Worker
65
+ include Celluloid
66
+
67
+ attr_reader :berksfile
68
+ attr_reader :downloader
69
+
70
+ def initialize(berksfile)
71
+ @berksfile = berksfile
72
+ @downloader = Downloader.new(berksfile)
73
+ end
74
+
75
+ # Install a specific dependency.
76
+ #
77
+ # @param [Dependency]
78
+ # the dependency to install
79
+ # @return [CachedCookbook]
80
+ # the installed cookbook
81
+ def install(dependency)
82
+ Berkshelf.log.info "Installing #{dependency}"
70
83
 
71
- if dependency.installed?
72
- Berkshelf.log.debug " Already installed - skipping install"
84
+ if dependency.installed?
85
+ Berkshelf.log.debug " Already installed - skipping install"
73
86
 
74
- Berkshelf.formatter.use(dependency)
75
- dependency.cached_cookbook
76
- else
77
- name, version = dependency.name, dependency.locked_version.to_s
78
- source = berksfile.source_for(name, version)
87
+ Berkshelf.formatter.use(dependency)
88
+ dependency.cached_cookbook
89
+ else
90
+ name, version = dependency.name, dependency.locked_version.to_s
91
+ source = berksfile.source_for(name, version)
79
92
 
80
- Berkshelf.log.debug " Downloading #{dependency.name} (#{dependency.locked_version}) from #{source}"
93
+ Berkshelf.log.debug " Downloading #{dependency.name} (#{dependency.locked_version}) from #{source}"
81
94
 
82
- cookbook = source.cookbook(name, version)
95
+ cookbook = source.cookbook(name, version)
83
96
 
84
- Berkshelf.log.debug " => #{cookbook.inspect}"
97
+ Berkshelf.log.debug " => #{cookbook.inspect}"
85
98
 
86
- Berkshelf.formatter.install(source, cookbook)
99
+ Berkshelf.formatter.install(source, cookbook)
87
100
 
88
- stash = downloader.download(name, version)
89
- CookbookStore.import(name, version, stash)
101
+ stash = downloader.download(name, version)
102
+ CookbookStore.import(name, version, stash)
103
+ end
90
104
  end
91
105
  end
92
106
 
@@ -112,9 +126,7 @@ module Berkshelf
112
126
  build_universe
113
127
  end
114
128
 
115
- cookbooks = dependencies.sort.collect do |dependency|
116
- install(dependency)
117
- end
129
+ cookbooks = dependencies.sort.map { |dependency| worker.future.install(dependency) }.map(&:value)
118
130
 
119
131
  [dependencies, cookbooks]
120
132
  end
@@ -155,9 +167,7 @@ module Berkshelf
155
167
 
156
168
  Berkshelf.log.debug " Starting resolution..."
157
169
 
158
- cookbooks = resolver.resolve.sort.collect do |dependency|
159
- install(dependency)
160
- end
170
+ cookbooks = resolver.resolve.sort.map { |dependency| worker.future.install(dependency) }.map(&:value)
161
171
 
162
172
  [dependencies, cookbooks]
163
173
  end
@@ -33,26 +33,18 @@ module Berkshelf
33
33
  # is actually the path reative to the associated Berksfile's parent
34
34
  # directory.
35
35
  #
36
- # @return [String]
36
+ # @return [Pathname]
37
37
  # the relative path relative to the target
38
38
  def relative_path
39
- my_path = Pathname.new(options[:path]).expand_path
40
- target_path = Pathname.new(dependency.berksfile.filepath).expand_path
41
- target_path = target_path.dirname if target_path.file?
42
-
43
- new_path = my_path.relative_path_from(target_path).to_s
44
-
45
- return new_path if new_path.index('.') == 0
46
- "./#{new_path}"
39
+ @relative_path ||= expanded_path.relative_path_from(Pathname.new(File.dirname(dependency.berksfile.filepath)))
47
40
  end
48
41
 
49
42
  # The fully expanded path of this cookbook on disk, relative to the
50
43
  # Berksfile.
51
44
  #
52
- # @return [String]
45
+ # @return [Pathname]
53
46
  def expanded_path
54
- parent = File.expand_path(File.dirname(dependency.berksfile.filepath))
55
- File.expand_path(relative_path, parent)
47
+ @expanded_path ||= Pathname.new File.expand_path(options[:path], File.dirname(dependency.berksfile.filepath))
56
48
  end
57
49
 
58
50
  def ==(other)
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = '3.0.0.rc1'
2
+ VERSION = '3.0.0'
3
3
  end
@@ -11,8 +11,8 @@ module Berkshelf
11
11
  berksfile: berksfile,
12
12
  )
13
13
  end
14
- let(:path) { fixtures_path.join('cookbooks', 'example_cookbook').to_s }
15
- let(:relative_path) { '../../../fixtures/cookbooks/example_cookbook' }
14
+ let(:path) { fixtures_path.join('cookbooks', 'example_cookbook') }
15
+ let(:relative_path) { Pathname.new('../../../fixtures/cookbooks/example_cookbook') }
16
16
 
17
17
  subject { described_class.new(dependency, path: path) }
18
18
 
@@ -44,7 +44,7 @@ module Berkshelf
44
44
 
45
45
  describe '#expanded_path' do
46
46
  it 'returns the expanded path, relative to the Berksfile' do
47
- absolute_path = File.expand_path(relative_path, File.dirname(berksfile.filepath))
47
+ absolute_path = Pathname.new(File.expand_path(relative_path, File.dirname(berksfile.filepath)))
48
48
  expect(subject.expanded_path).to eq(absolute_path)
49
49
  end
50
50
  end
@@ -92,7 +92,7 @@ module Berkshelf
92
92
  end
93
93
 
94
94
  describe '#to_s' do
95
- it 'uses the expanded path' do
95
+ it 'uses the relative path' do
96
96
  expect(subject.to_s).to eq("source at #{relative_path}")
97
97
  end
98
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-04-09 00:00:00.000000000 Z
15
+ date: 2014-04-14 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable
@@ -34,14 +34,14 @@ dependencies:
34
34
  requirements:
35
35
  - - "~>"
36
36
  - !ruby/object:Gem::Version
37
- version: 1.2.0.rc2
37
+ version: '1.2'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - "~>"
43
43
  - !ruby/object:Gem::Version
44
- version: 1.2.0.rc2
44
+ version: '1.2'
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: buff-config
47
47
  requirement: !ruby/object:Gem::Requirement
@@ -146,14 +146,14 @@ dependencies:
146
146
  requirements:
147
147
  - - "~>"
148
148
  - !ruby/object:Gem::Version
149
- version: 1.0.0.rc3
149
+ version: '1.1'
150
150
  type: :runtime
151
151
  prerelease: false
152
152
  version_requirements: !ruby/object:Gem::Requirement
153
153
  requirements:
154
154
  - - "~>"
155
155
  - !ruby/object:Gem::Version
156
- version: 1.0.0.rc3
156
+ version: '1.1'
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: thor
159
159
  requirement: !ruby/object:Gem::Requirement
@@ -182,6 +182,34 @@ dependencies:
182
182
  - - "~>"
183
183
  - !ruby/object:Gem::Version
184
184
  version: '2.6'
185
+ - !ruby/object:Gem::Dependency
186
+ name: celluloid
187
+ requirement: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - "~>"
190
+ - !ruby/object:Gem::Version
191
+ version: 0.16.0.pre
192
+ type: :runtime
193
+ prerelease: false
194
+ version_requirements: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - "~>"
197
+ - !ruby/object:Gem::Version
198
+ version: 0.16.0.pre
199
+ - !ruby/object:Gem::Dependency
200
+ name: celluloid-io
201
+ requirement: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - "~>"
204
+ - !ruby/object:Gem::Version
205
+ version: 0.16.0.pre
206
+ type: :runtime
207
+ prerelease: false
208
+ version_requirements: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - "~>"
211
+ - !ruby/object:Gem::Version
212
+ version: 0.16.0.pre
185
213
  - !ruby/object:Gem::Dependency
186
214
  name: aruba
187
215
  requirement: !ruby/object:Gem::Requirement