mini_portile 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +13 -0
  3. data/Rakefile +10 -1
  4. data/examples/Rakefile +85 -27
  5. data/lib/mini_portile.rb +51 -31
  6. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cee87cb39d1d3f26fada711165e1270a45ad07b5
4
- data.tar.gz: 608e501834649a00f3236fff4fb405fd6e16a2e9
3
+ metadata.gz: 01126f5630688f97f3ee6fe7d5350299597f7bf9
4
+ data.tar.gz: 0d187a46934aa17f7d1a175fb85212164e3c7e75
5
5
  SHA512:
6
- metadata.gz: 85b9ea5ef46b6e824bb17df60123cf0ddaea05bae22580b90ef2fbebeb383632f4a83257dc0db32e20cb68276e63d09421b7640663c3323b1ace022761c83773
7
- data.tar.gz: 5a3677ffb69d4e119fc8f45ec3a1367d23a65c1055b0c3831320a0bfb7711cc54effb386940d171907e6183db3aef129cb6fde7e880cf634a4f34bb5ee6fa7eb
6
+ metadata.gz: a4600f5802cc11e9b3cc22b3bcd5b775d7fadb49a30df4ccfa8c09e07699cda449f2515f3115a8d669d4e938f567dec88183cc06f510df0a708232f38d955816
7
+ data.tar.gz: 170c8eef4ba7a276c4e28a7bddfd148db1f4e7f25cecc06592e6e1a92abd020385a5dbd9dbf8aecfd358d3d09055362bcb58bdcb2be1b791d9cfe5a929b92f4d
data/History.txt CHANGED
@@ -1,3 +1,16 @@
1
+ === 0.6.0 / 2014-04-18
2
+
3
+ * Enhancements:
4
+ * Add default cert store and custom certs from `SSL_CERT_FILE` if present.
5
+ This increases compatibility with Ruby 1.8.7.
6
+
7
+ * Bugfixes:
8
+ * Specify Accept-Encoding to make sure a raw file content is downloaded.
9
+ Pull #30. [knu]
10
+
11
+ * Internal:
12
+ * Improve examples and use them as test harness.
13
+
1
14
  === 0.5.3 / 2014-03-24
2
15
 
3
16
  * Bugfixes:
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require "rubygems/package_task"
4
4
  GEM_SPEC = Gem::Specification.new do |s|
5
5
  # basic information
6
6
  s.name = "mini_portile"
7
- s.version = "0.5.3"
7
+ s.version = "0.6.0"
8
8
  s.platform = Gem::Platform::RUBY
9
9
 
10
10
  # description and details
@@ -42,3 +42,12 @@ Gem::PackageTask.new(GEM_SPEC) do |pkg|
42
42
  pkg.need_tar = false
43
43
  pkg.need_zip = false
44
44
  end
45
+
46
+ desc "Test MiniPortile by compiling examples"
47
+ task :test do
48
+ Dir.chdir("examples") do
49
+ sh "rake ports:all"
50
+ end
51
+ end
52
+
53
+ task :default => [:test]
data/examples/Rakefile CHANGED
@@ -1,46 +1,104 @@
1
1
  require File.expand_path("mini_portile", File.join(File.dirname(__FILE__), "../lib"))
2
2
 
3
- $recipes = {}
3
+ recipes = []
4
4
 
5
- ICONV_VERSION = "1.13.1"
6
- $recipes[:libiconv] = MiniPortile.new "libiconv", ICONV_VERSION
7
- $recipes[:libiconv].files << "ftp://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz"
5
+ # libiconv
6
+ libiconv = MiniPortile.new "libiconv", "1.14"
7
+ libiconv.files << "ftp://ftp.gnu.org/pub/gnu/#{libiconv.name}/#{libiconv.name}-#{libiconv.version}.tar.gz"
8
8
 
9
- $recipes[:sqlite3] = MiniPortile.new "sqlite3", "3.7.5"
10
- $recipes[:sqlite3].files << "http://sqlite.org/sqlite-autoconf-3070500.tar.gz"
9
+ recipes.push libiconv
11
10
 
12
- namespace :ports do
13
- directory "ports"
11
+ # sqlite3
12
+ sqlite3 = MiniPortile.new "sqlite3", "3.8.4.1"
13
+ sqlite3.files << "http://sqlite.org/2014/sqlite-autoconf-3080401.tar.gz"
14
+
15
+ recipes.push sqlite3
16
+
17
+ # c-ares
18
+ c_ares = MiniPortile.new "c-ares", "1.7.5"
19
+ c_ares.files << "https://s3.amazonaws.com/distfiles.openknapsack.org/#{c_ares.name}/#{c_ares.name}-#{c_ares.version}.tar.gz"
20
+
21
+ recipes.push c_ares
22
+
23
+ # zlib
24
+ class ZlibRecipe < MiniPortile
25
+ def windows?
26
+ !(host =~ /mswin|mingw/).nil?
27
+ end
14
28
 
15
- desc "Install port libiconv #{ICONV_VERSION}"
16
- task :libiconv => ["ports"] do |t|
17
- recipe = $recipes[:libiconv]
18
- checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
29
+ def configure
30
+ return super unless windows?
19
31
 
20
- unless File.exist?(checkpoint)
21
- recipe.cook
22
- touch checkpoint
32
+ Dir.chdir work_path do
33
+ mk = File.read 'win32/Makefile.gcc'
34
+ File.open 'win32/Makefile.gcc', 'wb' do |f|
35
+ f.puts "BINARY_PATH = #{path}/bin"
36
+ f.puts "LIBRARY_PATH = #{path}/lib"
37
+ f.puts "INCLUDE_PATH = #{path}/include"
38
+
39
+ cross_build? and
40
+ mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-")
41
+
42
+ f.puts mk
43
+ end
23
44
  end
45
+ end
46
+
47
+ def configure_defaults
48
+ ["--static"]
49
+ end
50
+
51
+ def configured?
52
+ return super unless windows?
53
+
54
+ !!(File.read(File.join(work_path, 'win32/Makefile.gcc')) =~ /^BINARY_PATH/)
55
+ end
56
+
57
+ def compile
58
+ return super unless windows?
59
+
60
+ execute "compile", "make -f win32/Makefile.gcc"
61
+ end
62
+
63
+ def install
64
+ return if installed?
65
+ return super unless windows?
66
+
67
+ execute "install", %Q(#{make_cmd} -f win32/Makefile.gcc install)
68
+ end
24
69
 
25
- recipe.activate
70
+ def cross_build?
71
+ host != original_host
26
72
  end
73
+ end
74
+
75
+ zlib = ZlibRecipe.new "zlib", "1.2.8"
76
+ zlib.files << "http://zlib.net/#{zlib.name}-#{zlib.version}.tar.gz"
77
+
78
+ recipes.push zlib
79
+
80
+ namespace :ports do
81
+ directory "ports"
82
+
83
+ recipes.each do |recipe|
84
+ desc "Install port #{recipe.name} #{recipe.version}"
85
+ task recipe.name => ["ports"] do |t|
86
+ checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
27
87
 
28
- desc "Install port sqlite3 #{$recipes[:sqlite3].version}"
29
- task :sqlite3 => ["ports"] do |t|
30
- recipe = $recipes[:sqlite3]
31
- checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
88
+ unless File.exist?(checkpoint)
89
+ recipe.cook
90
+ touch checkpoint
91
+ end
32
92
 
33
- unless File.exist?(checkpoint)
34
- recipe.cook
35
- touch checkpoint
93
+ recipe.activate
36
94
  end
37
95
 
38
- recipe.activate
96
+ task :all => recipe.name
39
97
  end
40
98
 
41
99
  desc "Install all ports and display installation location"
42
- task :all => [:libiconv, :sqlite3] do
43
- $recipes.each do |_, recipe|
100
+ task :all do
101
+ recipes.each do |recipe|
44
102
  puts "Artifacts of '#{recipe.name}' in '#{recipe.path}'"
45
103
  end
46
104
  puts "LDFLAGS: " << ENV['LDFLAGS'].inspect
@@ -49,7 +107,7 @@ end
49
107
 
50
108
  desc "Adjust all recipes host for cross-compilation"
51
109
  task :cross do
52
- $recipes.each do |_, recipe|
110
+ recipes.each do |recipe|
53
111
  recipe.host = "i686-w64-mingw32"
54
112
  end
55
113
  end
data/lib/mini_portile.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rbconfig'
2
2
  require 'net/http'
3
+ require 'net/https'
3
4
  require 'net/ftp'
4
5
  require 'fileutils'
5
6
  require 'tempfile'
@@ -321,46 +322,65 @@ private
321
322
 
322
323
  def download_file_http(url, full_path, count = 3)
323
324
  filename = File.basename(full_path)
325
+ uri = URI.parse(url)
324
326
 
325
327
  if ENV['http_proxy']
326
- protocol, userinfo, host, port = URI::split(ENV['http_proxy'])
328
+ _, userinfo, p_host, p_port = URI.split(ENV['http_proxy'])
327
329
  proxy_user, proxy_pass = userinfo.split(/:/) if userinfo
328
- http = Net::HTTP::Proxy(host, port, proxy_user, proxy_pass)
330
+ http = Net::HTTP.new(uri.host, uri.port, p_host, p_port, proxy_user, proxy_pass)
329
331
  else
330
- http = Net::HTTP
332
+ http = Net::HTTP.new(uri.host, uri.port)
333
+
334
+ if URI::HTTPS === uri
335
+ http.use_ssl = true
336
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
337
+
338
+ store = OpenSSL::X509::Store.new
339
+
340
+ # Auto-include system-provided certificates
341
+ store.set_default_paths
342
+
343
+ if ENV.has_key?("SSL_CERT_FILE") && File.exist?(ENV["SSL_CERT_FILE"])
344
+ store.add_file ENV["SSL_CERT_FILE"]
345
+ end
346
+
347
+ http.cert_store = store
348
+ end
331
349
  end
332
350
 
333
351
  message "Downloading #{filename} "
334
- http.get_response(URI.parse(url)) do |response|
335
- case response
336
- when Net::HTTPNotFound
337
- output "404 - Not Found"
338
- return false
339
-
340
- when Net::HTTPClientError
341
- output "Error: Client Error: #{response.inspect}"
342
- return false
343
-
344
- when Net::HTTPRedirection
345
- raise "Too many redirections for the original URL, halting." if count <= 0
346
- url = response["location"]
347
- return download_file(url, full_path, count - 1)
348
-
349
- when Net::HTTPOK
350
- with_tempfile(filename, full_path) do |temp_file|
351
- size = 0
352
- progress = 0
353
- total = response.header["Content-Length"].to_i
354
- response.read_body do |chunk|
355
- temp_file << chunk
356
- size += chunk.size
357
- new_progress = (size * 100) / total
358
- unless new_progress == progress
359
- message "\rDownloading %s (%3d%%) " % [filename, new_progress]
352
+ http.start do |h|
353
+ h.request_get(uri.path, 'Accept-Encoding' => 'identity') do |response|
354
+ case response
355
+ when Net::HTTPNotFound
356
+ output "404 - Not Found"
357
+ return false
358
+
359
+ when Net::HTTPClientError
360
+ output "Error: Client Error: #{response.inspect}"
361
+ return false
362
+
363
+ when Net::HTTPRedirection
364
+ raise "Too many redirections for the original URL, halting." if count <= 0
365
+ url = response["location"]
366
+ return download_file(url, full_path, count - 1)
367
+
368
+ when Net::HTTPOK
369
+ return with_tempfile(filename, full_path) do |temp_file|
370
+ size = 0
371
+ progress = 0
372
+ total = response.header["Content-Length"].to_i
373
+ response.read_body do |chunk|
374
+ temp_file << chunk
375
+ size += chunk.size
376
+ new_progress = (size * 100) / total
377
+ unless new_progress == progress
378
+ message "\rDownloading %s (%3d%%) " % [filename, new_progress]
379
+ end
380
+ progress = new_progress
360
381
  end
361
- progress = new_progress
382
+ output
362
383
  end
363
- output
364
384
  end
365
385
  end
366
386
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_portile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Lavena
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-24 00:00:00.000000000 Z
11
+ date: 2014-04-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simplistic port-like solution for developers. It provides a standard
14
14
  and simplified way to compile against dependency libraries without messing up your
@@ -21,37 +21,37 @@ extra_rdoc_files:
21
21
  - History.txt
22
22
  - LICENSE.txt
23
23
  files:
24
- - examples/Rakefile
25
- - lib/mini_portile.rb
26
- - Rakefile
27
24
  - History.txt
28
25
  - LICENSE.txt
29
26
  - README.rdoc
27
+ - Rakefile
28
+ - examples/Rakefile
29
+ - lib/mini_portile.rb
30
30
  homepage: http://github.com/luislavena/mini_portile
31
31
  licenses:
32
32
  - MIT
33
33
  metadata: {}
34
34
  post_install_message:
35
35
  rdoc_options:
36
- - --main
36
+ - "--main"
37
37
  - README.rdoc
38
- - --title
38
+ - "--title"
39
39
  - MiniPortile -- Documentation
40
40
  require_paths:
41
41
  - lib
42
42
  required_ruby_version: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - '>='
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 1.8.7
47
47
  required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - '>='
49
+ - - ">="
50
50
  - !ruby/object:Gem::Version
51
51
  version: 1.3.5
52
52
  requirements: []
53
53
  rubyforge_project:
54
- rubygems_version: 2.0.14
54
+ rubygems_version: 2.2.2
55
55
  signing_key:
56
56
  specification_version: 4
57
57
  summary: Simplistic port-like solution for developers