vanagon 0.8.0 → 0.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b41f01dda75f8d40767ea3c7e290cf11462ff94
4
- data.tar.gz: 7c9b7ce98ff34e60371dbf087366cb0fd488c53d
3
+ metadata.gz: c06666ceca69a65fb5cd8ed50f5d879d13405e32
4
+ data.tar.gz: b172cfec4a27c00b6e8817f5cf7514fc2a8a6cb2
5
5
  SHA512:
6
- metadata.gz: 5dda1a3fde0dfb600e38da84061bfd3f006b4f8a199e04900d067a4a96408affb102e916622d88b8fa0e04f6773f686bf5e2ef13aef108c5560d2c42e009df54
7
- data.tar.gz: 4263fedb95452fefc118f7a199d70756455cb02c0fadd1c36b9ad630cdfd8d67d647c7a358c683295ca5cc0d2c53f2eca1a5a1ee4efde71b9d91f02a864118f5
6
+ metadata.gz: fa03f9d6849a5d65ad269146547b7482fd9488bd936521ec8a5a65b6f2b5089a9eaa6054b348fcd620713ad8d6e999ac4210c3c256ea04f120420dde14b66443
7
+ data.tar.gz: 027c3f6e8cbf5a12378783d4871fad4cd41fe1a549cedb717c7927d6fe74abe8a87de2ca9aa202bab9ffba62fbe94676b73ff5a3f0a81e256488325113bf155e
data/README.md CHANGED
@@ -291,10 +291,4 @@ For more detailed examples of the DSLs available, please see the
291
291
  [examples](https://github.com/puppetlabs/vanagon/tree/master/examples) directory and the YARD documentation for vanagon.
292
292
 
293
293
  ## Maintainers
294
- The Release Engineering team at Puppet Labs
295
-
296
- Maintainer: Michael Stahnke <stahnma@puppet.com>
297
-
298
- Please log tickets and issues at our [Issue Tracker](https://tickets.puppet.com/browse/CPR). Set compononent to Vanagon.
299
-
300
- In addition there is an active #puppet-dev channel on Freenode.
294
+ See MAINTAINERS file.
@@ -278,6 +278,23 @@ class Vanagon
278
278
  # @param md5 [String] md5 sum of the source for verification
279
279
  def md5sum(md5)
280
280
  @component.options[:sum] = md5
281
+ @component.options[:sum_type] = "md5"
282
+ end
283
+
284
+ # Sets the sha256 sum to verify the sum of the source
285
+ #
286
+ # @param sha256 [String] sha256 sum of the source for verification
287
+ def sha256sum(sha256)
288
+ @component.options[:sum] = sha256
289
+ @component.options[:sum_type] = "sha256"
290
+ end
291
+
292
+ # Sets the sha512 sum to verify the sum of the source
293
+ #
294
+ # @param sha512 [String] sha512 sum of the source for verification
295
+ def sha512sum(sha512)
296
+ @component.options[:sum] = sha512
297
+ @component.options[:sum_type] = "sha512"
281
298
  end
282
299
 
283
300
  # Sets the ref of the source for use in a git source
@@ -87,7 +87,8 @@ class Vanagon
87
87
  if Vanagon::Component::Source::Http.valid_url?(parse_and_rewrite(uri))
88
88
  return Vanagon::Component::Source::Http.new parse_and_rewrite(uri),
89
89
  sum: options[:sum],
90
- workdir: options[:workdir]
90
+ workdir: options[:workdir],
91
+ sum_type: options[:sum_type]
91
92
  end
92
93
 
93
94
  # Then we try local
@@ -10,7 +10,7 @@ class Vanagon
10
10
  include Vanagon::Utilities
11
11
 
12
12
  # Accessors :url, :file, :extension, :workdir, :cleanup are inherited from Local
13
- attr_accessor :sum
13
+ attr_accessor :sum, :sum_type
14
14
 
15
15
  class << self
16
16
  def valid_url?(target_url) # rubocop:disable Metrics/AbcSize
@@ -42,14 +42,19 @@ class Vanagon
42
42
  # @param url [String] url of the http source to fetch
43
43
  # @param sum [String] sum to verify the download against
44
44
  # @param workdir [String] working directory to download into
45
+ # @param sum_type [String] type of sum we are verifying
45
46
  # @raise [RuntimeError] an exception is raised is sum is nil
46
- def initialize(url, sum:, workdir:, **options)
47
+ def initialize(url, sum:, workdir:, sum_type:, **options)
47
48
  unless sum
48
49
  fail "sum is required to validate the http source"
49
50
  end
51
+ unless sum_type
52
+ fail "sum_type is required to validate the http source"
53
+ end
50
54
  @url = url
51
55
  @sum = sum
52
56
  @workdir = workdir
57
+ @sum_type = sum_type
53
58
  end
54
59
 
55
60
  # Download the source from the url specified. Sets the full path to the
@@ -65,12 +70,12 @@ class Vanagon
65
70
  # Verify the downloaded file matches the provided sum
66
71
  #
67
72
  # @raise [RuntimeError] an exception is raised if the sum does not match the sum of the file
68
- def verify
73
+ def verify # rubocop:disable Metrics/AbcSize
69
74
  puts "Verifying file: #{file} against sum: '#{sum}'"
70
- actual = get_md5sum(File.join(workdir, file))
75
+ actual = get_sum(File.join(workdir, file), sum_type)
71
76
  return true if sum == actual
72
77
 
73
- fail "Unable to verify '#{File.join(workdir, file)}': md5sum mismatch (expected '#{sum}', got '#{actual}'')"
78
+ fail "Unable to verify '#{File.join(workdir, file)}': #{sum_type} mismatch (expected '#{sum}', got '#{actual}')"
74
79
  end
75
80
 
76
81
  # Downloads the file from @url into the @workdir
@@ -19,7 +19,7 @@ class Vanagon
19
19
  # @param file [String] file to md5sum
20
20
  # @return [String] md5sum of the given file
21
21
  def get_md5sum(file)
22
- Digest::MD5.file(file).hexdigest.to_s
22
+ get_sum(file, 'md5')
23
23
  end
24
24
 
25
25
  # Generic file summing utility
@@ -32,6 +32,8 @@ class Vanagon
32
32
  case type.downcase
33
33
  when 'md5'
34
34
  Digest::MD5.file(file).hexdigest.to_s
35
+ when 'sha256'
36
+ Digest::SHA256.file(file).hexdigest.to_s
35
37
  when 'sha512'
36
38
  Digest::SHA512.file(file).hexdigest.to_s
37
39
  else
@@ -1,5 +1,21 @@
1
1
  %global debug_package %{nil}
2
2
 
3
+ <%- if @platform.is_cisco_wrlinux? -%>
4
+ # Our cisco-5/7 build platforms are missing the definition of
5
+ # __os_install_post, so we have to manually set it here. This
6
+ # then enables the brp strip scripts, which are needed to reduce
7
+ # the size of our agent packages for these platforms. This is
8
+ # necessary as some targets will fail to even install the package
9
+ # without stripped binaries because yum's package cache is kept
10
+ # on a partition with ~50MB of free space.
11
+ %global __os_install_post \
12
+ /usr/lib64/rpm/brp-compress \
13
+ /usr/lib64/rpm/brp-strip %{__strip} \
14
+ /usr/lib64/rpm/brp-strip-static-archive %{__strip} \
15
+ /usr/lib64/rpm/brp-strip-comment-note %{__strip} %{__objdump} \
16
+ %{nil}
17
+ <%- end -%>
18
+
3
19
  # Turn off the brp-python-bytecompile script
4
20
  %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
5
21
  <% if @platform.is_cross_compiled_linux? -%>
@@ -10,21 +10,59 @@ describe "Vanagon::Component::Source::Http" do
10
10
  let (:plaintext_url) { "#{base_url}/#{plaintext_filename}" }
11
11
  let (:plaintext_dirname) { './' }
12
12
  let (:md5sum) { 'abcdssasasa' }
13
+ let (:sha256sum) { 'foobarbaz' }
14
+ let (:sha512sum) { 'teststring' }
13
15
  let (:workdir) { "/tmp" }
14
16
 
15
17
  describe "#dirname" do
16
18
  it "returns the name of the tarball, minus extension for archives" do
17
- http_source = Vanagon::Component::Source::Http.new(tar_url, sum: md5sum, workdir: workdir)
19
+ http_source = Vanagon::Component::Source::Http.new(tar_url, sum: md5sum, workdir: workdir, sum_type: "md5")
18
20
  expect(http_source).to receive(:download).and_return(tar_filename)
19
21
  http_source.fetch
20
22
  expect(http_source.dirname).to eq(tar_dirname)
21
23
  end
22
24
 
23
25
  it "returns the current directory for non-archive files" do
24
- http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: md5sum, workdir: workdir)
26
+ http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: md5sum, workdir: workdir, sum_type: "md5")
25
27
  expect(http_source).to receive(:download).and_return(plaintext_filename)
26
28
  http_source.fetch
27
29
  expect(http_source.dirname).to eq(plaintext_dirname)
28
30
  end
29
31
  end
32
+
33
+ describe "verify" do
34
+ it "fails with a bad sum_type" do
35
+ http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: md5sum, workdir: workdir, sum_type: "md4")
36
+ expect(http_source).to receive(:download).and_return(plaintext_filename)
37
+ http_source.fetch
38
+ expect{ http_source.verify }.to raise_error(RuntimeError)
39
+ end
40
+
41
+ it "calls md5 digest when it's supposed to" do
42
+ Digest::MD5.any_instance.stub(:file).and_return(Digest::MD5.new)
43
+ Digest::MD5.any_instance.stub(:hexdigest).and_return(md5sum)
44
+ http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: md5sum, workdir: workdir, sum_type: "md5")
45
+ expect(http_source).to receive(:download).and_return(plaintext_filename)
46
+ http_source.fetch
47
+ http_source.verify
48
+ end
49
+
50
+ it "calls sha256 digest when it's supposed to" do
51
+ Digest::SHA256.any_instance.stub(:file).and_return(Digest::SHA256.new)
52
+ Digest::SHA256.any_instance.stub(:hexdigest).and_return(sha256sum)
53
+ http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: sha256sum, workdir: workdir, sum_type: "sha256")
54
+ expect(http_source).to receive(:download).and_return(plaintext_filename)
55
+ http_source.fetch
56
+ http_source.verify
57
+ end
58
+
59
+ it "calls sha512 digest when it's supposed to" do
60
+ Digest::SHA512.any_instance.stub(:file).and_return(Digest::SHA512.new)
61
+ Digest::SHA512.any_instance.stub(:hexdigest).and_return(sha512sum)
62
+ http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: sha512sum, workdir: workdir, sum_type: "sha512")
63
+ expect(http_source).to receive(:download).and_return(plaintext_filename)
64
+ http_source.fetch
65
+ http_source.verify
66
+ end
67
+ end
30
68
  end
@@ -94,12 +94,12 @@ describe "Vanagon::Component::Source" do
94
94
  end
95
95
 
96
96
  it "returns an object of the correct type for http:// URLS" do
97
- expect(klass.source(http_url, sum: sum, workdir: workdir).class)
97
+ expect(klass.source(http_url, sum: sum, workdir: workdir, sum_type: "md5").class)
98
98
  .to equal(Vanagon::Component::Source::Http)
99
99
  end
100
100
 
101
101
  it "returns an object of the correct type for https:// URLS" do
102
- expect(klass.source(https_url, sum: sum, workdir: workdir).class)
102
+ expect(klass.source(https_url, sum: sum, workdir: workdir, sum_type: "md5").class)
103
103
  .to equal(Vanagon::Component::Source::Http)
104
104
  end
105
105
 
@@ -108,7 +108,7 @@ describe "Vanagon::Component::Source" do
108
108
  'http://buildsources.delivery.puppetlabs.net'
109
109
  end
110
110
  it "applies rewrite rules to HTTP URLs" do
111
- expect(klass.source(original_http_url, sum: sum, workdir: workdir).url)
111
+ expect(klass.source(original_http_url, sum: sum, workdir: workdir, sum_type: "md5").url)
112
112
  .to eq(rewritten_http_url)
113
113
  end
114
114
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-11 00:00:00.000000000 Z
11
+ date: 2016-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -229,40 +229,40 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  version: '0'
230
230
  requirements: []
231
231
  rubyforge_project:
232
- rubygems_version: 2.2.5
232
+ rubygems_version: 2.5.1
233
233
  signing_key:
234
234
  specification_version: 3
235
235
  summary: All of your packages will fit into this van with this one simple trick.
236
236
  test_files:
237
237
  - spec/lib/makefile_spec.rb
238
- - spec/lib/vanagon/common/pathname_spec.rb
239
- - spec/lib/vanagon/common/user_spec.rb
240
- - spec/lib/vanagon/component/dsl_spec.rb
241
- - spec/lib/vanagon/component/rules_spec.rb
242
- - spec/lib/vanagon/component/source/git_spec.rb
243
238
  - spec/lib/vanagon/component/source/http_spec.rb
244
239
  - spec/lib/vanagon/component/source/local_spec.rb
240
+ - spec/lib/vanagon/component/source/git_spec.rb
241
+ - spec/lib/vanagon/component/rules_spec.rb
242
+ - spec/lib/vanagon/component/dsl_spec.rb
245
243
  - spec/lib/vanagon/component/source_spec.rb
246
- - spec/lib/vanagon/component_spec.rb
247
- - spec/lib/vanagon/driver_spec.rb
248
- - spec/lib/vanagon/engine/base_spec.rb
249
- - spec/lib/vanagon/engine/docker_spec.rb
250
- - spec/lib/vanagon/engine/ec2_spec.rb
251
- - spec/lib/vanagon/engine/hardware_spec.rb
252
- - spec/lib/vanagon/engine/local_spec.rb
253
- - spec/lib/vanagon/engine/pooler_spec.rb
254
- - spec/lib/vanagon/extensions/ostruct/json_spec.rb
244
+ - spec/lib/vanagon/common/user_spec.rb
245
+ - spec/lib/vanagon/common/pathname_spec.rb
255
246
  - spec/lib/vanagon/extensions/set/json_spec.rb
247
+ - spec/lib/vanagon/extensions/ostruct/json_spec.rb
256
248
  - spec/lib/vanagon/extensions/string_spec.rb
257
- - spec/lib/vanagon/optparse_spec.rb
249
+ - spec/lib/vanagon/utilities/shell_utilities_spec.rb
258
250
  - spec/lib/vanagon/platform/deb_spec.rb
259
- - spec/lib/vanagon/platform/dsl_spec.rb
260
- - spec/lib/vanagon/platform/rpm/aix_spec.rb
261
- - spec/lib/vanagon/platform/rpm_spec.rb
262
251
  - spec/lib/vanagon/platform/solaris_11_spec.rb
252
+ - spec/lib/vanagon/platform/rpm_spec.rb
253
+ - spec/lib/vanagon/platform/dsl_spec.rb
263
254
  - spec/lib/vanagon/platform/windows_spec.rb
264
- - spec/lib/vanagon/platform_spec.rb
265
- - spec/lib/vanagon/project/dsl_spec.rb
255
+ - spec/lib/vanagon/platform/rpm/aix_spec.rb
256
+ - spec/lib/vanagon/optparse_spec.rb
266
257
  - spec/lib/vanagon/project_spec.rb
267
- - spec/lib/vanagon/utilities/shell_utilities_spec.rb
258
+ - spec/lib/vanagon/component_spec.rb
259
+ - spec/lib/vanagon/engine/base_spec.rb
260
+ - spec/lib/vanagon/engine/pooler_spec.rb
261
+ - spec/lib/vanagon/engine/ec2_spec.rb
262
+ - spec/lib/vanagon/engine/hardware_spec.rb
263
+ - spec/lib/vanagon/engine/local_spec.rb
264
+ - spec/lib/vanagon/engine/docker_spec.rb
265
+ - spec/lib/vanagon/driver_spec.rb
266
+ - spec/lib/vanagon/project/dsl_spec.rb
268
267
  - spec/lib/vanagon/utilities_spec.rb
268
+ - spec/lib/vanagon/platform_spec.rb