reap 4.3.3 → 4.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. data/COPYING +400 -8
  2. data/ProjectInfo +26 -26
  3. data/ProjectInfo.rb +88 -0
  4. data/bin/reap +1 -1
  5. data/bin/rubytest +1 -1
  6. data/data/reap/scaffold/standard/COPYING +403 -0
  7. data/data/reap/scaffold/{ChangeLog → standard/ChangeLog} +0 -0
  8. data/data/reap/scaffold/standard/INSTALL +14 -0
  9. data/data/reap/scaffold/{ProjectInfo → standard/ProjectInfo} +12 -12
  10. data/data/reap/scaffold/standard/README +3 -0
  11. data/data/reap/scaffold/standard/Rakefile +10 -0
  12. data/data/reap/scaffold/{INSTALL → standard/TODO} +0 -0
  13. data/data/reap/scaffold/subversion/trunk/COPYING +403 -0
  14. data/data/reap/scaffold/{README → subversion/trunk/ChangeLog} +0 -0
  15. data/data/reap/scaffold/subversion/trunk/INSTALL +14 -0
  16. data/data/reap/scaffold/subversion/trunk/ProjectInfo +78 -0
  17. data/data/reap/scaffold/subversion/trunk/README +3 -0
  18. data/data/reap/scaffold/subversion/trunk/Rakefile +10 -0
  19. data/data/reap/scaffold/{Todo → subversion/trunk/TODO} +0 -0
  20. data/data/reap/{setup-3.4.1/setup.rb → setup.rb} +181 -202
  21. data/{ChangeLog → doc/ChangeLog} +0 -0
  22. data/doc/doap.xml +27 -0
  23. data/doc/note/Rakefile.htm +69 -0
  24. data/{note/Rakefile → doc/note/aRakefile} +0 -0
  25. data/{note → doc/note}/composite_task.rb +0 -0
  26. data/{note → doc/note}/compositepublisher.rb +0 -0
  27. data/{note → doc/note}/ftptools.rb +0 -0
  28. data/{note → doc/note}/interface/interface.rb +0 -0
  29. data/{note → doc/note}/interface/rubyforge.rb +0 -0
  30. data/{note → doc/note}/license-each.rb +0 -0
  31. data/{note → doc/note}/package.rb.0 +0 -0
  32. data/{note → doc/note}/publisher.rb +0 -0
  33. data/{note → doc/note}/rubyforgepublisher.rb +0 -0
  34. data/{lib/reap/task → doc/note}/scaffold.rb +4 -3
  35. data/{lib/reap → doc/note}/setup.rb +7 -6
  36. data/{note → doc/note}/sshpublisher.rb +0 -0
  37. data/{note → doc/note}/suby-cvs.rb +0 -0
  38. data/{note → doc/note}/template.rb +0 -0
  39. data/lib/reap/bin/reap.rb +75 -51
  40. data/lib/reap/bin/{lint.rb → rubylint.rb} +0 -0
  41. data/lib/reap/projectinfo.rb +107 -50
  42. data/lib/reap/reap.rb +60 -0
  43. data/lib/reap/task.rb +46 -60
  44. data/lib/reap/task/doap.rb +67 -0
  45. data/lib/reap/task/info.rb +2 -2
  46. data/lib/reap/task/install.rb +29 -18
  47. data/lib/reap/task/package.rb +56 -56
  48. data/lib/reap/task/release.rb +34 -13
  49. data/package.rb +627 -0
  50. data/setup.rb +287 -272
  51. data/test/tc_reap.rb +1 -1
  52. metadata +64 -61
  53. data/ANN +0 -8
  54. data/data/reap/scaffold/COPYING +0 -11
  55. data/data/reap/scaffold/Rakefile +0 -146
  56. data/data/reap/scaffold/setup.rb +0 -1551
  57. data/data/reap/setup-3.4.1/COPYING +0 -515
  58. data/data/reap/setup-3.4.1/ChangeLog +0 -732
  59. data/data/reap/setup-3.4.1/Makefile +0 -56
  60. data/data/reap/setup-3.4.1/NEWS.en +0 -155
  61. data/data/reap/setup-3.4.1/NEWS.ja +0 -152
  62. data/data/reap/setup-3.4.1/README.en +0 -30
  63. data/data/reap/setup-3.4.1/README.ja +0 -34
  64. data/data/reap/setup-3.4.1/TODO +0 -14
  65. data/data/reap/setup-3.4.1/Template.README.en +0 -41
  66. data/data/reap/setup-3.4.1/Template.README.ja +0 -46
  67. data/data/reap/setup-3.4.1/Usage_en.txt +0 -231
  68. data/data/reap/setup-3.4.1/Usage_ja.txt +0 -250
  69. data/data/reap/setup-3.4.1/doc.en/hookapi.html +0 -91
  70. data/data/reap/setup-3.4.1/doc.en/index.html +0 -28
  71. data/data/reap/setup-3.4.1/doc.en/metaconfapi.html +0 -79
  72. data/data/reap/setup-3.4.1/doc.en/news.html +0 -189
  73. data/data/reap/setup-3.4.1/doc.en/usage.html +0 -297
  74. data/data/reap/setup-3.4.1/doc.ja/hookapi.html +0 -84
  75. data/data/reap/setup-3.4.1/doc.ja/index.html +0 -28
  76. data/data/reap/setup-3.4.1/doc.ja/metaconfapi.html +0 -80
  77. data/data/reap/setup-3.4.1/doc.ja/news.html +0 -186
  78. data/data/reap/setup-3.4.1/doc.ja/usage.html +0 -319
  79. data/data/reap/setup-3.4.1/sample/add-task.rb +0 -15
  80. data/data/reap/setup-3.4.1/test/test_installer.rb +0 -136
data/setup.rb CHANGED
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  #
4
2
  # setup.rb
5
3
  #
@@ -10,21 +8,50 @@
10
8
  # the GNU LGPL, Lesser General Public License version 2.1.
11
9
  #
12
10
 
13
- unless Enumerable.method_defined?(:map) # Ruby 1.4.6
14
- module Enumerable
15
- alias map collect
16
- end
11
+ #############################
12
+ # Forked from version 3.2.1 #
13
+ # #
14
+ # -trans #
15
+ #############################
16
+
17
+ # CHANGE No longer need to support 1.4.6 or 1.6 versions of Ruby.
18
+
19
+ # unless Enumerable.method_defined?(:map) # Ruby 1.4.6
20
+ # module Enumerable
21
+ # alias map collect
22
+ # end
23
+ # end
24
+
25
+ # unless File.respond_to?(:read) # Ruby 1.6
26
+ # def File.read(fname)
27
+ # open(fname) {|f|
28
+ # return f.read
29
+ # }
30
+ # end
31
+ # end
32
+
33
+ # This is hack!
34
+ # This is needed to install within an abitrary root dir.
35
+ # B/c setup.rb has become spegetti code, I was forced to do this hack.
36
+ # Setup.rb shuld be re-writ. I would use package.rb instead but
37
+ # it lacks hooks and extension compilation. But we'll keep
38
+ # an eye on that one for the future. -trans.
39
+
40
+ $setup_install_root = nil
41
+ ARGV.each{ |a|
42
+ if md = /--root=(.*)/.match( a )
43
+ $setup_install_root = md[1]
44
+ end
45
+ }
46
+ if $setup_install_root
47
+ ARGV.delete("--root=#{$setup_install_root}")
48
+ $setup_install_root = File.expand_path($setup_install_root)
49
+ puts "(root=#{$setup_install_root})"
17
50
  end
18
51
 
19
- unless File.respond_to?(:read) # Ruby 1.6
20
- def File.read(fname)
21
- open(fname) {|f|
22
- return f.read
23
- }
24
- end
25
- end
52
+ # Windows?
26
53
 
27
- unless Errno.const_defined?(:ENOTEMPTY) # Windows?
54
+ unless Errno.const_defined?(:ENOTEMPTY)
28
55
  module Errno
29
56
  class ENOTEMPTY
30
57
  # We do not raise this exception, implementation is not needed.
@@ -57,25 +84,16 @@ class ConfigTable
57
84
  @config_opt = nil
58
85
  @verbose = true
59
86
  @no_harm = false
60
- @libsrc_pattern = '*.rb'
61
87
  end
62
88
 
63
89
  attr_accessor :install_prefix
64
90
  attr_accessor :config_opt
65
91
 
66
- attr_writer :verbose
67
-
68
- def verbose?
69
- @verbose
70
- end
71
-
72
- attr_writer :no_harm
73
-
74
- def no_harm?
75
- @no_harm
76
- end
92
+ def verbose=(x) @verbose = x end
93
+ def verbose?() @verbose end
77
94
 
78
- attr_accessor :libsrc_pattern
95
+ def no_harm=(x) @no_harm = x end
96
+ def no_harm?() @no_harm end
79
97
 
80
98
  def [](key)
81
99
  lookup(key).resolve(self)
@@ -119,9 +137,7 @@ class ConfigTable
119
137
  end
120
138
  end
121
139
 
122
- def savefile
123
- '.config'
124
- end
140
+ def savefile() '.config' end
125
141
 
126
142
  def load_savefile
127
143
  begin
@@ -144,124 +160,126 @@ class ConfigTable
144
160
  end
145
161
 
146
162
  def load_standard_entries
147
- standard_entries(@rbconfig).each do |ent|
163
+ #standard_entries(@rbconfig).each do |ent|
164
+ standard_entries.each do |ent|
148
165
  add ent
149
166
  end
150
167
  end
151
168
 
152
- def standard_entries(rbconfig)
153
- c = rbconfig
169
+ def standard_entries #(rbconfig)
170
+ rbconfig = @rbconfig
154
171
 
155
- rubypath = c['bindir'] + '/' + c['ruby_install_name']
172
+ rubypath = File.join(rbconfig['bindir'], rbconfig['ruby_install_name'] + rbconfig['EXEEXT'])
156
173
 
157
- major = c['MAJOR'].to_i
158
- minor = c['MINOR'].to_i
159
- teeny = c['TEENY'].to_i
174
+ major = rbconfig['MAJOR'].to_i
175
+ minor = rbconfig['MINOR'].to_i
176
+ teeny = rbconfig['TEENY'].to_i
160
177
  version = "#{major}.#{minor}"
161
178
 
162
- # ruby ver. >= 1.4.4?
163
- newpath_p = ((major >= 2) or
164
- ((major == 1) and
165
- ((minor >= 5) or
166
- ((minor == 4) and (teeny >= 4)))))
179
+ # CHANGE Do not need to support these old versions any more.
180
+
181
+ # # ruby ver. >= 1.4.4?
182
+ # newpath_p = ((major >= 2) or
183
+ # ((major == 1) and
184
+ # ((minor >= 5) or
185
+ # ((minor == 4) and (teeny >= 4)))))
167
186
 
168
- if c['rubylibdir']
187
+ #if c['rubylibdir']
169
188
  # V > 1.6.3
170
- libruby = "#{c['prefix']}/lib/ruby"
171
- librubyver = c['rubylibdir']
172
- librubyverarch = c['archdir']
173
- siteruby = c['sitedir']
174
- siterubyver = c['sitelibdir']
175
- siterubyverarch = c['sitearchdir']
176
- elsif newpath_p
177
- # 1.4.4 <= V <= 1.6.3
178
- libruby = "#{c['prefix']}/lib/ruby"
179
- librubyver = "#{c['prefix']}/lib/ruby/#{version}"
180
- librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
181
- siteruby = c['sitedir']
182
- siterubyver = "$siteruby/#{version}"
183
- siterubyverarch = "$siterubyver/#{c['arch']}"
184
- else
185
- # V < 1.4.4
186
- libruby = "#{c['prefix']}/lib/ruby"
187
- librubyver = "#{c['prefix']}/lib/ruby/#{version}"
188
- librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
189
- siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby"
190
- siterubyver = siteruby
191
- siterubyverarch = "$siterubyver/#{c['arch']}"
192
- end
189
+
190
+ root = '/'
191
+ prefix = rbconfig['prefix']
192
+
193
+ libruby = "#{prefix}/lib/ruby"
194
+ librubyver = rbconfig['rubylibdir']
195
+ librubyverarch = rbconfig['archdir']
196
+ siteruby = rbconfig['sitedir']
197
+ siterubyver = rbconfig['sitelibdir']
198
+ siterubyverarch = rbconfig['sitearchdir']
199
+
200
+ bindir = paramize(rbconfig['bindir'])
201
+ libdir = paramize(rbconfig['libdir'])
202
+ datadir = paramize(rbconfig['datadir'])
203
+ mandir = paramize(rbconfig['mandir'])
204
+ sysconfdir = paramize(rbconfig['sysconfdir'])
205
+ localstatedir = paramize(rbconfig['localstatedir'])
206
+
207
+ # elsif newpath_p
208
+ # # 1.4.4 <= V <= 1.6.3
209
+ # libruby = "#{c['prefix']}/lib/ruby"
210
+ # librubyver = "#{c['prefix']}/lib/ruby/#{version}"
211
+ # librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
212
+ # siteruby = c['sitedir']
213
+ # siterubyver = "$siteruby/#{version}"
214
+ # siterubyverarch = "$siterubyver/#{c['arch']}"
215
+ # else
216
+ # # V < 1.4.4
217
+ # libruby = "#{c['prefix']}/lib/ruby"
218
+ # librubyver = "#{c['prefix']}/lib/ruby/#{version}"
219
+ # librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
220
+ # siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby"
221
+ # siterubyver = siteruby
222
+ # siterubyverarch = "$siterubyver/#{c['arch']}"
223
+ # end
224
+
193
225
  parameterize = lambda {|path|
194
- path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')
226
+ path.sub(/\A#{Regexp.quote(rbconfig['prefix'])}/, '$prefix')
195
227
  }
196
228
 
197
- if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
229
+ if arg = rbconfig['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
198
230
  makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
199
231
  else
200
232
  makeprog = 'make'
201
233
  end
202
234
 
235
+ installdir_lambda = lambda {|val, table|
236
+ case val
237
+ when 'std'
238
+ table['rbdir'] = '$librubyver'
239
+ table['sodir'] = '$librubyverarch'
240
+ when 'site'
241
+ table['rbdir'] = '$siterubyver'
242
+ table['sodir'] = '$siterubyverarch'
243
+ when 'home'
244
+ setup_rb_error '$HOME was not set' unless ENV['HOME']
245
+ table['prefix'] = ENV['HOME']
246
+ table['rbdir'] = '$libdir/ruby'
247
+ table['sodir'] = '$libdir/ruby'
248
+ end
249
+ }
250
+
203
251
  [
204
- ExecItem.new('installdirs', 'std/site/home',
205
- 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\
206
- {|val, table|
207
- case val
208
- when 'std'
209
- table['rbdir'] = '$librubyver'
210
- table['sodir'] = '$librubyverarch'
211
- when 'site'
212
- table['rbdir'] = '$siterubyver'
213
- table['sodir'] = '$siterubyverarch'
214
- when 'home'
215
- setup_rb_error '$HOME was not set' unless ENV['HOME']
216
- table['prefix'] = ENV['HOME']
217
- table['rbdir'] = '$libdir/ruby'
218
- table['sodir'] = '$libdir/ruby'
219
- end
220
- },
221
- PathItem.new('prefix', 'path', c['prefix'],
222
- 'path prefix of target environment'),
223
- PathItem.new('bindir', 'path', parameterize.call(c['bindir']),
224
- 'the directory for commands'),
225
- PathItem.new('libdir', 'path', parameterize.call(c['libdir']),
226
- 'the directory for libraries'),
227
- PathItem.new('datadir', 'path', parameterize.call(c['datadir']),
228
- 'the directory for shared data'),
229
- PathItem.new('mandir', 'path', parameterize.call(c['mandir']),
230
- 'the directory for man pages'),
231
- PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']),
232
- 'the directory for system configuration files'),
233
- PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']),
234
- 'the directory for local state data'),
235
- PathItem.new('libruby', 'path', libruby,
236
- 'the directory for ruby libraries'),
237
- PathItem.new('librubyver', 'path', librubyver,
238
- 'the directory for standard ruby libraries'),
239
- PathItem.new('librubyverarch', 'path', librubyverarch,
240
- 'the directory for standard ruby extensions'),
241
- PathItem.new('siteruby', 'path', siteruby,
242
- 'the directory for version-independent aux ruby libraries'),
243
- PathItem.new('siterubyver', 'path', siterubyver,
244
- 'the directory for aux ruby libraries'),
245
- PathItem.new('siterubyverarch', 'path', siterubyverarch,
246
- 'the directory for aux ruby binaries'),
247
- PathItem.new('rbdir', 'path', '$siterubyver',
248
- 'the directory for ruby scripts'),
249
- PathItem.new('sodir', 'path', '$siterubyverarch',
250
- 'the directory for ruby extentions'),
251
- PathItem.new('rubypath', 'path', rubypath,
252
- 'the path to set to #! line'),
253
- ProgramItem.new('rubyprog', 'name', rubypath,
254
- 'the ruby program using for installation'),
255
- ProgramItem.new('makeprog', 'name', makeprog,
256
- 'the make program to compile ruby extentions'),
257
- SelectItem.new('shebang', 'all/ruby/never', 'ruby',
258
- 'shebang line (#!) editing mode'),
259
- BoolItem.new('without-ext', 'yes/no', 'no',
260
- 'does not compile/install ruby extentions')
252
+ ExecItem.new('installdirs', 'std/site/home', 'install under libruby, site_ruby or $HOME respectively', &installdir_lambda),
253
+ PathItem.new('root', 'path', root, 'root destination directory'),
254
+ PathItem.new('prefix', 'path', prefix, 'path prefix of target environment'),
255
+ PathItem.new('bindir', 'path', bindir, 'the directory for commands'),
256
+ PathItem.new('libdir', 'path', libdir, 'the directory for libraries'),
257
+ PathItem.new('datadir', 'path', datadir, 'the directory for shared data'),
258
+ PathItem.new('mandir', 'path', mandir, 'the directory for man pages'),
259
+ PathItem.new('sysconfdir', 'path', sysconfdir, 'the directory for system configuration files'),
260
+ PathItem.new('localstatedir', 'path', localstatedir, 'the directory for local state data'),
261
+ PathItem.new('libruby', 'path', libruby, 'the directory for ruby libraries'),
262
+ PathItem.new('librubyver', 'path', librubyver, 'the directory for standard ruby libraries'),
263
+ PathItem.new('librubyverarch', 'path', librubyverarch, 'the directory for standard ruby extensions'),
264
+ PathItem.new('siteruby', 'path', siteruby, 'the directory for version-independent aux ruby libraries'),
265
+ PathItem.new('siterubyver', 'path', siterubyver, 'the directory for aux ruby libraries'),
266
+ PathItem.new('siterubyverarch', 'path', siterubyverarch, 'the directory for aux ruby binaries'),
267
+ PathItem.new('rbdir', 'path', '$siterubyver', 'the directory for ruby scripts'),
268
+ PathItem.new('sodir', 'path', '$siterubyverarch', 'the directory for ruby extentions'),
269
+ PathItem.new('rubypath', 'path', rubypath, 'the path to set to #! line'),
270
+ ProgramItem.new('rubyprog', 'name', rubypath, 'the ruby program using for installation'),
271
+ ProgramItem.new('makeprog', 'name', makeprog, 'the make program to compile ruby extentions'),
272
+ SelectItem.new('shebang', 'all/ruby/never', 'ruby', 'shebang line (#!) editing mode'),
273
+ BoolItem.new('without-ext', 'yes/no', 'no', 'does not compile/install ruby extentions')
261
274
  ]
262
275
  end
263
276
  private :standard_entries
264
277
 
278
+ def paramize( path )
279
+ path.sub(/\A#{Regexp.quote(@rbconfig['prefix'])}/, '$prefix')
280
+ end
281
+ private :paramize
282
+
265
283
  def load_multipackage_entries
266
284
  multipackage_entries().each do |ent|
267
285
  add ent
@@ -270,10 +288,8 @@ class ConfigTable
270
288
 
271
289
  def multipackage_entries
272
290
  [
273
- PackageSelectionItem.new('with', 'name,name...', '', 'ALL',
274
- 'package names that you want to install'),
275
- PackageSelectionItem.new('without', 'name,name...', '', 'NONE',
276
- 'package names that you do not want to install')
291
+ PackageSelectionItem.new('with', 'name,name...', '', 'ALL', 'package names that you want to install'),
292
+ PackageSelectionItem.new('without', 'name,name...', '', 'NONE', 'package names that you do not want to install')
277
293
  ]
278
294
  end
279
295
  private :multipackage_entries
@@ -338,13 +354,8 @@ class ConfigTable
338
354
  "--#{@name}=#{@template}"
339
355
  end
340
356
 
341
- def value?
342
- true
343
- end
344
-
345
- def value
346
- @value
347
- end
357
+ def value? ; true ; end
358
+ def value ; @value ; end
348
359
 
349
360
  def resolve(table)
350
361
  @value.gsub(%r<\$([^/]+)>) { table[$1] }
@@ -363,9 +374,7 @@ class ConfigTable
363
374
  end
364
375
 
365
376
  class BoolItem < Item
366
- def config_type
367
- 'bool'
368
- end
377
+ def config_type() 'bool' end
369
378
 
370
379
  def help_opt
371
380
  "--#{@name}"
@@ -375,20 +384,19 @@ class ConfigTable
375
384
 
376
385
  def check(val)
377
386
  return 'yes' unless val
378
- unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val
387
+ case val
388
+ when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes'
389
+ when /\An(o)?\z/i, /\Af(alse)\z/i then 'no'
390
+ else
379
391
  setup_rb_error "config: --#{@name} accepts only yes/no for argument"
380
392
  end
381
- (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no'
382
393
  end
383
394
  end
384
395
 
385
396
  class PathItem < Item
386
- def config_type
387
- 'path'
388
- end
397
+ def config_type() 'path' end
389
398
 
390
399
  private
391
-
392
400
  def check(path)
393
401
  setup_rb_error "config: --#{@name} requires argument" unless path
394
402
  path[0,1] == '$' ? path : File.expand_path(path)
@@ -396,9 +404,7 @@ class ConfigTable
396
404
  end
397
405
 
398
406
  class ProgramItem < Item
399
- def config_type
400
- 'program'
401
- end
407
+ def config_type() 'program' end
402
408
  end
403
409
 
404
410
  class SelectItem < Item
@@ -407,12 +413,9 @@ class ConfigTable
407
413
  @ok = selection.split('/')
408
414
  end
409
415
 
410
- def config_type
411
- 'select'
412
- end
416
+ def config_type() 'select' end
413
417
 
414
418
  private
415
-
416
419
  def check(val)
417
420
  unless @ok.include?(val.strip)
418
421
  setup_rb_error "config: use --#{@name}=#{@template} (#{val})"
@@ -474,7 +477,7 @@ class ConfigTable
474
477
  end
475
478
 
476
479
  class MetaConfigEnvironment
477
- def intiailize(config, installer)
480
+ def initialize(config, installer)
478
481
  @config = config
479
482
  @installer = installer
480
483
  end
@@ -539,7 +542,9 @@ end # class ConfigTable
539
542
  module FileOperations
540
543
 
541
544
  def mkdir_p(dirname, prefix = nil)
542
- dirname = prefix + File.expand_path(dirname) if prefix
545
+ dirname = File.join(prefix, File.expand_path(dirname)) if prefix
546
+ dirname = File.join( $setup_install_root, dirname ) if $setup_install_root
547
+
543
548
  $stderr.puts "mkdir -p #{dirname}" if verbose?
544
549
  return if no_harm?
545
550
 
@@ -623,11 +628,15 @@ module FileOperations
623
628
  end
624
629
 
625
630
  def install(from, dest, mode, prefix = nil)
631
+
632
+ realdest = prefix ? File.join(prefix, File.expand_path(dest)) : dest
633
+ realdest = File.join($setup_install_root, File.expand_path(realdest)) if $setup_install_root
634
+
626
635
  $stderr.puts "install #{from} #{dest}" if verbose?
627
636
  return if no_harm?
628
637
 
629
- realdest = prefix ? prefix + File.expand_path(dest) : dest
630
638
  realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest)
639
+
631
640
  str = File.binread(from)
632
641
  if diff?(str, realdest)
633
642
  verbose_off {
@@ -638,6 +647,10 @@ module FileOperations
638
647
  }
639
648
  File.chmod mode, realdest
640
649
 
650
+ # Do not make InstalledFiles entry if to alternate root.
651
+ # This prevents problem with root permissions on this file.
652
+ return true unless $setup_install_root
653
+
641
654
  File.open("#{objdir_root()}/InstalledFiles", 'a') {|f|
642
655
  if prefix
643
656
  f.puts realdest.sub(prefix, '')
@@ -662,7 +675,7 @@ module FileOperations
662
675
  def ruby(*args)
663
676
  command config('rubyprog'), *args
664
677
  end
665
-
678
+
666
679
  def make(task = nil)
667
680
  command(*[config('makeprog'), task].compact)
668
681
  end
@@ -702,33 +715,14 @@ module HookScriptAPI
702
715
  @config[key] = val
703
716
  end
704
717
 
705
- #
706
718
  # srcdir/objdir (works only in the package directory)
707
- #
708
719
 
709
- def curr_srcdir
710
- "#{srcdir_root()}/#{relpath()}"
711
- end
712
-
713
- def curr_objdir
714
- "#{objdir_root()}/#{relpath()}"
715
- end
716
-
717
- def srcfile(path)
718
- "#{curr_srcdir()}/#{path}"
719
- end
720
-
721
- def srcexist?(path)
722
- File.exist?(srcfile(path))
723
- end
724
-
725
- def srcdirectory?(path)
726
- File.dir?(srcfile(path))
727
- end
728
-
729
- def srcfile?(path)
730
- File.file?(srcfile(path))
731
- end
720
+ def curr_srcdir() "#{srcdir_root()}/#{relpath()}" end
721
+ def curr_objdir() "#{objdir_root()}/#{relpath()}" end
722
+ def srcfile(path) "#{curr_srcdir()}/#{path}" end
723
+ def srcexist?(path) File.exist?(srcfile(path)) end
724
+ def srcdirectory?(path) File.dir?(srcfile(path)) end
725
+ def srcfile?(path) File.file?(srcfile(path)) end
732
726
 
733
727
  def srcentries(path = '.')
734
728
  Dir.open("#{curr_srcdir()}/#{path}") {|d|
@@ -753,7 +747,7 @@ end
753
747
 
754
748
  class ToplevelInstaller
755
749
 
756
- Version = '3.4.0'
750
+ Version = '3.4.1'
757
751
  Copyright = 'Copyright (c) 2000-2005 Minero Aoki'
758
752
 
759
753
  TASKS = [
@@ -767,8 +761,8 @@ class ToplevelInstaller
767
761
  [ 'distclean',"does `make distclean' for each extention" ]
768
762
  ]
769
763
 
770
- def ToplevelInstaller.invoke
771
- config = ConfigTable.new(load_rbconfig())
764
+ def self.invoke
765
+ config = ConfigTable.new(load_rbconfig)
772
766
  config.load_standard_entries
773
767
  config.load_multipackage_entries if multipackage?
774
768
  config.fixup
@@ -776,11 +770,11 @@ class ToplevelInstaller
776
770
  klass.new(File.dirname($0), config).invoke
777
771
  end
778
772
 
779
- def ToplevelInstaller.multipackage?
773
+ def self.multipackage?
780
774
  File.dir?(File.dirname($0) + '/packages')
781
775
  end
782
776
 
783
- def ToplevelInstaller.load_rbconfig
777
+ def self.load_rbconfig
784
778
  if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg }
785
779
  ARGV.delete(arg)
786
780
  load File.expand_path(arg.split(/=/, 2)[1])
@@ -791,6 +785,7 @@ class ToplevelInstaller
791
785
  ::Config::CONFIG
792
786
  end
793
787
 
788
+
794
789
  def initialize(ardir_root, config)
795
790
  @ardir = File.expand_path(ardir_root)
796
791
  @config = config
@@ -829,7 +824,7 @@ class ToplevelInstaller
829
824
  __send__ "exec_#{task}"
830
825
  end
831
826
  end
832
-
827
+
833
828
  def run_metaconfigs
834
829
  @config.load_script "#{@ardir}/metaconfig"
835
830
  end
@@ -842,17 +837,9 @@ class ToplevelInstaller
842
837
  # Hook Script API bases
843
838
  #
844
839
 
845
- def srcdir_root
846
- @ardir
847
- end
848
-
849
- def objdir_root
850
- '.'
851
- end
852
-
853
- def relpath
854
- '.'
855
- end
840
+ def srcdir_root() @ardir end
841
+ def objdir_root() '.' end
842
+ def relpath() '.' end
856
843
 
857
844
  #
858
845
  # Option Parsing
@@ -894,6 +881,7 @@ class ToplevelInstaller
894
881
 
895
882
  def parsearg_no_options
896
883
  unless ARGV.empty?
884
+ task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1)
897
885
  setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}"
898
886
  end
899
887
  end
@@ -981,6 +969,7 @@ class ToplevelInstaller
981
969
  out.puts
982
970
  out.puts 'Options for INSTALL:'
983
971
  out.printf fmt, '--no-harm', 'only display what to do if given', 'off'
972
+ out.printf fmt, '--root=path', 'install root directory (effects all paths)', '/'
984
973
  out.printf fmt, '--prefix=path', 'install path prefix', ''
985
974
  out.puts
986
975
  end
@@ -1175,21 +1164,15 @@ class Installer
1175
1164
  "#<#{self.class} #{File.basename(@srcdir)}>"
1176
1165
  end
1177
1166
 
1167
+ def noop(rel) ; end
1168
+
1178
1169
  #
1179
1170
  # Hook Script API base methods
1180
1171
  #
1181
1172
 
1182
- def srcdir_root
1183
- @srcdir
1184
- end
1185
-
1186
- def objdir_root
1187
- @objdir
1188
- end
1189
-
1190
- def relpath
1191
- @currdir
1192
- end
1173
+ def srcdir_root() @srcdir end
1174
+ def objdir_root() @objdir end
1175
+ def relpath() @currdir end
1193
1176
 
1194
1177
  #
1195
1178
  # Config Access
@@ -1222,29 +1205,21 @@ class Installer
1222
1205
  exec_task_traverse 'config'
1223
1206
  end
1224
1207
 
1225
- def config_dir_bin(rel)
1226
- end
1227
-
1228
- def config_dir_lib(rel)
1229
- end
1230
-
1231
- def config_dir_man(rel)
1232
- end
1208
+ alias config_dir_bin noop
1209
+ alias config_dir_lib noop
1233
1210
 
1234
1211
  def config_dir_ext(rel)
1235
1212
  extconf if extdir?(curr_srcdir())
1236
1213
  end
1237
1214
 
1215
+ alias config_dir_data noop
1216
+ alias config_dir_conf noop
1217
+ alias config_dir_man noop
1218
+
1238
1219
  def extconf
1239
1220
  ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt
1240
1221
  end
1241
1222
 
1242
- def config_dir_data(rel)
1243
- end
1244
-
1245
- def config_dir_conf(rel)
1246
- end
1247
-
1248
1223
  #
1249
1224
  # TASK setup
1250
1225
  #
@@ -1255,43 +1230,89 @@ class Installer
1255
1230
 
1256
1231
  def setup_dir_bin(rel)
1257
1232
  files_of(curr_srcdir()).each do |fname|
1258
- adjust_shebang "#{curr_srcdir()}/#{fname}"
1233
+ update_shebang_line "#{curr_srcdir()}/#{fname}"
1259
1234
  end
1260
1235
  end
1261
1236
 
1262
- def adjust_shebang(path)
1237
+ alias setup_dir_lib noop
1238
+
1239
+ def setup_dir_ext(rel)
1240
+ make if extdir?(curr_srcdir())
1241
+ end
1242
+
1243
+ alias setup_dir_data noop
1244
+ alias setup_dir_conf noop
1245
+ alias setup_dir_man noop
1246
+
1247
+ def update_shebang_line(path)
1263
1248
  return if no_harm?
1249
+ return if config('shebang') == 'never'
1250
+ old = Shebang.load(path)
1251
+ if old
1252
+ $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1
1253
+ new = new_shebang(old)
1254
+ return if new.to_s == old.to_s
1255
+ else
1256
+ return unless config('shebang') == 'all'
1257
+ new = Shebang.new(config('rubypath'))
1258
+ end
1259
+ $stderr.puts "updating shebang: #{File.basename(path)}" if verbose?
1260
+ open_atomic_writer(path) {|output|
1261
+ File.open(path, 'rb') {|f|
1262
+ f.gets if old # discard
1263
+ output.puts new.to_s
1264
+ output.print f.read
1265
+ }
1266
+ }
1267
+ end
1268
+
1269
+ def new_shebang(old)
1270
+ if /\Aruby/ =~ File.basename(old.cmd)
1271
+ Shebang.new(config('rubypath'), old.args)
1272
+ elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby'
1273
+ Shebang.new(config('rubypath'), old.args[1..-1])
1274
+ else
1275
+ return old unless config('shebang') == 'all'
1276
+ Shebang.new(config('rubypath'))
1277
+ end
1278
+ end
1279
+
1280
+ def open_atomic_writer(path, &block)
1264
1281
  tmpfile = File.basename(path) + '.tmp'
1265
1282
  begin
1266
- File.open(path, 'rb') {|r|
1267
- first = r.gets
1268
- return unless File.basename(first.sub(/\A\#!/, '').split[0].to_s) == 'ruby'
1269
- $stderr.puts "adjusting shebang: #{File.basename(path)}" if verbose?
1270
- File.open(tmpfile, 'wb') {|w|
1271
- w.print first.sub(/\A\#!\s*\S+/, '#! ' + config('rubypath'))
1272
- w.write r.read
1273
- }
1274
- }
1275
- move_file tmpfile, File.basename(path)
1283
+ File.open(tmpfile, 'wb', &block)
1284
+ File.rename tmpfile, File.basename(path)
1276
1285
  ensure
1277
1286
  File.unlink tmpfile if File.exist?(tmpfile)
1278
1287
  end
1279
1288
  end
1280
1289
 
1281
- def setup_dir_lib(rel)
1282
- end
1290
+ class Shebang
1291
+ def Shebang.load(path)
1292
+ line = nil
1293
+ File.open(path) {|f|
1294
+ line = f.gets
1295
+ }
1296
+ return nil unless /\A#!/ =~ line
1297
+ parse(line)
1298
+ end
1283
1299
 
1284
- def setup_dir_man(rel)
1285
- end
1300
+ def Shebang.parse(line)
1301
+ cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ')
1302
+ new(cmd, args)
1303
+ end
1286
1304
 
1287
- def setup_dir_ext(rel)
1288
- make if extdir?(curr_srcdir())
1289
- end
1305
+ def initialize(cmd, args = [])
1306
+ @cmd = cmd
1307
+ @args = args
1308
+ end
1290
1309
 
1291
- def setup_dir_data(rel)
1292
- end
1310
+ attr_reader :cmd
1311
+ attr_reader :args
1293
1312
 
1294
- def setup_dir_conf(rel)
1313
+ def to_s
1314
+ "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}")
1315
+ end
1295
1316
  end
1296
1317
 
1297
1318
  #
@@ -1308,7 +1329,7 @@ class Installer
1308
1329
  end
1309
1330
 
1310
1331
  def install_dir_lib(rel)
1311
- install_files rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1332
+ install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644
1312
1333
  end
1313
1334
 
1314
1335
  def install_dir_ext(rel)
@@ -1334,13 +1355,14 @@ class Installer
1334
1355
 
1335
1356
  def install_files(list, dest, mode)
1336
1357
  mkdir_p dest, @config.install_prefix
1358
+ #mkdir_p dest, offset_dir
1337
1359
  list.each do |fname|
1338
1360
  install fname, dest, mode, @config.install_prefix
1339
1361
  end
1340
1362
  end
1341
1363
 
1342
- def rubyscripts
1343
- glob_select(@config.libsrc_pattern, targetfiles())
1364
+ def libfiles
1365
+ glob_reject(%w(*.y *.output), targetfiles())
1344
1366
  end
1345
1367
 
1346
1368
  def rubyextentions(dir)
@@ -1418,7 +1440,11 @@ class Installer
1418
1440
  return
1419
1441
  end
1420
1442
  $stderr.puts 'Running tests...' if verbose?
1421
- require 'test/unit'
1443
+ begin
1444
+ require 'test/unit'
1445
+ rescue LoadError
1446
+ setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.'
1447
+ end
1422
1448
  runner = Test::Unit::AutoRunner.new(true)
1423
1449
  runner.to_run << TESTDIR
1424
1450
  runner.run
@@ -1434,23 +1460,17 @@ class Installer
1434
1460
  rm_f 'InstalledFiles'
1435
1461
  end
1436
1462
 
1437
- def clean_dir_bin(rel)
1438
- end
1439
-
1440
- def clean_dir_lib(rel)
1441
- end
1463
+ alias clean_dir_bin noop
1464
+ alias clean_dir_lib noop
1465
+ alias clean_dir_data noop
1466
+ alias clean_dir_conf noop
1467
+ alias clean_dir_man noop
1442
1468
 
1443
1469
  def clean_dir_ext(rel)
1444
1470
  return unless extdir?(curr_srcdir())
1445
1471
  make 'clean' if File.file?('Makefile')
1446
1472
  end
1447
1473
 
1448
- def clean_dir_data(rel)
1449
- end
1450
-
1451
- def clean_dir_conf(rel)
1452
- end
1453
-
1454
1474
  #
1455
1475
  # TASK distclean
1456
1476
  #
@@ -1461,31 +1481,26 @@ class Installer
1461
1481
  rm_f 'InstalledFiles'
1462
1482
  end
1463
1483
 
1464
- def distclean_dir_bin(rel)
1465
- end
1466
-
1467
- def distclean_dir_lib(rel)
1468
- end
1484
+ alias distclean_dir_bin noop
1485
+ alias distclean_dir_lib noop
1469
1486
 
1470
1487
  def distclean_dir_ext(rel)
1471
1488
  return unless extdir?(curr_srcdir())
1472
1489
  make 'distclean' if File.file?('Makefile')
1473
1490
  end
1474
1491
 
1475
- def distclean_dir_data(rel)
1476
- end
1477
-
1478
- def distclean_dir_conf(rel)
1479
- end
1492
+ alias distclean_dir_data noop
1493
+ alias distclean_dir_conf noop
1494
+ alias distclean_dir_man noop
1480
1495
 
1481
1496
  #
1482
- # lib
1497
+ # Traversing
1483
1498
  #
1484
1499
 
1485
1500
  def exec_task_traverse(task)
1486
1501
  run_hook "pre-#{task}"
1487
1502
  FILETYPES.each do |type|
1488
- if config('without-ext') == 'yes' and type == 'ext'
1503
+ if type == 'ext' and config('without-ext') == 'yes'
1489
1504
  $stderr.puts 'skipping ext/* by user option' if verbose?
1490
1505
  next
1491
1506
  end