berkshelf 8.0.1 → 8.0.5

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
  SHA256:
3
- metadata.gz: 99d23b6a2d3692b3124db831c84e4038aac41cc9a21848b65a38256995f687a0
4
- data.tar.gz: ff21e7c229ce9564ad1dd589556ed8a89488cb66788e4c4268751036ead8b949
3
+ metadata.gz: ef3b782c88bc9fe560b6c02c84ab32f6df5e2bf39d3c4b56d441079952e56a96
4
+ data.tar.gz: bd6f6b271645d42e62c29fa74e3a7d4633533b8dd104e386d064374d175dd27e
5
5
  SHA512:
6
- metadata.gz: 539e905ff46b5d587ccb1911678c1ca8ae547e4bdd9e3c78e5a0aa69d9552f4f16eca2422659b5b2c3f6d1996276d6c0599af6edad81e0cdcd4c06aac7b390f3
7
- data.tar.gz: 883c28941e1735a37c102e7d175b634cf6a7ced2994508c5da3611b3d9a73b0fcdcc51bd3fea0c3a671a226e490e41e2808643a6ce51709983d33f4b1c62c46d
6
+ metadata.gz: 8f9111b9f7a17c8dd8a65463e963a4a6f5c662d3affd9cec1125f90b0d5d71b7a742ef51e6b50161791cdd94f920acd2240ba2fc1472054f596d2e7dd1b18d25
7
+ data.tar.gz: d5113a1ebeb056843f92b6ae6e25d6850127e257cea2596a4c7bc55d42ba8f81c76388c8451a5fca126231f029271b6f6197e57504fa201113219721aef0a619
@@ -152,7 +152,7 @@ module Berkshelf
152
152
  unpack_dir = Pathname.new(tmp_dir) + "#{name}-#{version}"
153
153
 
154
154
  url = remote_cookbook.location_path
155
- open(url, "rb") do |remote_file|
155
+ URI.open(url, "rb") do |remote_file|
156
156
  archive_path.open("wb") { |local_file| local_file.write remote_file.read }
157
157
  end
158
158
 
@@ -1,4 +1,5 @@
1
1
  require "archive/tar/minitar"
2
+ require "find" unless defined?(Find)
2
3
  require "zlib" unless defined?(Zlib)
3
4
 
4
5
  module Berkshelf
@@ -40,8 +41,18 @@ module Berkshelf
40
41
  # @return [String]
41
42
  # path to the generated archive
42
43
  def run(source)
43
- tgz = Zlib::GzipWriter.new(File.open(out_file, "wb"))
44
- Archive::Tar::Minitar.pack(Dir.glob("#{source}/*"), tgz)
44
+ begin
45
+ dest = Zlib::GzipWriter.open(out_file)
46
+ tar = RelativeTarWriter.new(dest, source)
47
+ Find.find(source) do |entry|
48
+ next if source == entry
49
+
50
+ Archive::Tar::Minitar.pack_file(entry, tar)
51
+ end
52
+ ensure
53
+ tar.close
54
+ dest.close
55
+ end
45
56
 
46
57
  out_file
47
58
  rescue SystemCallError => ex
@@ -67,5 +78,30 @@ module Berkshelf
67
78
 
68
79
  # @return [String]
69
80
  attr_reader :filename
81
+
82
+ # A private decorator for Archive::Tar::Minitar::Writer that
83
+ # turns absolute paths into relative ones.
84
+ class RelativeTarWriter < SimpleDelegator # :nodoc:
85
+ def initialize(io, base_path)
86
+ @base_path = Pathname.new(base_path)
87
+ super(Archive::Tar::Minitar::Writer.new(io))
88
+ end
89
+
90
+ %w{add_file add_file_simple mkdir}.each do |method|
91
+ class_eval <<~RUBY
92
+ def #{method}(name, *opts, &block)
93
+ super(relative_path(name), *opts, &block)
94
+ end
95
+ RUBY
96
+ end
97
+
98
+ private
99
+
100
+ attr_reader :base_path
101
+
102
+ def relative_path(path)
103
+ Pathname.new(path).relative_path_from(base_path).to_s
104
+ end
105
+ end
70
106
  end
71
107
  end
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = "8.0.1".freeze
2
+ VERSION = "8.0.5".freeze
3
3
  end
@@ -231,8 +231,8 @@ describe Berkshelf::Lockfile do
231
231
  expect(Chef::Environment).to receive(:from_hash).with(env_hash).and_return(environment)
232
232
 
233
233
  expect(environment).to receive(:cookbook_versions).with(
234
- "apt" => "= 1.0.0",
235
- "jenkins" => "= 1.4.5"
234
+ {"apt" => "= 1.0.0",
235
+ "jenkins" => "= 1.4.5"}
236
236
  )
237
237
 
238
238
  expect(environment).to receive(:save)
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: 8.0.1
4
+ version: 8.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -9,10 +9,10 @@ authors:
9
9
  - Michael Ivey
10
10
  - Justin Campbell
11
11
  - Seth Vargo
12
- autorequire:
12
+ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2022-05-19 00:00:00.000000000 Z
15
+ date: 2022-10-27 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mixlib-shellout
@@ -314,21 +314,6 @@ files:
314
314
  - spec/support/matchers/filepath_matchers.rb
315
315
  - spec/support/path_helpers.rb
316
316
  - spec/support/shared_examples/formatter.rb
317
- - spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb
318
- - spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h
319
- - spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb
320
- - spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb
321
- - spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb
322
- - spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb
323
- - spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h
324
- - spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb
325
- - spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb
326
- - spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb
327
- - spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb
328
- - spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h
329
- - spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb
330
- - spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb
331
- - spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb
332
317
  - spec/unit/berkshelf/berksfile_spec.rb
333
318
  - spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb
334
319
  - spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb
@@ -378,7 +363,7 @@ metadata:
378
363
  bug_tracker_uri: https://github.com/chef/berkshelf/issues
379
364
  source_code_uri: https://github.com/chef/berkshelf
380
365
  changelog_uri: https://github.com/chef/berkshelf/blob/main/CHANGELOG.md
381
- post_install_message:
366
+ post_install_message:
382
367
  rdoc_options: []
383
368
  require_paths:
384
369
  - lib
@@ -393,8 +378,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
393
378
  - !ruby/object:Gem::Version
394
379
  version: 2.0.0
395
380
  requirements: []
396
- rubygems_version: 3.2.3
397
- signing_key:
381
+ rubygems_version: 3.1.4
382
+ signing_key:
398
383
  specification_version: 4
399
384
  summary: Manages a Chef cookbook's dependencies
400
385
  test_files: []
@@ -1,2 +0,0 @@
1
- name 'fake'
2
- version '0.1.0'
@@ -1,2 +0,0 @@
1
- name 'fake'
2
- version '0.2.0'
@@ -1,2 +0,0 @@
1
- name 'fake'
2
- version '1.0.0'