mini_portile2 2.4.0 → 2.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +2 -0
- data/.github/workflows/ci.yml +71 -0
- data/.gitignore +3 -5
- data/CHANGELOG.md +87 -0
- data/Gemfile +2 -0
- data/README.md +89 -2
- data/Rakefile +2 -6
- data/SECURITY.md +13 -0
- data/lib/mini_portile2/mini_portile.rb +124 -57
- data/lib/mini_portile2/mini_portile_cmake.rb +15 -4
- data/lib/mini_portile2/version.rb +1 -1
- data/mini_portile2.gemspec +21 -21
- data/test/assets/test-download-archive.tar.gz +0 -0
- data/test/helper.rb +16 -0
- data/test/test_cmake.rb +39 -13
- data/test/test_cook.rb +55 -0
- data/test/test_download.rb +7 -5
- data/test/test_execute.rb +39 -0
- metadata +25 -27
- data/.concourse.yml +0 -83
- data/.travis.yml +0 -15
- data/appveyor.yml +0 -25
- data/concourse/mini_portile.yml +0 -141
- data/concourse/tasks/rake-test/task.ps1 +0 -11
- data/concourse/tasks/rake-test/task.sh +0 -13
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rbconfig'
|
2
2
|
require 'net/http'
|
3
3
|
require 'net/https'
|
4
|
-
require 'net/ftp'
|
5
4
|
require 'fileutils'
|
6
5
|
require 'tempfile'
|
7
6
|
require 'digest'
|
@@ -29,15 +28,27 @@ class Net::HTTP
|
|
29
28
|
end
|
30
29
|
|
31
30
|
class MiniPortile
|
31
|
+
DEFAULT_TIMEOUT = 10
|
32
|
+
|
32
33
|
attr_reader :name, :version, :original_host
|
33
34
|
attr_writer :configure_options
|
34
|
-
attr_accessor :host, :files, :patch_files, :target, :logger
|
35
|
+
attr_accessor :host, :files, :patch_files, :target, :logger, :source_directory
|
35
36
|
|
36
37
|
def self.windows?
|
37
|
-
RbConfig::CONFIG['target_os'] =~ /mswin|
|
38
|
+
RbConfig::CONFIG['target_os'] =~ /mswin|mingw/
|
39
|
+
end
|
40
|
+
|
41
|
+
# GNU MinGW compiled Ruby?
|
42
|
+
def self.mingw?
|
43
|
+
RbConfig::CONFIG['target_os'] =~ /mingw/
|
38
44
|
end
|
39
45
|
|
40
|
-
|
46
|
+
# MS Visual-C compiled Ruby?
|
47
|
+
def self.mswin?
|
48
|
+
RbConfig::CONFIG['target_os'] =~ /mswin/
|
49
|
+
end
|
50
|
+
|
51
|
+
def initialize(name, version, **kwargs)
|
41
52
|
@name = name
|
42
53
|
@version = version
|
43
54
|
@target = 'ports'
|
@@ -45,8 +56,25 @@ class MiniPortile
|
|
45
56
|
@patch_files = []
|
46
57
|
@log_files = {}
|
47
58
|
@logger = STDOUT
|
59
|
+
@source_directory = nil
|
48
60
|
|
49
61
|
@original_host = @host = detect_host
|
62
|
+
|
63
|
+
@gcc_command = kwargs[:gcc_command]
|
64
|
+
@make_command = kwargs[:make_command]
|
65
|
+
@open_timeout = kwargs[:open_timeout] || DEFAULT_TIMEOUT
|
66
|
+
@read_timeout = kwargs[:read_timeout] || DEFAULT_TIMEOUT
|
67
|
+
end
|
68
|
+
|
69
|
+
def source_directory=(path)
|
70
|
+
@source_directory = posix_path(path)
|
71
|
+
end
|
72
|
+
|
73
|
+
def prepare_build_directory
|
74
|
+
raise "source_directory is not set" if source_directory.nil?
|
75
|
+
output "Building #{@name} from source at '#{source_directory}'"
|
76
|
+
FileUtils.mkdir_p(File.join(tmp_path, [name, version].join("-")))
|
77
|
+
FileUtils.rm_rf(port_path) # make sure we always re-install
|
50
78
|
end
|
51
79
|
|
52
80
|
def download
|
@@ -71,9 +99,9 @@ class MiniPortile
|
|
71
99
|
when which('git')
|
72
100
|
lambda { |file|
|
73
101
|
message "Running git apply with #{file}... "
|
74
|
-
|
75
|
-
|
76
|
-
|
102
|
+
Dir.mktmpdir do |tmp_git_dir|
|
103
|
+
execute('patch', ["git", "--git-dir=#{tmp_git_dir}", "--work-tree=.", "apply", "--whitespace=warn", file], :initial_message => false)
|
104
|
+
end
|
77
105
|
}
|
78
106
|
when which('patch')
|
79
107
|
lambda { |file|
|
@@ -100,15 +128,16 @@ class MiniPortile
|
|
100
128
|
def configure
|
101
129
|
return if configured?
|
102
130
|
|
131
|
+
FileUtils.mkdir_p(tmp_path)
|
103
132
|
cache_file = File.join(tmp_path, 'configure.options_cache')
|
104
133
|
File.open(cache_file, "w") { |f| f.write computed_options.to_s }
|
105
134
|
|
135
|
+
command = Array(File.join((source_directory || "."), "configure"))
|
106
136
|
if RUBY_PLATFORM=~/mingw|mswin/
|
107
137
|
# Windows doesn't recognize the shebang.
|
108
|
-
|
109
|
-
else
|
110
|
-
execute('configure', %w(./configure) + computed_options)
|
138
|
+
command.unshift("sh")
|
111
139
|
end
|
140
|
+
execute('configure', command + computed_options, altlog: "config.log")
|
112
141
|
end
|
113
142
|
|
114
143
|
def compile
|
@@ -129,7 +158,7 @@ class MiniPortile
|
|
129
158
|
end
|
130
159
|
|
131
160
|
def configured?
|
132
|
-
configure = File.join(work_path, 'configure')
|
161
|
+
configure = File.join((source_directory || work_path), 'configure')
|
133
162
|
makefile = File.join(work_path, 'Makefile')
|
134
163
|
cache_file = File.join(tmp_path, 'configure.options_cache')
|
135
164
|
|
@@ -147,9 +176,13 @@ class MiniPortile
|
|
147
176
|
end
|
148
177
|
|
149
178
|
def cook
|
150
|
-
|
151
|
-
|
152
|
-
|
179
|
+
if source_directory
|
180
|
+
prepare_build_directory
|
181
|
+
else
|
182
|
+
download unless downloaded?
|
183
|
+
extract
|
184
|
+
patch
|
185
|
+
end
|
153
186
|
configure unless configured?
|
154
187
|
compile
|
155
188
|
install unless installed?
|
@@ -167,10 +200,7 @@ class MiniPortile
|
|
167
200
|
|
168
201
|
output "Activating #{@name} #{@version} (from #{port_path})..."
|
169
202
|
vars.each do |var, path|
|
170
|
-
full_path =
|
171
|
-
|
172
|
-
# turn into a valid Windows path (if required)
|
173
|
-
full_path.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
|
203
|
+
full_path = native_path(path)
|
174
204
|
|
175
205
|
# save current variable value
|
176
206
|
old_value = ENV[var] || ''
|
@@ -196,7 +226,33 @@ class MiniPortile
|
|
196
226
|
File.expand_path(port_path)
|
197
227
|
end
|
198
228
|
|
199
|
-
|
229
|
+
def gcc_cmd
|
230
|
+
(ENV["CC"] || @gcc_command || RbConfig::CONFIG["CC"] || "gcc").dup
|
231
|
+
end
|
232
|
+
|
233
|
+
def make_cmd
|
234
|
+
(ENV["MAKE"] || @make_command || ENV["make"] || "make").dup
|
235
|
+
end
|
236
|
+
|
237
|
+
private
|
238
|
+
|
239
|
+
def native_path(path)
|
240
|
+
path = File.expand_path(path)
|
241
|
+
if File::ALT_SEPARATOR
|
242
|
+
path.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
243
|
+
else
|
244
|
+
path
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def posix_path(path)
|
249
|
+
path = File.expand_path(path)
|
250
|
+
if File::ALT_SEPARATOR
|
251
|
+
"/" + path.tr(File::ALT_SEPARATOR, File::SEPARATOR).tr(":", File::SEPARATOR)
|
252
|
+
else
|
253
|
+
path
|
254
|
+
end
|
255
|
+
end
|
200
256
|
|
201
257
|
def tmp_path
|
202
258
|
"tmp/#{@host}/ports/#{@name}/#{@version}"
|
@@ -270,15 +326,18 @@ private
|
|
270
326
|
io.close_write
|
271
327
|
io.read
|
272
328
|
end
|
273
|
-
|
329
|
+
key_ids = gpg_status.scan(/\[GNUPG:\] IMPORT_OK \d+ (?<key_id>[0-9a-f]+)/i).map(&:first)
|
330
|
+
raise "invalid gpg key provided" if key_ids.empty?
|
274
331
|
|
275
332
|
# verify the signature against our keyring
|
276
333
|
gpg_status = IO.popen([gpg_exe, "--status-fd", "1", "--no-default-keyring", "--keyring", KEYRING_NAME, "--verify", signature_file, file[:local_path]], &:read)
|
277
334
|
|
278
335
|
# remove the key from our keyring
|
279
|
-
|
336
|
+
key_ids.each do |key_id|
|
337
|
+
IO.popen([gpg_exe, "--batch", "--yes", "--no-default-keyring", "--keyring", KEYRING_NAME, "--delete-keys", key_id], &:read)
|
338
|
+
raise "unable to delete the imported key" unless $?.exitstatus==0
|
339
|
+
end
|
280
340
|
|
281
|
-
raise "unable to delete the imported key" unless $?.exitstatus==0
|
282
341
|
raise "signature mismatch" unless gpg_status.match(/^\[GNUPG:\] VALIDSIG/)
|
283
342
|
|
284
343
|
else
|
@@ -318,6 +377,8 @@ private
|
|
318
377
|
'z'
|
319
378
|
when '.bz2', '.tbz2'
|
320
379
|
'j'
|
380
|
+
when '.xz'
|
381
|
+
'J'
|
321
382
|
when '.Z'
|
322
383
|
'Z'
|
323
384
|
else
|
@@ -367,24 +428,37 @@ private
|
|
367
428
|
execute('extract', [tar_exe, "#{tar_compression_switch(filename)}xf", file, "-C", target], {:cd => Dir.pwd, :initial_message => false})
|
368
429
|
end
|
369
430
|
|
370
|
-
|
371
|
-
|
431
|
+
# command could be an array of args, or one string containing a command passed to the shell. See
|
432
|
+
# Process.spawn for more information.
|
433
|
+
def execute(action, command, command_opts={})
|
434
|
+
opt_message = command_opts.fetch(:initial_message, true)
|
435
|
+
opt_debug = command_opts.fetch(:debug, false)
|
436
|
+
opt_cd = command_opts.fetch(:cd) { work_path }
|
437
|
+
opt_env = command_opts.fetch(:env) { Hash.new }
|
438
|
+
opt_altlog = command_opts.fetch(:altlog, nil)
|
372
439
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
440
|
+
log_out = log_file(action)
|
441
|
+
|
442
|
+
Dir.chdir(opt_cd) do
|
443
|
+
output "DEBUG: env is #{opt_env.inspect}" if opt_debug
|
444
|
+
output "DEBUG: command is #{command.inspect}" if opt_debug
|
445
|
+
message "Running '#{action}' for #{@name} #{@version}... " if opt_message
|
377
446
|
|
378
447
|
if Process.respond_to?(:spawn) && ! RbConfig.respond_to?(:java)
|
379
|
-
|
448
|
+
options = {[:out, :err]=>[log_out, "a"]}
|
449
|
+
output "DEBUG: options are #{options.inspect}" if opt_debug
|
450
|
+
args = [opt_env, command, options].flatten
|
380
451
|
pid = spawn(*args)
|
381
452
|
Process.wait(pid)
|
382
453
|
else
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
454
|
+
env_args = opt_env.map { |k,v| "#{k}=#{v}".shellescape }.join(" ")
|
455
|
+
c = if command.kind_of?(Array)
|
456
|
+
command.map(&:shellescape).join(" ")
|
457
|
+
else
|
458
|
+
command
|
459
|
+
end
|
460
|
+
redirected = %Q{env #{env_args} #{c} > #{log_out.shellescape} 2>&1}
|
461
|
+
output "DEBUG: final command is #{redirected.inspect}" if opt_debug
|
388
462
|
system redirected
|
389
463
|
end
|
390
464
|
|
@@ -392,12 +466,12 @@ private
|
|
392
466
|
output "OK"
|
393
467
|
return true
|
394
468
|
else
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
output(
|
400
|
-
output("
|
469
|
+
output "ERROR. Please review logs to see what happened:\n"
|
470
|
+
[log_out, opt_altlog].compact.each do |log|
|
471
|
+
next unless File.exist?(log)
|
472
|
+
output("----- contents of '#{log}' -----")
|
473
|
+
output(File.read(log))
|
474
|
+
output("----- end of file -----")
|
401
475
|
end
|
402
476
|
raise "Failed to complete #{action} task"
|
403
477
|
end
|
@@ -448,7 +522,6 @@ private
|
|
448
522
|
def download_file_http(url, full_path, count = 3)
|
449
523
|
filename = File.basename(full_path)
|
450
524
|
with_tempfile(filename, full_path) do |temp_file|
|
451
|
-
progress = 0
|
452
525
|
total = 0
|
453
526
|
params = {
|
454
527
|
"Accept-Encoding" => 'identity',
|
@@ -457,12 +530,13 @@ private
|
|
457
530
|
if total
|
458
531
|
new_progress = (bytes * 100) / total
|
459
532
|
message "\rDownloading %s (%3d%%) " % [filename, new_progress]
|
460
|
-
progress = new_progress
|
461
533
|
else
|
462
534
|
# Content-Length is unavailable because Transfer-Encoding is chunked
|
463
535
|
message "\rDownloading %s " % [filename]
|
464
536
|
end
|
465
|
-
}
|
537
|
+
},
|
538
|
+
:open_timeout => @open_timeout,
|
539
|
+
:read_timeout => @read_timeout,
|
466
540
|
}
|
467
541
|
proxy_uri = URI.parse(url).scheme.downcase == 'https' ?
|
468
542
|
ENV["https_proxy"] :
|
@@ -487,7 +561,7 @@ private
|
|
487
561
|
return download_file(redirect.url, full_path, count-1)
|
488
562
|
rescue => e
|
489
563
|
count = count - 1
|
490
|
-
puts "#{count} retrie(s) left for #{filename}"
|
564
|
+
puts "#{count} retrie(s) left for #{filename} (#{e.message})"
|
491
565
|
if count > 0
|
492
566
|
sleep 1
|
493
567
|
return download_file_http(url, full_path, count)
|
@@ -505,17 +579,18 @@ private
|
|
505
579
|
end
|
506
580
|
|
507
581
|
def download_file_ftp(uri, full_path)
|
582
|
+
require "net/ftp"
|
508
583
|
filename = File.basename(uri.path)
|
509
584
|
with_tempfile(filename, full_path) do |temp_file|
|
510
|
-
progress = 0
|
511
585
|
total = 0
|
512
586
|
params = {
|
513
587
|
:content_length_proc => lambda{|length| total = length },
|
514
588
|
:progress_proc => lambda{|bytes|
|
515
589
|
new_progress = (bytes * 100) / total
|
516
590
|
message "\rDownloading %s (%3d%%) " % [filename, new_progress]
|
517
|
-
|
518
|
-
|
591
|
+
},
|
592
|
+
:open_timeout => @open_timeout,
|
593
|
+
:read_timeout => @read_timeout,
|
519
594
|
}
|
520
595
|
if ENV["ftp_proxy"]
|
521
596
|
_, userinfo, _p_host, _p_port = URI.split(ENV['ftp_proxy'])
|
@@ -530,6 +605,8 @@ private
|
|
530
605
|
end
|
531
606
|
output
|
532
607
|
end
|
608
|
+
rescue LoadError
|
609
|
+
raise LoadError, "Ruby #{RUBY_VERSION} does not provide the net-ftp gem, please add it as a dependency if you need to use FTP"
|
533
610
|
rescue Net::FTPError
|
534
611
|
return false
|
535
612
|
end
|
@@ -543,14 +620,4 @@ private
|
|
543
620
|
FileUtils.mkdir_p File.dirname(full_path)
|
544
621
|
FileUtils.mv temp_file.path, full_path, :force => true
|
545
622
|
end
|
546
|
-
|
547
|
-
def gcc_cmd
|
548
|
-
cc = ENV["CC"] || RbConfig::CONFIG["CC"] || "gcc"
|
549
|
-
return cc.dup
|
550
|
-
end
|
551
|
-
|
552
|
-
def make_cmd
|
553
|
-
m = ENV['MAKE'] || ENV['make'] || 'make'
|
554
|
-
return m.dup
|
555
|
-
end
|
556
623
|
end
|
@@ -5,9 +5,16 @@ class MiniPortileCMake < MiniPortile
|
|
5
5
|
"-DCMAKE_INSTALL_PREFIX=#{File.expand_path(port_path)}"
|
6
6
|
end
|
7
7
|
|
8
|
+
def initialize(name, version, **kwargs)
|
9
|
+
super(name, version, **kwargs)
|
10
|
+
@cmake_command = kwargs[:cmake_command]
|
11
|
+
end
|
12
|
+
|
8
13
|
def configure_defaults
|
9
|
-
if MiniPortile.
|
10
|
-
['-G
|
14
|
+
if MiniPortile.mswin?
|
15
|
+
['-G', 'NMake Makefiles']
|
16
|
+
elsif MiniPortile.mingw?
|
17
|
+
['-G', 'MSYS Makefiles']
|
11
18
|
else
|
12
19
|
[]
|
13
20
|
end
|
@@ -19,7 +26,7 @@ class MiniPortileCMake < MiniPortile
|
|
19
26
|
cache_file = File.join(tmp_path, 'configure.options_cache')
|
20
27
|
File.open(cache_file, "w") { |f| f.write computed_options.to_s }
|
21
28
|
|
22
|
-
execute('configure',
|
29
|
+
execute('configure', [cmake_cmd] + computed_options + ["."])
|
23
30
|
end
|
24
31
|
|
25
32
|
def configured?
|
@@ -34,7 +41,11 @@ class MiniPortileCMake < MiniPortile
|
|
34
41
|
end
|
35
42
|
|
36
43
|
def make_cmd
|
37
|
-
return "nmake" if MiniPortile.
|
44
|
+
return "nmake" if MiniPortile.mswin?
|
38
45
|
super
|
39
46
|
end
|
47
|
+
|
48
|
+
def cmake_cmd
|
49
|
+
(ENV["CMAKE"] || @cmake_command || "cmake").dup
|
50
|
+
end
|
40
51
|
end
|
data/mini_portile2.gemspec
CHANGED
@@ -1,42 +1,42 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "mini_portile2/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
7
|
+
spec.name = "mini_portile2"
|
8
|
+
spec.version = MiniPortile::VERSION
|
9
9
|
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
10
|
+
spec.authors = ["Luis Lavena", "Mike Dalessio", "Lars Kanis"]
|
11
|
+
spec.email = "mike.dalessio@gmail.com"
|
12
12
|
|
13
|
-
spec.summary
|
14
|
-
spec.description
|
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
15
|
|
16
|
-
spec.homepage
|
17
|
-
spec.licenses
|
16
|
+
spec.homepage = "https://github.com/flavorjones/mini_portile"
|
17
|
+
spec.licenses = ["MIT"]
|
18
18
|
|
19
19
|
begin
|
20
|
-
spec.files
|
20
|
+
spec.files = `git ls-files -z`.split("\x0")
|
21
21
|
rescue Exception => e
|
22
22
|
warn "WARNING: could not set spec.files: #{e.class}: #{e}"
|
23
23
|
end
|
24
24
|
|
25
25
|
# omit the `examples` directory from the gem, because it's large and
|
26
26
|
# not necessary to be packaged in the gem.
|
27
|
-
example_files
|
27
|
+
example_files = spec.files.grep(%r{^examples/})
|
28
28
|
spec.files -= example_files
|
29
29
|
|
30
|
-
spec.executables
|
31
|
-
spec.test_files
|
30
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
31
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features|examples)/})
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
|
-
spec.
|
35
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
36
|
-
spec.add_development_dependency "minitest", "~> 5.11"
|
37
|
-
spec.add_development_dependency "minitest-hooks", "~> 1.5.0"
|
38
|
-
spec.add_development_dependency "minitar", "~> 0.7"
|
39
|
-
spec.add_development_dependency "concourse", "~> 0.16"
|
34
|
+
spec.required_ruby_version = ">= 2.3.0"
|
40
35
|
|
41
|
-
spec.
|
36
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
37
|
+
spec.add_development_dependency "minitar", "~> 0.9"
|
38
|
+
spec.add_development_dependency "minitest", "~> 5.15"
|
39
|
+
spec.add_development_dependency "minitest-hooks", "~> 1.5"
|
40
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
41
|
+
spec.add_development_dependency "webrick", "~> 1.7"
|
42
42
|
end
|
Binary file
|
data/test/helper.rb
CHANGED
@@ -57,4 +57,20 @@ class TestCase < Minitest::Test
|
|
57
57
|
ensure
|
58
58
|
ENV['GIT_DIR'] = old
|
59
59
|
end
|
60
|
+
|
61
|
+
def with_env(env)
|
62
|
+
before = ENV.to_h.dup
|
63
|
+
env.each { |k, v| ENV[k] = v }
|
64
|
+
yield
|
65
|
+
ensure
|
66
|
+
ENV.replace(before)
|
67
|
+
end
|
68
|
+
|
69
|
+
def without_env(*keys, &blk)
|
70
|
+
before = ENV.to_h.dup
|
71
|
+
keys.flatten.each { |k| ENV.delete(k) }
|
72
|
+
yield
|
73
|
+
ensure
|
74
|
+
ENV.replace(before)
|
75
|
+
end
|
60
76
|
end
|
data/test/test_cmake.rb
CHANGED
@@ -5,8 +5,6 @@ class TestCMake < TestCase
|
|
5
5
|
|
6
6
|
def before_all
|
7
7
|
super
|
8
|
-
return if MiniPortile.windows?
|
9
|
-
|
10
8
|
@assets_path = File.expand_path("../assets", __FILE__)
|
11
9
|
@tar_path = File.expand_path("../../tmp/test-cmake-1.0.tar.gz", __FILE__)
|
12
10
|
|
@@ -19,7 +17,6 @@ class TestCMake < TestCase
|
|
19
17
|
@recipe = MiniPortileCMake.new("test-cmake", "1.0").tap do |recipe|
|
20
18
|
recipe.files << "http://localhost:#{HTTP_PORT}/#{ERB::Util.url_encode(File.basename(@tar_path))}"
|
21
19
|
recipe.patch_files << File.join(@assets_path, "patch 1.diff")
|
22
|
-
recipe.configure_options << "--option=\"path with 'space'\""
|
23
20
|
git_dir = File.join(@assets_path, "git")
|
24
21
|
with_custom_git_dir(git_dir) do
|
25
22
|
recipe.cook
|
@@ -29,19 +26,22 @@ class TestCMake < TestCase
|
|
29
26
|
|
30
27
|
def after_all
|
31
28
|
super
|
32
|
-
return if MiniPortile.windows?
|
33
|
-
|
34
29
|
stop_webrick
|
35
30
|
# leave test files for inspection
|
36
31
|
end
|
37
32
|
|
33
|
+
def exe_name
|
34
|
+
case
|
35
|
+
when MiniPortile.windows? then "hello.exe"
|
36
|
+
else "hello"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
38
40
|
def test_cmake_inherits_from_base
|
39
41
|
assert(MiniPortileCMake <= MiniPortile)
|
40
42
|
end
|
41
43
|
|
42
44
|
def test_configure
|
43
|
-
skip if MiniPortile.windows?
|
44
|
-
|
45
45
|
cmakecache = File.join(work_dir, "CMakeCache.txt")
|
46
46
|
assert File.exist?(cmakecache), cmakecache
|
47
47
|
|
@@ -49,16 +49,42 @@ class TestCMake < TestCase
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_compile
|
52
|
-
|
53
|
-
|
54
|
-
binary = File.join(work_dir, "hello")
|
52
|
+
binary = File.join(work_dir, exe_name)
|
55
53
|
assert File.exist?(binary), binary
|
56
54
|
end
|
57
55
|
|
58
56
|
def test_install
|
59
|
-
|
60
|
-
|
61
|
-
binary = File.join(recipe.path, "bin", "hello")
|
57
|
+
binary = File.join(recipe.path, "bin", exe_name)
|
62
58
|
assert File.exist?(binary), binary
|
63
59
|
end
|
64
60
|
end
|
61
|
+
|
62
|
+
class TestCMakeConfig < TestCase
|
63
|
+
def test_make_command_configuration
|
64
|
+
MiniPortile.stub(:mswin?, false) do
|
65
|
+
without_env("MAKE") do
|
66
|
+
assert_equal("make", MiniPortileCMake.new("test", "1.0.0").make_cmd)
|
67
|
+
assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
|
68
|
+
end
|
69
|
+
with_env("MAKE"=>"asdf") do
|
70
|
+
assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0").make_cmd)
|
71
|
+
assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
MiniPortile.stub(:mswin?, true) do
|
76
|
+
assert_equal("nmake", MiniPortileCMake.new("test", "1.0.0").make_cmd)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_cmake_command_configuration
|
81
|
+
without_env("CMAKE") do
|
82
|
+
assert_equal("cmake", MiniPortileCMake.new("test", "1.0.0").cmake_cmd)
|
83
|
+
assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", cmake_command: "xyzzy").cmake_cmd)
|
84
|
+
end
|
85
|
+
with_env("CMAKE"=>"asdf") do
|
86
|
+
assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0").cmake_cmd)
|
87
|
+
assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0", cmake_command: "xyzzy").cmake_cmd)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/test/test_cook.rb
CHANGED
@@ -67,6 +67,32 @@ class TestCook < TestCase
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
class TestCookConfiguration < TestCase
|
71
|
+
def test_make_command_configuration
|
72
|
+
without_env("MAKE") do
|
73
|
+
assert_equal("make", MiniPortile.new("test", "1.0.0").make_cmd)
|
74
|
+
assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
|
75
|
+
end
|
76
|
+
with_env("MAKE"=>"asdf") do
|
77
|
+
assert_equal("asdf", MiniPortile.new("test", "1.0.0").make_cmd)
|
78
|
+
assert_equal("asdf", MiniPortile.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_gcc_command_configuration
|
83
|
+
without_env("CC") do
|
84
|
+
expected_compiler = RbConfig::CONFIG["CC"] || "gcc"
|
85
|
+
assert_equal(expected_compiler, MiniPortile.new("test", "1.0.0").gcc_cmd)
|
86
|
+
assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd)
|
87
|
+
end
|
88
|
+
with_env("CC"=>"asdf") do
|
89
|
+
assert_equal("asdf", MiniPortile.new("test", "1.0.0").gcc_cmd)
|
90
|
+
assert_equal("asdf", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
70
96
|
class TestCookWithBrokenGitDir < TestCase
|
71
97
|
#
|
72
98
|
# this is a test for #69
|
@@ -113,3 +139,32 @@ class TestCookWithBrokenGitDir < TestCase
|
|
113
139
|
end
|
114
140
|
end
|
115
141
|
end
|
142
|
+
|
143
|
+
class TestCookAgainstSourceDirectory < TestCase
|
144
|
+
attr_accessor :recipe
|
145
|
+
|
146
|
+
def setup
|
147
|
+
super
|
148
|
+
|
149
|
+
@recipe ||= MiniPortile.new("test mini portile", "1.0.0").tap do |recipe|
|
150
|
+
recipe.source_directory = File.expand_path("../assets/test mini portile-1.0.0", __FILE__)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_source_directory
|
155
|
+
recipe.cook
|
156
|
+
|
157
|
+
path = File.join(work_dir, "configure.txt")
|
158
|
+
assert(File.exist?(path))
|
159
|
+
assert_equal((recipe.configure_options + ["--prefix=#{recipe.path}"]).inspect,
|
160
|
+
File.read(path).chomp);
|
161
|
+
|
162
|
+
path = File.join(work_dir, "compile.txt")
|
163
|
+
assert(File.exist?(path))
|
164
|
+
assert_equal("[\"all\"]", File.read(path).chomp);
|
165
|
+
|
166
|
+
path = File.join(work_dir, "install.txt")
|
167
|
+
assert(File.exist?(path))
|
168
|
+
assert_equal("[\"install\"]", File.read(path).chomp);
|
169
|
+
end
|
170
|
+
end
|
data/test/test_download.rb
CHANGED
@@ -18,10 +18,12 @@ describe "recipe download" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
begin
|
22
|
+
block.call
|
23
|
+
ensure
|
24
|
+
thread.kill
|
25
|
+
server.close
|
26
|
+
end
|
25
27
|
|
26
28
|
request_count.must_be :>, 0
|
27
29
|
end
|
@@ -60,7 +62,7 @@ describe "recipe download" do
|
|
60
62
|
@recipe.files << "file://#{path}"
|
61
63
|
@recipe.download
|
62
64
|
assert File.exist?(dest)
|
63
|
-
Digest::MD5.file(dest).hexdigest.must_equal "
|
65
|
+
Digest::MD5.file(dest).hexdigest.must_equal "ee0e9f44e72213015ef976d5ac23931d"
|
64
66
|
end
|
65
67
|
|
66
68
|
it "other" do
|