mini_portile2 2.2.0.rc1 → 2.2.0

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: 7085b002833202ee7455beb829f9fb787bca8129
4
- data.tar.gz: 097a89cc3ffe2a742947a3310c284d518ab8a9f6
3
+ metadata.gz: 2a300c53f89d0d5c33f152aedaf83c93fd7cf2da
4
+ data.tar.gz: ea999f1800170b0eca5d7d2f4ebc34b27ea1dcbd
5
5
  SHA512:
6
- metadata.gz: 033fb41be5b3c882e6a02eb806695a22db54ce2b8ef2253b9475822f4bb5764157d411cb2a2da143da8c10ca887e65fc85a0dd60c741867d700ce07afa688e20
7
- data.tar.gz: 6b0df87be823d602b38508a924f85de1d1923840d184484bddb7ccf05542e8d9895919593c6e8870c5515b320ddd640aec5f20470ad1b19dd348ff28f1605fac
6
+ metadata.gz: 47e8494cf606445724bf155bcd430568526c17142659a7dc4596dc0f8572f6b88ac2322565a63cf5323e9cb29a311cfd1c3ed866c323bec7c95e1e885142f5f9
7
+ data.tar.gz: '08246743bb302ab883fefa47657ea49d0b132bdeb2c59daf85d890c1b45aacc155111c1e7568e9f228a859150b20535169ad9281148cdf8278506cbfa4b84996'
data/.gitignore CHANGED
@@ -3,3 +3,5 @@ tmp
3
3
  Gemfile.lock
4
4
  .bundle
5
5
  ports
6
+ concourse/private.yml
7
+ concourse/mini_portile.final.yml
@@ -1,12 +1,15 @@
1
- --
1
+ ---
2
2
  language: ruby
3
3
  sudo: false
4
- rvm:
5
- - 1.9.3
6
- - 2.0
7
- - 2.1
8
- - 2.2
9
- - 2.3.0
10
- - ruby-head
11
- - jruby-1.7.23
12
- - jruby-9.0.4.0
4
+ matrix:
5
+ include:
6
+ - rvm: 1.9.3
7
+ - rvm: 2.0
8
+ - rvm: 2.1
9
+ - rvm: 2.2.5
10
+ - rvm: 2.3.1
11
+ - rvm: 2.4.0
12
+ env:
13
+ - RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
14
+ - rvm: jruby-1.7
15
+ - rvm: jruby-9.1.5.0
@@ -1,8 +1,13 @@
1
- ### 2.2.0.rc1 / 2016-03-08
1
+ ### 2.2.0 / 2017-06-04
2
2
 
3
3
  #### Enhancements
4
4
 
5
- * Add experimental support for cmake-based projects
5
+ * Remove MD5 hashing of configure options, not avialbale in FIPS mode. (#78)
6
+ * Add experimental support for cmake-based projects.
7
+ * Retry on HTTP failures during downloads. [#63] (Thanks, @jtarchie and @jvshahid!)
8
+ * Support Ruby 2.4 frozen string literals.
9
+ * Support applying patches for users with misconfigured git worktree. [#69]
10
+ * Support gpg signature verification of download resources.
6
11
 
7
12
 
8
13
  ### 2.1.0 / 2016-01-06
data/README.md CHANGED
@@ -147,7 +147,7 @@ task :libiconv do
147
147
  recipe = MiniPortile.new("libiconv", "1.13.1")
148
148
  recipe.files << {
149
149
  url: "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz"],
150
- md5: "7ab33ebd26687c744a37264a330bbe9a"
150
+ sha256: "55a36168306089009d054ccdd9d013041bfc3ab26be7033d107821f1c4949a49"
151
151
  }
152
152
  checkpoint = ".#{recipe.name}-#{recipe.version}.installed"
153
153
 
@@ -174,6 +174,45 @@ The above example will:
174
174
  As an exercise for the reader, you could specify the libiconv version
175
175
  in an environment variable or a configuration file.
176
176
 
177
+ ### Download verification
178
+ MiniPortile supports HTTPS, HTTP, FTP and FILE sources for download.
179
+ The integrity of the downloaded file can be verified per hash value or PGP signature.
180
+ This is particular important for untrusted sources (non-HTTPS).
181
+
182
+ #### Hash digest verification
183
+ MiniPortile can verify the integrity of the downloaded file per SHA256, SHA1 or MD5 hash digest.
184
+
185
+ ```ruby
186
+ recipe.files << {
187
+ url: "http://your.host/file.tar.bz2",
188
+ sha256: "<32 byte hex value>",
189
+ }
190
+ ```
191
+
192
+ #### PGP signature verification
193
+ MiniPortile can also verify the integrity of the downloaded file per PGP signature.
194
+
195
+ ```ruby
196
+ public_key = <<-EOT
197
+ -----BEGIN PGP PUBLIC KEY BLOCK-----
198
+ Version: GnuPG v1
199
+
200
+ mQENBE7SKu8BCADQo6x4ZQfAcPlJMLmL8zBEBUS6GyKMMMDtrTh3Yaq481HB54oR
201
+ [...]
202
+ -----END PGP PUBLIC KEY BLOCK-----
203
+ EOT
204
+
205
+ recipe.files << {
206
+ url: "http://your.host/file.tar.bz2",
207
+ gpg: {
208
+ key: public_key,
209
+ signature_url: "http://your.host/file.tar.bz2.sig"
210
+ }
211
+ }
212
+ ```
213
+
214
+ Please note, that the `gpg` executable is required to verify the signature.
215
+ It is therefore recommended to use the hash verification method instead of PGP, when used in `extconf.rb` while `gem install`.
177
216
 
178
217
  ### Native and/or Cross Compilation
179
218
 
data/Rakefile CHANGED
@@ -1,10 +1,11 @@
1
1
  require "rake/clean"
2
2
  require 'bundler/gem_tasks'
3
+ require 'concourse'
3
4
 
4
5
  namespace :test do
5
6
  desc "Test MiniPortile by running unit tests"
6
7
  task :unit do
7
- sh "ruby -w -W2 -I. -Ilib -e \"#{Dir["test/test_*.rb"].map{|f| "require '#{f}';"}.join}\" -- -v"
8
+ sh "ruby -w -W2 -I. -Ilib -e \"#{Dir["test/test_*.rb"].map{|f| "require '#{f}';"}.join}\" -- #{ENV['TESTOPTS']} -v"
8
9
  end
9
10
 
10
11
  desc "Test MiniPortile by compiling examples"
@@ -23,3 +24,6 @@ desc "Run all tests"
23
24
  task :test => ["test:unit", "test:examples"]
24
25
 
25
26
  task :default => [:test]
27
+
28
+
29
+ Concourse.new("mini_portile").create_tasks!
@@ -7,6 +7,7 @@ install:
7
7
  - ruby --version
8
8
  - gem --version
9
9
  - bundle install
10
+ - gpg --version
10
11
 
11
12
  build: off
12
13
 
@@ -0,0 +1,160 @@
1
+ % ruby_version = RUBIES[:mri].last
2
+
3
+ groups:
4
+ - name: master
5
+ jobs:
6
+ - ruby-<%= ruby_version %>
7
+ - windows-install-ruby-2.3
8
+ - ruby-2.3-devkit
9
+
10
+ - name: PRs
11
+ jobs:
12
+ - pr-pending
13
+ - ruby-<%= ruby_version %>-pr
14
+ - pr-success
15
+
16
+ resource_types:
17
+ - name: pull-request
18
+ type: docker-image
19
+ source:
20
+ repository: jtarchie/pr
21
+
22
+ resources:
23
+ - name: ci
24
+ type: git
25
+ source:
26
+ uri: https://github.com/flavorjones/mini_portile/
27
+ branch: master
28
+ disable_ci_skip: true # always get the latest pipeline configuration
29
+
30
+ - name: nokogiri-ci
31
+ type: git
32
+ source:
33
+ uri: https://github.com/sparklemotion/nokogiri/
34
+ branch: master
35
+ disable_ci_skip: true # always get the latest pipeline configuration
36
+
37
+ - name: mini_portile
38
+ type: git
39
+ source:
40
+ uri: https://github.com/flavorjones/mini_portile/
41
+ branch: master
42
+ ignore_paths:
43
+ - concourse/**
44
+
45
+ - name: mini_portile-pr
46
+ type: pull-request
47
+ source:
48
+ repo: flavorjones/mini_portile
49
+ access_token: {{github-repo-status-access-token}}
50
+ ignore_paths:
51
+ - concourse/**
52
+
53
+ jobs:
54
+ #
55
+ # master
56
+ #
57
+ - name: ruby-<%= ruby_version %>
58
+ public: true
59
+ plan:
60
+ - get: ci
61
+ - get: mini_portile
62
+ trigger: true
63
+ - task: rake-test
64
+ config:
65
+ platform: linux
66
+ image_resource:
67
+ type: docker-image
68
+ source: {repository: ruby, tag: "<%= ruby_version %>"}
69
+ inputs:
70
+ - name: ci
71
+ - name: mini_portile
72
+ run:
73
+ path: ci/concourse/tasks/rake-test/task.sh
74
+
75
+ - name: windows-install-ruby-2.3
76
+ public: true
77
+ serial_groups: [windows-configuration]
78
+ plan:
79
+ - get: nokogiri-ci
80
+ - get: mini_portile
81
+ trigger: true
82
+ - task: setup
83
+ config:
84
+ platform: windows
85
+ inputs:
86
+ - name: nokogiri-ci
87
+ path: ci
88
+ run:
89
+ path: powershell
90
+ args: ["-File", "ci/concourse/tasks/windows-config/install-ruby-and-devkit.ps1"]
91
+
92
+ - name: ruby-2.3-devkit
93
+ public: true
94
+ plan:
95
+ - get: ci
96
+ - get: nokogiri-ci
97
+ - get: mini_portile
98
+ trigger: true
99
+ passed: ["windows-install-ruby-2.3"]
100
+ - task: rake-test
101
+ config:
102
+ platform: windows
103
+ inputs:
104
+ - name: ci
105
+ - name: nokogiri-ci
106
+ - name: mini_portile
107
+ run:
108
+ path: powershell
109
+ args: ["-File", "ci/concourse/tasks/rake-test/task.ps1"]
110
+
111
+ #
112
+ # PRs
113
+ #
114
+ - name: pr-pending
115
+ public: true
116
+ plan:
117
+ - get: ci
118
+ - get: mini_portile-pr
119
+ trigger: true
120
+ version: every
121
+ - put: mini_portile-pr
122
+ params: {path: mini_portile-pr, status: pending}
123
+
124
+ - name: ruby-<%= ruby_version %>-pr
125
+ public: true
126
+ serial_groups: [pr]
127
+ plan:
128
+ - get: ci
129
+ - get: mini_portile-pr
130
+ trigger: true
131
+ version: every
132
+ passed: [pr-pending]
133
+ - task: rake-test
134
+ config:
135
+ platform: linux
136
+ image_resource:
137
+ type: docker-image
138
+ source: {repository: ruby, tag: "<%= ruby_version %>"}
139
+ inputs:
140
+ - name: ci
141
+ - name: mini_portile-pr
142
+ path: mini_portile
143
+ run:
144
+ path: ci/concourse/tasks/rake-test/task.sh
145
+ on_failure:
146
+ put: mini_portile-pr
147
+ params: {path: mini_portile-pr, status: failure}
148
+
149
+ - name: pr-success
150
+ public: true
151
+ serial_groups: [pr]
152
+ disable_manual_trigger: true
153
+ plan:
154
+ - get: mini_portile-pr
155
+ trigger: true
156
+ version: every
157
+ passed:
158
+ - ruby-<%= ruby_version %>-pr
159
+ - put: mini_portile-pr
160
+ params: {path: mini_portile-pr, status: success}
@@ -0,0 +1,13 @@
1
+ . "nokogiri-ci\concourse\shared\common.ps1"
2
+ . "c:\var\vcap\packages\windows-ruby-dev-tools\prelude.ps1"
3
+
4
+ prepend-path $ruby23_bin_path
5
+ $env:RUBYOPT = "-rdevkit"
6
+
7
+ push-location mini_portile
8
+
9
+ stream-cmd "gem" "install bundler"
10
+ stream-cmd "bundle" "install"
11
+ stream-cmd "bundle" "exec rake test"
12
+
13
+ pop-location
@@ -0,0 +1,13 @@
1
+ #! /usr/bin/env bash
2
+
3
+ set -e -x -u
4
+
5
+ apt-get update
6
+ apt-get install -y cmake
7
+
8
+ pushd mini_portile
9
+
10
+ bundle install
11
+ bundle exec rake test
12
+
13
+ popd
@@ -4,7 +4,7 @@ require 'net/https'
4
4
  require 'net/ftp'
5
5
  require 'fileutils'
6
6
  require 'tempfile'
7
- require 'digest/md5'
7
+ require 'digest'
8
8
  require 'open-uri'
9
9
  require 'cgi'
10
10
  require 'rbconfig'
@@ -72,7 +72,7 @@ class MiniPortile
72
72
  message "Running git apply with #{file}... "
73
73
  # By --work-tree=. git-apply uses the current directory as
74
74
  # the project root and will not search upwards for .git.
75
- execute('patch', ["git", "--work-tree=.", "apply", "--whitespace=warn", file], :initial_message => false)
75
+ execute('patch', ["git", "--git-dir=.", "--work-tree=.", "apply", "--whitespace=warn", file], :initial_message => false)
76
76
  }
77
77
  when which('patch')
78
78
  lambda { |file|
@@ -99,9 +99,8 @@ class MiniPortile
99
99
  def configure
100
100
  return if configured?
101
101
 
102
- md5_file = File.join(tmp_path, 'configure.md5')
103
- digest = Digest::MD5.hexdigest(computed_options.to_s)
104
- File.open(md5_file, "w") { |f| f.write digest }
102
+ cache_file = File.join(tmp_path, 'configure.options_cache')
103
+ File.open(cache_file, "w") { |f| f.write computed_options.to_s }
105
104
 
106
105
  if RUBY_PLATFORM=~/mingw|mswin/
107
106
  # Windows doesn't recognize the shebang.
@@ -131,12 +130,12 @@ class MiniPortile
131
130
  def configured?
132
131
  configure = File.join(work_path, 'configure')
133
132
  makefile = File.join(work_path, 'Makefile')
134
- md5_file = File.join(tmp_path, 'configure.md5')
133
+ cache_file = File.join(tmp_path, 'configure.options_cache')
135
134
 
136
- stored_md5 = File.exist?(md5_file) ? File.read(md5_file) : ""
137
- current_md5 = Digest::MD5.hexdigest(computed_options.to_s)
135
+ stored_options = File.exist?(cache_file) ? File.read(cache_file) : ""
136
+ current_options = computed_options.to_s
138
137
 
139
- (current_md5 == stored_md5) && newer?(makefile, configure)
138
+ (current_options == stored_options) && newer?(makefile, configure)
140
139
  end
141
140
 
142
141
  def installed?
@@ -251,16 +250,47 @@ private
251
250
  end
252
251
  end
253
252
 
253
+ KEYRING_NAME = "mini_portile_keyring.gpg"
254
+
254
255
  def verify_file(file)
255
- digest = case
256
- when exp=file[:sha256] then Digest::SHA256
257
- when exp=file[:sha1] then Digest::SHA1
258
- when exp=file[:md5] then Digest::MD5
259
- end
260
- if digest
261
- is = digest.file(file[:local_path]).hexdigest
262
- unless is == exp.downcase
263
- raise "Downloaded file '#{file[:local_path]}' has wrong hash: expected: #{exp} is: #{is}"
256
+ if file.has_key?(:gpg)
257
+ gpg = file[:gpg]
258
+
259
+ signature_url = gpg[:signature_url] || "#{file[:url]}.asc"
260
+ signature_file = file[:local_path] + ".asc"
261
+ # download the signature file
262
+ download_file(signature_url, signature_file)
263
+
264
+ gpg_exe = which('gpg2') || which('gpg') || raise("Neither GPG nor GPG2 is installed")
265
+
266
+ # import the key into our own keyring
267
+ gpg_status = IO.popen([gpg_exe, "--status-fd", "1", "--no-default-keyring", "--keyring", KEYRING_NAME, "--import"], "w+") do |io|
268
+ io.write gpg[:key]
269
+ io.close_write
270
+ io.read
271
+ end
272
+ raise "invalid gpg key provided" unless /\[GNUPG:\] IMPORT_OK \d+ (?<key_id>[0-9a-f]+)/i =~ gpg_status
273
+
274
+ # verify the signature against our keyring
275
+ gpg_status = IO.popen([gpg_exe, "--status-fd", "1", "--no-default-keyring", "--keyring", KEYRING_NAME, "--verify", signature_file, file[:local_path]], &:read)
276
+
277
+ # remove the key from our keyring
278
+ IO.popen([gpg_exe, "--batch", "--yes", "--no-default-keyring", "--keyring", KEYRING_NAME, "--delete-keys", key_id], &:read)
279
+
280
+ raise "unable to delete the imported key" unless $?.exitstatus==0
281
+ raise "signature mismatch" unless gpg_status.match(/^\[GNUPG:\] VALIDSIG/)
282
+
283
+ else
284
+ digest = case
285
+ when exp=file[:sha256] then Digest::SHA256
286
+ when exp=file[:sha1] then Digest::SHA1
287
+ when exp=file[:md5] then Digest::MD5
288
+ end
289
+ if digest
290
+ is = digest.file(file[:local_path]).hexdigest
291
+ unless is == exp.downcase
292
+ raise "Downloaded file '#{file[:local_path]}' has wrong hash: expected: #{exp} is: #{is}"
293
+ end
264
294
  end
265
295
  end
266
296
  end
@@ -438,6 +468,7 @@ private
438
468
  [proxy_uri, proxy_user, proxy_pass]
439
469
  end
440
470
  end
471
+
441
472
  begin
442
473
  OpenURI.open_uri(url, 'rb', params) do |io|
443
474
  temp_file << io.read
@@ -446,8 +477,15 @@ private
446
477
  rescue OpenURI::HTTPRedirect => redirect
447
478
  raise "Too many redirections for the original URL, halting." if count <= 0
448
479
  count = count - 1
449
- return download_file(redirect.url, full_path, count - 1)
480
+ return download_file(redirect.url, full_path, count-1)
450
481
  rescue => e
482
+ count = count - 1
483
+ puts "#{count} retrie(s) left for #{filename}"
484
+ if count > 0
485
+ sleep 1
486
+ return download_file_http(url, full_path, count)
487
+ end
488
+
451
489
  output e.message
452
490
  return false
453
491
  end
@@ -16,9 +16,8 @@ class MiniPortileCMake < MiniPortile
16
16
  def configure
17
17
  return if configured?
18
18
 
19
- md5_file = File.join(tmp_path, 'configure.md5')
20
- digest = Digest::MD5.hexdigest(computed_options.to_s)
21
- File.open(md5_file, "w") { |f| f.write digest }
19
+ cache_file = File.join(tmp_path, 'configure.options_cache')
20
+ File.open(cache_file, "w") { |f| f.write computed_options.to_s }
22
21
 
23
22
  execute('configure', %w(cmake) + computed_options + ["."])
24
23
  end
@@ -26,16 +25,16 @@ class MiniPortileCMake < MiniPortile
26
25
  def configured?
27
26
  configure = File.join(work_path, 'configure')
28
27
  makefile = File.join(work_path, 'CMakefile')
29
- md5_file = File.join(tmp_path, 'configure.md5')
28
+ cache_file = File.join(tmp_path, 'configure.options_cache')
30
29
 
31
- stored_md5 = File.exist?(md5_file) ? File.read(md5_file) : ""
32
- current_md5 = Digest::MD5.hexdigest(computed_options.to_s)
30
+ stored_options = File.exist?(cache_file) ? File.read(cache_file) : ""
31
+ current_options = computed_options.to_s
33
32
 
34
- (current_md5 == stored_md5) && newer?(makefile, configure)
33
+ (current_options == stored_options) && newer?(makefile, configure)
35
34
  end
36
35
 
37
36
  def make_cmd
38
37
  return "nmake" if MiniPortile.windows?
39
38
  super
40
39
  end
41
- end
40
+ end
@@ -1,3 +1,3 @@
1
1
  class MiniPortile
2
- VERSION = "2.2.0.rc1"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -16,7 +16,11 @@ Gem::Specification.new do |spec|
16
16
  spec.homepage = 'http://github.com/flavorjones/mini_portile'
17
17
  spec.licenses = ['MIT']
18
18
 
19
- spec.files = `git ls-files -z`.split("\x0")
19
+ begin
20
+ spec.files = `git ls-files -z`.split("\x0")
21
+ rescue Exception => e
22
+ warn "WARNING: could not set spec.files: #{e.class}: #{e}"
23
+ end
20
24
 
21
25
  # omit the `examples` directory from the gem, because it's large and
22
26
  # not necessary to be packaged in the gem.
@@ -28,10 +32,11 @@ Gem::Specification.new do |spec|
28
32
  spec.require_paths = ["lib"]
29
33
 
30
34
  spec.add_development_dependency "bundler", "~> 1.7"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "minitest", "~> 5.8.0"
33
- spec.add_development_dependency "minitest-hooks", "~> 1.4.0"
34
- spec.add_development_dependency "minitar", "~> 0.5.4"
35
+ spec.add_development_dependency "rake", "~> 12.0"
36
+ spec.add_development_dependency "minitest", "~> 5.8"
37
+ spec.add_development_dependency "minitest-hooks", "~> 1.4"
38
+ spec.add_development_dependency "minitar", "~> 0.5"
39
+ spec.add_development_dependency "concourse", "~> 0.12"
35
40
 
36
41
  spec.required_ruby_version = ">= 1.9.2"
37
42
  end
@@ -0,0 +1 @@
1
+ test
@@ -0,0 +1,9 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG v1
3
+
4
+ iJwEAAECAAYFAlcFOD8ACgkQZeg+SWTDcLNIswP/XvVRoJ+eQ2u2v+WjXdBBKBSW
5
+ pzM216aJPRBxPl98xNUUKjqga+tjKmIHJn5T4CIxHqis1toPxtE5tKnc6cVO1aqY
6
+ bCUfkWyt/A3qRHQuniRUWSBKZWdk+j3AopTpd3i/r/s0pDj3bMHJ7bDOTsEskNcM
7
+ KpgFfNM1ieFRQmIWPWg=
8
+ =kbKc
9
+ -----END PGP SIGNATURE-----
@@ -0,0 +1,9 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG v1
3
+
4
+ iJwEAQECAAYFAlcFLEgACgkQZeg+SWTDcLPVwgQAg8KTI91Ryx38YplzgWV9tUPj
5
+ o7J7IEzb8faE7m2mgtq8m62DvA4h/PJzmbh1EJJ4VkO+A4O2LVh/bTgnyYXv+kMu
6
+ sEmvK35PnAC8r7pv98VSbMEXyV/rK3+uGhTvnXZYkULvMVYkN/EHIh2bCQJ3R14X
7
+ MY8El95QST8/dR/yBkw=
8
+ =qbod
9
+ -----END PGP SIGNATURE-----
@@ -8,8 +8,7 @@ class TestCook < TestCase
8
8
  @assets_path = File.expand_path("../assets", __FILE__)
9
9
  @tar_path = File.expand_path("../../tmp/test mini portile-1.0.0.tar.gz", __FILE__)
10
10
 
11
- # remove any previous test files
12
- FileUtils.rm_rf("tmp")
11
+ FileUtils.rm_rf("tmp") # remove any previous test files
13
12
 
14
13
  create_tar(@tar_path, @assets_path, "test mini portile-1.0.0")
15
14
  start_webrick(File.dirname(@tar_path))
@@ -28,7 +27,7 @@ class TestCook < TestCase
28
27
  def after_all
29
28
  super
30
29
  stop_webrick
31
- # leave test files for inspection
30
+ FileUtils.rm_rf("tmp") # remove test files
32
31
  end
33
32
 
34
33
  def test_download
@@ -67,3 +66,50 @@ class TestCook < TestCase
67
66
  assert_equal( ["install"].inspect, IO.read(txt).chomp )
68
67
  end
69
68
  end
69
+
70
+ class TestCookWithBrokenGitDir < TestCase
71
+ #
72
+ # this is a test for #69
73
+ # https://github.com/flavorjones/mini_portile/issues/69
74
+ #
75
+ attr_accessor :assets_path, :tar_path, :recipe
76
+
77
+ def before_all
78
+ super
79
+ @assets_path = File.expand_path("../assets", __FILE__)
80
+ @tar_path = File.expand_path("../../tmp/test-mini-portile-1.0.0.tar.gz", __FILE__)
81
+
82
+ @git_dir = File.join(@assets_path, "git-broken")
83
+ FileUtils.rm_rf @git_dir
84
+ FileUtils.mkdir_p @git_dir
85
+ Dir.chdir(@git_dir) do
86
+ File.open ".git", "w" do |f|
87
+ f.write "gitdir: /nonexistent"
88
+ end
89
+ end
90
+
91
+ create_tar(@tar_path, @assets_path, "test mini portile-1.0.0")
92
+
93
+ @recipe = MiniPortile.new("test mini portile", "1.0.0").tap do |recipe|
94
+ recipe.files << "file://#{@tar_path}"
95
+ recipe.patch_files << File.join(@assets_path, "patch 1.diff")
96
+ recipe.configure_options << "--option=\"path with 'space'\""
97
+ end
98
+
99
+ Dir.chdir(@git_dir) do
100
+ @recipe.cook
101
+ end
102
+ end
103
+
104
+ def after_all
105
+ FileUtils.rm_rf @git_dir
106
+ end
107
+
108
+ def test_patch
109
+ Dir.chdir(@git_dir) do
110
+ patch1 = File.join(work_dir, "patch 1.txt")
111
+ assert File.exist?(patch1), patch1
112
+ assert_match( /^\tchange 1/, IO.read(patch1) )
113
+ end
114
+ end
115
+ end
@@ -66,5 +66,150 @@ class TestDigest < TestCase
66
66
  def test_wrong_md5
67
67
  download_with_wrong_digest(:md5)
68
68
  end
69
+
70
+ def public_key
71
+ <<-KEY
72
+ -----BEGIN PGP PUBLIC KEY BLOCK-----
73
+ Version: GnuPG v1
74
+
75
+ mI0EVwUhJQEEAMYxFhgaAdM2Ul5r+XfpqAaI7SOxB14eRjhFjhchy4ylgVxetyLq
76
+ di3zeANXBIHsLBl7quYTlnmhJr/+GQRkCnXWiUp0tJsBVzGM3puK7c534gakEUH6
77
+ AlDtj5p3IeygzSyn8u7KORv+ainXfhwkvTO04mJmxAb2uT8ngKYFdPa1ABEBAAG0
78
+ J1Rlc3QgTWluaXBvcnRpbGUgPHRlc3RAbWluaXBvcnRpbGUub3JnPoi4BBMBAgAi
79
+ BQJXBSElAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRBl6D5JZMNwswAK
80
+ A/90Cdb+PX21weBR2Q6uR06M/alPexuXXyJL8ZcwbQMJ/pBBgcS5/h1+rQkBI/CN
81
+ qpXdDlw2Xys2k0sNwdjIw3hmYRzBrddXlCSW3Sifq/hS+kfPZ1snQmIjCgy1Xky5
82
+ QGCcPUxBUxzmra88LakkDO+euKK3hcrfeFIi611lTum1NLiNBFcFISUBBADoyY6z
83
+ 2PwH3RWUbqv0VX1s3/JO3v3xMjCRKPlFwsNwLTBtZoWfR6Ao1ajeCuZKfzNKIQ2I
84
+ rn86Rcqyrq4hTj+7BTWjkIPOBthjiL1YqbEBtX7jcYRkYvdQz/IG2F4zVV6X4AAR
85
+ Twx7qaXNt67ArzbHCe5gLNRUK6e6OArkahMv7QARAQABiJ8EGAECAAkFAlcFISUC
86
+ GwwACgkQZeg+SWTDcLNFiwP/TR33ClqWOz0mpjt0xPEoZ0ORmV6fo4sjjzgQoHH/
87
+ KTdsabJbGp8oLQGW/mx3OxgbsAkyZymb5H5cjaF4HtSd4cxI5t1C9ZS/ytN8pqfR
88
+ e29SBje8DAAJn2l57s2OddXLPQ0DUwCcdNEaqgHwSk/Swxc7K+IpfvjLKHKUZZBP
89
+ 4Ko=
90
+ =SVWi
91
+ -----END PGP PUBLIC KEY BLOCK-----
92
+ KEY
93
+ end
94
+
95
+ def test_with_valid_gpg_signature
96
+ data_file = File.expand_path(File.join(File.dirname(__FILE__), 'assets', 'gpg-fixtures', 'data'))
97
+
98
+ @recipe.files << {
99
+ :url => "file://#{data_file}",
100
+ :gpg => {
101
+ :key => public_key,
102
+ :signature_url => "file://#{data_file}.asc"
103
+ }
104
+ }
105
+ @recipe.download
106
+ end
107
+
108
+ def test_optional_gpg_signature_url
109
+ data_file = File.expand_path(File.join(File.dirname(__FILE__), 'assets', 'gpg-fixtures', 'data'))
110
+
111
+ @recipe.files << {
112
+ :url => "file://#{data_file}",
113
+ :gpg => {
114
+ :key => public_key
115
+ }
116
+ }
117
+ @recipe.download
118
+ end
119
+
120
+ def test_with_invalid_gpg_signature
121
+ data_file = File.expand_path(File.join(File.dirname(__FILE__), 'assets', 'gpg-fixtures', 'data'))
122
+
123
+ @recipe.files << {
124
+ :url => "file://#{data_file}",
125
+ :gpg => {
126
+ :key => public_key,
127
+ :signature_url => "file://#{data_file}.invalid.asc"
128
+ }
129
+ }
130
+ exception = assert_raises(RuntimeError){
131
+ @recipe.download
132
+ }
133
+ assert_equal("signature mismatch", exception.message)
134
+ end
135
+
136
+ def test_with_invalid_key
137
+ data_file = File.expand_path(File.join(File.dirname(__FILE__), 'assets', 'gpg-fixtures', 'data'))
138
+
139
+ @recipe.files << {
140
+ :url => "file://#{data_file}",
141
+ :gpg => {
142
+ :key => "thisisaninvalidkey",
143
+ :signature_url => "file://#{data_file}.asc"
144
+ }
145
+ }
146
+ exception = assert_raises(RuntimeError){ @recipe.download }
147
+ assert_equal("invalid gpg key provided", exception.message)
148
+ end
149
+
150
+ def test_with_different_key_than_one_used_to_sign
151
+ puts "################"
152
+
153
+ key = <<-KEY
154
+ -----BEGIN PGP PUBLIC KEY BLOCK-----
155
+ Version: GnuPG v1
156
+
157
+ mQENBE7SKu8BCADQo6x4ZQfAcPlJMLmL8zBEBUS6GyKMMMDtrTh3Yaq481HB54oR
158
+ 0cpKL05Ff9upjrIzLD5TJUCzYYM9GQOhguDUP8+ZU9JpSz3yO2TvH7WBbUZ8FADf
159
+ hblmmUBLNgOWgLo3W+FYhl3mz1GFS2Fvid6Tfn02L8CBAj7jxbjL1Qj/OA/WmLLc
160
+ m6BMTqI7IBlYW2vyIOIHasISGiAwZfp0ucMeXXvTtt14LGa8qXVcFnJT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EOYJ9CH3wARAQABiQEf
192
+ BBgBAgAJBQJO0irvAhsMAAoJEFIKmZOhwFL4844H/jo8icCcS6eOWvnen7lg0FcC
193
+ o1fIm4wW3tEmkQdchSHECJDq7pgTloN65pwB5tBoT47cyYNZA9eTfJVgRc74q5ce
194
+ xKOYrMC3KuAqWbwqXhkVs0nkWxnOIidTHSXvBZfDFA4Idwte94Thrzf8Pn8UESud
195
+ TiqrWoCBXk2UyVsl03gJblSJAeJGYPPeo+Yj6m63OWe2+/S2VTgmbPS/RObn0Aeg
196
+ 7yuff0n5+ytEt2KL51gOQE2uIxTCawHr12PsllPkbqPk/PagIttfEJqn9b0CrqPC
197
+ 3HREePb2aMJ/Ctw/76COwn0mtXeIXLCTvBmznXfaMKllsqbsy2nCJ2P2uJjOntw=
198
+ =4JAR
199
+ -----END PGP PUBLIC KEY BLOCK-----
200
+ KEY
201
+
202
+ data_file = File.expand_path(File.join(File.dirname(__FILE__), 'assets', 'gpg-fixtures', 'data'))
203
+
204
+ @recipe.files << {
205
+ :url => "file://#{data_file}",
206
+ :gpg => {
207
+ :key => key,
208
+ :signature_url => "file://#{data_file}.asc"
209
+ }
210
+ }
211
+ exception = assert_raises(RuntimeError){ @recipe.download }
212
+ assert_equal("signature mismatch", exception.message)
213
+ end
69
214
  end
70
215
 
@@ -5,22 +5,24 @@ describe "recipe download" do
5
5
 
6
6
  attr :recipe
7
7
 
8
- def server_must_receive_connection &block
8
+ def server_must_receive_connection(connections = 3, &block)
9
9
  request_count = 0
10
10
 
11
11
  server = TCPServer.open('localhost', TestCase::HTTP_PORT)
12
12
  thread = Thread.new do
13
- conn = server.accept
14
- request_count += 1
15
- conn.puts "CONNECTION SUCESSFULLY MADE"
16
- conn.close
13
+ connections.times do
14
+ conn = server.accept
15
+ request_count += 1
16
+ conn.puts "CONNECTION SUCESSFULLY MADE" rescue SystemCallError
17
+ conn.close
18
+ end
17
19
  end
18
20
 
19
21
  block.call
20
22
 
21
23
  thread.kill
22
24
  server.close
23
-
25
+
24
26
  request_count.must_be :>, 0
25
27
  end
26
28
 
@@ -32,21 +34,21 @@ describe "recipe download" do
32
34
  describe "urls" do
33
35
  it "ftp" do
34
36
  @recipe.files << "ftp://localhost:#{TestCase::HTTP_PORT}/foo"
35
- server_must_receive_connection do
37
+ server_must_receive_connection 1 do
36
38
  @recipe.download
37
39
  end
38
40
  end
39
41
 
40
42
  it "handles http" do
41
43
  @recipe.files << "http://localhost:#{TestCase::HTTP_PORT}/foo"
42
- server_must_receive_connection do
44
+ server_must_receive_connection 3 do
43
45
  @recipe.download
44
46
  end
45
47
  end
46
48
 
47
49
  it "handles https" do
48
50
  @recipe.files << "https://localhost:#{TestCase::HTTP_PORT}/foo"
49
- server_must_receive_connection do
51
+ server_must_receive_connection 3 do
50
52
  @recipe.download
51
53
  end
52
54
  end
@@ -10,7 +10,7 @@ class TestProxy < TestCase
10
10
  s = gs.accept
11
11
  gs.close
12
12
  begin
13
- req = ''
13
+ req = ''.dup
14
14
  while (l=s.gets) && !l.chomp.empty?
15
15
  req << l
16
16
  end
@@ -25,7 +25,7 @@ class TestProxy < TestCase
25
25
  else
26
26
  yield "http://localhost:#{gs.addr[1]}"
27
27
  end
28
-
28
+
29
29
  # Set timeout for reception of the request
30
30
  Thread.new do
31
31
  sleep 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_portile2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.rc1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Lavena
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-03-08 00:00:00.000000000 Z
13
+ date: 2017-06-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -32,56 +32,70 @@ dependencies:
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '10.0'
35
+ version: '12.0'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '10.0'
42
+ version: '12.0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: minitest
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 5.8.0
49
+ version: '5.8'
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 5.8.0
56
+ version: '5.8'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: minitest-hooks
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 1.4.0
63
+ version: '1.4'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: 1.4.0
70
+ version: '1.4'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: minitar
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: 0.5.4
77
+ version: '0.5'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: 0.5.4
84
+ version: '0.5'
85
+ - !ruby/object:Gem::Dependency
86
+ name: concourse
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '0.12'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '0.12'
85
99
  description: Simplistic port-like solution for developers. It provides a standard
86
100
  and simplified way to compile against dependency libraries without messing up your
87
101
  system.
@@ -99,12 +113,18 @@ files:
99
113
  - README.md
100
114
  - Rakefile
101
115
  - appveyor.yml
116
+ - concourse/mini_portile.yml
117
+ - concourse/tasks/rake-test/task.ps1
118
+ - concourse/tasks/rake-test/task.sh
102
119
  - lib/mini_portile2.rb
103
120
  - lib/mini_portile2/mini_portile.rb
104
121
  - lib/mini_portile2/mini_portile_cmake.rb
105
122
  - lib/mini_portile2/version.rb
106
123
  - mini_portile2.gemspec
107
124
  - test/assets/git/config
125
+ - test/assets/gpg-fixtures/data
126
+ - test/assets/gpg-fixtures/data.asc
127
+ - test/assets/gpg-fixtures/data.invalid.asc
108
128
  - test/assets/patch 1.diff
109
129
  - test/assets/test mini portile-1.0.0/configure
110
130
  - test/assets/test-cmake-1.0/CMakeLists.txt
@@ -131,17 +151,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
151
  version: 1.9.2
132
152
  required_rubygems_version: !ruby/object:Gem::Requirement
133
153
  requirements:
134
- - - ">"
154
+ - - ">="
135
155
  - !ruby/object:Gem::Version
136
- version: 1.3.1
156
+ version: '0'
137
157
  requirements: []
138
158
  rubyforge_project:
139
- rubygems_version: 2.5.1
159
+ rubygems_version: 2.6.10
140
160
  signing_key:
141
161
  specification_version: 4
142
162
  summary: Simplistic port-like solution for developers
143
163
  test_files:
144
164
  - test/assets/git/config
165
+ - test/assets/gpg-fixtures/data
166
+ - test/assets/gpg-fixtures/data.asc
167
+ - test/assets/gpg-fixtures/data.invalid.asc
145
168
  - test/assets/patch 1.diff
146
169
  - test/assets/test mini portile-1.0.0/configure
147
170
  - test/assets/test-cmake-1.0/CMakeLists.txt