rmagick 1.10.1 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

@@ -29,6 +29,7 @@ def rmdir(dir, no_check=false)
29
29
  end
30
30
  end
31
31
 
32
+
32
33
  # Load up default values
33
34
  rbconfig = 'rbconfig'
34
35
 
@@ -51,22 +52,23 @@ end
51
52
 
52
53
  require rbconfig # get specified/default rbconfig.rb
53
54
 
54
- version = ::Config::CONFIG['MAJOR'] + '.' + ::Config::CONFIG['MINOR']
55
+ version = ::Config::CONFIG['ruby_version']
55
56
  arch = ::Config::CONFIG['arch']
56
57
 
57
58
  prefix ||= ::Config::CONFIG['prefix']
58
- site_ruby ||= prefix+'/lib/ruby/site_ruby/'+version
59
- so_dir ||= prefix+'/lib/ruby/site_ruby/'+version+'/'+arch
60
- doc_dir ||= prefix+'/share/RMagick'
59
+ site_ruby ||= File.join(prefix, 'lib', 'ruby', 'site_ruby', version)
60
+ so_dir ||= File.join(prefix, 'lib', 'ruby', 'site_ruby', version, arch)
61
+ doc_dir ||= File.join(prefix, 'share', 'RMagick')
62
+ dlext = ::Config::CONFIG['DLEXT']
61
63
 
62
- File.safe_unlink("#{site_ruby}/RMagick.rb", true)
63
- File.safe_unlink("#{so_dir}/RMagick.so", true)
64
+ File.safe_unlink File.join(site_ruby, 'RMagick.rb'), true
65
+ File.safe_unlink File.join(so_dir, 'RMagick.' + dlext), true
64
66
 
65
- rmdir("#{site_ruby}/rvg", true)
66
- rmdir(doc_dir+'/ex/images')
67
- rmdir(doc_dir+'/ex')
68
- rmdir(doc_dir+'/css')
69
- rmdir(doc_dir+'/scripts')
70
- rmdir(doc_dir)
67
+ rmdir File.join(site_ruby, 'rvg'), true
68
+ rmdir File.join(doc_dir, 'ex', 'images')
69
+ rmdir File.join(doc_dir, 'ex')
70
+ rmdir File.join(doc_dir, 'css')
71
+ rmdir File.join(doc_dir, 'scripts')
72
+ rmdir doc_dir
71
73
 
72
74
  exit
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rmagick
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.10.1
7
- date: 2006-02-25 00:00:00 -05:00
6
+ version: 1.11.0
7
+ date: 2006-05-11 00:00:00 -04:00
8
8
  summary: RMagick is an interface between the Ruby programming language and the ImageMagick and GraphicsMagick image processing libraries.
9
9
  require_paths:
10
10
  - lib
@@ -36,12 +36,13 @@ files:
36
36
  - README-Mac-OSX.txt
37
37
  - README.txt
38
38
  - configure.ac
39
- - install.rb
39
+ - gem_config.rb
40
40
  - metaconfig.in
41
41
  - post-clean.rb
42
42
  - post-install.rb
43
43
  - post-setup.rb
44
44
  - rmagick.gemspec
45
+ - setup.rb
45
46
  - uninstall.rb
46
47
  - examples
47
48
  - lib
@@ -381,7 +382,7 @@ extra_rdoc_files: []
381
382
  executables: []
382
383
 
383
384
  extensions:
384
- - configure
385
+ - gem_config.rb
385
386
  requirements:
386
387
  - ImageMagick 6.0.0 or later, or GraphicsMagick 1.0.0 or later
387
388
  dependencies: []
data/install.rb DELETED
@@ -1,1018 +0,0 @@
1
- #
2
- # This file is automatically generated. DO NOT MODIFY!
3
- #
4
- # install.rb
5
- #
6
- # Copyright (c) 2000-2002 Minero Aoki <aamine@loveruby.net>
7
- #
8
- # This program is free software.
9
- # You can distribute/modify this program under the terms of
10
- # the GNU Lesser General Public License version 2.
11
- #
12
-
13
- ### begin compat.rb
14
-
15
- unless Enumerable.instance_methods(false).include? 'inject' then
16
- module Enumerable
17
- def inject( result )
18
- each do |i|
19
- result = yield(result, i)
20
- end
21
- result
22
- end
23
- end
24
- end
25
-
26
- def File.read_all( fname )
27
- File.open(fname, 'rb') {|f| return f.read }
28
- end
29
-
30
- def File.write( fname, str )
31
- File.open(fname, 'wb') {|f| f.write str }
32
- end
33
-
34
- ### end compat.rb
35
- ### begin config.rb
36
-
37
- i = ARGV.detect { |arg| arg =~ /\A--rbconfig=/ }
38
-
39
- if i then
40
- i =~ /\A--rbconfig=/
41
- file = $'
42
- ARGV.delete_if { |arg| arg == i }
43
- require file
44
- else
45
- require 'rbconfig'
46
- end
47
-
48
-
49
- class ConfigTable
50
-
51
- c = ::Config::CONFIG
52
-
53
- rubypath = c['bindir'] + '/' + c['ruby_install_name']
54
-
55
- major = c['MAJOR'].to_i
56
- minor = c['MINOR'].to_i
57
- teeny = c['TEENY'].to_i
58
- version = "#{major}.#{minor}"
59
-
60
- # ruby ver. >= 1.4.4?
61
- newpath_p = ((major >= 2) or
62
- ((major == 1) and
63
- ((minor >= 5) or
64
- ((minor == 4) and (teeny >= 4)))))
65
-
66
- re = Regexp.new('\A' + Regexp.quote(c['prefix']))
67
- subprefix = lambda {|path|
68
- re === path and path.sub(re, '$prefix')
69
- }
70
-
71
- if c['rubylibdir'] then
72
- # 1.6.3 < V
73
- stdruby = subprefix.call(c['rubylibdir'])
74
- siteruby = subprefix.call(c['sitedir'])
75
- versite = subprefix.call(c['sitelibdir'])
76
- sodir = subprefix.call(c['sitearchdir'])
77
- elsif newpath_p then
78
- # 1.4.4 <= V <= 1.6.3
79
- stdruby = "$prefix/lib/ruby/#{version}"
80
- siteruby = subprefix.call(c['sitedir'])
81
- versite = siteruby + '/' + version
82
- sodir = "$site-ruby/#{c['arch']}"
83
- else
84
- # V < 1.4.4
85
- stdruby = "$prefix/lib/ruby/#{version}"
86
- siteruby = "$prefix/lib/ruby/#{version}/site_ruby"
87
- versite = siteruby
88
- sodir = "$site-ruby/#{c['arch']}"
89
- end
90
-
91
- DESCRIPTER = [
92
- [ 'prefix', [ c['prefix'],
93
- 'path',
94
- 'path prefix of target environment' ] ],
95
- [ 'std-ruby', [ stdruby,
96
- 'path',
97
- 'the directory for standard ruby libraries' ] ],
98
- [ 'site-ruby-common', [ siteruby,
99
- 'path',
100
- 'the directory for version-independent non-standard ruby libraries' ] ],
101
- [ 'site-ruby', [ versite,
102
- 'path',
103
- 'the directory for non-standard ruby libraries' ] ],
104
- [ 'bin-dir', [ '$prefix/bin',
105
- 'path',
106
- 'the directory for commands' ] ],
107
- [ 'rb-dir', [ '$site-ruby',
108
- 'path',
109
- 'the directory for ruby scripts' ] ],
110
- [ 'so-dir', [ sodir,
111
- 'path',
112
- 'the directory for ruby extentions' ] ],
113
- [ 'data-dir', [ '$prefix/share',
114
- 'path',
115
- 'the directory for shared data' ] ],
116
- [ 'ruby-path', [ rubypath,
117
- 'path',
118
- 'path to set to #! line' ] ],
119
- [ 'ruby-prog', [ rubypath,
120
- 'name',
121
- 'the ruby program using for installation' ] ],
122
- [ 'make-prog', [ 'make',
123
- 'name',
124
- 'the make program to compile ruby extentions' ] ],
125
- [ 'without-ext', [ 'no',
126
- 'yes/no',
127
- 'does not compile/install ruby extentions' ] ]
128
- ]
129
-
130
- SAVE_FILE = 'config.save'
131
-
132
- def ConfigTable.each_name( &block )
133
- keys().each( &block )
134
- end
135
-
136
- def ConfigTable.keys
137
- DESCRIPTER.collect {|k,*dummy| k }
138
- end
139
-
140
- def ConfigTable.each_definition( &block )
141
- DESCRIPTER.each( &block )
142
- end
143
-
144
- def ConfigTable.get_entry( name )
145
- name, ent = DESCRIPTER.assoc(name)
146
- ent
147
- end
148
-
149
- def ConfigTable.get_entry!( name )
150
- get_entry(name) or raise ArgumentError, "no such config: #{name}"
151
- end
152
-
153
- def ConfigTable.add_entry( name, vals )
154
- ConfigTable::DESCRIPTER.push [name,vals]
155
- end
156
-
157
- def ConfigTable.remove_entry( name )
158
- get_entry name or raise ArgumentError, "no such config: #{name}"
159
- DESCRIPTER.delete_if {|n,arr| n == name }
160
- end
161
-
162
- def ConfigTable.config_key?( name )
163
- get_entry(name) ? true : false
164
- end
165
-
166
- def ConfigTable.bool_config?( name )
167
- ent = get_entry(name) or return false
168
- ent[1] == 'yes/no'
169
- end
170
-
171
- def ConfigTable.value_config?( name )
172
- ent = get_entry(name) or return false
173
- ent[1] != 'yes/no'
174
- end
175
-
176
- def ConfigTable.path_config?( name )
177
- ent = get_entry(name) or return false
178
- ent[1] == 'path'
179
- end
180
-
181
-
182
- class << self
183
-
184
- alias newobj new
185
-
186
- def new
187
- c = newobj()
188
- c.__send__ :init
189
- c
190
- end
191
-
192
- def load
193
- c = newobj()
194
- File.file? SAVE_FILE or
195
- raise InstallError, "#{File.basename $0} config first"
196
- File.foreach( SAVE_FILE ) do |line|
197
- k, v = line.split( '=', 2 )
198
- c.instance_eval {
199
- @table[k] = v.strip
200
- }
201
- end
202
- c
203
- end
204
-
205
- end
206
-
207
- def initialize
208
- @table = {}
209
- end
210
-
211
- def init
212
- DESCRIPTER.each do |k, (default, vname, desc, default2)|
213
- @table[k] = default
214
- end
215
- end
216
- private :init
217
-
218
- def save
219
- File.open( SAVE_FILE, 'w' ) {|f|
220
- @table.each do |k, v|
221
- f.printf "%s=%s\n", k, v if v
222
- end
223
- }
224
- end
225
-
226
- def []=( k, v )
227
- ConfigTable.config_key? k or raise InstallError, "unknown config option #{k}"
228
- if ConfigTable.path_config? k then
229
- @table[k] = (v[0,1] != '$') ? File.expand_path(v) : v
230
- else
231
- @table[k] = v
232
- end
233
- end
234
-
235
- def []( key )
236
- @table[key] or return nil
237
- @table[key].gsub( %r<\$([^/]+)> ) { self[$1] }
238
- end
239
-
240
- def set_raw( key, val )
241
- @table[key] = val
242
- end
243
-
244
- def get_raw( key )
245
- @table[key]
246
- end
247
-
248
- end
249
-
250
-
251
- class MetaConfigEnvironment
252
-
253
- def self.eval_file( file )
254
- return unless File.file? file
255
- new.instance_eval File.read_all(file), file, 1
256
- end
257
-
258
- private
259
-
260
- def config_names
261
- ConfigTable.keys
262
- end
263
-
264
- def config?( name )
265
- ConfigTable.config_key? name
266
- end
267
-
268
- def bool_config?( name )
269
- ConfigTable.bool_config? name
270
- end
271
-
272
- def value_config?( name )
273
- ConfigTable.value_config? name
274
- end
275
-
276
- def path_config?( name )
277
- ConfigTable.path_config? name
278
- end
279
-
280
- def add_config( name, argname, default, desc )
281
- ConfigTable.add_entry name,[default,argname,desc]
282
- end
283
-
284
- def add_path_config( name, default, desc )
285
- add_config name, 'path', default, desc
286
- end
287
-
288
- def add_bool_config( name, default, desc )
289
- add_config name, 'yes/no', default ? 'yes' : 'no', desc
290
- end
291
-
292
- def set_config_default( name, default )
293
- if bool_config? name then
294
- ConfigTable.get_entry!(name)[0] = default ? 'yes' : 'no'
295
- else
296
- ConfigTable.get_entry!(name)[0] = default
297
- end
298
- end
299
-
300
- def remove_config( name )
301
- ent = ConfigTable.get_entry(name)
302
- ConfigTable.remove_entry name
303
- ent
304
- end
305
-
306
- end
307
-
308
- ### end config.rb
309
- ### begin fileop.rb
310
-
311
- module FileOperations
312
-
313
- def mkdir_p( dname, prefix = nil )
314
- dname = prefix + dname if prefix
315
- $stderr.puts "mkdir -p #{dname}" if verbose?
316
- return if no_harm?
317
-
318
- # does not check '/'... it's too abnormal case
319
- dirs = dname.split(%r_(?=/)_)
320
- if /\A[a-z]:\z/i === dirs[0] then
321
- disk = dirs.shift
322
- dirs[0] = disk + dirs[0]
323
- end
324
- dirs.each_index do |idx|
325
- path = dirs[0..idx].join('')
326
- Dir.mkdir path unless dir? path
327
- end
328
- end
329
-
330
- def rm_f( fname )
331
- $stderr.puts "rm -f #{fname}" if verbose?
332
- return if no_harm?
333
-
334
- if File.exist? fname or File.symlink? fname then
335
- File.chmod 0777, fname
336
- File.unlink fname
337
- end
338
- end
339
-
340
- def rm_rf( dn )
341
- $stderr.puts "rm -rf #{dn}" if verbose?
342
- return if no_harm?
343
-
344
- Dir.chdir dn
345
- Dir.foreach('.') do |fn|
346
- next if fn == '.'
347
- next if fn == '..'
348
- if dir? fn then
349
- verbose_off {
350
- rm_rf fn
351
- }
352
- else
353
- verbose_off {
354
- rm_f fn
355
- }
356
- end
357
- end
358
- Dir.chdir '..'
359
- Dir.rmdir dn
360
- end
361
-
362
- def mv( src, dest )
363
- rm_f dest
364
- begin
365
- File.link src, dest
366
- rescue
367
- File.write dest, File.read_all(src)
368
- File.chmod File.stat(src).mode, dest
369
- end
370
- rm_f src
371
- end
372
-
373
- def install( from, dest, mode, prefix = nil )
374
- $stderr.puts "install #{from} #{dest}" if verbose?
375
- return if no_harm?
376
-
377
- realdest = prefix + dest if prefix
378
- if dir? realdest then
379
- realdest += '/' + File.basename(from)
380
- end
381
- str = File.read_all(from)
382
- if diff? str, realdest then
383
- verbose_off {
384
- rm_f realdest if File.exist? realdest
385
- }
386
- File.write realdest, str
387
- File.chmod mode, realdest
388
-
389
- File.open( objdir + '/InstalledFiles', 'a' ) {|f| f.puts realdest }
390
- end
391
- end
392
-
393
- def diff?( orig, targ )
394
- return true unless File.exist? targ
395
- orig != File.read_all(targ)
396
- end
397
-
398
- def command( str )
399
- $stderr.puts str if verbose?
400
- system str or raise RuntimeError, "'system #{str}' failed"
401
- end
402
-
403
- def ruby( str )
404
- command config('ruby-prog') + ' ' + str
405
- end
406
-
407
- def dir?( dname )
408
- # for corrupted windows stat()
409
- File.directory?( (dname[-1,1] == '/') ? dname : dname + '/' )
410
- end
411
-
412
- def all_files( dname )
413
- Dir.open( dname ) {|d|
414
- return d.find_all {|n| File.file? "#{dname}/#{n}" }
415
- }
416
- end
417
-
418
- def all_dirs( dname )
419
- Dir.open( dname ) {|d|
420
- return d.find_all {|n| dir? "#{dname}/#{n}" } - %w(. ..)
421
- }
422
- end
423
-
424
- end
425
-
426
- ### end fileop.rb
427
- ### begin base.rb
428
-
429
- class InstallError < StandardError; end
430
-
431
-
432
- class Installer
433
-
434
- Version = '3.1.2'
435
- Copyright = 'Copyright (c) 2000-2002 Minero Aoki'
436
-
437
-
438
- @toplevel = nil
439
-
440
- def self.declear_toplevel_installer( inst )
441
- @toplevel and
442
- raise ArgumentError, 'more than one toplevel installer decleared'
443
- @toplevel = inst
444
- end
445
-
446
- def self.toplevel_installer
447
- @toplevel
448
- end
449
-
450
-
451
- FILETYPES = %w( bin lib ext data )
452
-
453
- include FileOperations
454
-
455
- def initialize( config, opt, srcroot, objroot )
456
- @config = config
457
- @options = opt
458
- @srcdir = File.expand_path(srcroot)
459
- @objdir = File.expand_path(objroot)
460
- @currdir = '.'
461
- end
462
-
463
- def inspect
464
- "#<#{self.class} #{__id__}>"
465
- end
466
-
467
- #
468
- # configs/options
469
- #
470
-
471
- def get_config( key )
472
- @config[key]
473
- end
474
-
475
- alias config get_config
476
-
477
- def set_config( key, val )
478
- @config[key] = val
479
- end
480
-
481
- def no_harm?
482
- @options['no-harm']
483
- end
484
-
485
- def verbose?
486
- @options['verbose']
487
- end
488
-
489
- def verbose_off
490
- save, @options['verbose'] = @options['verbose'], false
491
- yield
492
- @options['verbose'] = save
493
- end
494
-
495
- #
496
- # srcdir/objdir
497
- #
498
-
499
- attr_reader :srcdir
500
- alias srcdir_root srcdir
501
- alias package_root srcdir
502
-
503
- def curr_srcdir
504
- "#{@srcdir}/#{@currdir}"
505
- end
506
-
507
- attr_reader :objdir
508
- alias objdir_root objdir
509
-
510
- def curr_objdir
511
- "#{@objdir}/#{@currdir}"
512
- end
513
-
514
- def srcfile( path )
515
- curr_srcdir + '/' + path
516
- end
517
-
518
- def srcexist?( path )
519
- File.exist? srcfile(path)
520
- end
521
-
522
- def srcdirectory?( path )
523
- dir? srcfile(path)
524
- end
525
-
526
- def srcfile?( path )
527
- File.file? srcfile(path)
528
- end
529
-
530
- def srcentries( path = '.' )
531
- Dir.open( curr_srcdir + '/' + path ) {|d|
532
- return d.to_a - %w(. ..) - hookfilenames
533
- }
534
- end
535
-
536
- def srcfiles( path = '.' )
537
- srcentries(path).find_all {|fname|
538
- File.file? File.join(curr_srcdir, path, fname)
539
- }
540
- end
541
-
542
- def srcdirectories( path = '.' )
543
- srcentries(path).find_all {|fname|
544
- dir? File.join(curr_srcdir, path, fname)
545
- }
546
- end
547
-
548
- def dive_into( rel )
549
- return unless dir? "#{@srcdir}/#{rel}"
550
-
551
- dir = File.basename(rel)
552
- Dir.mkdir dir unless dir? dir
553
- save = Dir.pwd
554
- Dir.chdir dir
555
- $stderr.puts '---> ' + rel if verbose?
556
- @currdir = rel
557
- yield
558
- Dir.chdir save
559
- $stderr.puts '<--- ' + rel if verbose?
560
- @currdir = File.dirname(rel)
561
- end
562
-
563
- #
564
- # config
565
- #
566
-
567
- def exec_config
568
- exec_task_traverse 'config'
569
- end
570
-
571
- def config_dir_bin( rel )
572
- end
573
-
574
- def config_dir_lib( rel )
575
- end
576
-
577
- def config_dir_ext( rel )
578
- extconf if extdir? curr_srcdir
579
- end
580
-
581
- def extconf
582
- opt = @options['config-opt'].join(' ')
583
- command "#{config('ruby-prog')} #{curr_srcdir}/extconf.rb #{opt}"
584
- end
585
-
586
- def config_dir_data( rel )
587
- end
588
-
589
- #
590
- # setup
591
- #
592
-
593
- def exec_setup
594
- exec_task_traverse 'setup'
595
- end
596
-
597
- def setup_dir_bin( relpath )
598
- all_files( curr_srcdir ).each do |fname|
599
- add_rubypath "#{curr_srcdir}/#{fname}"
600
- end
601
- end
602
-
603
- SHEBANG_RE = /\A\#!\s*\S*ruby\S*/
604
-
605
- def add_rubypath( path )
606
- $stderr.puts %Q<set #! line to "\#!#{config('ruby-path')}" for #{path} ...> if verbose?
607
- return if no_harm?
608
-
609
- tmpfile = File.basename(path) + '.tmp'
610
- begin
611
- File.open( path ) {|r|
612
- File.open( tmpfile, 'w' ) {|w|
613
- first = r.gets
614
- return unless SHEBANG_RE === first # reject '/usr/bin/env ruby'
615
-
616
- w.print first.sub( SHEBANG_RE, '#!' + config('ruby-path') )
617
- w.write r.read
618
- } }
619
- mv tmpfile, File.basename(path)
620
- ensure
621
- rm_f tmpfile if File.exist? tmpfile
622
- end
623
- end
624
-
625
- def setup_dir_lib( relpath )
626
- end
627
-
628
- def setup_dir_ext( relpath )
629
- if extdir? curr_srcdir then
630
- make
631
- end
632
- end
633
-
634
- def make
635
- command config('make-prog')
636
- end
637
-
638
- def setup_dir_data( relpath )
639
- end
640
-
641
- #
642
- # install
643
- #
644
-
645
- def exec_install
646
- exec_task_traverse 'install'
647
- end
648
-
649
- def install_dir_bin( rel )
650
- install_files targfiles, config('bin-dir') + '/' + rel, 0755
651
- end
652
-
653
- def install_dir_lib( rel )
654
- install_files targfiles, config('rb-dir') + '/' + rel, 0644
655
- end
656
-
657
- def install_dir_ext( rel )
658
- if extdir? curr_srcdir then
659
- install_dir_ext_main File.dirname(rel)
660
- end
661
- end
662
-
663
- def install_dir_ext_main( rel )
664
- install_files allext('.'), config('so-dir') + '/' + rel, 0555
665
- end
666
-
667
- def install_dir_data( rel )
668
- install_files targfiles, config('data-dir') + '/' + rel, 0644
669
- end
670
-
671
- def install_files( list, dest, mode )
672
- mkdir_p dest, @options['install-prefix']
673
- list.each do |fname|
674
- install fname, dest, mode, @options['install-prefix']
675
- end
676
- end
677
-
678
- def targfiles
679
- (targfilenames() - hookfilenames()).collect {|fname|
680
- File.exist?(fname) ? fname : File.join(curr_srcdir(), fname)
681
- }
682
- end
683
-
684
- def targfilenames
685
- [ curr_srcdir(), '.' ].inject([]) {|ret, dir|
686
- ret | all_files(dir)
687
- }
688
- end
689
-
690
- def hookfilenames
691
- %w( pre-%s post-%s pre-%s.rb post-%s.rb ).collect {|fmt|
692
- %w( config setup install clean ).collect {|t| sprintf fmt, t }
693
- }.flatten
694
- end
695
-
696
- def allext( dir )
697
- _allext(dir) or raise InstallError,
698
- "no extention exists: Have you done 'ruby #{$0} setup' ?"
699
- end
700
-
701
- DLEXT = /\.#{ ::Config::CONFIG['DLEXT'] }\z/
702
-
703
- def _allext( dir )
704
- Dir.open( dir ) {|d|
705
- return d.find_all {|fname| DLEXT === fname }
706
- }
707
- end
708
-
709
- #
710
- # clean
711
- #
712
-
713
- def exec_clean
714
- exec_task_traverse 'clean'
715
- rm_f 'config.save'
716
- rm_f 'InstalledFiles'
717
- end
718
-
719
- def clean_dir_bin( rel )
720
- end
721
-
722
- def clean_dir_lib( rel )
723
- end
724
-
725
- def clean_dir_ext( rel )
726
- clean
727
- end
728
-
729
- def clean
730
- command config('make-prog') + ' clean' if File.file? 'Makefile'
731
- end
732
-
733
- def clean_dir_data( rel )
734
- end
735
-
736
- #
737
- # lib
738
- #
739
-
740
- def exec_task_traverse( task )
741
- run_hook 'pre-' + task
742
- FILETYPES.each do |type|
743
- if config('without-ext') == 'yes' and type == 'ext' then
744
- $stderr.puts 'skipping ext/* by user option' if verbose?
745
- next
746
- end
747
- traverse task, type, task + '_dir_' + type
748
- end
749
- run_hook 'post-' + task
750
- end
751
-
752
- def traverse( task, rel, mid )
753
- dive_into( rel ) {
754
- run_hook 'pre-' + task
755
- __send__ mid, rel.sub( %r_\A.*?(?:/|\z)_, '' )
756
- all_dirs( curr_srcdir ).each do |d|
757
- traverse task, rel + '/' + d, mid
758
- end
759
- run_hook 'post-' + task
760
- }
761
- end
762
-
763
- def run_hook( name )
764
- try_run_hook curr_srcdir + '/' + name or
765
- try_run_hook curr_srcdir + '/' + name + '.rb'
766
- end
767
-
768
- def try_run_hook( fname )
769
- return false unless File.file? fname
770
-
771
- env = self.dup
772
- begin
773
- env.instance_eval File.read_all(fname), fname, 1
774
- rescue
775
- raise InstallError, "hook #{fname} failed:\n" + $!.message
776
- end
777
- true
778
- end
779
-
780
- def extdir?( dir )
781
- File.exist? dir + '/MANIFEST'
782
- end
783
-
784
- end
785
-
786
- ### end base.rb
787
- ### begin toplevel.rb
788
-
789
- class ToplevelInstaller < Installer
790
-
791
- TASKS = [
792
- [ 'config', 'saves your configurations' ],
793
- [ 'show', 'shows current configuration' ],
794
- [ 'setup', 'compiles extention or else' ],
795
- [ 'install', 'installs files' ],
796
- [ 'clean', "does `make clean' for each extention" ]
797
- ]
798
-
799
-
800
- def initialize( root )
801
- super nil, {'verbose' => true}, root, '.'
802
- Installer.declear_toplevel_installer self
803
- end
804
-
805
-
806
- def execute
807
- run_metaconfigs
808
-
809
- case task = parsearg_global()
810
- when 'config'
811
- @config = ConfigTable.new
812
- else
813
- @config = ConfigTable.load
814
- end
815
- parsearg_TASK task
816
-
817
- exectask task
818
- end
819
-
820
-
821
- def run_metaconfigs
822
- MetaConfigEnvironment.eval_file "#{srcdir_root}/#{metaconfig}"
823
- end
824
-
825
- def metaconfig
826
- 'metaconfig'
827
- end
828
-
829
-
830
- def exectask( task )
831
- if task == 'show' then
832
- exec_show
833
- else
834
- try task
835
- end
836
- end
837
-
838
- def try( task )
839
- $stderr.printf "#{File.basename $0}: entering %s phase...\n", task if verbose?
840
- begin
841
- __send__ 'exec_' + task
842
- rescue
843
- $stderr.printf "%s failed\n", task
844
- raise
845
- end
846
- $stderr.printf "#{File.basename $0}: %s done.\n", task if verbose?
847
- end
848
-
849
- #
850
- # processing arguments
851
- #
852
-
853
- def parsearg_global
854
- task_re = /\A(?:#{TASKS.collect {|i| i[0] }.join '|'})\z/
855
-
856
- while arg = ARGV.shift do
857
- case arg
858
- when /\A\w+\z/
859
- task_re === arg or raise InstallError, "wrong task: #{arg}"
860
- return arg
861
-
862
- when '-q', '--quiet'
863
- @options['verbose'] = false
864
-
865
- when '--verbose'
866
- @options['verbose'] = true
867
-
868
- when '-h', '--help'
869
- print_usage $stdout
870
- exit 0
871
-
872
- when '-v', '--version'
873
- puts "#{File.basename $0} version #{Version}"
874
- exit 0
875
-
876
- when '--copyright'
877
- puts Copyright
878
- exit 0
879
-
880
- else
881
- raise InstallError, "unknown global option '#{arg}'"
882
- end
883
- end
884
-
885
- raise InstallError, 'no task or global option given'
886
- end
887
-
888
-
889
- def parsearg_TASK( task )
890
- mid = "parsearg_#{task}"
891
- if respond_to? mid, true then
892
- __send__ mid
893
- else
894
- ARGV.empty? or
895
- raise InstallError, "#{task}: unknown options: #{ARGV.join ' '}"
896
- end
897
- end
898
-
899
- def parsearg_config
900
- re = /\A--(#{ConfigTable.keys.join '|'})(?:=(.*))?\z/
901
- @options['config-opt'] = []
902
-
903
- while i = ARGV.shift do
904
- if /\A--?\z/ === i then
905
- @options['config-opt'] = ARGV.dup
906
- break
907
- end
908
- m = re.match(i) or raise InstallError, "config: unknown option #{i}"
909
- name, value = m.to_a[1,2]
910
- if value then
911
- if ConfigTable.bool_config?(name) then
912
- /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i === value or raise InstallError, "config: --#{name} allows only yes/no for argument"
913
- value = (/\Ay(es)?|\At(rue)/i === value) ? 'yes' : 'no'
914
- end
915
- else
916
- ConfigTable.bool_config?(name) or raise InstallError, "config: --#{name} requires argument"
917
- value = 'yes'
918
- end
919
- @config[name] = value
920
- end
921
- end
922
-
923
- def parsearg_install
924
- @options['no-harm'] = false
925
- @options['install-prefix'] = ''
926
- while a = ARGV.shift do
927
- case a
928
- when /\A--no-harm\z/
929
- @options['no-harm'] = true
930
- when /\A--prefix=(.*)\z/
931
- path = $1
932
- path = File.expand_path(path) unless path[0,1] == '/'
933
- @options['install-prefix'] = path
934
- else
935
- raise InstallError, "install: unknown option #{a}"
936
- end
937
- end
938
- end
939
-
940
-
941
- def print_usage( out )
942
- out.puts
943
- out.puts 'Usage:'
944
- out.puts " ruby #{File.basename $0} <global option>"
945
- out.puts " ruby #{File.basename $0} [<global options>] <task> [<task options>]"
946
-
947
- fmt = " %-20s %s\n"
948
- out.puts
949
- out.puts 'Global options:'
950
- out.printf fmt, '-q,--quiet', 'suppress message outputs'
951
- out.printf fmt, ' --verbose', 'output messages verbosely'
952
- out.printf fmt, '-h,--help', 'print this message'
953
- out.printf fmt, '-v,--version', 'print version and quit'
954
- out.printf fmt, '--copyright', 'print copyright and quit'
955
-
956
- out.puts
957
- out.puts 'Tasks:'
958
- TASKS.each do |name, desc|
959
- out.printf " %-10s %s\n", name, desc
960
- end
961
-
962
- out.puts
963
- out.puts 'Options for config:'
964
- ConfigTable.each_definition do |name, (default, arg, desc, default2)|
965
- out.printf " %-20s %s [%s]\n",
966
- '--'+ name + (ConfigTable.bool_config?(name) ? '' : '='+arg),
967
- desc,
968
- default2 || default
969
- end
970
- out.printf " %-20s %s [%s]\n",
971
- '--rbconfig=path', 'your rbconfig.rb to load', "running ruby's"
972
-
973
- out.puts
974
- out.puts 'Options for install:'
975
- out.printf " %-20s %s [%s]\n",
976
- '--no-harm', 'only display what to do if given', 'off'
977
-
978
- out.puts
979
- end
980
-
981
- #
982
- # config
983
- #
984
-
985
- def exec_config
986
- super
987
- @config.save
988
- end
989
-
990
- #
991
- # show
992
- #
993
-
994
- def exec_show
995
- ConfigTable.each_name do |k|
996
- v = @config.get_raw(k)
997
- if not v or v.empty? then
998
- v = '(not specified)'
999
- end
1000
- printf "%-10s %s\n", k, v
1001
- end
1002
- end
1003
-
1004
- end
1005
-
1006
- ### end toplevel.rb
1007
-
1008
- if $0 == __FILE__ then
1009
- begin
1010
- installer = ToplevelInstaller.new( File.dirname($0) )
1011
- installer.execute
1012
- rescue
1013
- raise if $fDEBUG
1014
- $stderr.puts $!.message
1015
- $stderr.puts "try 'ruby #{$0} --help' for usage"
1016
- exit 1
1017
- end
1018
- end