mini_portile2 2.0.0.rc1

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