rubytree 0.9.5 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +0 -6
- data/Gemfile.lock +75 -44
- data/History.rdoc +18 -2
- data/LICENSE.md +1 -2
- data/README.md +10 -8
- data/Rakefile +43 -35
- data/examples/example_basic.rb +11 -8
- data/lib/rubytree.rb +1 -1
- data/lib/tree/binarytree.rb +17 -18
- data/lib/tree/tree_deps.rb +8 -8
- data/lib/tree/utils/camel_case_method_handler.rb +12 -14
- data/lib/tree/utils/hash_converter.rb +62 -64
- data/lib/tree/utils/json_converter.rb +16 -17
- data/lib/tree/utils/metrics_methods.rb +12 -9
- data/lib/tree/utils/path_methods.rb +8 -10
- data/lib/tree/utils/tree_merge_handler.rb +9 -10
- data/lib/tree/utils/utils.rb +3 -2
- data/lib/tree/version.rb +2 -3
- data/lib/tree.rb +143 -123
- data/rubytree.gemspec +27 -25
- data/setup.rb +239 -259
- data/spec/spec_helper.rb +10 -0
- data/spec/tree_spec.rb +72 -0
- data/test/run_test.rb +6 -6
- data/test/test_binarytree.rb +93 -92
- data/test/test_rubytree_require.rb +2 -4
- data/test/test_subclassed_node.rb +13 -16
- data/test/test_thread_and_fiber.rb +10 -13
- data/test/test_tree.rb +565 -572
- metadata +98 -29
- data/TAGS +0 -248
- data/gem_graph.png +0 -0
data/setup.rb
CHANGED
@@ -8,21 +8,21 @@
|
|
8
8
|
# the GNU LGPL, Lesser General Public License version 2.1.
|
9
9
|
#
|
10
10
|
|
11
|
-
unless Enumerable.method_defined?(:map)
|
11
|
+
unless Enumerable.method_defined?(:map) # Ruby 1.4.6
|
12
12
|
module Enumerable
|
13
13
|
alias map collect
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
unless File.respond_to?(:read)
|
17
|
+
unless File.respond_to?(:read) # Ruby 1.6
|
18
18
|
def File.read(fname)
|
19
|
-
open(fname)
|
19
|
+
open(fname) do |f|
|
20
20
|
return f.read
|
21
|
-
|
21
|
+
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
unless Errno.const_defined?(:ENOTEMPTY)
|
25
|
+
unless Errno.const_defined?(:ENOTEMPTY) # Windows?
|
26
26
|
module Errno
|
27
27
|
class ENOTEMPTY
|
28
28
|
# We do not raise this exception, implementation is not needed.
|
@@ -31,19 +31,17 @@ unless Errno.const_defined?(:ENOTEMPTY) # Windows?
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def File.binread(fname)
|
34
|
-
open(fname, 'rb')
|
34
|
+
open(fname, 'rb') do |f|
|
35
35
|
return f.read
|
36
|
-
|
36
|
+
end
|
37
37
|
end
|
38
38
|
|
39
39
|
# for corrupted Windows' stat(2)
|
40
40
|
def File.dir?(path)
|
41
|
-
File.directory?(
|
41
|
+
File.directory?(path[-1, 1] == '/' ? path : path + '/')
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
44
|
class ConfigTable
|
46
|
-
|
47
45
|
include Enumerable
|
48
46
|
|
49
47
|
def initialize(rbconfig)
|
@@ -57,17 +55,14 @@ class ConfigTable
|
|
57
55
|
@no_harm = false
|
58
56
|
end
|
59
57
|
|
60
|
-
attr_accessor :install_prefix
|
61
|
-
attr_accessor :config_opt
|
58
|
+
attr_accessor :install_prefix, :config_opt
|
62
59
|
|
63
|
-
attr_writer :verbose
|
60
|
+
attr_writer :verbose, :no_harm
|
64
61
|
|
65
62
|
def verbose?
|
66
63
|
@verbose
|
67
64
|
end
|
68
65
|
|
69
|
-
attr_writer :no_harm
|
70
|
-
|
71
66
|
def no_harm?
|
72
67
|
@no_harm
|
73
68
|
end
|
@@ -81,7 +76,7 @@ class ConfigTable
|
|
81
76
|
end
|
82
77
|
|
83
78
|
def names
|
84
|
-
@items.map {|i| i.name }
|
79
|
+
@items.map { |i| i.name }
|
85
80
|
end
|
86
81
|
|
87
82
|
def each(&block)
|
@@ -103,15 +98,13 @@ class ConfigTable
|
|
103
98
|
|
104
99
|
def remove(name)
|
105
100
|
item = lookup(name)
|
106
|
-
@items.delete_if {|i| i.name == name }
|
107
|
-
@table.delete_if {|name, i| i.name == name }
|
101
|
+
@items.delete_if { |i| i.name == name }
|
102
|
+
@table.delete_if { |name, i| i.name == name }
|
108
103
|
item
|
109
104
|
end
|
110
105
|
|
111
106
|
def load_script(path, inst = nil)
|
112
|
-
if File.file?(path)
|
113
|
-
MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path
|
114
|
-
end
|
107
|
+
MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path if File.file?(path)
|
115
108
|
end
|
116
109
|
|
117
110
|
def savefile
|
@@ -119,23 +112,21 @@ class ConfigTable
|
|
119
112
|
end
|
120
113
|
|
121
114
|
def load_savefile
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
self[k] = v.strip
|
126
|
-
end
|
127
|
-
rescue Errno::ENOENT
|
128
|
-
setup_rb_error $!.message + "\n#{File.basename($0)} config first"
|
115
|
+
File.foreach(savefile) do |line|
|
116
|
+
k, v = *line.split(/=/, 2)
|
117
|
+
self[k] = v.strip
|
129
118
|
end
|
119
|
+
rescue Errno::ENOENT
|
120
|
+
setup_rb_error $!.message + "\n#{File.basename($0)} config first"
|
130
121
|
end
|
131
122
|
|
132
123
|
def save
|
133
|
-
@items.each {|i| i.value }
|
134
|
-
File.open(savefile
|
124
|
+
@items.each { |i| i.value }
|
125
|
+
File.open(savefile, 'w') do |f|
|
135
126
|
@items.each do |i|
|
136
127
|
f.printf "%s=%s\n", i.name, i.value if i.value? and i.value
|
137
128
|
end
|
138
|
-
|
129
|
+
end
|
139
130
|
end
|
140
131
|
|
141
132
|
def load_standard_entries
|
@@ -185,20 +176,20 @@ class ConfigTable
|
|
185
176
|
siterubyver = siteruby
|
186
177
|
siterubyverarch = "$siterubyver/#{c['arch']}"
|
187
178
|
end
|
188
|
-
parameterize = lambda {|path|
|
179
|
+
parameterize = lambda { |path|
|
189
180
|
path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')
|
190
181
|
}
|
191
182
|
|
192
|
-
if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
183
|
+
makeprog = if arg = c['configure_args'].split.detect { |arg| /--with-make-prog=/ =~ arg }
|
184
|
+
arg.sub(/'/, '').split(/=/, 2)[1]
|
185
|
+
else
|
186
|
+
'make'
|
187
|
+
end
|
197
188
|
|
198
189
|
[
|
199
190
|
ExecItem.new('installdirs', 'std/site/home',
|
200
191
|
'std: install under libruby; site: install under site_ruby; home: install under $HOME')\
|
201
|
-
|
192
|
+
do |val, table|
|
202
193
|
case val
|
203
194
|
when 'std'
|
204
195
|
table['rbdir'] = '$librubyver'
|
@@ -212,7 +203,7 @@ class ConfigTable
|
|
212
203
|
table['rbdir'] = '$libdir/ruby'
|
213
204
|
table['sodir'] = '$libdir/ruby'
|
214
205
|
end
|
215
|
-
|
206
|
+
end,
|
216
207
|
PathItem.new('prefix', 'path', c['prefix'],
|
217
208
|
'path prefix of target environment'),
|
218
209
|
PathItem.new('bindir', 'path', parameterize.call(c['bindir']),
|
@@ -234,7 +225,7 @@ class ConfigTable
|
|
234
225
|
PathItem.new('librubyverarch', 'path', librubyverarch,
|
235
226
|
'the directory for standard ruby extensions'),
|
236
227
|
PathItem.new('siteruby', 'path', siteruby,
|
237
|
-
|
228
|
+
'the directory for version-independent aux ruby libraries'),
|
238
229
|
PathItem.new('siterubyver', 'path', siterubyver,
|
239
230
|
'the directory for aux ruby libraries'),
|
240
231
|
PathItem.new('siterubyverarch', 'path', siterubyverarch,
|
@@ -258,7 +249,7 @@ class ConfigTable
|
|
258
249
|
private :standard_entries
|
259
250
|
|
260
251
|
def load_multipackage_entries
|
261
|
-
multipackage_entries
|
252
|
+
multipackage_entries.each do |ent|
|
262
253
|
add ent
|
263
254
|
end
|
264
255
|
end
|
@@ -274,22 +265,21 @@ class ConfigTable
|
|
274
265
|
private :multipackage_entries
|
275
266
|
|
276
267
|
ALIASES = {
|
277
|
-
'std-ruby'
|
278
|
-
'stdruby'
|
279
|
-
'rubylibdir'
|
280
|
-
'archdir'
|
281
|
-
'site-ruby-common' => 'siteruby',
|
282
|
-
'site-ruby'
|
283
|
-
'bin-dir'
|
284
|
-
'
|
285
|
-
'
|
286
|
-
'
|
287
|
-
'
|
288
|
-
'ruby-
|
289
|
-
'ruby
|
290
|
-
'
|
291
|
-
'make
|
292
|
-
'make' => 'makeprog'
|
268
|
+
'std-ruby' => 'librubyver',
|
269
|
+
'stdruby' => 'librubyver',
|
270
|
+
'rubylibdir' => 'librubyver',
|
271
|
+
'archdir' => 'librubyverarch',
|
272
|
+
'site-ruby-common' => 'siteruby', # For backward compatibility
|
273
|
+
'site-ruby' => 'siterubyver', # For backward compatibility
|
274
|
+
'bin-dir' => 'bindir',
|
275
|
+
'rb-dir' => 'rbdir',
|
276
|
+
'so-dir' => 'sodir',
|
277
|
+
'data-dir' => 'datadir',
|
278
|
+
'ruby-path' => 'rubypath',
|
279
|
+
'ruby-prog' => 'rubyprog',
|
280
|
+
'ruby' => 'rubyprog',
|
281
|
+
'make-prog' => 'makeprog',
|
282
|
+
'make' => 'makeprog'
|
293
283
|
}
|
294
284
|
|
295
285
|
def fixup
|
@@ -303,7 +293,7 @@ class ConfigTable
|
|
303
293
|
|
304
294
|
def parse_opt(opt)
|
305
295
|
m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}"
|
306
|
-
m.to_a[1,2]
|
296
|
+
m.to_a[1, 2]
|
307
297
|
end
|
308
298
|
|
309
299
|
def dllext
|
@@ -323,8 +313,7 @@ class ConfigTable
|
|
323
313
|
@description = desc
|
324
314
|
end
|
325
315
|
|
326
|
-
attr_reader :name
|
327
|
-
attr_reader :description
|
316
|
+
attr_reader :name, :description, :value
|
328
317
|
|
329
318
|
attr_accessor :default
|
330
319
|
alias help_default default
|
@@ -337,12 +326,8 @@ class ConfigTable
|
|
337
326
|
true
|
338
327
|
end
|
339
328
|
|
340
|
-
def value
|
341
|
-
@value
|
342
|
-
end
|
343
|
-
|
344
329
|
def resolve(table)
|
345
|
-
@value.gsub(%r
|
330
|
+
@value.gsub(%r{\$([^/]+)}) { table[Regexp.last_match(1)] }
|
346
331
|
end
|
347
332
|
|
348
333
|
def set(val)
|
@@ -370,6 +355,7 @@ class ConfigTable
|
|
370
355
|
|
371
356
|
def check(val)
|
372
357
|
return 'yes' unless val
|
358
|
+
|
373
359
|
case val
|
374
360
|
when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes'
|
375
361
|
when /\An(o)?\z/i, /\Af(alse)\z/i then 'no'
|
@@ -387,8 +373,8 @@ class ConfigTable
|
|
387
373
|
private
|
388
374
|
|
389
375
|
def check(path)
|
390
|
-
setup_rb_error "config: --#{@name} requires argument"
|
391
|
-
path[0,1] == '$' ? path : File.expand_path(path)
|
376
|
+
setup_rb_error "config: --#{@name} requires argument" unless path
|
377
|
+
path[0, 1] == '$' ? path : File.expand_path(path)
|
392
378
|
end
|
393
379
|
end
|
394
380
|
|
@@ -411,9 +397,7 @@ class ConfigTable
|
|
411
397
|
private
|
412
398
|
|
413
399
|
def check(val)
|
414
|
-
unless @ok.include?(val.strip)
|
415
|
-
setup_rb_error "config: use --#{@name}=#{@template} (#{val})"
|
416
|
-
end
|
400
|
+
setup_rb_error "config: use --#{@name}=#{@template} (#{val})" unless @ok.include?(val.strip)
|
417
401
|
val.strip
|
418
402
|
end
|
419
403
|
end
|
@@ -433,17 +417,15 @@ class ConfigTable
|
|
433
417
|
false
|
434
418
|
end
|
435
419
|
|
436
|
-
def resolve(
|
437
|
-
setup_rb_error "$#{name
|
420
|
+
def resolve(_table)
|
421
|
+
setup_rb_error "$#{name} wrongly used as option value"
|
438
422
|
end
|
439
423
|
|
440
424
|
undef set
|
441
425
|
|
442
426
|
def evaluate(val, table)
|
443
427
|
v = val.strip.downcase
|
444
|
-
unless @ok.include?(v)
|
445
|
-
setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})"
|
446
|
-
end
|
428
|
+
setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})" unless @ok.include?(v)
|
447
429
|
@action.call v, table
|
448
430
|
end
|
449
431
|
end
|
@@ -463,9 +445,7 @@ class ConfigTable
|
|
463
445
|
private
|
464
446
|
|
465
447
|
def check(val)
|
466
|
-
unless File.dir?("packages/#{val}")
|
467
|
-
setup_rb_error "config: no such package: #{val}"
|
468
|
-
end
|
448
|
+
setup_rb_error "config: no such package: #{val}" unless File.dir?("packages/#{val}")
|
469
449
|
val
|
470
450
|
end
|
471
451
|
end
|
@@ -518,30 +498,33 @@ class ConfigTable
|
|
518
498
|
|
519
499
|
# For only multipackage
|
520
500
|
def packages
|
521
|
-
|
501
|
+
unless @installer
|
502
|
+
raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor'
|
503
|
+
end
|
504
|
+
|
522
505
|
@installer.packages
|
523
506
|
end
|
524
507
|
|
525
508
|
# For only multipackage
|
526
509
|
def declare_packages(list)
|
527
|
-
|
510
|
+
unless @installer
|
511
|
+
raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor'
|
512
|
+
end
|
513
|
+
|
528
514
|
@installer.packages = list
|
529
515
|
end
|
530
516
|
end
|
531
|
-
|
532
|
-
end # class ConfigTable
|
533
|
-
|
517
|
+
end # class ConfigTable
|
534
518
|
|
535
519
|
# This module requires: #verbose?, #no_harm?
|
536
520
|
module FileOperations
|
537
|
-
|
538
521
|
def mkdir_p(dirname, prefix = nil)
|
539
522
|
dirname = prefix + File.expand_path(dirname) if prefix
|
540
|
-
|
523
|
+
warn "mkdir -p #{dirname}" if verbose?
|
541
524
|
return if no_harm?
|
542
525
|
|
543
526
|
# Does not check '/', it's too abnormal.
|
544
|
-
dirs = File.expand_path(dirname).split(%r
|
527
|
+
dirs = File.expand_path(dirname).split(%r{(?=/)})
|
545
528
|
if /\A[a-z]:\z/i =~ dirs[0]
|
546
529
|
disk = dirs.shift
|
547
530
|
dirs[0] = disk + dirs[0]
|
@@ -553,14 +536,16 @@ module FileOperations
|
|
553
536
|
end
|
554
537
|
|
555
538
|
def rm_f(path)
|
556
|
-
|
539
|
+
warn "rm -f #{path}" if verbose?
|
557
540
|
return if no_harm?
|
541
|
+
|
558
542
|
force_remove_file path
|
559
543
|
end
|
560
544
|
|
561
545
|
def rm_rf(path)
|
562
|
-
|
546
|
+
warn "rm -rf #{path}" if verbose?
|
563
547
|
return if no_harm?
|
548
|
+
|
564
549
|
remove_tree path
|
565
550
|
end
|
566
551
|
|
@@ -578,6 +563,7 @@ module FileOperations
|
|
578
563
|
Dir.foreach(path) do |ent|
|
579
564
|
next if ent == '.'
|
580
565
|
next if ent == '..'
|
566
|
+
|
581
567
|
entpath = "#{path}/#{ent}"
|
582
568
|
if File.symlink?(entpath)
|
583
569
|
remove_file entpath
|
@@ -598,68 +584,66 @@ module FileOperations
|
|
598
584
|
force_remove_file dest
|
599
585
|
begin
|
600
586
|
File.rename src, dest
|
601
|
-
rescue
|
602
|
-
File.open(dest, 'wb')
|
587
|
+
rescue StandardError
|
588
|
+
File.open(dest, 'wb') do |f|
|
603
589
|
f.write File.binread(src)
|
604
|
-
|
590
|
+
end
|
605
591
|
File.chmod File.stat(src).mode, dest
|
606
592
|
File.unlink src
|
607
593
|
end
|
608
594
|
end
|
609
595
|
|
610
596
|
def force_remove_file(path)
|
611
|
-
|
612
|
-
|
613
|
-
rescue
|
614
|
-
end
|
597
|
+
remove_file path
|
598
|
+
rescue StandardError
|
615
599
|
end
|
616
600
|
|
617
601
|
def remove_file(path)
|
618
|
-
File.chmod
|
602
|
+
File.chmod 0o777, path
|
619
603
|
File.unlink path
|
620
604
|
end
|
621
605
|
|
622
606
|
def install(from, dest, mode, prefix = nil)
|
623
|
-
|
607
|
+
warn "install #{from} #{dest}" if verbose?
|
624
608
|
return if no_harm?
|
625
609
|
|
626
610
|
realdest = prefix ? prefix + File.expand_path(dest) : dest
|
627
611
|
realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest)
|
628
612
|
str = File.binread(from)
|
629
613
|
if diff?(str, realdest)
|
630
|
-
verbose_off
|
614
|
+
verbose_off do
|
631
615
|
rm_f realdest if File.exist?(realdest)
|
632
|
-
|
633
|
-
File.open(realdest, 'wb')
|
616
|
+
end
|
617
|
+
File.open(realdest, 'wb') do |f|
|
634
618
|
f.write str
|
635
|
-
|
619
|
+
end
|
636
620
|
File.chmod mode, realdest
|
637
621
|
|
638
|
-
File.open("#{objdir_root
|
622
|
+
File.open("#{objdir_root}/InstalledFiles", 'a') do |f|
|
639
623
|
if prefix
|
640
624
|
f.puts realdest.sub(prefix, '')
|
641
625
|
else
|
642
626
|
f.puts realdest
|
643
627
|
end
|
644
|
-
|
628
|
+
end
|
645
629
|
end
|
646
630
|
end
|
647
631
|
|
648
632
|
def diff?(new_content, path)
|
649
633
|
return true unless File.exist?(path)
|
634
|
+
|
650
635
|
new_content != File.binread(path)
|
651
636
|
end
|
652
637
|
|
653
638
|
def command(*args)
|
654
|
-
|
655
|
-
system(*args) or raise
|
656
|
-
"system(#{args.map{|a| a.inspect }.join(' ')}) failed"
|
639
|
+
warn args.join(' ') if verbose?
|
640
|
+
system(*args) or raise "system(#{args.map { |a| a.inspect }.join(' ')}) failed"
|
657
641
|
end
|
658
642
|
|
659
643
|
def ruby(*args)
|
660
644
|
command config('rubyprog'), *args
|
661
645
|
end
|
662
|
-
|
646
|
+
|
663
647
|
def make(task = nil)
|
664
648
|
command(*[config('makeprog'), task].compact)
|
665
649
|
end
|
@@ -669,25 +653,22 @@ module FileOperations
|
|
669
653
|
end
|
670
654
|
|
671
655
|
def files_of(dir)
|
672
|
-
Dir.open(dir)
|
673
|
-
return d.select {|ent| File.file?("#{dir}/#{ent}") }
|
674
|
-
|
656
|
+
Dir.open(dir) do |d|
|
657
|
+
return d.select { |ent| File.file?("#{dir}/#{ent}") }
|
658
|
+
end
|
675
659
|
end
|
676
660
|
|
677
|
-
DIR_REJECT = %w
|
661
|
+
DIR_REJECT = %w[. .. CVS SCCS RCS CVS.adm .svn]
|
678
662
|
|
679
663
|
def directories_of(dir)
|
680
|
-
Dir.open(dir)
|
681
|
-
return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT
|
682
|
-
|
664
|
+
Dir.open(dir) do |d|
|
665
|
+
return d.select { |ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT
|
666
|
+
end
|
683
667
|
end
|
684
|
-
|
685
668
|
end
|
686
669
|
|
687
|
-
|
688
670
|
# This module requires: #srcdir_root, #objdir_root, #relpath
|
689
671
|
module HookScriptAPI
|
690
|
-
|
691
672
|
def get_config(key)
|
692
673
|
@config[key]
|
693
674
|
end
|
@@ -704,15 +685,15 @@ module HookScriptAPI
|
|
704
685
|
#
|
705
686
|
|
706
687
|
def curr_srcdir
|
707
|
-
"#{srcdir_root
|
688
|
+
"#{srcdir_root}/#{relpath}"
|
708
689
|
end
|
709
690
|
|
710
691
|
def curr_objdir
|
711
|
-
"#{objdir_root
|
692
|
+
"#{objdir_root}/#{relpath}"
|
712
693
|
end
|
713
694
|
|
714
695
|
def srcfile(path)
|
715
|
-
"#{curr_srcdir
|
696
|
+
"#{curr_srcdir}/#{path}"
|
716
697
|
end
|
717
698
|
|
718
699
|
def srcexist?(path)
|
@@ -722,63 +703,60 @@ module HookScriptAPI
|
|
722
703
|
def srcdirectory?(path)
|
723
704
|
File.dir?(srcfile(path))
|
724
705
|
end
|
725
|
-
|
706
|
+
|
726
707
|
def srcfile?(path)
|
727
708
|
File.file?(srcfile(path))
|
728
709
|
end
|
729
710
|
|
730
711
|
def srcentries(path = '.')
|
731
|
-
Dir.open("#{curr_srcdir
|
732
|
-
return d.to_a - %w
|
733
|
-
|
712
|
+
Dir.open("#{curr_srcdir}/#{path}") do |d|
|
713
|
+
return d.to_a - %w[. ..]
|
714
|
+
end
|
734
715
|
end
|
735
716
|
|
736
717
|
def srcfiles(path = '.')
|
737
|
-
srcentries(path).select
|
738
|
-
File.file?(File.join(curr_srcdir
|
739
|
-
|
718
|
+
srcentries(path).select do |fname|
|
719
|
+
File.file?(File.join(curr_srcdir, path, fname))
|
720
|
+
end
|
740
721
|
end
|
741
722
|
|
742
723
|
def srcdirectories(path = '.')
|
743
|
-
srcentries(path).select
|
744
|
-
File.dir?(File.join(curr_srcdir
|
745
|
-
|
724
|
+
srcentries(path).select do |fname|
|
725
|
+
File.dir?(File.join(curr_srcdir, path, fname))
|
726
|
+
end
|
746
727
|
end
|
747
|
-
|
748
728
|
end
|
749
729
|
|
750
|
-
|
751
730
|
class ToplevelInstaller
|
752
|
-
|
753
731
|
Version = '3.4.1'
|
754
732
|
Copyright = 'Copyright (c) 2000-2005 Minero Aoki'
|
755
733
|
|
756
734
|
TASKS = [
|
757
|
-
[
|
758
|
-
[
|
759
|
-
[
|
760
|
-
[
|
761
|
-
[
|
762
|
-
[
|
763
|
-
[
|
764
|
-
[
|
735
|
+
['all', 'do config, setup, then install'],
|
736
|
+
['config', 'saves your configurations'],
|
737
|
+
['show', 'shows current configuration'],
|
738
|
+
['setup', 'compiles ruby extentions and others'],
|
739
|
+
['install', 'installs files'],
|
740
|
+
['test', 'run all tests in test/'],
|
741
|
+
['clean', "does `make clean' for each extention"],
|
742
|
+
['distclean', "does `make distclean' for each extention"]
|
765
743
|
]
|
766
744
|
|
767
|
-
def
|
768
|
-
config = ConfigTable.new(load_rbconfig
|
745
|
+
def self.invoke
|
746
|
+
config = ConfigTable.new(load_rbconfig)
|
769
747
|
config.load_standard_entries
|
770
748
|
config.load_multipackage_entries if multipackage?
|
771
749
|
config.fixup
|
772
|
-
klass = (multipackage?
|
750
|
+
klass = (multipackage? ? ToplevelInstallerMulti : ToplevelInstaller)
|
773
751
|
klass.new(File.dirname($0), config).invoke
|
774
752
|
end
|
775
753
|
|
776
|
-
def
|
754
|
+
def self.multipackage?
|
777
755
|
File.dir?(File.dirname($0) + '/packages')
|
778
756
|
end
|
779
757
|
|
780
|
-
def
|
781
|
-
if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg }
|
758
|
+
def self.load_rbconfig
|
759
|
+
if arg = ARGV.detect { |arg| /\A--rbconfig=/ =~ arg }
|
782
760
|
ARGV.delete(arg)
|
783
761
|
load File.expand_path(arg.split(/=/, 2)[1])
|
784
762
|
$".push 'rbconfig.rb'
|
@@ -800,12 +778,12 @@ class ToplevelInstaller
|
|
800
778
|
end
|
801
779
|
|
802
780
|
def inspect
|
803
|
-
"#<#{self.class} #{__id__
|
781
|
+
"#<#{self.class} #{__id__}>"
|
804
782
|
end
|
805
783
|
|
806
784
|
def invoke
|
807
785
|
run_metaconfigs
|
808
|
-
case task = parsearg_global
|
786
|
+
case task = parsearg_global
|
809
787
|
when nil, 'all'
|
810
788
|
parsearg_config
|
811
789
|
init_installers
|
@@ -815,7 +793,7 @@ class ToplevelInstaller
|
|
815
793
|
else
|
816
794
|
case task
|
817
795
|
when 'config', 'test'
|
818
|
-
|
796
|
+
|
819
797
|
when 'clean', 'distclean'
|
820
798
|
@config.load_savefile if File.exist?(@config.savefile)
|
821
799
|
else
|
@@ -826,7 +804,7 @@ class ToplevelInstaller
|
|
826
804
|
__send__ "exec_#{task}"
|
827
805
|
end
|
828
806
|
end
|
829
|
-
|
807
|
+
|
830
808
|
def run_metaconfigs
|
831
809
|
@config.load_script "#{@ardir}/metaconfig"
|
832
810
|
end
|
@@ -882,16 +860,16 @@ class ToplevelInstaller
|
|
882
860
|
end
|
883
861
|
|
884
862
|
def valid_task?(t)
|
885
|
-
valid_task_re
|
863
|
+
valid_task_re =~ t
|
886
864
|
end
|
887
865
|
|
888
866
|
def valid_task_re
|
889
|
-
@valid_task_re ||= /\A(?:#{TASKS.map {|task,
|
867
|
+
@valid_task_re ||= /\A(?:#{TASKS.map { |task, _desc| task }.join('|')})\z/
|
890
868
|
end
|
891
869
|
|
892
870
|
def parsearg_no_options
|
893
871
|
unless ARGV.empty?
|
894
|
-
task = caller(0).first.slice(
|
872
|
+
task = caller(0).first.slice(/`parsearg_(\w+)'/, 1)
|
895
873
|
setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}"
|
896
874
|
end
|
897
875
|
end
|
@@ -937,7 +915,7 @@ class ToplevelInstaller
|
|
937
915
|
@config.no_harm = true
|
938
916
|
when /\A--prefix=/
|
939
917
|
path = a.split(/=/, 2)[1]
|
940
|
-
path = File.expand_path(path) unless path[0,1] == '/'
|
918
|
+
path = File.expand_path(path) unless path[0, 1] == '/'
|
941
919
|
@config.install_prefix = path
|
942
920
|
else
|
943
921
|
setup_rb_error "install: unknown option #{a}"
|
@@ -962,7 +940,7 @@ class ToplevelInstaller
|
|
962
940
|
out.printf fmt, ' --verbose', 'output messages verbosely'
|
963
941
|
out.printf fmt, ' --help', 'print this message'
|
964
942
|
out.printf fmt, ' --version', 'print version and quit'
|
965
|
-
out.printf fmt, ' --copyright',
|
943
|
+
out.printf fmt, ' --copyright', 'print copyright and quit'
|
966
944
|
out.puts
|
967
945
|
out.puts 'Tasks:'
|
968
946
|
TASKS.each do |name, desc|
|
@@ -975,11 +953,11 @@ class ToplevelInstaller
|
|
975
953
|
@config.each do |item|
|
976
954
|
out.printf fmt, item.help_opt, item.description, item.help_default
|
977
955
|
end
|
978
|
-
out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's"
|
956
|
+
out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load', "running ruby's"
|
979
957
|
out.puts
|
980
958
|
out.puts 'Options for INSTALL:'
|
981
959
|
out.printf fmt, '--no-harm', 'only display what to do if given', 'off'
|
982
|
-
out.printf fmt, '--prefix=path',
|
960
|
+
out.printf fmt, '--prefix=path', 'install path prefix', ''
|
983
961
|
out.puts
|
984
962
|
end
|
985
963
|
|
@@ -989,7 +967,7 @@ class ToplevelInstaller
|
|
989
967
|
|
990
968
|
def exec_config
|
991
969
|
@installer.exec_config
|
992
|
-
@config.save
|
970
|
+
@config.save # must be final
|
993
971
|
end
|
994
972
|
|
995
973
|
def exec_setup
|
@@ -1017,18 +995,16 @@ class ToplevelInstaller
|
|
1017
995
|
def exec_distclean
|
1018
996
|
@installer.exec_distclean
|
1019
997
|
end
|
1020
|
-
|
1021
|
-
end # class ToplevelInstaller
|
1022
|
-
|
998
|
+
end # class ToplevelInstaller
|
1023
999
|
|
1024
1000
|
class ToplevelInstallerMulti < ToplevelInstaller
|
1025
|
-
|
1026
1001
|
include FileOperations
|
1027
1002
|
|
1028
1003
|
def initialize(ardir_root, config)
|
1029
1004
|
super
|
1030
1005
|
@packages = directories_of("#{@ardir}/packages")
|
1031
1006
|
raise 'no package exists' if @packages.empty?
|
1007
|
+
|
1032
1008
|
@root_installer = Installer.new(@config, @ardir, File.expand_path('.'))
|
1033
1009
|
end
|
1034
1010
|
|
@@ -1043,6 +1019,7 @@ class ToplevelInstallerMulti < ToplevelInstaller
|
|
1043
1019
|
|
1044
1020
|
def packages=(list)
|
1045
1021
|
raise 'package list is empty' if list.empty?
|
1022
|
+
|
1046
1023
|
list.each do |name|
|
1047
1024
|
raise "directory packages/#{name} does not exist"\
|
1048
1025
|
unless File.dir?("#{@ardir}/packages/#{name}")
|
@@ -1054,21 +1031,21 @@ class ToplevelInstallerMulti < ToplevelInstaller
|
|
1054
1031
|
@installers = {}
|
1055
1032
|
@packages.each do |pack|
|
1056
1033
|
@installers[pack] = Installer.new(@config,
|
1057
|
-
|
1058
|
-
|
1034
|
+
"#{@ardir}/packages/#{pack}",
|
1035
|
+
"packages/#{pack}")
|
1059
1036
|
end
|
1060
1037
|
with = extract_selection(config('with'))
|
1061
1038
|
without = extract_selection(config('without'))
|
1062
|
-
@selected = @installers.keys.select
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1039
|
+
@selected = @installers.keys.select do |name|
|
1040
|
+
(with.empty? or with.include?(name)) \
|
1041
|
+
and !without.include?(name)
|
1042
|
+
end
|
1066
1043
|
end
|
1067
1044
|
|
1068
1045
|
def extract_selection(list)
|
1069
1046
|
a = list.split(/,/)
|
1070
1047
|
a.each do |name|
|
1071
|
-
setup_rb_error "no such package: #{name}"
|
1048
|
+
setup_rb_error "no such package: #{name}" unless @installers.key?(name)
|
1072
1049
|
end
|
1073
1050
|
a
|
1074
1051
|
end
|
@@ -1086,40 +1063,40 @@ class ToplevelInstallerMulti < ToplevelInstaller
|
|
1086
1063
|
|
1087
1064
|
def exec_config
|
1088
1065
|
run_hook 'pre-config'
|
1089
|
-
each_selected_installers {|inst| inst.exec_config }
|
1066
|
+
each_selected_installers { |inst| inst.exec_config }
|
1090
1067
|
run_hook 'post-config'
|
1091
|
-
@config.save
|
1068
|
+
@config.save # must be final
|
1092
1069
|
end
|
1093
1070
|
|
1094
1071
|
def exec_setup
|
1095
1072
|
run_hook 'pre-setup'
|
1096
|
-
each_selected_installers {|inst| inst.exec_setup }
|
1073
|
+
each_selected_installers { |inst| inst.exec_setup }
|
1097
1074
|
run_hook 'post-setup'
|
1098
1075
|
end
|
1099
1076
|
|
1100
1077
|
def exec_install
|
1101
1078
|
run_hook 'pre-install'
|
1102
|
-
each_selected_installers {|inst| inst.exec_install }
|
1079
|
+
each_selected_installers { |inst| inst.exec_install }
|
1103
1080
|
run_hook 'post-install'
|
1104
1081
|
end
|
1105
1082
|
|
1106
1083
|
def exec_test
|
1107
1084
|
run_hook 'pre-test'
|
1108
|
-
each_selected_installers {|inst| inst.exec_test }
|
1085
|
+
each_selected_installers { |inst| inst.exec_test }
|
1109
1086
|
run_hook 'post-test'
|
1110
1087
|
end
|
1111
1088
|
|
1112
1089
|
def exec_clean
|
1113
1090
|
rm_f @config.savefile
|
1114
1091
|
run_hook 'pre-clean'
|
1115
|
-
each_selected_installers {|inst| inst.exec_clean }
|
1092
|
+
each_selected_installers { |inst| inst.exec_clean }
|
1116
1093
|
run_hook 'post-clean'
|
1117
1094
|
end
|
1118
1095
|
|
1119
1096
|
def exec_distclean
|
1120
1097
|
rm_f @config.savefile
|
1121
1098
|
run_hook 'pre-distclean'
|
1122
|
-
each_selected_installers {|inst| inst.exec_distclean }
|
1099
|
+
each_selected_installers { |inst| inst.exec_distclean }
|
1123
1100
|
run_hook 'post-distclean'
|
1124
1101
|
end
|
1125
1102
|
|
@@ -1130,7 +1107,7 @@ class ToplevelInstallerMulti < ToplevelInstaller
|
|
1130
1107
|
def each_selected_installers
|
1131
1108
|
Dir.mkdir 'packages' unless File.dir?('packages')
|
1132
1109
|
@selected.each do |pack|
|
1133
|
-
|
1110
|
+
warn "Processing the package `#{pack}' ..." if verbose?
|
1134
1111
|
Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}")
|
1135
1112
|
Dir.chdir "packages/#{pack}"
|
1136
1113
|
yield @installers[pack]
|
@@ -1151,13 +1128,10 @@ class ToplevelInstallerMulti < ToplevelInstaller
|
|
1151
1128
|
def no_harm?
|
1152
1129
|
@config.no_harm?
|
1153
1130
|
end
|
1154
|
-
|
1155
|
-
end # class ToplevelInstallerMulti
|
1156
|
-
|
1131
|
+
end # class ToplevelInstallerMulti
|
1157
1132
|
|
1158
1133
|
class Installer
|
1159
|
-
|
1160
|
-
FILETYPES = %w( bin lib ext data conf man )
|
1134
|
+
FILETYPES = %w[bin lib ext data conf man]
|
1161
1135
|
|
1162
1136
|
include FileOperations
|
1163
1137
|
include HookScriptAPI
|
@@ -1173,8 +1147,7 @@ class Installer
|
|
1173
1147
|
"#<#{self.class} #{File.basename(@srcdir)}>"
|
1174
1148
|
end
|
1175
1149
|
|
1176
|
-
def noop(rel)
|
1177
|
-
end
|
1150
|
+
def noop(rel); end
|
1178
1151
|
|
1179
1152
|
#
|
1180
1153
|
# Hook Script API base methods
|
@@ -1207,12 +1180,11 @@ class Installer
|
|
1207
1180
|
end
|
1208
1181
|
|
1209
1182
|
def verbose_off
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
end
|
1183
|
+
save = @config.verbose?
|
1184
|
+
@config.verbose = false
|
1185
|
+
yield
|
1186
|
+
ensure
|
1187
|
+
@config.verbose = save
|
1216
1188
|
end
|
1217
1189
|
|
1218
1190
|
#
|
@@ -1226,8 +1198,8 @@ class Installer
|
|
1226
1198
|
alias config_dir_bin noop
|
1227
1199
|
alias config_dir_lib noop
|
1228
1200
|
|
1229
|
-
def config_dir_ext(
|
1230
|
-
extconf if extdir?(curr_srcdir
|
1201
|
+
def config_dir_ext(_rel)
|
1202
|
+
extconf if extdir?(curr_srcdir)
|
1231
1203
|
end
|
1232
1204
|
|
1233
1205
|
alias config_dir_data noop
|
@@ -1235,7 +1207,7 @@ class Installer
|
|
1235
1207
|
alias config_dir_man noop
|
1236
1208
|
|
1237
1209
|
def extconf
|
1238
|
-
ruby "#{curr_srcdir
|
1210
|
+
ruby "#{curr_srcdir}/extconf.rb", *@config.config_opt
|
1239
1211
|
end
|
1240
1212
|
|
1241
1213
|
#
|
@@ -1246,16 +1218,16 @@ class Installer
|
|
1246
1218
|
exec_task_traverse 'setup'
|
1247
1219
|
end
|
1248
1220
|
|
1249
|
-
def setup_dir_bin(
|
1250
|
-
files_of(curr_srcdir
|
1251
|
-
update_shebang_line "#{curr_srcdir
|
1221
|
+
def setup_dir_bin(_rel)
|
1222
|
+
files_of(curr_srcdir).each do |fname|
|
1223
|
+
update_shebang_line "#{curr_srcdir}/#{fname}"
|
1252
1224
|
end
|
1253
1225
|
end
|
1254
1226
|
|
1255
1227
|
alias setup_dir_lib noop
|
1256
1228
|
|
1257
|
-
def setup_dir_ext(
|
1258
|
-
make if extdir?(curr_srcdir
|
1229
|
+
def setup_dir_ext(_rel)
|
1230
|
+
make if extdir?(curr_srcdir)
|
1259
1231
|
end
|
1260
1232
|
|
1261
1233
|
alias setup_dir_data noop
|
@@ -1265,23 +1237,27 @@ class Installer
|
|
1265
1237
|
def update_shebang_line(path)
|
1266
1238
|
return if no_harm?
|
1267
1239
|
return if config('shebang') == 'never'
|
1240
|
+
|
1268
1241
|
old = Shebang.load(path)
|
1269
1242
|
if old
|
1270
|
-
|
1243
|
+
if old.args.size > 1
|
1244
|
+
warn "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work."
|
1245
|
+
end
|
1271
1246
|
new = new_shebang(old)
|
1272
1247
|
return if new.to_s == old.to_s
|
1273
1248
|
else
|
1274
1249
|
return unless config('shebang') == 'all'
|
1250
|
+
|
1275
1251
|
new = Shebang.new(config('rubypath'))
|
1276
1252
|
end
|
1277
|
-
|
1278
|
-
open_atomic_writer(path)
|
1279
|
-
File.open(path, 'rb')
|
1280
|
-
f.gets if old
|
1253
|
+
warn "updating shebang: #{File.basename(path)}" if verbose?
|
1254
|
+
open_atomic_writer(path) do |output|
|
1255
|
+
File.open(path, 'rb') do |f|
|
1256
|
+
f.gets if old # discard
|
1281
1257
|
output.puts new.to_s
|
1282
1258
|
output.print f.read
|
1283
|
-
|
1284
|
-
|
1259
|
+
end
|
1260
|
+
end
|
1285
1261
|
end
|
1286
1262
|
|
1287
1263
|
def new_shebang(old)
|
@@ -1291,6 +1267,7 @@ class Installer
|
|
1291
1267
|
Shebang.new(config('rubypath'), old.args[1..-1])
|
1292
1268
|
else
|
1293
1269
|
return old unless config('shebang') == 'all'
|
1270
|
+
|
1294
1271
|
Shebang.new(config('rubypath'))
|
1295
1272
|
end
|
1296
1273
|
end
|
@@ -1306,16 +1283,17 @@ class Installer
|
|
1306
1283
|
end
|
1307
1284
|
|
1308
1285
|
class Shebang
|
1309
|
-
def
|
1286
|
+
def self.load(path)
|
1310
1287
|
line = nil
|
1311
|
-
File.open(path)
|
1288
|
+
File.open(path) do |f|
|
1312
1289
|
line = f.gets
|
1313
|
-
|
1290
|
+
end
|
1314
1291
|
return nil unless /\A#!/ =~ line
|
1292
|
+
|
1315
1293
|
parse(line)
|
1316
1294
|
end
|
1317
1295
|
|
1318
|
-
def
|
1296
|
+
def self.parse(line)
|
1319
1297
|
cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ')
|
1320
1298
|
new(cmd, args)
|
1321
1299
|
end
|
@@ -1325,8 +1303,7 @@ class Installer
|
|
1325
1303
|
@args = args
|
1326
1304
|
end
|
1327
1305
|
|
1328
|
-
attr_reader :cmd
|
1329
|
-
attr_reader :args
|
1306
|
+
attr_reader :cmd, :args
|
1330
1307
|
|
1331
1308
|
def to_s
|
1332
1309
|
"#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}")
|
@@ -1343,32 +1320,33 @@ class Installer
|
|
1343
1320
|
end
|
1344
1321
|
|
1345
1322
|
def install_dir_bin(rel)
|
1346
|
-
install_files targetfiles
|
1323
|
+
install_files targetfiles, "#{config('bindir')}/#{rel}", 0o755
|
1347
1324
|
end
|
1348
1325
|
|
1349
1326
|
def install_dir_lib(rel)
|
1350
|
-
install_files libfiles
|
1327
|
+
install_files libfiles, "#{config('rbdir')}/#{rel}", 0o644
|
1351
1328
|
end
|
1352
1329
|
|
1353
1330
|
def install_dir_ext(rel)
|
1354
|
-
return unless extdir?(curr_srcdir
|
1331
|
+
return unless extdir?(curr_srcdir)
|
1332
|
+
|
1355
1333
|
install_files rubyextentions('.'),
|
1356
1334
|
"#{config('sodir')}/#{File.dirname(rel)}",
|
1357
|
-
|
1335
|
+
0o555
|
1358
1336
|
end
|
1359
1337
|
|
1360
1338
|
def install_dir_data(rel)
|
1361
|
-
install_files targetfiles
|
1339
|
+
install_files targetfiles, "#{config('datadir')}/#{rel}", 0o644
|
1362
1340
|
end
|
1363
1341
|
|
1364
1342
|
def install_dir_conf(rel)
|
1365
1343
|
# FIXME: should not remove current config files
|
1366
1344
|
# (rename previous file to .old/.org)
|
1367
|
-
install_files targetfiles
|
1345
|
+
install_files targetfiles, "#{config('sysconfdir')}/#{rel}", 0o644
|
1368
1346
|
end
|
1369
1347
|
|
1370
1348
|
def install_dir_man(rel)
|
1371
|
-
install_files targetfiles
|
1349
|
+
install_files targetfiles, "#{config('mandir')}/#{rel}", 0o644
|
1372
1350
|
end
|
1373
1351
|
|
1374
1352
|
def install_files(list, dest, mode)
|
@@ -1379,57 +1357,56 @@ class Installer
|
|
1379
1357
|
end
|
1380
1358
|
|
1381
1359
|
def libfiles
|
1382
|
-
glob_reject(%w
|
1360
|
+
glob_reject(%w[*.y *.output], targetfiles)
|
1383
1361
|
end
|
1384
1362
|
|
1385
|
-
def rubyextentions(
|
1386
|
-
ents = glob_select("*.#{@config.dllext}", targetfiles
|
1387
|
-
if ents.empty?
|
1388
|
-
setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first"
|
1389
|
-
end
|
1363
|
+
def rubyextentions(_dir)
|
1364
|
+
ents = glob_select("*.#{@config.dllext}", targetfiles)
|
1365
|
+
setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" if ents.empty?
|
1390
1366
|
ents
|
1391
1367
|
end
|
1392
1368
|
|
1393
1369
|
def targetfiles
|
1394
|
-
mapdir(existfiles
|
1370
|
+
mapdir(existfiles - hookfiles)
|
1395
1371
|
end
|
1396
1372
|
|
1397
1373
|
def mapdir(ents)
|
1398
|
-
ents.map
|
1374
|
+
ents.map do |ent|
|
1399
1375
|
if File.exist?(ent)
|
1400
|
-
then ent
|
1401
|
-
else
|
1376
|
+
then ent # objdir
|
1377
|
+
else
|
1378
|
+
"#{curr_srcdir}/#{ent}" # srcdir
|
1402
1379
|
end
|
1403
|
-
|
1380
|
+
end
|
1404
1381
|
end
|
1405
1382
|
|
1406
1383
|
# picked up many entries from cvs-1.11.1/src/ignore.c
|
1407
|
-
JUNK_FILES = %w
|
1384
|
+
JUNK_FILES = %w[
|
1408
1385
|
core RCSLOG tags TAGS .make.state
|
1409
1386
|
.nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
|
1410
1387
|
*~ *.old *.bak *.BAK *.orig *.rej _$* *$
|
1411
1388
|
|
1412
1389
|
*.org *.in .*
|
1413
|
-
|
1390
|
+
]
|
1414
1391
|
|
1415
1392
|
def existfiles
|
1416
|
-
glob_reject(JUNK_FILES, (files_of(curr_srcdir
|
1393
|
+
glob_reject(JUNK_FILES, (files_of(curr_srcdir) | files_of('.')))
|
1417
1394
|
end
|
1418
1395
|
|
1419
1396
|
def hookfiles
|
1420
|
-
%w
|
1421
|
-
%w
|
1422
|
-
|
1397
|
+
%w[pre-%s post-%s pre-%s.rb post-%s.rb].map do |fmt|
|
1398
|
+
%w[config setup install clean].map { |t| format(fmt, t) }
|
1399
|
+
end.flatten
|
1423
1400
|
end
|
1424
1401
|
|
1425
1402
|
def glob_select(pat, ents)
|
1426
1403
|
re = globs2re([pat])
|
1427
|
-
ents.select {|ent| re =~ ent }
|
1404
|
+
ents.select { |ent| re =~ ent }
|
1428
1405
|
end
|
1429
1406
|
|
1430
1407
|
def glob_reject(pats, ents)
|
1431
1408
|
re = globs2re(pats)
|
1432
|
-
ents.reject {|ent| re =~ ent }
|
1409
|
+
ents.reject { |ent| re =~ ent }
|
1433
1410
|
end
|
1434
1411
|
|
1435
1412
|
GLOB2REGEX = {
|
@@ -1441,7 +1418,7 @@ class Installer
|
|
1441
1418
|
|
1442
1419
|
def globs2re(pats)
|
1443
1420
|
/\A(?:#{
|
1444
|
-
pats.map {|pat| pat.gsub(/[
|
1421
|
+
pats.map { |pat| pat.gsub(/[.$\#*]/) { |ch| GLOB2REGEX[ch] } }.join('|')
|
1445
1422
|
})\z/
|
1446
1423
|
end
|
1447
1424
|
|
@@ -1453,10 +1430,10 @@ class Installer
|
|
1453
1430
|
|
1454
1431
|
def exec_test
|
1455
1432
|
unless File.directory?('test')
|
1456
|
-
|
1433
|
+
warn 'no test in this package' if verbose?
|
1457
1434
|
return
|
1458
1435
|
end
|
1459
|
-
|
1436
|
+
warn 'Running tests...' if verbose?
|
1460
1437
|
begin
|
1461
1438
|
require 'test/unit'
|
1462
1439
|
rescue LoadError
|
@@ -1483,8 +1460,9 @@ class Installer
|
|
1483
1460
|
alias clean_dir_conf noop
|
1484
1461
|
alias clean_dir_man noop
|
1485
1462
|
|
1486
|
-
def clean_dir_ext(
|
1487
|
-
return unless extdir?(curr_srcdir
|
1463
|
+
def clean_dir_ext(_rel)
|
1464
|
+
return unless extdir?(curr_srcdir)
|
1465
|
+
|
1488
1466
|
make 'clean' if File.file?('Makefile')
|
1489
1467
|
end
|
1490
1468
|
|
@@ -1501,8 +1479,9 @@ class Installer
|
|
1501
1479
|
alias distclean_dir_bin noop
|
1502
1480
|
alias distclean_dir_lib noop
|
1503
1481
|
|
1504
|
-
def distclean_dir_ext(
|
1505
|
-
return unless extdir?(curr_srcdir
|
1482
|
+
def distclean_dir_ext(_rel)
|
1483
|
+
return unless extdir?(curr_srcdir)
|
1484
|
+
|
1506
1485
|
make 'distclean' if File.file?('Makefile')
|
1507
1486
|
end
|
1508
1487
|
|
@@ -1518,7 +1497,7 @@ class Installer
|
|
1518
1497
|
run_hook "pre-#{task}"
|
1519
1498
|
FILETYPES.each do |type|
|
1520
1499
|
if type == 'ext' and config('without-ext') == 'yes'
|
1521
|
-
|
1500
|
+
warn 'skipping ext/* by user option' if verbose?
|
1522
1501
|
next
|
1523
1502
|
end
|
1524
1503
|
traverse task, type, "#{task}_dir_#{type}"
|
@@ -1527,14 +1506,14 @@ class Installer
|
|
1527
1506
|
end
|
1528
1507
|
|
1529
1508
|
def traverse(task, rel, mid)
|
1530
|
-
dive_into(rel)
|
1509
|
+
dive_into(rel) do
|
1531
1510
|
run_hook "pre-#{task}"
|
1532
|
-
__send__ mid, rel.sub(%r
|
1533
|
-
directories_of(curr_srcdir
|
1511
|
+
__send__ mid, rel.sub(%r{\A.*?(?:/|\z)}, '')
|
1512
|
+
directories_of(curr_srcdir).each do |d|
|
1534
1513
|
traverse task, "#{rel}/#{d}", mid
|
1535
1514
|
end
|
1536
1515
|
run_hook "post-#{task}"
|
1537
|
-
|
1516
|
+
end
|
1538
1517
|
end
|
1539
1518
|
|
1540
1519
|
def dive_into(rel)
|
@@ -1544,29 +1523,29 @@ class Installer
|
|
1544
1523
|
Dir.mkdir dir unless File.dir?(dir)
|
1545
1524
|
prevdir = Dir.pwd
|
1546
1525
|
Dir.chdir dir
|
1547
|
-
|
1526
|
+
warn '---> ' + rel if verbose?
|
1548
1527
|
@currdir = rel
|
1549
1528
|
yield
|
1550
1529
|
Dir.chdir prevdir
|
1551
|
-
|
1530
|
+
warn '<--- ' + rel if verbose?
|
1552
1531
|
@currdir = File.dirname(rel)
|
1553
1532
|
end
|
1554
1533
|
|
1555
1534
|
def run_hook(id)
|
1556
|
-
path = [
|
1557
|
-
|
1535
|
+
path = ["#{curr_srcdir}/#{id}",
|
1536
|
+
"#{curr_srcdir}/#{id}.rb"].detect { |cand| File.file?(cand) }
|
1558
1537
|
return unless path
|
1538
|
+
|
1559
1539
|
begin
|
1560
1540
|
instance_eval File.read(path), path, 1
|
1561
|
-
rescue
|
1541
|
+
rescue StandardError
|
1562
1542
|
raise if $DEBUG
|
1543
|
+
|
1563
1544
|
setup_rb_error "hook #{path} failed:\n" + $!.message
|
1564
1545
|
end
|
1565
1546
|
end
|
1566
|
-
|
1567
1547
|
end # class Installer
|
1568
1548
|
|
1569
|
-
|
1570
1549
|
class SetupError < StandardError; end
|
1571
1550
|
|
1572
1551
|
def setup_rb_error(msg)
|
@@ -1578,8 +1557,9 @@ if $0 == __FILE__
|
|
1578
1557
|
ToplevelInstaller.invoke
|
1579
1558
|
rescue SetupError
|
1580
1559
|
raise if $DEBUG
|
1581
|
-
|
1582
|
-
|
1560
|
+
|
1561
|
+
warn $!.message
|
1562
|
+
warn "Try 'ruby #{$0} --help' for detailed usage."
|
1583
1563
|
exit 1
|
1584
1564
|
end
|
1585
1565
|
end
|