reap 9.3.1 → 9.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -3
- data/MANIFEST +4 -2
- data/Rakefile +1 -1495
- data/bin/{reap-stamp → reap-version} +0 -0
- data/data/reap/base/Rakefile +1 -1485
- data/data/reap/base/setup.rb +1467 -0
- data/lib/reap/default.yaml +1 -1
- data/lib/reap/project.rb +1 -1
- data/lib/reap/project/package.rb +8 -3
- data/lib/reap/project/rdoc.rb +1 -1
- data/lib/reap/project/rubyforge.rb +5 -0
- data/lib/reap/project/{stamp.rb → version.rb} +43 -5
- data/meta/VERSION +1 -1
- data/setup.rb +1467 -0
- metadata +7 -5
data/CHANGES
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
=== 9.3.
|
1
|
+
=== 9.3.2 // 2008-02-18
|
2
2
|
|
3
|
-
*
|
4
|
-
*
|
3
|
+
* Renamed reap-stamp to reap-version.
|
4
|
+
* Using new setup.rb (3.5.0) which links to the Rakefile.
|
5
5
|
|
6
6
|
=== 9.1.2 // 2008-02-04
|
7
7
|
|
data/MANIFEST
CHANGED
@@ -10,6 +10,7 @@ test/unit/lib/reap/extensions/test_array.rb
|
|
10
10
|
NOTES
|
11
11
|
CHANGES
|
12
12
|
README
|
13
|
+
setup.rb
|
13
14
|
meta
|
14
15
|
meta/project.yaml
|
15
16
|
meta/unixname
|
@@ -52,6 +53,7 @@ lib/reap/project/make.rb
|
|
52
53
|
lib/reap/project/log.rb
|
53
54
|
lib/reap/project/test.rb
|
54
55
|
lib/reap/project/site.rb
|
56
|
+
lib/reap/project/version.rb
|
55
57
|
lib/reap/project/rubyforge.rb
|
56
58
|
lib/reap/project/html.rb
|
57
59
|
lib/reap/project/stats.rb
|
@@ -60,7 +62,6 @@ lib/reap/project/scaffold.rb
|
|
60
62
|
lib/reap/project/clean.rb
|
61
63
|
lib/reap/project/publish.rb
|
62
64
|
lib/reap/project/spec.rb
|
63
|
-
lib/reap/project/stamp.rb
|
64
65
|
lib/reap/project/svn.rb
|
65
66
|
lib/reap/project/scm.rb
|
66
67
|
lib/reap/project/package.rb
|
@@ -81,6 +82,7 @@ data/reap/base/test/template.rb
|
|
81
82
|
data/reap/base/NOTES
|
82
83
|
data/reap/base/CHANGES
|
83
84
|
data/reap/base/README.erb
|
85
|
+
data/reap/base/setup.rb
|
84
86
|
data/reap/base/meta
|
85
87
|
data/reap/base/meta/unixname.erb
|
86
88
|
data/reap/base/lib
|
@@ -99,6 +101,7 @@ bin/reap-log
|
|
99
101
|
bin/reap-test-cross
|
100
102
|
bin/reap-check-syntax
|
101
103
|
bin/reap-make-static
|
104
|
+
bin/reap-version
|
102
105
|
bin/reap-make-distclean
|
103
106
|
bin/reap-clobber
|
104
107
|
bin/reap-install-gem
|
@@ -113,7 +116,6 @@ bin/reap-rollout
|
|
113
116
|
bin/reap-spec
|
114
117
|
bin/reap-prepare
|
115
118
|
bin/reap-test-load
|
116
|
-
bin/reap-stamp
|
117
119
|
bin/reap-announce
|
118
120
|
bin/reap-test
|
119
121
|
bin/reap-clean
|
data/Rakefile
CHANGED
@@ -1,1496 +1,2 @@
|
|
1
|
-
|
2
|
-
require 'optparse'
|
3
|
-
require 'rbconfig'
|
4
|
-
|
5
|
-
# TODO: Is this the best way to do this? Is there any other way?
|
6
|
-
PACKAGE = (
|
7
|
-
if file = Dir['{.,meta/}unixname{,.txt}'].first
|
8
|
-
File.read(file).strip
|
9
|
-
else
|
10
|
-
abort "Requires package unix-name. Edit .unixname or meta/unixname."
|
11
|
-
end
|
12
|
-
)
|
13
|
-
GENERATE_DOCS = true # TODO: maybe just check if it already exists instead?
|
14
|
-
|
15
|
-
# UberTask defines all the tasks one needs for the typical end-user
|
16
|
-
# to configure, compile, test and install a package to their system.
|
17
|
-
|
18
|
-
class UberTask
|
19
|
-
|
20
|
-
attr_accessor :package
|
21
|
-
attr_accessor :gendocs
|
22
|
-
|
23
|
-
attr :config
|
24
|
-
|
25
|
-
#
|
26
|
-
def initialize(package_name, generate_docs=true) #:yield:
|
27
|
-
@package = package_name
|
28
|
-
@gendocs = generate_docs
|
29
|
-
@config = Configure.new
|
30
|
-
yield[self] if block_given?
|
31
|
-
define
|
32
|
-
end
|
33
|
-
|
34
|
-
#
|
35
|
-
def define
|
36
|
-
# Default task will compile and test.
|
37
|
-
|
38
|
-
task :default => [:setup, :test]
|
39
|
-
|
40
|
-
#
|
41
|
-
# TASK config
|
42
|
-
#
|
43
|
-
|
44
|
-
desc "Configure for your system."
|
45
|
-
task :config => [:config_load] do
|
46
|
-
config.quiet = Rake.application.options.silent
|
47
|
-
config.exec_config
|
48
|
-
end
|
49
|
-
|
50
|
-
if File.exist?(Configure::FILENAME)
|
51
|
-
desc "Reconfigure for your system."
|
52
|
-
task :reconfig do
|
53
|
-
config.quiet = Rake.application.options.silent
|
54
|
-
config.exec_config
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
#
|
59
|
-
|
60
|
-
task :config_load do
|
61
|
-
if File.file?('.config')
|
62
|
-
config.load
|
63
|
-
else
|
64
|
-
abort "Run rake config first."
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
#
|
69
|
-
# TASK show
|
70
|
-
#
|
71
|
-
|
72
|
-
desc "Display current configuraiton."
|
73
|
-
task :show do
|
74
|
-
config.show
|
75
|
-
end
|
76
|
-
|
77
|
-
#
|
78
|
-
# TASK clean & clobber
|
79
|
-
#
|
80
|
-
|
81
|
-
require 'rake/clean'
|
82
|
-
|
83
|
-
CLOBBER.include(Configure::FILENAME)
|
84
|
-
CLOBBER.include(Installer::MANIFEST)
|
85
|
-
CLOBBER.include(File.join('doc', PACKAGE, 'rdoc')) if GENERATE_DOCS
|
86
|
-
|
87
|
-
task :clean => [:makeclean]
|
88
|
-
task :clobber => [:distclean]
|
89
|
-
|
90
|
-
task :makeclean do
|
91
|
-
config.extensions.each do |dir|
|
92
|
-
Dir.chdir(dir) do
|
93
|
-
config.make 'clean' if File.file?('Makefile')
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
task :distclean do
|
99
|
-
config.extensions.each do |dir|
|
100
|
-
Dir.chdir(dir) do
|
101
|
-
config.make 'distclean' if File.file?('Makefile')
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
#
|
107
|
-
# TASK all
|
108
|
-
#
|
109
|
-
|
110
|
-
if File.exist?('.config')
|
111
|
-
desc "Setup, test, document and install."
|
112
|
-
task :all => [:setup, :test, :doc, :index, :install]
|
113
|
-
else
|
114
|
-
# shortcut
|
115
|
-
desc "Configure, setup, test, document and install."
|
116
|
-
task :all => [:config, :setup, :test, :doc, :install]
|
117
|
-
end
|
118
|
-
|
119
|
-
#
|
120
|
-
# TASK setup
|
121
|
-
#
|
122
|
-
|
123
|
-
# TODO: No shebang until it works at install time and doesn't overwrite the repo scripts.
|
124
|
-
|
125
|
-
desc "Compile extensions." # update shebangs
|
126
|
-
task :setup => [:config_load, :extconf, :make] #, :shebang]
|
127
|
-
|
128
|
-
task :extconf => [:config_load] do
|
129
|
-
config.extensions.each do |dir|
|
130
|
-
next if File.file?(File.join(dir, 'Makefile'))
|
131
|
-
Dir.chdir(dir) do
|
132
|
-
config.ruby('extconf.rb', config.configopt)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
task :make => [:config_load] do
|
138
|
-
config.extensions.each do |dir|
|
139
|
-
Dir.chdir(dir) do
|
140
|
-
config.make
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
task :shebang => [:config_load, :installer] do
|
146
|
-
Dir.chdir('bin') do
|
147
|
-
executables = Dir['*'].select{ |f| File.file?(f) }
|
148
|
-
executables.each do |file|
|
149
|
-
INSTALLER.update_shebang_line(file)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
#
|
155
|
-
# TASK test
|
156
|
-
#
|
157
|
-
|
158
|
-
# You can provide a test/suite.rb file to be run if
|
159
|
-
# by the testrb command, if you special testing requirements.
|
160
|
-
|
161
|
-
desc "Run unit tests."
|
162
|
-
task :test => [:config_load, :setup] do
|
163
|
-
runner = config.testrunner
|
164
|
-
# build testrb options
|
165
|
-
opt = []
|
166
|
-
opt << " -v" if verbose?
|
167
|
-
opt << " --runner #{runner}"
|
168
|
-
if File.file?('test/suite.rb')
|
169
|
-
notests = false
|
170
|
-
opt << "test/suite.rb"
|
171
|
-
else
|
172
|
-
notests = Dir["test/**/*.rb"].empty?
|
173
|
-
lib = ["lib"] + config.extensions.collect{ |d| File.dirname(d) }
|
174
|
-
opt << "-I" + lib.join(':')
|
175
|
-
opt << Dir["test/**/{test,tc}*.rb"]
|
176
|
-
end
|
177
|
-
opt = opt.flatten.join(' ').strip
|
178
|
-
# run tests
|
179
|
-
if notests
|
180
|
-
$stderr.puts 'No tests.' #if verbose?
|
181
|
-
else
|
182
|
-
cmd = "testrb #{opt}"
|
183
|
-
$stderr.puts cmd if verbose?
|
184
|
-
system cmd #config.ruby "-S tesrb", opt
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
#
|
189
|
-
# TASK doc
|
190
|
-
#
|
191
|
-
|
192
|
-
# If a .document file is available, it will be
|
193
|
-
# used to compile the list of toplevel files
|
194
|
-
# to document. (For some reason it doesn't use
|
195
|
-
# the .document file on it's own.)
|
196
|
-
#
|
197
|
-
# Note that this places the rdoc in doc/name/rdoc,
|
198
|
-
# So that they are subsequently installed to your
|
199
|
-
# system by the installer. To prevent this use
|
200
|
-
# the @without_doc@ config option.
|
201
|
-
|
202
|
-
if GENERATE_DOCS
|
203
|
-
desc "Generate html docs."
|
204
|
-
task :doc => [:config_load] do
|
205
|
-
output = File.join('doc', PACKAGE, 'rdoc')
|
206
|
-
title = (PACKAGE.capitalize + " API").strip
|
207
|
-
main = Dir.glob("README{,.txt}", File::FNM_CASEFOLD).first
|
208
|
-
template = config.rdoctemplate || 'html'
|
209
|
-
|
210
|
-
opt = []
|
211
|
-
opt << "-U"
|
212
|
-
opt << "-S"
|
213
|
-
opt << "--op=#{output}"
|
214
|
-
opt << "--template=#{template}"
|
215
|
-
opt << "--title=#{title}"
|
216
|
-
opt << "--main=#{main}" if main
|
217
|
-
|
218
|
-
if File.exist?('.document')
|
219
|
-
files = File.read('.document').split("\n")
|
220
|
-
files.reject!{ |l| l =~ /^\s*[#]/ || l !~ /\S/ }
|
221
|
-
files.collect!{ |f| f.strip }
|
222
|
-
opt << files
|
223
|
-
else
|
224
|
-
opt << main if main
|
225
|
-
opt << ["lib", "ext"]
|
226
|
-
end
|
227
|
-
|
228
|
-
opt = opt.flatten
|
229
|
-
|
230
|
-
if no_harm?
|
231
|
-
puts "rdoc #{opt.join(' ').strip}"
|
232
|
-
else
|
233
|
-
#sh "rdoc {opt.join(' ').strip}"
|
234
|
-
require 'rdoc/rdoc'
|
235
|
-
::RDoc::RDoc.new.document(opt)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
else
|
239
|
-
task :doc do
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
#
|
244
|
-
# TASK index
|
245
|
-
#
|
246
|
-
|
247
|
-
# This task generates and installs the ri docs to
|
248
|
-
# the designated installdirs-based location.
|
249
|
-
#
|
250
|
-
# It is unfortunate that this isn't more like rdocing.
|
251
|
-
# In that we can't first generate them, then install them.
|
252
|
-
# We have to do it all at once. We may be able to fix this
|
253
|
-
# later, but it requires special action by the installer,
|
254
|
-
# so it will have to wait.
|
255
|
-
|
256
|
-
desc "Generate and install index docs."
|
257
|
-
task :index => [:config_load] do
|
258
|
-
case config.installdirs
|
259
|
-
when 'std'
|
260
|
-
output = "--ri-system"
|
261
|
-
when 'site'
|
262
|
-
output = "--ri-site"
|
263
|
-
when 'home'
|
264
|
-
output = "--ri"
|
265
|
-
else
|
266
|
-
abort "bad config: sould not be possible -- installdirs = #{config.installdirs}"
|
267
|
-
end
|
268
|
-
|
269
|
-
opt = []
|
270
|
-
|
271
|
-
if File.exist?('.document')
|
272
|
-
files = File.read('.document').split("\n")
|
273
|
-
files.reject!{ |l| l =~ /^\s*[#]/ || l !~ /\S/ }
|
274
|
-
files.collect!{ |f| f.strip }
|
275
|
-
opt << files
|
276
|
-
else
|
277
|
-
opt << ["lib", "ext"]
|
278
|
-
end
|
279
|
-
|
280
|
-
opt << "-U"
|
281
|
-
opt << output
|
282
|
-
opt << files
|
283
|
-
opt = opt.flatten
|
284
|
-
|
285
|
-
if no_harm?
|
286
|
-
puts "rdoc #{opt.join(' ').strip}"
|
287
|
-
else
|
288
|
-
#sh "rdoc #{opt.join(' ').strip}"
|
289
|
-
require 'rdoc/rdoc'
|
290
|
-
::RDoc::RDoc.new.document(opt)
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
#
|
295
|
-
# TASK install & uninstall
|
296
|
-
#
|
297
|
-
|
298
|
-
# Install uses the installation procedures developed by Minero Aoki
|
299
|
-
# for setup.rb. Over time it would be nice to "rakeify" these. Every
|
300
|
-
# file installed is listed in the install manifest (.installedfiles).
|
301
|
-
#
|
302
|
-
# The uninstall task simply reads the install manifest, and removes
|
303
|
-
# the files listed there from your system. Note, when you use the
|
304
|
-
# clobber task, this file is removed. So be sure not to clobber,
|
305
|
-
# if you pan to uninstall!
|
306
|
-
#
|
307
|
-
# TODO: Maybe the install manifest should never be clobber, expect
|
308
|
-
# after an uninstall?
|
309
|
-
|
310
|
-
desc "Install package files."
|
311
|
-
task :install => [:config_load, :setup, :installer] do
|
312
|
-
@installer.exec_install
|
313
|
-
unless config.without_index?
|
314
|
-
Rake::Task[:index].invoke
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
if Installer.uninstallable?
|
319
|
-
desc "Remove previously installed files."
|
320
|
-
task :uninstall => [:confg_load, :installer] do
|
321
|
-
@installer.exec_uninstall
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
task :installer do
|
326
|
-
@installer = Installer.new(config)
|
327
|
-
@installer.verbose = env('verbose')
|
328
|
-
@installer.no_harm = env('noharm')
|
329
|
-
end
|
330
|
-
|
331
|
-
#
|
332
|
-
# TASK help
|
333
|
-
#
|
334
|
-
|
335
|
-
# Yea, we all need help some times ;)
|
336
|
-
|
337
|
-
desc "Display config help information."
|
338
|
-
task :help do
|
339
|
-
puts Configure::HELP
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
# Get environament variables.
|
344
|
-
|
345
|
-
def env(*keys)
|
346
|
-
key = keys.find{ |k| ENV[k.to_s] || ENV[k.to_s.downcase] || ENV[k.to_s.upcase] }
|
347
|
-
ENV[key] if key
|
348
|
-
end
|
349
|
-
|
350
|
-
def verbose?
|
351
|
-
env('verbose')
|
352
|
-
end
|
353
|
-
|
354
|
-
def no_harm?
|
355
|
-
env('noharm','nowrite')
|
356
|
-
end
|
357
|
-
|
358
|
-
end
|
359
|
-
|
360
|
-
# Configure class is used to generate the .config file
|
361
|
-
# contining the settings used for installing a package.
|
362
|
-
# These settings can be altered by the user if required
|
363
|
-
# for their particular system, either via the command line
|
364
|
-
# or environment variables.
|
365
|
-
|
366
|
-
class Configure
|
367
|
-
|
368
|
-
Version = [1,0,0]
|
369
|
-
Copyright = "Copyright (c) 2008 Trans"
|
370
|
-
|
371
|
-
Error = Class.new(StandardError)
|
372
|
-
|
373
|
-
RBCONFIG = ::Config::CONFIG
|
374
|
-
FILENAME = '.config'
|
375
|
-
|
376
|
-
DESCRIPTIONS = [
|
377
|
-
[:prefix , 'Path prefix of target environment'],
|
378
|
-
[:bindir , 'Directory for commands'],
|
379
|
-
[:libdir , 'Directory for libraries'],
|
380
|
-
[:datadir , 'Directory for shared data'],
|
381
|
-
[:mandir , 'Directory for man pages'],
|
382
|
-
[:docdir , 'Directory for documentation'],
|
383
|
-
[:sysconfdir , 'Directory for system configuration files'],
|
384
|
-
[:localstatedir , 'Directory for local state data'],
|
385
|
-
[:libruby , 'Directory for ruby libraries'],
|
386
|
-
[:librubyver , 'Directory for standard ruby libraries'],
|
387
|
-
[:librubyverarch , 'Directory for standard ruby extensions'],
|
388
|
-
[:siteruby , 'Directory for version-independent aux ruby libraries'],
|
389
|
-
[:siterubyver , 'Directory for aux ruby libraries'],
|
390
|
-
[:siterubyverarch , 'Directory for aux ruby binaries'],
|
391
|
-
[:rbdir , 'Directory for ruby scripts'],
|
392
|
-
[:sodir , 'Directory for ruby extentions'],
|
393
|
-
[:rubypath , 'Path to set to #! line'],
|
394
|
-
[:rubyprog , 'Ruby program using for installation'],
|
395
|
-
[:makeprog , 'Make program to compile ruby extentions'],
|
396
|
-
[:without_ext , 'Do not compile/install ruby extentions'],
|
397
|
-
[:without_doc , 'Do not install docs'],
|
398
|
-
[:without_index , 'Do not generate ri docs'],
|
399
|
-
[:shebang , 'Shebang line (#!) editing mode (all,ruby,never)'],
|
400
|
-
[:installdirs , 'Install location mode (std,site,home)'],
|
401
|
-
[:testrunner , 'Runner to use for testing (console|tk|gtk|gtk2)'],
|
402
|
-
[:rdoctemplate , 'Document template to use (html)']
|
403
|
-
]
|
404
|
-
|
405
|
-
# List of configurable options.
|
406
|
-
OPTIONS = DESCRIPTIONS.collect{ |(k,v)| k.to_s }
|
407
|
-
|
408
|
-
# Pathname attribute. Pathnames are automatically expanded
|
409
|
-
# unless they start with '$', a path variable.
|
410
|
-
def self.attr_pathname(name)
|
411
|
-
class_eval %{
|
412
|
-
def #{name}
|
413
|
-
@#{name}.gsub(%r<\\$([^/]+)>){ self[$1] }
|
414
|
-
end
|
415
|
-
def #{name}=(path)
|
416
|
-
raise Error, "bad config: #{name.to_s.upcase} requires argument" unless path
|
417
|
-
@#{name} = (path[0,1] == '$' ? path : File.expand_path(path))
|
418
|
-
end
|
419
|
-
}
|
420
|
-
end
|
421
|
-
|
422
|
-
# List of pathnames. These are not expanded though.
|
423
|
-
def self.attr_pathlist(name)
|
424
|
-
class_eval %{
|
425
|
-
def #{name}
|
426
|
-
@#{name}
|
427
|
-
end
|
428
|
-
def #{name}=(pathlist)
|
429
|
-
case pathlist
|
430
|
-
when Array
|
431
|
-
@#{name} = pathlist
|
432
|
-
else
|
433
|
-
@#{name} = pathlist.to_s.split(/[:;,]/)
|
434
|
-
end
|
435
|
-
end
|
436
|
-
}
|
437
|
-
end
|
438
|
-
|
439
|
-
# Adds boolean support.
|
440
|
-
def self.attr_accessor(*names)
|
441
|
-
bools, attrs = names.partition{ |name| name.to_s =~ /\?$/ }
|
442
|
-
attr_boolean *bools
|
443
|
-
super *attrs
|
444
|
-
end
|
445
|
-
|
446
|
-
# Boolean attribute. Can be assigned true, false, nil, or
|
447
|
-
# a string matching yes|true|y|t or no|false|n|f.
|
448
|
-
def self.attr_boolean(*names)
|
449
|
-
names.each do |name|
|
450
|
-
name = name.to_s.chomp('?')
|
451
|
-
attr_reader name # MAYBE: Deprecate
|
452
|
-
code = %{
|
453
|
-
def #{name}?; @#{name}; end
|
454
|
-
def #{name}=(val)
|
455
|
-
case val
|
456
|
-
when true, false, nil
|
457
|
-
@#{name} = val
|
458
|
-
else
|
459
|
-
case val.to_s.downcase
|
460
|
-
when 'y', 'yes', 't', 'true'
|
461
|
-
@#{name} = true
|
462
|
-
when 'n', 'no', 'f', 'false'
|
463
|
-
@#{name} = false
|
464
|
-
else
|
465
|
-
raise Error, "bad config: use #{name.upcase}=(yes|no) [\#{val}]"
|
466
|
-
end
|
467
|
-
end
|
468
|
-
end
|
469
|
-
}
|
470
|
-
class_eval code
|
471
|
-
end
|
472
|
-
end
|
473
|
-
|
474
|
-
# path prefix of target environment
|
475
|
-
attr_pathname :prefix
|
476
|
-
|
477
|
-
# directory for commands
|
478
|
-
attr_pathname :bindir
|
479
|
-
|
480
|
-
#directory for libraries
|
481
|
-
attr_pathname :libdir
|
482
|
-
|
483
|
-
# directory for shared data
|
484
|
-
attr_pathname :datadir
|
485
|
-
|
486
|
-
# directory for man pages
|
487
|
-
attr_pathname :mandir
|
488
|
-
|
489
|
-
# directory for documentation
|
490
|
-
attr_pathname :docdir
|
491
|
-
|
492
|
-
# directory for system configuration files
|
493
|
-
attr_pathname :sysconfdir
|
494
|
-
|
495
|
-
# directory for local state data
|
496
|
-
attr_pathname :localstatedir
|
497
|
-
|
498
|
-
# directory for ruby libraries
|
499
|
-
attr_pathname :libruby
|
500
|
-
|
501
|
-
# directory for standard ruby libraries
|
502
|
-
attr_pathname :librubyver
|
503
|
-
|
504
|
-
# directory for standard ruby extensions
|
505
|
-
attr_pathname :librubyverarch
|
506
|
-
|
507
|
-
# directory for version-independent aux ruby libraries
|
508
|
-
attr_pathname :siteruby
|
509
|
-
|
510
|
-
# directory for aux ruby libraries
|
511
|
-
attr_pathname :siterubyver
|
512
|
-
|
513
|
-
# directory for aux ruby binaries
|
514
|
-
attr_pathname :siterubyverarch
|
515
|
-
|
516
|
-
# directory for ruby scripts
|
517
|
-
attr_pathname :rbdir
|
518
|
-
|
519
|
-
# directory for ruby extentions
|
520
|
-
attr_pathname :sodir
|
521
|
-
|
522
|
-
# path to set to #! line
|
523
|
-
attr_accessor :rubypath
|
524
|
-
|
525
|
-
# ruby program using for installation
|
526
|
-
attr_accessor :rubyprog
|
527
|
-
|
528
|
-
# program to compile ruby extentions
|
529
|
-
attr_accessor :makeprog
|
530
|
-
|
531
|
-
# shebang line (#!) editing mode (all,ruby,never)', 'all/ruby/never
|
532
|
-
attr_accessor :shebang
|
533
|
-
|
534
|
-
# install location mode (std: libruby, site: site_ruby, home: $HOME)
|
535
|
-
attr_accessor :installdirs
|
536
|
-
|
537
|
-
# options to pass to extconfig.rb
|
538
|
-
attr_accessor :configopt
|
539
|
-
|
540
|
-
# do not compile/install ruby extentions
|
541
|
-
attr_accessor :without_ext?
|
542
|
-
|
543
|
-
# do not compile/install ruby extentions
|
544
|
-
attr_accessor :without_doc?
|
545
|
-
|
546
|
-
# do not compile/install ruby extentions
|
547
|
-
attr_accessor :without_index?
|
548
|
-
|
549
|
-
# document template to use [html]
|
550
|
-
attr_accessor :rdoctemplate
|
551
|
-
|
552
|
-
# runner to use for testing (console|tk|gtk|gtk2)
|
553
|
-
attr_accessor :testrunner
|
554
|
-
|
555
|
-
# Run silently.
|
556
|
-
attr_accessor :quiet?
|
557
|
-
|
558
|
-
# shebang has only three options.
|
559
|
-
def shebang=(val)
|
560
|
-
if %w(all ruby never).include?(val)
|
561
|
-
@shebang = val
|
562
|
-
else
|
563
|
-
raise Error, "bad config: use SHEBANG=(all|ruby|never) [#{val}]"
|
564
|
-
end
|
565
|
-
end
|
566
|
-
|
567
|
-
# installdirs has only three options; and it has side-effects.
|
568
|
-
def installdirs=(val)
|
569
|
-
@installdirs = val
|
570
|
-
case val.to_s
|
571
|
-
when 'std'
|
572
|
-
self.rbdir = '$librubyver'
|
573
|
-
self.sodir = '$librubyverarch'
|
574
|
-
when 'site'
|
575
|
-
self.rbdir = '$siterubyver'
|
576
|
-
self.sodir = '$siterubyverarch'
|
577
|
-
when 'home'
|
578
|
-
raise Error, 'HOME is not set.' unless ENV['HOME']
|
579
|
-
self.prefix = ENV['HOME']
|
580
|
-
self.rbdir = '$libdir/ruby'
|
581
|
-
self.sodir = '$libdir/ruby'
|
582
|
-
else
|
583
|
-
raise Error, "bad config: use INSTALLDIRS=(std|site|home|local) [#{val}]"
|
584
|
-
end
|
585
|
-
end
|
586
|
-
|
587
|
-
# Get configuration from environment.
|
588
|
-
def getenv
|
589
|
-
OPTIONS.each do |name|
|
590
|
-
if value = ENV[name] || ENV[name.upcase]
|
591
|
-
__send__("#{name}=",value)
|
592
|
-
end
|
593
|
-
end
|
594
|
-
end
|
595
|
-
|
596
|
-
# Load configuration.
|
597
|
-
def load
|
598
|
-
#if File.file?(FILENAME)
|
599
|
-
begin
|
600
|
-
File.foreach(FILENAME) do |line|
|
601
|
-
k, v = *line.split(/=/, 2)
|
602
|
-
__send__("#{k}=",v.strip) #self[k] = v.strip
|
603
|
-
end
|
604
|
-
rescue Errno::ENOENT
|
605
|
-
raise Error, $!.message + "\n#{File.basename($0)} config first"
|
606
|
-
end
|
607
|
-
#end
|
608
|
-
end
|
609
|
-
|
610
|
-
# Save configuration.
|
611
|
-
def save
|
612
|
-
File.open(FILENAME, 'w') do |f|
|
613
|
-
OPTIONS.each do |name|
|
614
|
-
val = self[name]
|
615
|
-
case val
|
616
|
-
when Array
|
617
|
-
f << "#{name}=#{val.join(';')}\n"
|
618
|
-
else
|
619
|
-
f << "#{name}=#{val}\n"
|
620
|
-
end
|
621
|
-
end
|
622
|
-
end
|
623
|
-
end
|
624
|
-
|
625
|
-
def show
|
626
|
-
fmt = "%-20s %s\n"
|
627
|
-
OPTIONS.each do |name|
|
628
|
-
value = self[name]
|
629
|
-
printf fmt, name, __send__(name) if value
|
630
|
-
end
|
631
|
-
printf fmt, 'VERBOSE', verbose? ? 'yes' : 'no'
|
632
|
-
printf fmt, 'NOHARM', no_harm? ? 'yes' : 'no'
|
633
|
-
end
|
634
|
-
|
635
|
-
# Get unresloved attribute.
|
636
|
-
def [](name)
|
637
|
-
instance_variable_get("@#{name}")
|
638
|
-
end
|
639
|
-
|
640
|
-
# Set attribute.
|
641
|
-
def []=(name, value)
|
642
|
-
instance_variable_set("@#{name}", value)
|
643
|
-
end
|
644
|
-
|
645
|
-
# Resolved attribute. (for paths)
|
646
|
-
#def resolve(name)
|
647
|
-
# self[name].gsub(%r<\\$([^/]+)>){ self[$1] }
|
648
|
-
#end
|
649
|
-
|
650
|
-
# New ConfigTable
|
651
|
-
def initialize(values=nil)
|
652
|
-
initialize_defaults
|
653
|
-
if values
|
654
|
-
values.each{ |k,v| __send__("#{k}=", v) }
|
655
|
-
end
|
656
|
-
yeild(self) if block_given?
|
657
|
-
end
|
658
|
-
|
659
|
-
# Assign CONFIG defaults
|
660
|
-
#
|
661
|
-
# TODO: Does this handle 'nmake' on windows?
|
662
|
-
|
663
|
-
def initialize_defaults
|
664
|
-
prefix = RBCONFIG['prefix']
|
665
|
-
|
666
|
-
rubypath = File.join(RBCONFIG['bindir'], RBCONFIG['ruby_install_name'] + RBCONFIG['EXEEXT'])
|
667
|
-
|
668
|
-
# V > 1.6.3
|
669
|
-
libruby = "#{prefix}/lib/ruby"
|
670
|
-
librubyver = RBCONFIG['rubylibdir']
|
671
|
-
librubyverarch = RBCONFIG['archdir']
|
672
|
-
siteruby = RBCONFIG['sitedir']
|
673
|
-
siterubyver = RBCONFIG['sitelibdir']
|
674
|
-
siterubyverarch = RBCONFIG['sitearchdir']
|
675
|
-
|
676
|
-
if arg = RBCONFIG['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
|
677
|
-
makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
|
678
|
-
else
|
679
|
-
makeprog = 'make'
|
680
|
-
end
|
681
|
-
|
682
|
-
parameterize = lambda do |path|
|
683
|
-
val = RBCONFIG[path]
|
684
|
-
val.sub(/\A#{Regexp.quote(prefix)}/, '$prefix')
|
685
|
-
end
|
686
|
-
|
687
|
-
self.prefix = prefix
|
688
|
-
self.bindir = parameterize['bindir']
|
689
|
-
self.libdir = parameterize['libdir']
|
690
|
-
self.datadir = parameterize['datadir']
|
691
|
-
self.mandir = parameterize['mandir']
|
692
|
-
self.docdir = File.dirname(parameterize['docdir']) # b/c of trailing $(PACKAGE)
|
693
|
-
self.sysconfdir = parameterize['sysconfdir']
|
694
|
-
self.localstatedir = parameterize['localstatedir']
|
695
|
-
self.libruby = libruby
|
696
|
-
self.librubyver = librubyver
|
697
|
-
self.librubyverarch = librubyverarch
|
698
|
-
self.siteruby = siteruby
|
699
|
-
self.siterubyver = siterubyver
|
700
|
-
self.siterubyverarch = siterubyverarch
|
701
|
-
self.rbdir = '$siterubyver'
|
702
|
-
self.sodir = '$siterubyverarch'
|
703
|
-
self.rubypath = rubypath
|
704
|
-
self.rubyprog = rubypath
|
705
|
-
self.makeprog = makeprog
|
706
|
-
self.shebang = 'ruby'
|
707
|
-
self.without_ext = 'no'
|
708
|
-
self.without_doc = 'no'
|
709
|
-
self.without_index = 'no'
|
710
|
-
self.installdirs = 'site'
|
711
|
-
self.rdoctemplate = 'html'
|
712
|
-
self.testrunner = 'console'
|
713
|
-
self.configopt = ''
|
714
|
-
end
|
715
|
-
|
716
|
-
def show
|
717
|
-
fmt = "%-20s %s\n"
|
718
|
-
OPTIONS.each do |name|
|
719
|
-
value = self[name]
|
720
|
-
printf fmt, name, __send__(name)
|
721
|
-
end
|
722
|
-
end
|
723
|
-
|
724
|
-
#
|
725
|
-
def exec_config
|
726
|
-
getenv
|
727
|
-
save
|
728
|
-
#create_makefiles if compiles?
|
729
|
-
create_rakefile
|
730
|
-
show unless quiet?
|
731
|
-
puts "Configuration saved."
|
732
|
-
end
|
733
|
-
|
734
|
-
def extconfs
|
735
|
-
@extconfs ||= Dir['ext/**/extconf.rb']
|
736
|
-
end
|
737
|
-
|
738
|
-
def extensions
|
739
|
-
@extensions ||= extconfs.collect{ |f| File.dirname(f) }
|
740
|
-
end
|
741
|
-
|
742
|
-
def compiles?
|
743
|
-
!extensions.empty?
|
744
|
-
end
|
745
|
-
|
746
|
-
#def create_makefiles
|
747
|
-
# extensions.each do |dir|
|
748
|
-
# Dir.chdir(dir) do
|
749
|
-
# ruby('extconf.rb', configopt)
|
750
|
-
# end
|
751
|
-
# end
|
752
|
-
#end
|
753
|
-
|
754
|
-
# Create rakefile, if it doesn't exist.
|
755
|
-
def create_rakefile
|
756
|
-
unless Dir['[Rr]akefile{,.rb}'].first
|
757
|
-
File.open('Rakefile', 'w') do |f|
|
758
|
-
f << DATA.read
|
759
|
-
end
|
760
|
-
end
|
761
|
-
end
|
762
|
-
|
763
|
-
def ruby(*args)
|
764
|
-
command rubyprog, *args
|
765
|
-
end
|
766
|
-
|
767
|
-
def make(task = nil)
|
768
|
-
command(*[makeprog, task].compact)
|
769
|
-
end
|
770
|
-
|
771
|
-
def command(*args)
|
772
|
-
$stderr.puts args.join(' ') if $DEBUG
|
773
|
-
system(*args) or raise RuntimeError, "system(#{args.map{|a| a.inspect }.join(' ')}) failed"
|
774
|
-
end
|
775
|
-
|
776
|
-
# Help output.
|
777
|
-
|
778
|
-
HELP = <<-END
|
779
|
-
The Uber Rakefile v#{Version.join('.')}
|
780
|
-
|
781
|
-
Usage:
|
782
|
-
|
783
|
-
#{File.basename($0)} [options]
|
784
|
-
|
785
|
-
The Uber Rakefile is designed to install a Ruby package. It does this by breaking
|
786
|
-
the steps involved down into individual rake tasks. This gives the installer the
|
787
|
-
opportunity to adjust installation settings as required for a particular
|
788
|
-
platform. A typical installation procedure is:
|
789
|
-
|
790
|
-
$ rake config
|
791
|
-
$ rake setup
|
792
|
-
$ rake install
|
793
|
-
|
794
|
-
If you are certain of the default configuration settings (which are usually correct),
|
795
|
-
you can use the simple shortcut:
|
796
|
-
|
797
|
-
$ rake all
|
798
|
-
|
799
|
-
See rake -T for all available tasks.
|
800
|
-
|
801
|
-
Below is the list of options available for the config task.
|
802
|
-
|
803
|
-
Configuration options:
|
804
|
-
END
|
805
|
-
|
806
|
-
fmt = " %-20s %s\n"
|
807
|
-
DESCRIPTIONS.each do |name, desc|
|
808
|
-
HELP << fmt % ["#{name}", desc]
|
809
|
-
end
|
810
|
-
|
811
|
-
HELP << <<-END
|
812
|
-
|
813
|
-
Other options:
|
814
|
-
verbose Provide extra ouput
|
815
|
-
nowrite Do not write to disk.
|
816
|
-
noharm Same as nowrite.
|
817
|
-
|
818
|
-
Installdirs options correspond to: libruby, site_ruby and $HOME repsectively.
|
819
|
-
|
820
|
-
END
|
821
|
-
|
822
|
-
# Other options:
|
823
|
-
# -q --quiet Run silently
|
824
|
-
# -h --help Display this help information
|
825
|
-
# --version Show version
|
826
|
-
# --copyright Show copyright
|
827
|
-
#
|
828
|
-
# END
|
829
|
-
|
830
|
-
HELP.gsub!(/^\ \ /,'')
|
831
|
-
|
832
|
-
# CLI runner. This uses OptionParser to parse
|
833
|
-
# command line arguments. (May chnage to GetoptLong).
|
834
|
-
|
835
|
-
def self.start_cli
|
836
|
-
config = new
|
837
|
-
|
838
|
-
opts = OptionParser.new
|
839
|
-
|
840
|
-
DESCRIPTIONS.each do |name, desc|
|
841
|
-
opts.on("--#{name}", desc) do |val|
|
842
|
-
ENV[name.upcase] = val
|
843
|
-
end
|
844
|
-
end
|
845
|
-
|
846
|
-
# Tail options (eg. commands in option form)
|
847
|
-
|
848
|
-
opts.on("-q", "--quiet", "Run silently") do |val|
|
849
|
-
config.quiet = true
|
850
|
-
end
|
851
|
-
|
852
|
-
opts.on_tail("-h", "--help", "Display help information") do
|
853
|
-
puts HELP
|
854
|
-
exit
|
855
|
-
end
|
856
|
-
|
857
|
-
opts.on_tail("--version", "Show version") do
|
858
|
-
puts File.basename($0) + ' v' + Setup::Version.join('.')
|
859
|
-
exit
|
860
|
-
end
|
861
|
-
|
862
|
-
opts.on_tail("--copyright", "Show copyright") do
|
863
|
-
puts Setup::Copyright
|
864
|
-
exit
|
865
|
-
end
|
866
|
-
|
867
|
-
begin
|
868
|
-
opts.parse!(ARGV)
|
869
|
-
rescue OptionParser::InvalidOption
|
870
|
-
$stderr.puts $!.capitalize
|
871
|
-
exit 1
|
872
|
-
end
|
873
|
-
|
874
|
-
begin
|
875
|
-
config.exec_config
|
876
|
-
rescue Configure::Error
|
877
|
-
raise if $DEBUG
|
878
|
-
$stderr.puts $!.message
|
879
|
-
$stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
|
880
|
-
exit 1
|
881
|
-
end
|
882
|
-
end
|
883
|
-
|
884
|
-
end
|
885
|
-
|
886
|
-
# Command line run
|
887
|
-
if __FILE__ == $0
|
888
|
-
Configure.start_cli
|
889
|
-
end
|
890
|
-
|
891
|
-
#
|
892
|
-
#
|
893
|
-
#
|
894
|
-
|
895
|
-
class Installer
|
896
|
-
|
897
|
-
MANIFEST = '.installedfiles'
|
898
|
-
|
899
|
-
FILETYPES = %w( bin lib ext data conf man doc )
|
900
|
-
|
901
|
-
# Has this been installed previously?
|
902
|
-
def self.uninstallable?
|
903
|
-
File.exist?(MANIFEST)
|
904
|
-
end
|
905
|
-
|
906
|
-
# Configuration
|
907
|
-
attr :config
|
908
|
-
|
909
|
-
attr_writer :no_harm
|
910
|
-
attr_writer :verbose
|
911
|
-
|
912
|
-
attr_accessor :install_prefix
|
913
|
-
|
914
|
-
# New Installer.
|
915
|
-
def initialize(config) #:yield:
|
916
|
-
srcroot = '.'
|
917
|
-
objroot = '.'
|
918
|
-
|
919
|
-
@config = config
|
920
|
-
|
921
|
-
@srcdir = File.expand_path(srcroot)
|
922
|
-
@objdir = File.expand_path(objroot)
|
923
|
-
@currdir = '.'
|
924
|
-
|
925
|
-
@verbose = false
|
926
|
-
|
927
|
-
#self.verbose = ENV['VERBOSE'] if ENV['VERBOSE']
|
928
|
-
#self.no_harm = ENV['NO_HARM'] if ENV['NO_HARM']
|
929
|
-
|
930
|
-
yield(self) if block_given?
|
931
|
-
end
|
932
|
-
|
933
|
-
def inspect
|
934
|
-
"#<#{self.class} #{File.basename(@srcdir)}>"
|
935
|
-
end
|
936
|
-
|
937
|
-
# Do not write to disk.
|
938
|
-
def no_harm? ; @no_harm; end
|
939
|
-
|
940
|
-
# Verbose output?
|
941
|
-
def verbose? ; @verbose || @no_harm; end
|
942
|
-
|
943
|
-
# Yes, very very verbose output.
|
944
|
-
def very_verbose? ; @very_verbose; end
|
945
|
-
|
946
|
-
def verbose_off #:yield:
|
947
|
-
begin
|
948
|
-
save, @verbose = verbose?, false
|
949
|
-
yield
|
950
|
-
ensure
|
951
|
-
@verbose = save
|
952
|
-
end
|
953
|
-
end
|
954
|
-
|
955
|
-
# Are we running an installation?
|
956
|
-
def installation?; @installation; end
|
957
|
-
def installation!; @installation = true; end
|
958
|
-
|
959
|
-
#
|
960
|
-
# Hook Script API bases
|
961
|
-
#
|
962
|
-
|
963
|
-
def srcdir_root
|
964
|
-
@srcdir
|
965
|
-
end
|
966
|
-
|
967
|
-
def objdir_root
|
968
|
-
@objdir
|
969
|
-
end
|
970
|
-
|
971
|
-
def relpath
|
972
|
-
@currdir
|
973
|
-
end
|
974
|
-
|
975
|
-
# Used as a null traversal.
|
976
|
-
def noop(rel) ; end
|
977
|
-
|
978
|
-
def update_shebang_line(path)
|
979
|
-
return if no_harm?
|
980
|
-
return if config.shebang == 'never'
|
981
|
-
old = Shebang.load(path)
|
982
|
-
if old
|
983
|
-
if old.args.size > 1
|
984
|
-
$stderr.puts "warning: #{path}"
|
985
|
-
$stderr.puts "Shebang line has too many args."
|
986
|
-
$stderr.puts "It is not portable and your program may not work."
|
987
|
-
end
|
988
|
-
new = new_shebang(old)
|
989
|
-
return if new.to_s == old.to_s
|
990
|
-
else
|
991
|
-
return unless config.shebang == 'all'
|
992
|
-
new = Shebang.new(config.rubypath)
|
993
|
-
end
|
994
|
-
$stderr.puts "updating shebang: #{File.basename(path)}" if verbose?
|
995
|
-
open_atomic_writer(path) {|output|
|
996
|
-
File.open(path, 'rb') {|f|
|
997
|
-
f.gets if old # discard
|
998
|
-
output.puts new.to_s
|
999
|
-
output.print f.read
|
1000
|
-
}
|
1001
|
-
}
|
1002
|
-
end
|
1003
|
-
|
1004
|
-
def new_shebang(old)
|
1005
|
-
if /\Aruby/ =~ File.basename(old.cmd)
|
1006
|
-
Shebang.new(config.rubypath, old.args)
|
1007
|
-
elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby'
|
1008
|
-
Shebang.new(config.rubypath, old.args[1..-1])
|
1009
|
-
else
|
1010
|
-
return old unless config.shebang == 'all'
|
1011
|
-
Shebang.new(config.rubypath)
|
1012
|
-
end
|
1013
|
-
end
|
1014
|
-
|
1015
|
-
def open_atomic_writer(path, &block)
|
1016
|
-
tmpfile = File.basename(path) + '.tmp'
|
1017
|
-
begin
|
1018
|
-
File.open(tmpfile, 'wb', &block)
|
1019
|
-
File.rename tmpfile, File.basename(path)
|
1020
|
-
ensure
|
1021
|
-
File.unlink tmpfile if File.exist?(tmpfile)
|
1022
|
-
end
|
1023
|
-
end
|
1024
|
-
|
1025
|
-
class Shebang
|
1026
|
-
def Shebang.load(path)
|
1027
|
-
line = nil
|
1028
|
-
File.open(path) {|f|
|
1029
|
-
line = f.gets
|
1030
|
-
}
|
1031
|
-
return nil unless /\A#!/ =~ line
|
1032
|
-
parse(line)
|
1033
|
-
end
|
1034
|
-
|
1035
|
-
def Shebang.parse(line)
|
1036
|
-
cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ')
|
1037
|
-
new(cmd, args)
|
1038
|
-
end
|
1039
|
-
|
1040
|
-
def initialize(cmd, args = [])
|
1041
|
-
@cmd = cmd
|
1042
|
-
@args = args
|
1043
|
-
end
|
1044
|
-
|
1045
|
-
attr_reader :cmd
|
1046
|
-
attr_reader :args
|
1047
|
-
|
1048
|
-
def to_s
|
1049
|
-
"#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}")
|
1050
|
-
end
|
1051
|
-
end
|
1052
|
-
|
1053
|
-
#
|
1054
|
-
# TASK install
|
1055
|
-
#
|
1056
|
-
|
1057
|
-
def exec_install
|
1058
|
-
installation! # mark that we are installing
|
1059
|
-
#rm_f MANIFEST # we'll append rather then delete
|
1060
|
-
exec_task_traverse 'install'
|
1061
|
-
end
|
1062
|
-
|
1063
|
-
def install_dir_bin(rel)
|
1064
|
-
install_files targetfiles(), "#{config.bindir}/#{rel}", 0755
|
1065
|
-
end
|
1066
|
-
|
1067
|
-
def install_dir_lib(rel)
|
1068
|
-
install_files libfiles(), "#{config.rbdir}/#{rel}", 0644
|
1069
|
-
end
|
1070
|
-
|
1071
|
-
def install_dir_ext(rel)
|
1072
|
-
return unless extdir?(curr_srcdir())
|
1073
|
-
install_files rubyextentions('.'),
|
1074
|
-
"#{config.sodir}/#{File.dirname(rel)}", 0555
|
1075
|
-
end
|
1076
|
-
|
1077
|
-
def install_dir_data(rel)
|
1078
|
-
install_files targetfiles(), "#{config.datadir}/#{rel}", 0644
|
1079
|
-
end
|
1080
|
-
|
1081
|
-
def install_dir_doc(rel)
|
1082
|
-
return if config.without_doc?
|
1083
|
-
install_files targetfiles(), "#{config.docdir}/#{rel}", 0644
|
1084
|
-
end
|
1085
|
-
|
1086
|
-
def install_dir_conf(rel)
|
1087
|
-
# FIXME: should not remove current config files
|
1088
|
-
# (rename previous file to .old/.org)
|
1089
|
-
install_files targetfiles(), "#{config.sysconfdir}/#{rel}", 0644
|
1090
|
-
end
|
1091
|
-
|
1092
|
-
def install_dir_man(rel)
|
1093
|
-
install_files targetfiles(), "#{config.mandir}/#{rel}", 0644
|
1094
|
-
end
|
1095
|
-
|
1096
|
-
def install_files(list, dest, mode)
|
1097
|
-
mkdir_p dest, install_prefix
|
1098
|
-
list.each do |fname|
|
1099
|
-
install fname, dest, mode, install_prefix
|
1100
|
-
end
|
1101
|
-
end
|
1102
|
-
|
1103
|
-
def libfiles
|
1104
|
-
glob_reject(%w(*.y *.output), targetfiles())
|
1105
|
-
end
|
1106
|
-
|
1107
|
-
def rubyextentions(dir)
|
1108
|
-
ents = glob_select("*.#{dllext}", targetfiles())
|
1109
|
-
if ents.empty?
|
1110
|
-
setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first"
|
1111
|
-
end
|
1112
|
-
ents
|
1113
|
-
end
|
1114
|
-
|
1115
|
-
def dllext
|
1116
|
-
RBCONFIG['DLEXT']
|
1117
|
-
end
|
1118
|
-
|
1119
|
-
def targetfiles
|
1120
|
-
mapdir(existfiles() - hookfiles())
|
1121
|
-
end
|
1122
|
-
|
1123
|
-
def mapdir(ents)
|
1124
|
-
ents.map {|ent|
|
1125
|
-
if File.exist?(ent)
|
1126
|
-
then ent # objdir
|
1127
|
-
else "#{curr_srcdir()}/#{ent}" # srcdir
|
1128
|
-
end
|
1129
|
-
}
|
1130
|
-
end
|
1131
|
-
|
1132
|
-
# picked up many entries from cvs-1.11.1/src/ignore.c
|
1133
|
-
JUNK_FILES = %w(
|
1134
|
-
core RCSLOG tags TAGS .make.state
|
1135
|
-
.nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
|
1136
|
-
*~ *.old *.bak *.BAK *.orig *.rej _$* *$
|
1137
|
-
|
1138
|
-
*.org *.in .*
|
1139
|
-
)
|
1140
|
-
|
1141
|
-
def existfiles
|
1142
|
-
glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.')))
|
1143
|
-
end
|
1144
|
-
|
1145
|
-
def hookfiles
|
1146
|
-
%w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt|
|
1147
|
-
%w( config setup install clean ).map {|t| sprintf(fmt, t) }
|
1148
|
-
}.flatten
|
1149
|
-
end
|
1150
|
-
|
1151
|
-
def glob_select(pat, ents)
|
1152
|
-
re = globs2re([pat])
|
1153
|
-
ents.select {|ent| re =~ ent }
|
1154
|
-
end
|
1155
|
-
|
1156
|
-
def glob_reject(pats, ents)
|
1157
|
-
re = globs2re(pats)
|
1158
|
-
ents.reject {|ent| re =~ ent }
|
1159
|
-
end
|
1160
|
-
|
1161
|
-
GLOB2REGEX = {
|
1162
|
-
'.' => '\.',
|
1163
|
-
'$' => '\$',
|
1164
|
-
'#' => '\#',
|
1165
|
-
'*' => '.*'
|
1166
|
-
}
|
1167
|
-
|
1168
|
-
def globs2re(pats)
|
1169
|
-
/\A(?:#{
|
1170
|
-
pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|')
|
1171
|
-
})\z/
|
1172
|
-
end
|
1173
|
-
|
1174
|
-
#
|
1175
|
-
# TASK uninstall
|
1176
|
-
#
|
1177
|
-
|
1178
|
-
def exec_uninstall
|
1179
|
-
files = File.read(MANIFEST).split("\n")
|
1180
|
-
files.each do |file|
|
1181
|
-
next if /^\#/ =~ file # skip comments
|
1182
|
-
rm_f(file) if File.exist?(file)
|
1183
|
-
end
|
1184
|
-
end
|
1185
|
-
|
1186
|
-
#
|
1187
|
-
# Traversing
|
1188
|
-
#
|
1189
|
-
|
1190
|
-
#
|
1191
|
-
def exec_task_traverse(task)
|
1192
|
-
run_hook "pre-#{task}"
|
1193
|
-
FILETYPES.each do |type|
|
1194
|
-
if type == 'ext' and config.without_ext == 'yes'
|
1195
|
-
$stderr.puts 'skipping ext/* by user option' if verbose?
|
1196
|
-
next
|
1197
|
-
end
|
1198
|
-
traverse task, type, "#{task}_dir_#{type}"
|
1199
|
-
end
|
1200
|
-
run_hook "post-#{task}"
|
1201
|
-
end
|
1202
|
-
|
1203
|
-
#
|
1204
|
-
def traverse(task, rel, mid)
|
1205
|
-
dive_into(rel) {
|
1206
|
-
run_hook "pre-#{task}"
|
1207
|
-
__send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '')
|
1208
|
-
directories_of(curr_srcdir()).each do |d|
|
1209
|
-
traverse task, "#{rel}/#{d}", mid
|
1210
|
-
end
|
1211
|
-
run_hook "post-#{task}"
|
1212
|
-
}
|
1213
|
-
end
|
1214
|
-
|
1215
|
-
#
|
1216
|
-
def dive_into(rel)
|
1217
|
-
return unless File.dir?("#{@srcdir}/#{rel}")
|
1218
|
-
|
1219
|
-
dir = File.basename(rel)
|
1220
|
-
Dir.mkdir dir unless File.dir?(dir)
|
1221
|
-
prevdir = Dir.pwd
|
1222
|
-
Dir.chdir dir
|
1223
|
-
$stderr.puts '---> ' + rel if very_verbose?
|
1224
|
-
@currdir = rel
|
1225
|
-
yield
|
1226
|
-
Dir.chdir prevdir
|
1227
|
-
$stderr.puts '<--- ' + rel if very_verbose?
|
1228
|
-
@currdir = File.dirname(rel)
|
1229
|
-
end
|
1230
|
-
|
1231
|
-
#
|
1232
|
-
def run_hook(id)
|
1233
|
-
path = [ "#{curr_srcdir()}/#{id}",
|
1234
|
-
"#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) }
|
1235
|
-
return unless path
|
1236
|
-
begin
|
1237
|
-
instance_eval File.read(path), path, 1
|
1238
|
-
rescue
|
1239
|
-
raise if $DEBUG
|
1240
|
-
setup_rb_error "hook #{path} failed:\n" + $!.message
|
1241
|
-
end
|
1242
|
-
end
|
1243
|
-
|
1244
|
-
# File Operations
|
1245
|
-
#
|
1246
|
-
# These use: #verbose? and #no_harm?
|
1247
|
-
|
1248
|
-
def binread(fname)
|
1249
|
-
File.open(fname, 'rb'){ |f|
|
1250
|
-
return f.read
|
1251
|
-
}
|
1252
|
-
end
|
1253
|
-
|
1254
|
-
def mkdir_p(dirname, prefix = nil)
|
1255
|
-
dirname = prefix + File.expand_path(dirname) if prefix
|
1256
|
-
$stderr.puts "mkdir -p #{dirname}" if verbose?
|
1257
|
-
return if no_harm?
|
1258
|
-
|
1259
|
-
# Does not check '/', it's too abnormal.
|
1260
|
-
dirs = File.expand_path(dirname).split(%r<(?=/)>)
|
1261
|
-
if /\A[a-z]:\z/i =~ dirs[0]
|
1262
|
-
disk = dirs.shift
|
1263
|
-
dirs[0] = disk + dirs[0]
|
1264
|
-
end
|
1265
|
-
dirs.each_index do |idx|
|
1266
|
-
path = dirs[0..idx].join('')
|
1267
|
-
Dir.mkdir path unless File.dir?(path)
|
1268
|
-
end
|
1269
|
-
end
|
1270
|
-
|
1271
|
-
def rm_f(path)
|
1272
|
-
$stderr.puts "rm -f #{path}" if verbose?
|
1273
|
-
return if no_harm?
|
1274
|
-
force_remove_file path
|
1275
|
-
end
|
1276
|
-
|
1277
|
-
def rm_rf(path)
|
1278
|
-
$stderr.puts "rm -rf #{path}" if verbose?
|
1279
|
-
return if no_harm?
|
1280
|
-
remove_tree path
|
1281
|
-
end
|
1282
|
-
|
1283
|
-
def remove_tree(path)
|
1284
|
-
if File.symlink?(path)
|
1285
|
-
remove_file path
|
1286
|
-
elsif File.dir?(path)
|
1287
|
-
remove_tree0 path
|
1288
|
-
else
|
1289
|
-
force_remove_file path
|
1290
|
-
end
|
1291
|
-
end
|
1292
|
-
|
1293
|
-
def remove_tree0(path)
|
1294
|
-
Dir.foreach(path) do |ent|
|
1295
|
-
next if ent == '.'
|
1296
|
-
next if ent == '..'
|
1297
|
-
entpath = "#{path}/#{ent}"
|
1298
|
-
if File.symlink?(entpath)
|
1299
|
-
remove_file entpath
|
1300
|
-
elsif File.dir?(entpath)
|
1301
|
-
remove_tree0 entpath
|
1302
|
-
else
|
1303
|
-
force_remove_file entpath
|
1304
|
-
end
|
1305
|
-
end
|
1306
|
-
begin
|
1307
|
-
Dir.rmdir path
|
1308
|
-
rescue Errno::ENOTEMPTY
|
1309
|
-
# directory may not be empty
|
1310
|
-
end
|
1311
|
-
end
|
1312
|
-
|
1313
|
-
def move_file(src, dest)
|
1314
|
-
force_remove_file dest
|
1315
|
-
begin
|
1316
|
-
File.rename src, dest
|
1317
|
-
rescue
|
1318
|
-
File.open(dest, 'wb') {|f|
|
1319
|
-
f.write binread(src)
|
1320
|
-
}
|
1321
|
-
File.chmod File.stat(src).mode, dest
|
1322
|
-
File.unlink src
|
1323
|
-
end
|
1324
|
-
end
|
1325
|
-
|
1326
|
-
def force_remove_file(path)
|
1327
|
-
begin
|
1328
|
-
remove_file path
|
1329
|
-
rescue
|
1330
|
-
end
|
1331
|
-
end
|
1332
|
-
|
1333
|
-
def remove_file(path)
|
1334
|
-
File.chmod 0777, path
|
1335
|
-
File.unlink path
|
1336
|
-
end
|
1337
|
-
|
1338
|
-
def install(from, dest, mode, prefix = nil)
|
1339
|
-
$stderr.puts "install #{from} #{dest}" if verbose?
|
1340
|
-
return if no_harm?
|
1341
|
-
|
1342
|
-
realdest = prefix ? prefix + File.expand_path(dest) : dest
|
1343
|
-
realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest)
|
1344
|
-
str = binread(from)
|
1345
|
-
if diff?(str, realdest)
|
1346
|
-
verbose_off {
|
1347
|
-
rm_f realdest if File.exist?(realdest)
|
1348
|
-
}
|
1349
|
-
File.open(realdest, 'wb') {|f|
|
1350
|
-
f.write str
|
1351
|
-
}
|
1352
|
-
File.chmod mode, realdest
|
1353
|
-
|
1354
|
-
File.open("#{objdir_root()}/#{MANIFEST}", 'a') {|f|
|
1355
|
-
if prefix
|
1356
|
-
f.puts realdest.sub(prefix, '')
|
1357
|
-
else
|
1358
|
-
f.puts realdest
|
1359
|
-
end
|
1360
|
-
}
|
1361
|
-
end
|
1362
|
-
end
|
1363
|
-
|
1364
|
-
def diff?(new_content, path)
|
1365
|
-
return true unless File.exist?(path)
|
1366
|
-
new_content != binread(path)
|
1367
|
-
end
|
1368
|
-
|
1369
|
-
def command(*args)
|
1370
|
-
$stderr.puts args.join(' ') if verbose?
|
1371
|
-
system(*args) or raise RuntimeError,
|
1372
|
-
"system(#{args.map{|a| a.inspect }.join(' ')}) failed"
|
1373
|
-
end
|
1374
|
-
|
1375
|
-
def ruby(*args)
|
1376
|
-
command config.rubyprog, *args
|
1377
|
-
end
|
1378
|
-
|
1379
|
-
def make(task = nil)
|
1380
|
-
command(*[config.makeprog, task].compact)
|
1381
|
-
end
|
1382
|
-
|
1383
|
-
def extdir?(dir)
|
1384
|
-
File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb")
|
1385
|
-
end
|
1386
|
-
|
1387
|
-
def files_of(dir)
|
1388
|
-
Dir.open(dir) {|d|
|
1389
|
-
return d.select {|ent| File.file?("#{dir}/#{ent}") }
|
1390
|
-
}
|
1391
|
-
end
|
1392
|
-
|
1393
|
-
DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn )
|
1394
|
-
|
1395
|
-
def directories_of(dir)
|
1396
|
-
Dir.open(dir) {|d|
|
1397
|
-
return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT
|
1398
|
-
}
|
1399
|
-
end
|
1400
|
-
|
1401
|
-
#
|
1402
|
-
# Hook Script API
|
1403
|
-
#
|
1404
|
-
# These require: #srcdir_root, #objdir_root, #relpath
|
1405
|
-
#
|
1406
|
-
|
1407
|
-
#
|
1408
|
-
def get_config(key)
|
1409
|
-
config.__send__(key)
|
1410
|
-
end
|
1411
|
-
|
1412
|
-
# obsolete: use metaconfig to change configuration
|
1413
|
-
# TODO: what to do with?
|
1414
|
-
def set_config(key, val)
|
1415
|
-
config[key] = val
|
1416
|
-
end
|
1417
|
-
|
1418
|
-
#
|
1419
|
-
# srcdir/objdir (works only in the package directory)
|
1420
|
-
#
|
1421
|
-
|
1422
|
-
def curr_srcdir
|
1423
|
-
"#{srcdir_root()}/#{relpath()}"
|
1424
|
-
end
|
1425
|
-
|
1426
|
-
def curr_objdir
|
1427
|
-
"#{objdir_root()}/#{relpath()}"
|
1428
|
-
end
|
1429
|
-
|
1430
|
-
def srcfile(path)
|
1431
|
-
"#{curr_srcdir()}/#{path}"
|
1432
|
-
end
|
1433
|
-
|
1434
|
-
def srcexist?(path)
|
1435
|
-
File.exist?(srcfile(path))
|
1436
|
-
end
|
1437
|
-
|
1438
|
-
def srcdirectory?(path)
|
1439
|
-
File.dir?(srcfile(path))
|
1440
|
-
end
|
1441
|
-
|
1442
|
-
def srcfile?(path)
|
1443
|
-
File.file?(srcfile(path))
|
1444
|
-
end
|
1445
|
-
|
1446
|
-
def srcentries(path = '.')
|
1447
|
-
Dir.open("#{curr_srcdir()}/#{path}") {|d|
|
1448
|
-
return d.to_a - %w(. ..)
|
1449
|
-
}
|
1450
|
-
end
|
1451
|
-
|
1452
|
-
def srcfiles(path = '.')
|
1453
|
-
srcentries(path).select {|fname|
|
1454
|
-
File.file?(File.join(curr_srcdir(), path, fname))
|
1455
|
-
}
|
1456
|
-
end
|
1457
|
-
|
1458
|
-
def srcdirectories(path = '.')
|
1459
|
-
srcentries(path).select {|fname|
|
1460
|
-
File.dir?(File.join(curr_srcdir(), path, fname))
|
1461
|
-
}
|
1462
|
-
end
|
1463
|
-
|
1464
|
-
end
|
1465
|
-
|
1466
|
-
#
|
1467
|
-
# Ruby extensions
|
1468
|
-
#
|
1469
|
-
|
1470
|
-
unless File.respond_to?(:read) # Ruby 1.6 and less
|
1471
|
-
def File.read(fname)
|
1472
|
-
open(fname) {|f|
|
1473
|
-
return f.read
|
1474
|
-
}
|
1475
|
-
end
|
1476
|
-
end
|
1477
|
-
|
1478
|
-
unless Errno.const_defined?(:ENOTEMPTY) # Windows?
|
1479
|
-
module Errno
|
1480
|
-
class ENOTEMPTY
|
1481
|
-
# We do not raise this exception, implementation is not needed.
|
1482
|
-
end
|
1483
|
-
end
|
1484
|
-
end
|
1485
|
-
|
1486
|
-
# for corrupted Windows' stat(2)
|
1487
|
-
def File.dir?(path)
|
1488
|
-
File.directory?((path[-1,1] == '/') ? path : path + '/')
|
1489
|
-
end
|
1490
|
-
|
1491
|
-
#
|
1492
|
-
# The End
|
1493
|
-
#
|
1494
|
-
|
1495
|
-
UberTask.new(PACKAGE, GENERATE_DOCS)
|
1
|
+
require File.join(File.dirname(__FILE__), "setup.rb")
|
1496
2
|
|