mini_portile 0.6.2 → 0.7.0.rc1

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.
@@ -0,0 +1,3 @@
1
+ class MiniPortile
2
+ VERSION = "0.7.0.rc1"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mini_portile/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mini_portile"
8
+ spec.version = MiniPortile::VERSION
9
+
10
+ spec.authors = ['Luis Lavena', 'Mike Dalessio']
11
+ spec.email = 'mike.dalessio@gmail.com'
12
+
13
+ spec.summary = "Simplistic port-like solution for developers"
14
+ spec.description = "Simplistic port-like solution for developers. It provides a standard and simplified way to compile against dependency libraries without messing up your system."
15
+
16
+ spec.homepage = 'http://github.com/flavorjones/mini_portile'
17
+ spec.licenses = ['MIT']
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features|examples)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "test-unit", "~> 3.0"
27
+ spec.add_development_dependency "minitar", "~> 0.5.4"
28
+
29
+ spec.required_ruby_version = ">= 1.9.3"
30
+ end
@@ -0,0 +1,7 @@
1
+ diff --git "a/patch 1.txt" "b/patch 1.txt"
2
+ new file mode 100644
3
+ index 0000000..70885e4
4
+ --- /dev/null
5
+ +++ "b/patch 1.txt"
6
+ @@ -0,0 +1 @@
7
+ +change 1
@@ -0,0 +1,11 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ ruby -e "p ARGV" -- "$@" > configure.txt
5
+
6
+ cat <<EOT >Makefile
7
+ all:
8
+ ruby -e "p ARGV" -- "\$@" > compile.txt
9
+ install:
10
+ ruby -e "p ARGV" -- "\$@" > install.txt
11
+ EOT
@@ -0,0 +1,46 @@
1
+ require 'test/unit'
2
+ require 'webrick'
3
+ require 'fileutils'
4
+ require 'zlib'
5
+ require 'archive/tar/minitar'
6
+
7
+ class TestCase < Test::Unit::TestCase
8
+ class << self
9
+ HTTP_PORT = 23523
10
+
11
+ attr_accessor :webrick
12
+
13
+ def start_webrick(path)
14
+ @webrick = WEBrick::HTTPServer.new(:Port => HTTP_PORT, :DocumentRoot => path).tap do |w|
15
+ Thread.new do
16
+ w.start
17
+ end
18
+ until w.status==:Running
19
+ sleep 0.1
20
+ end
21
+ end
22
+ end
23
+
24
+ def stop_webrick
25
+ if w=@webrick
26
+ w.shutdown
27
+ until w.status==:Stop
28
+ sleep 0.1
29
+ end
30
+ end
31
+ end
32
+
33
+ def create_tar(tar_path, assets_path)
34
+ FileUtils.mkdir_p(File.dirname(tar_path))
35
+ Zlib::GzipWriter.open(tar_path) do |fdtgz|
36
+ Dir.chdir(assets_path) do
37
+ Archive::Tar::Minitar.pack("test mini portile-1.0.0", fdtgz)
38
+ end
39
+ end
40
+ end
41
+
42
+ def work_dir(r=recipe)
43
+ "tmp/#{r.host}/ports/#{r.name}/#{r.version}/#{r.name}-#{r.version}"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,71 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+ require 'fileutils'
3
+ require 'mini_portile'
4
+ require 'erb'
5
+
6
+ class TestCook < TestCase
7
+ class << self
8
+ attr_accessor :assets_path
9
+ attr_accessor :tar_path
10
+ attr_accessor :recipe
11
+
12
+ def startup
13
+ @assets_path = File.expand_path("../assets", __FILE__)
14
+ @tar_path = File.expand_path("../../tmp/test mini portile-1.0.0.tar.gz", __FILE__)
15
+
16
+ # remove any previous test files
17
+ FileUtils.rm_rf("tmp")
18
+
19
+ create_tar(@tar_path, @assets_path)
20
+ start_webrick(File.dirname(@tar_path))
21
+
22
+ @recipe = MiniPortile.new("test mini portile", "1.0.0").tap do |recipe|
23
+ recipe.files << "http://localhost:#{HTTP_PORT}/#{ERB::Util.url_encode(File.basename(@tar_path))}"
24
+ recipe.patch_files << File.join(@assets_path, "patch 1.diff")
25
+ recipe.configure_options << "--option=\"path with 'space'\""
26
+ recipe.cook
27
+ end
28
+ end
29
+
30
+ def shutdown
31
+ stop_webrick
32
+ # leave test files for inspection
33
+ end
34
+ end
35
+
36
+ def test_download
37
+ download = "ports/archives/test%20mini%20portile-1.0.0.tar.gz"
38
+ assert File.exist?(download), download
39
+ end
40
+
41
+ def test_untar
42
+ configure = File.join(self.class.work_dir, "configure")
43
+ assert File.exist?(configure), configure
44
+ assert_match( /^#!\/bin\/sh/, IO.read(configure) )
45
+ end
46
+
47
+ def test_patch
48
+ patch1 = File.join(self.class.work_dir, "patch 1.txt")
49
+ assert File.exist?(patch1), patch1
50
+ assert_match( /^change 1/, IO.read(patch1) )
51
+ end
52
+
53
+ def test_configure
54
+ txt = File.join(self.class.work_dir, "configure.txt")
55
+ assert File.exist?(txt), txt
56
+ opts = self.class.recipe.configure_options + ["--prefix=#{self.class.recipe.path}"]
57
+ assert_equal( opts.inspect, IO.read(txt).chomp )
58
+ end
59
+
60
+ def test_compile
61
+ txt = File.join(self.class.work_dir, "compile.txt")
62
+ assert File.exist?(txt), txt
63
+ assert_equal( ["all"].inspect, IO.read(txt).chomp )
64
+ end
65
+
66
+ def test_install
67
+ txt = File.join(self.class.work_dir, "install.txt")
68
+ assert File.exist?(txt), txt
69
+ assert_equal( ["install"].inspect, IO.read(txt).chomp )
70
+ end
71
+ end
@@ -0,0 +1,75 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+ require 'fileutils'
3
+ require 'mini_portile'
4
+ require 'erb'
5
+
6
+ class TestDigest < TestCase
7
+ class << self
8
+ attr_accessor :assets_path
9
+ attr_accessor :tar_path
10
+ attr_accessor :recipe
11
+
12
+ def startup
13
+ @assets_path = File.expand_path("../assets", __FILE__)
14
+ @tar_path = File.expand_path("../../tmp/test-digest-1.0.0.tar.gz", __FILE__)
15
+
16
+ # remove any previous test files
17
+ FileUtils.rm_rf("tmp")
18
+
19
+ create_tar(@tar_path, @assets_path)
20
+ start_webrick(File.dirname(@tar_path))
21
+ end
22
+
23
+ def shutdown
24
+ stop_webrick
25
+ # leave test files for inspection
26
+ end
27
+ end
28
+
29
+ def setup
30
+ # remove any download files
31
+ FileUtils.rm_rf("ports/archives")
32
+
33
+ @recipe = MiniPortile.new("test-digest", "1.0.0")
34
+ end
35
+
36
+ def download_with_digest(key, klass)
37
+ @recipe.files << {
38
+ :url => "http://localhost:#{self.class.webrick.config[:Port]}/#{ERB::Util.url_encode(File.basename(self.class.tar_path))}",
39
+ key => klass.file(self.class.tar_path).hexdigest,
40
+ }
41
+ @recipe.download
42
+ end
43
+
44
+ def download_with_wrong_digest(key)
45
+ @recipe.files << {
46
+ :url => "http://localhost:#{self.class.webrick.config[:Port]}/#{ERB::Util.url_encode(File.basename(self.class.tar_path))}",
47
+ key => "0011223344556677",
48
+ }
49
+ assert_raise(RuntimeError){ @recipe.download }
50
+ end
51
+
52
+ def test_sha256
53
+ download_with_digest(:sha256, Digest::SHA256)
54
+ end
55
+
56
+ def test_wrong_sha256
57
+ download_with_wrong_digest(:sha256)
58
+ end
59
+
60
+ def test_sha1
61
+ download_with_digest(:sha1, Digest::SHA1)
62
+ end
63
+
64
+ def test_wrong_sha1
65
+ download_with_wrong_digest(:sha1)
66
+ end
67
+
68
+ def test_md5
69
+ download_with_digest(:md5, Digest::MD5)
70
+ end
71
+
72
+ def test_wrong_md5
73
+ download_with_wrong_digest(:md5)
74
+ end
75
+ end
@@ -0,0 +1,124 @@
1
+ # Encoding: utf-8
2
+
3
+ require File.expand_path('../helper', __FILE__)
4
+ require 'fileutils'
5
+ require 'socket'
6
+ require 'erb'
7
+ require 'mini_portile'
8
+
9
+ class TestProxy < TestCase
10
+ def with_dummy_proxy(username=nil, password=nil)
11
+ gs = TCPServer.open('localhost', 0)
12
+ th = Thread.new do
13
+ s = gs.accept
14
+ gs.close
15
+ begin
16
+ req = ''
17
+ while (l=s.gets) && !l.chomp.empty?
18
+ req << l
19
+ end
20
+ req
21
+ ensure
22
+ s.close
23
+ end
24
+ end
25
+
26
+ if username && password
27
+ yield "http://#{ERB::Util.url_encode(username)}:#{ERB::Util.url_encode(password)}@localhost:#{gs.addr[1]}"
28
+ else
29
+ yield "http://localhost:#{gs.addr[1]}"
30
+ end
31
+
32
+ # Set timeout for reception of the request
33
+ Thread.new do
34
+ sleep 1
35
+ th.kill
36
+ end
37
+ th.value
38
+ end
39
+
40
+ def setup
41
+ # remove any download files
42
+ FileUtils.rm_rf("port/archives")
43
+ end
44
+
45
+ def assert_proxy_auth(expected, request)
46
+ if request =~ /^Proxy-Authorization: Basic (.*)/
47
+ assert_equal 'user: @name:@12: üMp', $1.unpack("m")[0].force_encoding(__ENCODING__)
48
+ else
49
+ flunk "No authentication request"
50
+ end
51
+ end
52
+
53
+ def test_http_proxy
54
+ recipe = MiniPortile.new("test http_proxy", "1.0.0")
55
+ recipe.files << "http://myserver/path/to/tar.gz"
56
+ request = with_dummy_proxy do |url, thread|
57
+ ENV['http_proxy'] = url
58
+ recipe.download rescue RuntimeError
59
+ ENV.delete('http_proxy')
60
+ end
61
+ assert_match(/GET http:\/\/myserver\/path\/to\/tar.gz/, request)
62
+ end
63
+
64
+ def test_http_proxy_with_basic_auth
65
+ recipe = MiniPortile.new("test http_proxy", "1.0.0")
66
+ recipe.files << "http://myserver/path/to/tar.gz"
67
+ request = with_dummy_proxy('user: @name', '@12: üMp') do |url, thread|
68
+ ENV['http_proxy'] = url
69
+ recipe.download rescue RuntimeError
70
+ ENV.delete('http_proxy')
71
+ end
72
+
73
+ assert_match(/GET http:\/\/myserver\/path\/to\/tar.gz/, request)
74
+ assert_proxy_auth 'user: @name:@12: üMp', request
75
+ end
76
+
77
+ def test_https_proxy
78
+ recipe = MiniPortile.new("test https_proxy", "1.0.0")
79
+ recipe.files << "https://myserver/path/to/tar.gz"
80
+ request = with_dummy_proxy do |url, thread|
81
+ ENV['https_proxy'] = url
82
+ recipe.download rescue RuntimeError
83
+ ENV.delete('https_proxy')
84
+ end
85
+ assert_match(/CONNECT myserver:443/, request)
86
+ end
87
+
88
+ def test_https_proxy_with_basic_auth
89
+ recipe = MiniPortile.new("test https_proxy", "1.0.0")
90
+ recipe.files << "https://myserver/path/to/tar.gz"
91
+ request = with_dummy_proxy('user: @name', '@12: üMp') do |url, thread|
92
+ ENV['https_proxy'] = url
93
+ recipe.download rescue RuntimeError
94
+ ENV.delete('https_proxy')
95
+ end
96
+
97
+ assert_match(/CONNECT myserver:443/, request)
98
+ assert_proxy_auth 'user: @name:@12: üMp', request
99
+ end
100
+
101
+ def test_ftp_proxy
102
+ recipe = MiniPortile.new("test ftp_proxy", "1.0.0")
103
+ recipe.files << "ftp://myserver/path/to/tar.gz"
104
+ request = with_dummy_proxy do |url, thread|
105
+ ENV['ftp_proxy'] = url
106
+ recipe.download rescue RuntimeError
107
+ ENV.delete('ftp_proxy')
108
+ end
109
+ assert_match(/GET ftp:\/\/myserver\/path\/to\/tar.gz/, request)
110
+ end
111
+
112
+ def test_ftp_proxy_with_basic_auth
113
+ recipe = MiniPortile.new("test ftp_proxy", "1.0.0")
114
+ recipe.files << "ftp://myserver/path/to/tar.gz"
115
+ request = with_dummy_proxy('user: @name', '@12: üMp') do |url, thread|
116
+ ENV['ftp_proxy'] = url
117
+ recipe.download rescue RuntimeError
118
+ ENV.delete('ftp_proxy')
119
+ end
120
+
121
+ assert_match(/GET ftp:\/\/myserver\/path\/to\/tar.gz/, request)
122
+ assert_proxy_auth 'user: @name:@12: üMp', request
123
+ end
124
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_portile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Lavena
@@ -9,51 +9,124 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-30 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2015-08-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.7'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.7'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: test-unit
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitar
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 0.5.4
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 0.5.4
14
70
  description: Simplistic port-like solution for developers. It provides a standard
15
71
  and simplified way to compile against dependency libraries without messing up your
16
72
  system.
17
73
  email: mike.dalessio@gmail.com
18
74
  executables: []
19
75
  extensions: []
20
- extra_rdoc_files:
21
- - README.rdoc
22
- - History.txt
23
- - LICENSE.txt
76
+ extra_rdoc_files: []
24
77
  files:
25
- - History.txt
78
+ - ".gitignore"
79
+ - ".travis.yml"
80
+ - CHANGELOG.md
81
+ - Gemfile
26
82
  - LICENSE.txt
27
- - README.rdoc
83
+ - README.md
28
84
  - Rakefile
85
+ - appveyor.yml
86
+ - examples/.gitignore
29
87
  - examples/Rakefile
88
+ - examples/libiconv-patches/1-avoid-gets-error.patch
30
89
  - lib/mini_portile.rb
90
+ - lib/mini_portile/mini_portile.rb
91
+ - lib/mini_portile/version.rb
92
+ - mini_portile.gemspec
93
+ - test/assets/patch 1.diff
94
+ - test/assets/test mini portile-1.0.0/configure
95
+ - test/helper.rb
96
+ - test/test_cook.rb
97
+ - test/test_digest.rb
98
+ - test/test_proxy.rb
31
99
  homepage: http://github.com/flavorjones/mini_portile
32
100
  licenses:
33
101
  - MIT
34
102
  metadata: {}
35
103
  post_install_message:
36
- rdoc_options:
37
- - "--main"
38
- - README.rdoc
39
- - "--title"
40
- - MiniPortile -- Documentation
104
+ rdoc_options: []
41
105
  require_paths:
42
106
  - lib
43
107
  required_ruby_version: !ruby/object:Gem::Requirement
44
108
  requirements:
45
109
  - - ">="
46
110
  - !ruby/object:Gem::Version
47
- version: 1.8.7
111
+ version: 1.9.3
48
112
  required_rubygems_version: !ruby/object:Gem::Requirement
49
113
  requirements:
50
- - - ">="
114
+ - - ">"
51
115
  - !ruby/object:Gem::Version
52
- version: 1.3.5
116
+ version: 1.3.1
53
117
  requirements: []
54
118
  rubyforge_project:
55
- rubygems_version: 2.2.2
119
+ rubygems_version: 2.4.6
56
120
  signing_key:
57
121
  specification_version: 4
58
122
  summary: Simplistic port-like solution for developers
59
- test_files: []
123
+ test_files:
124
+ - examples/.gitignore
125
+ - examples/Rakefile
126
+ - examples/libiconv-patches/1-avoid-gets-error.patch
127
+ - test/assets/patch 1.diff
128
+ - test/assets/test mini portile-1.0.0/configure
129
+ - test/helper.rb
130
+ - test/test_cook.rb
131
+ - test/test_digest.rb
132
+ - test/test_proxy.rb