-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rb
executable file
·4107 lines (3697 loc) · 99.7 KB
/
build.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env ruby
# build.rb - Monolithic rant script, autogenerated by rant-import 0.5.8.
#
# Copyright (C) 2005 Stefan Lang <[email protected]>
#
# This program is free software.
# You can distribute/modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
require 'getoptlong'
require 'rbconfig'
unless Process::Status.method_defined?(:success?) # new in 1.8.2
class Process::Status
def success?; exitstatus == 0; end
end
end
unless Regexp.respond_to? :union # new in 1.8.1
def Regexp.union(*patterns)
return /(?!)/ if patterns.empty?
Regexp.new(patterns.join("|"))
end
end
if RUBY_VERSION < "1.8.2"
class Array
undef_method :flatten, :flatten!
def flatten
cp = self.dup
cp.flatten!
cp
end
def flatten!
res = []
flattened = false
self.each { |e|
if e.respond_to? :to_ary
res.concat(e.to_ary)
flattened = true
else
res << e
end
}
if flattened
replace(res)
flatten!
self
end
end
end
end
class String
def _rant_sub_ext(ext, new_ext = nil)
if new_ext
self.sub(/#{Regexp.escape ext}$/, new_ext)
else
self.sub(/(\.[^.]*$)|$/, ".#{ext}")
end
end
end
module Rant
VERSION = '0.5.8'
@__rant_no_value__ = Object.new.freeze
def self.__rant_no_value__
@__rant_no_value__
end
module Env
OS = ::Config::CONFIG['target']
RUBY = ::Config::CONFIG['ruby_install_name']
RUBY_BINDIR = ::Config::CONFIG['bindir']
RUBY_EXE = File.join(RUBY_BINDIR, RUBY + ::Config::CONFIG["EXEEXT"])
@@zip_bin = false
@@tar_bin = false
if OS =~ /mswin/i
def on_windows?; true; end
else
def on_windows?; false; end
end
def have_zip?
if @@zip_bin == false
@@zip_bin = find_bin "zip"
end
!@@zip_bin.nil?
end
def have_tar?
if @@tar_bin == false
@@tar_bin = find_bin "tar"
end
!@@tar_bin.nil?
end
def pathes
path = ENV[on_windows? ? "Path" : "PATH"]
return [] unless path
path.split(on_windows? ? ";" : ":")
end
def find_bin bin_name
if on_windows?
bin_name_exe = nil
if bin_name !~ /\.[^\.]{1,3}$/i
bin_name_exe = bin_name + ".exe"
end
pathes.each { |dir|
file = File.join(dir, bin_name)
return file if test(?f, file)
if bin_name_exe
file = File.join(dir, bin_name_exe)
return file if test(?f, file)
end
}
else
pathes.each { |dir|
file = File.join(dir, bin_name)
return file if test(?x, file)
}
end
nil
end
def shell_path path
if on_windows?
path = path.tr("/", "\\")
if path.include? ' '
'"' + path + '"'
else
path
end
else
if path.include? ' '
"'" + path + "'"
else
path
end
end
end
extend self
end # module Env
module Sys
def sp(arg)
if arg.respond_to? :to_ary
arg.to_ary.map{ |e| sp e }.join(' ')
else
_escaped_path arg
end
end
def escape(arg)
if arg.respond_to? :to_ary
arg.to_ary.map{ |e| escape e }.join(' ')
else
_escaped arg
end
end
if Env.on_windows?
def _escaped_path(path)
_escaped(path.to_s.tr("/", "\\"))
end
def _escaped(arg)
sarg = arg.to_s
return sarg unless sarg.include?(" ")
sarg << "\\" if sarg[-1].chr == "\\"
"\"#{sarg}\""
end
def regular_filename(fn)
fn.to_str.tr("\\", "/").gsub(%r{/{2,}}, "/")
end
else
def _escaped_path(path)
path.to_s.gsub(/(?=\s)/, "\\")
end
alias _escaped _escaped_path
def regular_filename(fn)
fn.to_str.gsub(%r{/{2,}}, "/")
end
end
private :_escaped_path
private :_escaped
def split_all(path)
names = regular_filename(path).split(%r{/})
names[0] = "/" if names[0] && names[0].empty?
names
end
extend self
end # module Sys
ROOT_RANTFILE = "root.rant"
SUB_RANTFILE = "sub.rant"
RANTFILES = [ "Rantfile", "rantfile", ROOT_RANTFILE ]
CODE_IMPORTS = []
class RantAbortException < StandardError
end
class RantDoneException < StandardError
end
class Error < StandardError
end
module Generators
end
module RantVar
class Error < Rant::Error
end
class ConstraintError < Error
attr_reader :constraint, :val
def initialize(constraint, val, msg = nil)
@msg = msg
@constraint = constraint
@val = val
end
def message
val_desc = @val.inspect
val_desc[7..-1] = "..." if val_desc.length > 10
"#{val_desc} doesn't match constraint: #@constraint"
end
end
class NotAConstraintFactoryError < Error
attr_reader :obj
def initialize(obj, msg = nil)
@msg = msg
@obj = obj
end
def message
obj_desc = @obj.inspect
obj_desc[7..-1] = "..." if obj_desc.length > 10
"#{obj_desc} is not a valid constraint factory"
end
end
class InvalidVidError < Error
def initialize(vid, msg = nil)
@msg = msg
@vid = vid
end
def message
vid_desc = @vid.inspect
vid_desc[7..-1] = "..." if vid_desc.length > 10
"#{vid_desc} is not a valid var identifier"
end
end
class InvalidConstraintError < Error
end
class QueryError < Error
end
class Space
@@env_ref = Object.new
def initialize
@store = {}
@constraints = {}
end
def query(*args, &block)
case args.size
when 0
raise QueryError, "no arguments", caller
when 1
arg = args.first
if Hash === arg
if arg.size == 1
arg.each { |k,v|
self[k] = v if self[k].nil?
}
self
else
init_all arg
end
else
self[arg]
end
when 2, 3
vid, cf, val = *args
constrain vid,
get_factory(cf).rant_constraint
self[vid] = val if val
else
raise QueryError, "too many arguments"
end
end
def restrict vid, ct, *ct_args
if vid.respond_to? :to_ary
vid.to_ary.each { |v| restrict(v, ct, *ct_args) }
else
constrain vid,
get_factory(ct).rant_constraint(*ct_args)
end
self
end
def get_factory id
if String === id || Symbol === id
id = Constraints.const_get(id) rescue nil
end
unless id.respond_to? :rant_constraint
raise NotAConstraintFactoryError.new(id), caller
end
id
end
private :get_factory
def [](vid)
vid = RantVar.valid_vid vid
val = @store[vid]
val.equal?(@@env_ref) ? ENV[vid] : val
end
def []=(vid, val)
vid = RantVar.valid_vid(vid)
c = @constraints[vid]
if @store[vid] == @@env_ref
ENV[vid] = c ? c.filter(val) : val
else
@store[vid] = c ? c.filter(val) : val
end
end
def env(*vars)
vars.flatten.each { |var|
vid = RantVar.valid_vid(var)
cur_val = @store[vid]
next if cur_val == @@env_ref
ENV[vid] = cur_val unless cur_val.nil?
@store[vid] = @@env_ref
}
nil
end
def set_all hash
unless Hash === hash
raise QueryError,
"set_all argument has to be a hash"
end
hash.each_pair { |k, v|
self[k] = v
}
end
def init_all hash
unless Hash === hash
raise QueryError,
"init_all argument has to be a hash"
end
hash.each_pair { |k, v|
self[k] = v if self[k].nil?
}
end
def constrain vid, constraint
vid = RantVar.valid_vid(vid)
unless RantVar.valid_constraint? constraint
raise InvalidConstraintError, constraint
end
@constraints[vid] = constraint
if @store.member? vid
begin
val = @store[vid]
@store[vid] = constraint.filter(@store[vid])
rescue
@store[vid] = constraint.default
raise ConstraintError.new(constraint, val)
end
else
@store[vid] = constraint.default
end
end
def has_var?(vid)
!self[vid].nil?
end
def _set(vid, val) #:nodoc:
@store[vid] = val
end
def _get(vid) #:nodoc:
@store[vid]
end
def _init(vid, val) #:nodoc:
@store[vid] ||= val
end
end # class Space
module Constraint
def matches? val
filter val
true
rescue
return false
end
end
def valid_vid(obj)
case obj
when String; obj
when Symbol; obj.to_s
else
if obj.respond_to? :to_str
obj.to_str
else
raise InvalidVidError.new(obj)
end
end
end
def valid_constraint?(obj)
obj.respond_to?(:filter) &&
obj.respond_to?(:matches?) &&
obj.respond_to?(:default)
end
module_function :valid_constraint?, :valid_vid
module Constraints
class AutoList
include Constraint
class << self
alias rant_constraint new
end
def filter(val)
if val.respond_to? :to_ary
val.to_ary
elsif val.nil?
raise ConstraintError.new(self, val)
else
[val]
end
end
def default
[]
end
def to_s
"list or single, non-nil value"
end
end
end # module Constraints
end # module RantVar
end # module Rant
require 'fileutils'
module Rant
def FileList(arg)
if arg.respond_to?(:to_rant_filelist)
arg.to_rant_filelist
elsif arg.respond_to?(:to_ary)
FileList.new(arg.to_ary)
else
raise TypeError,
"cannot convert #{arg.class} into Rant::FileList"
end
end
module_function :FileList
class FileList
include Enumerable
ESC_SEPARATOR = Regexp.escape(File::SEPARATOR)
ESC_ALT_SEPARATOR = File::ALT_SEPARATOR ?
Regexp.escape(File::ALT_SEPARATOR) : nil
class << self
def [](*patterns)
new.hide_dotfiles.include(*patterns)
end
def glob(*patterns)
fl = new.hide_dotfiles.ignore(".", "..").include(*patterns)
if block_given? then yield fl else fl end
end
def glob_all(*patterns)
fl = new.ignore(".", "..").include(*patterns)
if block_given? then yield fl else fl end
end
end
def initialize(store = [])
@pending = false
@def_glob_dotfiles = true
@items = store
@ignore_rx = nil
@keep = {}
@actions = []
end
alias _object_dup dup
private :_object_dup
def dup
c = _object_dup
c.items = @items.dup
c.actions = @actions.dup
c.ignore_rx = @ignore_rx.dup if @ignore_rx
c.instance_variable_set(:@keep, @keep.dup)
c
end
def copy
c = _object_dup
c.items = @items.map { |entry| entry.dup }
c.actions = @actions.dup
c.ignore_rx = @ignore_rx.dup if @ignore_rx
h_keep = {}
@keep.each_key { |entry| h_keep[entry] = true }
c.instance_variable_set(:@keep, h_keep)
c
end
def glob_dotfiles?
@def_glob_dotfiles
end
def glob_dotfiles=(flag)
@def_glob_dotfiles = flag ? true : false
end
def hide_dotfiles
@def_glob_dotfiles = false
self
end
def glob_dotfiles
@def_glob_dotfiles = true
self
end
protected
attr_accessor :actions, :items
attr_accessor :pending
attr_accessor :ignore_rx
public
def each(&block)
resolve if @pending
@items.each(&block)
self
end
def to_ary
resolve if @pending
@items
end
alias to_a to_ary
alias entries to_ary # entries: defined in Enumerable
def to_rant_filelist
self
end
def +(other)
if other.respond_to? :to_rant_filelist
c = other.to_rant_filelist.dup
c.actions.concat(@actions)
c.items.concat(@items)
c.pending = !c.actions.empty?
c
elsif other.respond_to? :to_ary
c = dup
c.actions <<
[:apply_ary_method_1, :concat, other.to_ary.dup]
c.pending = true
c
else
raise TypeError,
"cannot add #{other.class} to Rant::FileList"
end
end
def <<(file)
@actions << [:apply_ary_method_1, :push, file]
@keep[file] = true
@pending = true
self
end
def keep(entry)
@keep[entry] = true
@items << entry
self
end
def concat(ary)
if @pending
ary = ary.to_ary.dup
@actions << [:apply_ary_method_1, :concat, ary]
else
ix = ignore_rx and ary = ary.to_ary.reject { |f| f =~ ix }
@items.concat(ary)
end
self
end
def size
resolve if @pending
@items.size
end
alias length size
def empty?
resolve if @pending
@items.empty?
end
def join(sep = ' ')
resolve if @pending
@items.join(sep)
end
def pop
resolve if @pending
@items.pop
end
def push(entry)
resolve if @pending
@items.push(entry) if entry !~ ignore_rx
self
end
def shift
resolve if @pending
@items.shift
end
def unshift(entry)
resolve if @pending
@items.unshift(entry) if entry !~ ignore_rx
self
end
if Object.method_defined?(:fcall) || Object.method_defined?(:funcall) # in Ruby 1.9 like __send__
@@__send_private__ = Object.method_defined?(:fcall) ? :fcall : :funcall
def resolve
@pending = false
@actions.each{ |action| self.__send__(@@__send_private__, *action) }.clear
ix = ignore_rx
if ix
@items.reject! { |f| f =~ ix && !@keep[f] }
end
self
end
else
def resolve
@pending = false
@actions.each{ |action| self.__send__(*action) }.clear
ix = ignore_rx
if ix
@items.reject! { |f| f =~ ix && !@keep[f] }
end
self
end
end
def include(*pats)
@def_glob_dotfiles ? glob_all(*pats) : glob_unix(*pats)
end
alias glob include
def glob_unix(*patterns)
patterns.flatten.each { |pat|
@actions << [:apply_glob_unix, pat]
}
@pending = true
self
end
def glob_all(*patterns)
patterns.flatten.each { |pat|
@actions << [:apply_glob_all, pat]
}
@pending = true
self
end
if RUBY_VERSION < "1.8.2"
FN_DOTFILE_RX_ = ESC_ALT_SEPARATOR ?
/(^|(#{ESC_SEPARATOR}|#{ESC_ALT_SEPARATOR})+)\..*
((#{ESC_SEPARATOR}|#{ESC_ALT_SEPARATOR})+|$)/x :
/(^|#{ESC_SEPARATOR}+)\..* (#{ESC_SEPARATOR}+|$)/x
def apply_glob_unix(pattern)
inc_files = Dir.glob(pattern)
unless pattern =~ /(^|\/)\./
inc_files.reject! { |fn| fn =~ FN_DOTFILE_RX_ }
end
@items.concat(inc_files)
end
else
def apply_glob_unix(pattern)
@items.concat(Dir.glob(pattern))
end
end
private :apply_glob_unix
def apply_glob_all(pattern)
@items.concat(Dir.glob(pattern, File::FNM_DOTMATCH))
end
private :apply_glob_all
def exclude(*patterns)
patterns.each { |pat|
if Regexp === pat
@actions << [:apply_exclude_rx, pat]
else
@actions << [:apply_exclude, pat]
end
}
@pending = true
self
end
def ignore(*patterns)
patterns.each { |pat|
add_ignore_rx(Regexp === pat ? pat : mk_all_rx(pat))
}
@pending = true
self
end
def add_ignore_rx(rx)
@ignore_rx =
if @ignore_rx
Regexp.union(@ignore_rx, rx)
else
rx
end
end
private :add_ignore_rx
def apply_exclude(pattern)
@items.reject! { |elem|
File.fnmatch?(pattern, elem, File::FNM_DOTMATCH) && !@keep[elem]
}
end
private :apply_exclude
def apply_exclude_rx(rx)
@items.reject! { |elem|
elem =~ rx && !@keep[elem]
}
end
private :apply_exclude_rx
def exclude_name(*names)
names.each { |name|
@actions << [:apply_exclude_rx, mk_all_rx(name)]
}
@pending = true
self
end
alias shun exclude_name
if File::ALT_SEPARATOR
def mk_all_rx(file)
/(^|(#{ESC_SEPARATOR}|#{ESC_ALT_SEPARATOR})+)#{Regexp.escape(file)}
((#{ESC_SEPARATOR}|#{ESC_ALT_SEPARATOR})+|$)/x
end
else
def mk_all_rx(file)
/(^|#{ESC_SEPARATOR}+)#{Regexp.escape(file)}
(#{ESC_SEPARATOR}+|$)/x
end
end
private :mk_all_rx
def exclude_path(*patterns)
patterns.each { |pat|
@actions << [:apply_exclude_path, pat]
}
@pending = true
self
end
def apply_exclude_path(pattern)
flags = File::FNM_DOTMATCH|File::FNM_PATHNAME
@items.reject! { |elem|
File.fnmatch?(pattern, elem, flags) && !@keep[elem]
}
end
private :apply_exclude
def select(&block)
d = dup
d.actions << [:apply_select, block]
d.pending = true
d
end
alias find_all select
def apply_select blk
@items = @items.select(&blk)
end
private :apply_select
def map(&block)
d = dup
d.actions << [:apply_ary_method, :map!, block]
d.pending = true
d
end
alias collect map
def sub_ext(ext, new_ext=nil)
map { |f| f._rant_sub_ext ext, new_ext }
end
def ext(ext_str)
sub_ext(ext_str)
end
def arglist
Rant::Sys.sp to_ary
end
alias to_s arglist
alias object_inspect inspect
def uniq!
@actions << [:apply_ary_method, :uniq!]
@pending = true
self
end
def sort!
@actions << [:apply_ary_method, :sort!]
@pending = true
self
end
def map!(&block)
@actions << [:apply_ary_method, :map!, block]
@pending = true
self
end
def reject!(&block)
@actions << [:apply_ary_method, :reject!, block]
@pending = true
self
end
private
def apply_ary_method(meth, block=nil)
@items.send meth, &block
end
def apply_ary_method_1(meth, arg1, block=nil)
@items.send meth, arg1, &block
end
end # class FileList
end # module Rant
if RUBY_VERSION == "1.8.3"
module FileUtils
METHODS = singleton_methods - %w(private_module_function
commands options have_option? options_of collect_method)
module Verbose
class << self
public(*::FileUtils::METHODS)
end
public(*::FileUtils::METHODS)
end
end
end
if RUBY_VERSION < "1.8.1"
module FileUtils
undef_method :fu_list
def fu_list(arg)
arg.respond_to?(:to_ary) ? arg.to_ary : [arg]
end
end
end
module Rant
class RacFileList < FileList
attr_reader :subdir
attr_reader :basedir
def initialize(rac, store = [])
super(store)
@rac = rac
@subdir = @rac.current_subdir
@basedir = Dir.pwd
@ignore_hash = nil
@add_ignore_args = []
update_ignore_rx
end
def dup
c = super
c.instance_variable_set(
:@add_ignore_args, @add_ignore_args.dup)
c
end
def copy
c = super
c.instance_variable_set(
:@add_ignore_args, @add_ignore_args.map { |e| e.dup })
c
end
alias filelist_ignore ignore
def ignore(*patterns)
@add_ignore_args.concat patterns
self
end
def ignore_rx
update_ignore_rx
@ignore_rx
end
alias filelist_resolve resolve
def resolve
Sys.cd(@basedir) { filelist_resolve }
end
def each_cd(&block)
old_pwd = Dir.pwd
Sys.cd(@basedir)
filelist_resolve if @pending
@items.each(&block)
ensure
Sys.cd(old_pwd)
end
private
def update_ignore_rx
ri = @rac.var[:ignore]
ri = ri ? (ri + @add_ignore_args) : @add_ignore_args
rh = ri.hash
unless rh == @ignore_hash
@ignore_rx = nil
filelist_ignore(*ri)
@ignore_hash = rh
end
end
end # class RacFileList
class MultiFileList
attr_reader :cur_list
def initialize(rac)
@rac = rac
@cur_list = RacFileList.new(@rac)
@lists = [@cur_list]
end
def each_entry(&block)
@lists.each { |list|
list.each_cd(&block)
}
end
def add(filelist)
@cur_list = filelist
@lists << filelist
self
end
def method_missing(sym, *args, &block)
if @cur_list && @cur_list.respond_to?(sym)
if @cur_list.subdir == @rac.current_subdir
@cur_list.send(sym, *args, &block)
else
add(RacFileList.new(@rac))
@cur_list.send(sym, *args, &block)
end
else
super
end
end
end # class MultiFileList
class CommandError < StandardError
attr_reader :cmd
attr_reader :status
def initialize(cmd, status=nil, msg=nil)
@msg = msg
@cmd = cmd
@status = status
end
def message
if !@msg && cmd
if status
"Command failed with status #{status.exitstatus}:\n" +
"[#{cmd}]"
else
"Command failed:\n[#{cmd}]"
end
else
@msg
end
end
end
module Sys
include ::FileUtils::Verbose
@symlink_supported = true
class << self
attr_accessor :symlink_supported
end
def fu_output_message(msg) #:nodoc:
end
private :fu_output_message
def fu_each_src_dest(src, *rest)
src = src.to_ary if src.respond_to? :to_ary
super(src, *rest)
end
private :fu_each_src_dest
def sh(*cmd_args, &block)
cmd_args.flatten!
cmd = cmd_args.join(" ")
fu_output_message cmd
success = system(*cmd_args)
if block_given?
block[$?]
elsif !success
raise CommandError.new(cmd, $?)
end
end
def ruby(*args, &block)
if args.empty?