reap 6.0.2 → 9.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/COPYING +666 -395
- data/MANIFEST +139 -0
- data/NOTES +12 -0
- data/README +19 -163
- data/bin/reap-announce +7 -0
- data/bin/reap-check-load +8 -0
- data/bin/reap-check-syntax +7 -0
- data/bin/reap-clean +7 -0
- data/bin/reap-clobber +7 -0
- data/bin/reap-doc +7 -0
- data/bin/reap-doc-rdoc +7 -0
- data/bin/reap-doc-ri +7 -0
- data/bin/reap-init +69 -0
- data/bin/reap-inspect +7 -0
- data/bin/reap-install +8 -0
- data/bin/reap-install-gem +8 -0
- data/bin/reap-log +7 -0
- data/bin/reap-log-changes +8 -0
- data/bin/reap-log-notes +8 -0
- data/bin/reap-make +7 -0
- data/bin/reap-make-clean +7 -0
- data/bin/reap-make-distclean +7 -0
- data/bin/reap-make-extconf +7 -0
- data/bin/reap-make-static +8 -0
- data/bin/reap-package +8 -0
- data/bin/reap-package-gem +7 -0
- data/bin/reap-package-tgz +7 -0
- data/bin/reap-package-zip +7 -0
- data/bin/reap-prepare +7 -0
- data/bin/reap-publish +7 -0
- data/bin/reap-release +7 -0
- data/bin/reap-scaffold +8 -0
- data/bin/reap-scm-branch +7 -0
- data/bin/reap-scm-tag +7 -0
- data/bin/reap-spec +7 -0
- data/bin/reap-spec-doc +8 -0
- data/bin/reap-stamp +7 -0
- data/bin/reap-stats +7 -0
- data/bin/reap-test +7 -0
- data/bin/reap-test-cross +7 -0
- data/bin/reap-test-load +9 -0
- data/bin/reap-test-solo +7 -0
- data/bin/reap-uninstall +7 -0
- data/bin/reap-uninstall-gem +7 -0
- data/data/reap/base/CHANGES +19 -0
- data/data/reap/base/COPYING +674 -0
- data/data/reap/base/NOTES +12 -0
- data/data/reap/base/README +8 -0
- data/data/reap/build/rake/Rakefile +130 -0
- data/{forge/reference/installers → data/reap/build/rake}/setup.rb +155 -97
- data/data/reap/build/rake-lite/install.rb +79 -0
- data/data/reap/build/tasks/task/rdoc +211 -0
- data/data/reap/{setup.rb → build/tasks/task/setup} +248 -200
- data/data/reap/build/tasks/task/test +38 -0
- data/data/reap/init/meta/project.yaml +21 -0
- data/demo/README +15 -0
- data/demo/lib/foo/foo.rb +7 -0
- data/demo/meta/VERSION +1 -0
- data/demo/meta/project.yaml +21 -0
- data/lib/reap/application.rb +80 -0
- data/lib/reap/default.yaml +77 -0
- data/lib/reap/extensions/array.rb +50 -0
- data/lib/reap/extensions/hash.rb +63 -0
- data/lib/reap/extensions/string.rb +31 -0
- data/lib/reap/extensions.rb +6 -0
- data/lib/reap/iobject.rb +264 -0
- data/lib/reap/manager/announce.rb +193 -0
- data/lib/reap/manager/check.rb +109 -0
- data/lib/reap/manager/clean.rb +58 -0
- data/lib/reap/manager/gem.rb +200 -0
- data/lib/reap/manager/html.rb +69 -0
- data/lib/reap/manager/log.rb +214 -0
- data/lib/reap/manager/make.rb +109 -0
- data/lib/reap/manager/pack.rb +232 -0
- data/lib/reap/manager/publish.rb +72 -0
- data/lib/reap/manager/rdoc.rb +194 -0
- data/lib/reap/manager/release.rb +78 -0
- data/lib/reap/manager/rubyforge.rb +44 -0
- data/lib/reap/manager/scaffold.rb +138 -0
- data/lib/reap/manager/scm.rb +66 -0
- data/lib/reap/manager/site.rb +27 -0
- data/lib/reap/manager/spec.rb +94 -0
- data/lib/reap/manager/stats.rb +145 -0
- data/lib/reap/manager/svn.rb +76 -0
- data/lib/reap/manager/test.rb +389 -0
- data/lib/reap/manager.rb +74 -0
- data/lib/reap/metadata.rb +603 -0
- data/lib/reap/project.rb +165 -0
- data/lib/reap/settings.rb +67 -0
- data/lib/reap/systems/rubyforge.rb +737 -0
- data/lib/reap/systems/subversion.rb +333 -0
- data/lib/reap/utilities/fileutils.rb +304 -0
- data/lib/reap/utilities/netutils.rb +221 -0
- data/lib/reap/utilities/setuputils.rb +124 -0
- data/lib/reap/utilities/shellutils.rb +175 -0
- data/log/Changelog.txt +107 -0
- data/log/FIXME.txt +25 -0
- data/log/TODO.txt +72 -0
- data/meta/VERSION +1 -0
- data/meta/description +4 -0
- data/meta/project.yaml +20 -0
- data/task/man +14 -0
- data/task/rdoc +20 -0
- data/{data/reap/scaffold/standard/setup.rb → task/setup} +248 -200
- metadata +225 -153
- data/ProjectInfo +0 -105
- data/bin/reap +0 -5
- data/bin/rubytest +0 -5
- data/data/reap/install.rb +0 -62
- data/data/reap/scaffold/standard/COPYING +0 -403
- data/data/reap/scaffold/standard/ChangeLog +0 -0
- data/data/reap/scaffold/standard/INSTALL +0 -14
- data/data/reap/scaffold/standard/ProjectInfo +0 -77
- data/data/reap/scaffold/standard/README +0 -3
- data/data/reap/scaffold/standard/Rakefile +0 -10
- data/data/reap/scaffold/standard/TODO +0 -0
- data/data/reap/scaffold/subversion/trunk/COPYING +0 -403
- data/data/reap/scaffold/subversion/trunk/ChangeLog +0 -0
- data/data/reap/scaffold/subversion/trunk/INSTALL +0 -14
- data/data/reap/scaffold/subversion/trunk/ProjectInfo +0 -76
- data/data/reap/scaffold/subversion/trunk/README +0 -3
- data/data/reap/scaffold/subversion/trunk/Rakefile +0 -10
- data/data/reap/scaffold/subversion/trunk/TODO +0 -0
- data/data/reap/scaffold/subversion/trunk/setup.rb +0 -1568
- data/forge/ProjectInfo +0 -38
- data/forge/ProjectInfo.rb +0 -76
- data/forge/TODO +0 -10
- data/forge/installer.rb +0 -250
- data/forge/reference/Rakefile +0 -124
- data/forge/reference/Rakefile.htm +0 -69
- data/forge/reference/aRakefile +0 -60
- data/forge/reference/compositepublisher.rb +0 -24
- data/forge/reference/ftptools.rb +0 -139
- data/forge/reference/installers/package.rb +0 -629
- data/forge/reference/license-each.rb +0 -85
- data/forge/reference/publisher.rb +0 -75
- data/forge/reference/rubyforge.rb +0 -247
- data/forge/reference/rubyforgepublisher.rb +0 -18
- data/forge/reference/sshpublisher.rb +0 -47
- data/forge/reference/suby-cvs.rb +0 -46
- data/forge/scaffold.rb +0 -126
- data/forge/unit_runner/README +0 -6
- data/forge/unit_runner/commentrunner.rb +0 -62
- data/forge/unit_runner/cunit.rb +0 -17
- data/forge/unit_runner/forkedrunner.rb +0 -91
- data/forge/unit_runner/sample.rb +0 -16
- data/lib/reap/bin/reap.rb +0 -230
- data/lib/reap/bin/rubytest.rb +0 -53
- data/lib/reap/class/announce.rb +0 -220
- data/lib/reap/class/doap.rb +0 -80
- data/lib/reap/class/extest.rb +0 -146
- data/lib/reap/class/filer.rb +0 -62
- data/lib/reap/class/manifest.rb +0 -68
- data/lib/reap/class/package.rb +0 -576
- data/lib/reap/class/publish.rb +0 -152
- data/lib/reap/class/rdoc.rb +0 -123
- data/lib/reap/class/test.rb +0 -264
- data/lib/reap/projectinfo.rb +0 -208
- data/lib/reap/rake.rb +0 -42
- data/lib/reap/reap.rb +0 -89
- data/lib/reap/tasks.rb +0 -756
- data/lib/reap/taskutils.rb +0 -122
- data/note/LATEST +0 -44
- data/note/doap.xml +0 -28
- data/note/history/Rakefile-0.1 +0 -308
- data/sample/ProjectInfo +0 -96
- data/sample/Rakefile +0 -9
- data/sample/Reapfile +0 -11
- data/sample/task/demo.rb +0 -15
- data/setup.rb +0 -1568
- data/web/ProjectInfo.html +0 -75
- data/web/images/grape.jpg +0 -0
- data/web/index.html +0 -312
@@ -1,629 +0,0 @@
|
|
1
|
-
require 'rbconfig'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'pp'
|
4
|
-
require 'optparse'
|
5
|
-
require 'yaml'
|
6
|
-
|
7
|
-
module Package
|
8
|
-
|
9
|
-
class SpecificationError < StandardError; end
|
10
|
-
# forward declaration of the specification classes so we can keep all
|
11
|
-
# constants here
|
12
|
-
class PackageSpecification_1_0; end
|
13
|
-
# Default semantics
|
14
|
-
PackageSpecification = PackageSpecification_1_0
|
15
|
-
|
16
|
-
#TODO: could get this collected automatically with Class#inherited etc
|
17
|
-
SEMANTICS = { "1.0" => PackageSpecification_1_0 }
|
18
|
-
|
19
|
-
KINDS = [
|
20
|
-
:bin, :lib, :ext, :data, :conf, :doc
|
21
|
-
]
|
22
|
-
|
23
|
-
#{{{ list of files to be ignored stolen from setup.rb
|
24
|
-
mapping = { '.' => '\.', '$' => '\$', '#' => '\#', '*' => '.*' }
|
25
|
-
ignore_files = %w[core RCSLOG tags TAGS .make.state .nse_depinfo
|
26
|
-
#* .#* cvslog.* ,* .del-* *.olb *~ *.old *.bak *.BAK *.orig *.rej _$* *$
|
27
|
-
*.org *.in .* ]
|
28
|
-
#end of robbery
|
29
|
-
IGNORE_FILES = ignore_files.map do |x|
|
30
|
-
Regexp.new('\A' + x.gsub(/[\.\$\#\*]/){|c| mapping[c]} + '\z')
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.config(name)
|
34
|
-
# XXX use pathname
|
35
|
-
prefix = Regexp.quote(Config::CONFIG["prefix"])
|
36
|
-
exec_prefix = Regexp.quote(Config::CONFIG["exec_prefix"])
|
37
|
-
Config::CONFIG[name].gsub(/\A\/?(#{prefix}|#{exec_prefix})\/?/, '')
|
38
|
-
end
|
39
|
-
|
40
|
-
SITE_DIRS = {
|
41
|
-
:bin => config("bindir"),
|
42
|
-
:lib => config("sitelibdir"),
|
43
|
-
:ext => config("sitearchdir"),
|
44
|
-
:data => config("datadir"),
|
45
|
-
:conf => config("sysconfdir"),
|
46
|
-
:doc => File.join(config("datadir"), "doc"),
|
47
|
-
}
|
48
|
-
|
49
|
-
VENDOR_DIRS = {
|
50
|
-
:bin => config("bindir"),
|
51
|
-
:lib => config("rubylibdir"),
|
52
|
-
:ext => config("archdir"),
|
53
|
-
:data => config("datadir"),
|
54
|
-
:conf => config("sysconfdir"),
|
55
|
-
:doc => File.join(config("datadir"), "doc"),
|
56
|
-
}
|
57
|
-
|
58
|
-
MODES = {
|
59
|
-
:bin => 0755,
|
60
|
-
:lib => 0644,
|
61
|
-
:ext => 0755, # was: 0555,
|
62
|
-
:data => 0644,
|
63
|
-
:conf => 0644,
|
64
|
-
:doc => 0644,
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
SETUP_OPTIONS = {:parse_cmdline => true, :load_conf => true, :run_tasks => true}
|
69
|
-
|
70
|
-
def self.setup(version, options = {}, &instructions)
|
71
|
-
prefixes = dirs = nil
|
72
|
-
options = SETUP_OPTIONS.dup.update(options)
|
73
|
-
|
74
|
-
if options[:load_conf] && File.exist?("config.save")
|
75
|
-
config = YAML.load_file "config.save"
|
76
|
-
prefixes = config[:prefixes]
|
77
|
-
dirs = config[:dirs]
|
78
|
-
end
|
79
|
-
|
80
|
-
pkg = package_specification_with_semantics(version).new(prefixes, dirs)
|
81
|
-
pkg.parse_command_line if options[:parse_cmdline]
|
82
|
-
pkg.instance_eval(&instructions)
|
83
|
-
|
84
|
-
pkg.run_tasks if options[:run_tasks]
|
85
|
-
|
86
|
-
# pkg.install
|
87
|
-
pkg
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.package_specification_with_semantics(version)
|
91
|
-
#XXX: implement the full x.y(.z)? semantics
|
92
|
-
r = SEMANTICS[version]
|
93
|
-
raise SpecificationError, "Unknown version #{version}." unless r
|
94
|
-
r
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
module Actions
|
99
|
-
|
100
|
-
class InstallFile
|
101
|
-
|
102
|
-
attr_reader :source, :destination, :mode
|
103
|
-
|
104
|
-
def initialize(source, destination, mode, options)
|
105
|
-
@source = source
|
106
|
-
@destination = destination
|
107
|
-
@mode = mode
|
108
|
-
@options = options
|
109
|
-
end
|
110
|
-
|
111
|
-
def install
|
112
|
-
FileUtils.install @source, File.join(@options.destdir, @destination),
|
113
|
-
{:verbose => @options.verbose,
|
114
|
-
:noop => @options.noop, :mode => @mode }
|
115
|
-
end
|
116
|
-
|
117
|
-
def hash
|
118
|
-
[@source.hash, @destination.hash].hash
|
119
|
-
end
|
120
|
-
|
121
|
-
def eql?(other)
|
122
|
-
self.class == other.class &&
|
123
|
-
@source == other.source &&
|
124
|
-
@destination == other.destination &&
|
125
|
-
@mode == other.mode
|
126
|
-
end
|
127
|
-
|
128
|
-
def <=>(other)
|
129
|
-
FULL_ORDER[self, other] || self.destination <=> other.destination
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
class MkDir
|
134
|
-
|
135
|
-
attr_reader :directory
|
136
|
-
|
137
|
-
def initialize(directory, options)
|
138
|
-
@directory = directory
|
139
|
-
@options = options
|
140
|
-
end
|
141
|
-
|
142
|
-
def install
|
143
|
-
FileUtils.mkdir_p File.join(@options.destdir, @directory),
|
144
|
-
{:verbose => @options.verbose,
|
145
|
-
:noop => @options.noop }
|
146
|
-
end
|
147
|
-
|
148
|
-
def <=>(other)
|
149
|
-
FULL_ORDER[self, other] || self.directory <=> other.directory
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
class FixShebang
|
154
|
-
|
155
|
-
attr_reader :destination
|
156
|
-
|
157
|
-
def initialize(destination, options)
|
158
|
-
@options = options
|
159
|
-
@destination = destination
|
160
|
-
end
|
161
|
-
|
162
|
-
def install
|
163
|
-
path = File.join(@options.destdir, @destination)
|
164
|
-
fix_shebang(path)
|
165
|
-
end
|
166
|
-
|
167
|
-
# taken from rpa-base, originally based on setup.rb's
|
168
|
-
# modify: #!/usr/bin/ruby
|
169
|
-
# modify: #! /usr/bin/ruby
|
170
|
-
# modify: #!ruby
|
171
|
-
# not modify: #!/usr/bin/env ruby
|
172
|
-
SHEBANG_RE = /\A\#!\s*\S*ruby\S*/
|
173
|
-
|
174
|
-
#TODO allow the ruby-prog to be placed in the shebang line to be passed as
|
175
|
-
# an option
|
176
|
-
def fix_shebang(path)
|
177
|
-
tmpfile = path + '.tmp'
|
178
|
-
begin
|
179
|
-
#XXX: needed at all?
|
180
|
-
# it seems that FileUtils doesn't expose its default output
|
181
|
-
# @fileutils_output = $stderr
|
182
|
-
# we might want to allow this to be redirected.
|
183
|
-
$stderr.puts "shebang:open #{tmpfile}" if @options.verbose
|
184
|
-
unless @options.noop
|
185
|
-
File.open(path) do |r|
|
186
|
-
File.open(tmpfile, 'w', 0755) do |w|
|
187
|
-
first = r.gets
|
188
|
-
return unless SHEBANG_RE =~ first
|
189
|
-
w.print first.sub(SHEBANG_RE, '#!' + Config::CONFIG['ruby-prog'])
|
190
|
-
w.write r.read
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
FileUtils.mv(tmpfile, path, :verbose => @options.verbose,
|
195
|
-
:noop => @options.noop)
|
196
|
-
ensure
|
197
|
-
FileUtils.rm_f(tmpfile, :verbose => @options.verbose,
|
198
|
-
:noop => @options.noop)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
def <=>(other)
|
203
|
-
FULL_ORDER[self, other] || self.destination <=> other.destination
|
204
|
-
end
|
205
|
-
|
206
|
-
def hash
|
207
|
-
@destination.hash
|
208
|
-
end
|
209
|
-
|
210
|
-
def eql?(other)
|
211
|
-
self.class == other.class && self.destination == other.destination
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
order = [MkDir, InstallFile, FixShebang]
|
216
|
-
FULL_ORDER = lambda do |me, other|
|
217
|
-
a, b = order.index(me.class), order.index(other.class)
|
218
|
-
if a && b
|
219
|
-
(r = a - b) == 0 ? nil : r
|
220
|
-
else
|
221
|
-
-1 # arbitrary
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
class ActionList < Array
|
226
|
-
|
227
|
-
def directories!(options)
|
228
|
-
dirnames = []
|
229
|
-
map! { |d|
|
230
|
-
if d.kind_of?(InstallFile) && !dirnames.include?(File.dirname(d.destination))
|
231
|
-
dirnames << File.dirname(d.destination)
|
232
|
-
[MkDir.new(File.dirname(d.destination), options), d]
|
233
|
-
else
|
234
|
-
d
|
235
|
-
end
|
236
|
-
}
|
237
|
-
flatten!
|
238
|
-
end
|
239
|
-
|
240
|
-
def run(task)
|
241
|
-
each { |action| action.__send__ task }
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
end # module Actions
|
246
|
-
|
247
|
-
Options = Struct.new(:noop, :verbose, :destdir)
|
248
|
-
|
249
|
-
class PackageSpecification_1_0
|
250
|
-
|
251
|
-
TASKS = %w[config setup install test show]
|
252
|
-
# default options for translate(foo => bar)
|
253
|
-
TRANSLATE_DEFAULT_OPTIONS = { :inherit => true }
|
254
|
-
|
255
|
-
def self.declare_file_type(args, &handle_arg)
|
256
|
-
str_arr_p = lambda{|x| Array === x && x.all?{|y| String === y}}
|
257
|
-
|
258
|
-
# strict type checking --- we don't want this to be extended arbitrarily
|
259
|
-
unless args.size == 1 && Hash === args.first &&
|
260
|
-
args.first.all?{|f,r| [Proc, String, NilClass].include?(r.class) &&
|
261
|
-
(String === f || str_arr_p[f])} or
|
262
|
-
args.all?{|x| String === x || str_arr_p[x]}
|
263
|
-
raise SpecificationError,
|
264
|
-
"Unspecified semantics for the given arguments: #{args.inspect}"
|
265
|
-
end
|
266
|
-
|
267
|
-
if args.size == 1 && Hash === args.first
|
268
|
-
args.first.to_a.each do |file, rename_info|
|
269
|
-
if Array === file
|
270
|
-
# ignoring boring files
|
271
|
-
handle_arg.call(file, true, rename_info)
|
272
|
-
else
|
273
|
-
# we do want "boring" files given explicitly
|
274
|
-
handle_arg.call([file], false, rename_info)
|
275
|
-
end
|
276
|
-
end
|
277
|
-
else
|
278
|
-
args.each do |a|
|
279
|
-
if Array === a
|
280
|
-
a.each{|file| handle_arg.call(file, true, nil)}
|
281
|
-
else
|
282
|
-
handle_arg.call(a, false, nil)
|
283
|
-
end
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
#{{{ define the file tagging methods
|
289
|
-
KINDS.each { |kind|
|
290
|
-
define_method(kind) { |*args| # if this were 1.9 we could also take a block
|
291
|
-
bin_callback = lambda do |kind_, type, dest, options|
|
292
|
-
next if kind_ != :bin || type == :dir
|
293
|
-
@actions << Actions::FixShebang.new(dest, options)
|
294
|
-
end
|
295
|
-
#TODO: refactor
|
296
|
-
self.class.declare_file_type(args) do |files, ignore_p, opt_rename_info|
|
297
|
-
files.each do |file|
|
298
|
-
next if ignore_p && IGNORE_FILES.any?{|re| re.match(file)}
|
299
|
-
add_file(kind, file, opt_rename_info, &bin_callback)
|
300
|
-
end
|
301
|
-
end
|
302
|
-
}
|
303
|
-
}
|
304
|
-
|
305
|
-
def unit_test(*files)
|
306
|
-
@unit_tests.concat files.flatten
|
307
|
-
end
|
308
|
-
|
309
|
-
attr_accessor :actions, :options
|
310
|
-
|
311
|
-
def self.metadata(name)
|
312
|
-
define_method(name) { |*args|
|
313
|
-
if args.size == 1
|
314
|
-
@metadata[name] = args.first
|
315
|
-
end
|
316
|
-
@metadata[name]
|
317
|
-
}
|
318
|
-
end
|
319
|
-
|
320
|
-
metadata :name
|
321
|
-
metadata :version
|
322
|
-
metadata :author
|
323
|
-
|
324
|
-
|
325
|
-
def translate_dir(kind, dir)
|
326
|
-
replaced_dir_parts = dir.split(%r{/})
|
327
|
-
kept_dir_parts = []
|
328
|
-
loop do
|
329
|
-
replaced_path = replaced_dir_parts.join("/")
|
330
|
-
target, options = @translate[kind][replaced_path]
|
331
|
-
options ||= TRANSLATE_DEFAULT_OPTIONS
|
332
|
-
if target && (replaced_path == dir || options[:inherit])
|
333
|
-
dir = (target != '' ? File.join(target, *kept_dir_parts) :
|
334
|
-
File.join(*kept_dir_parts))
|
335
|
-
break
|
336
|
-
end
|
337
|
-
break if replaced_dir_parts.empty?
|
338
|
-
kept_dir_parts.unshift replaced_dir_parts.pop
|
339
|
-
end
|
340
|
-
dir
|
341
|
-
end
|
342
|
-
|
343
|
-
def add_file(kind, filename, new_filename_info, &callback)
|
344
|
-
#TODO: refactor!!!
|
345
|
-
if File.directory? filename #XXX setup.rb and rpa-base defined File.dir?
|
346
|
-
# to cope with some win32 issue
|
347
|
-
dir = filename.sub(/\A\.\//, "").sub(/\/\z/, "")
|
348
|
-
dest = File.join(@prefixes[kind], @dirs[kind], translate_dir(kind, dir))
|
349
|
-
@actions << Actions::MkDir.new(dest, @options)
|
350
|
-
callback.call(kind, :dir, dest, @options) if block_given?
|
351
|
-
else
|
352
|
-
if new_filename_info
|
353
|
-
case new_filename_info
|
354
|
-
when Proc
|
355
|
-
dest_name = new_filename_info.call(filename.dup)
|
356
|
-
else
|
357
|
-
dest_name = new_filename_info.dup
|
358
|
-
end
|
359
|
-
else
|
360
|
-
dest_name = filename.dup
|
361
|
-
end
|
362
|
-
|
363
|
-
dirname = File.dirname(dest_name)
|
364
|
-
dirname = "" if dirname == "."
|
365
|
-
dest_name = File.join(translate_dir(kind, dirname), File.basename(dest_name))
|
366
|
-
|
367
|
-
dest = File.join(@prefixes[kind], @dirs[kind], dest_name)
|
368
|
-
@actions << Actions::InstallFile.new(filename, dest, MODES[kind], @options)
|
369
|
-
callback.call(kind, :file, dest, @options) if block_given?
|
370
|
-
end
|
371
|
-
end
|
372
|
-
|
373
|
-
def initialize(prefixes = nil, dirs = nil)
|
374
|
-
@prefix = Config::CONFIG["prefix"].gsub(/\A\//, '')
|
375
|
-
@translate = {}
|
376
|
-
@prefixes = (prefixes || {}).dup
|
377
|
-
KINDS.each { |kind|
|
378
|
-
@prefixes[kind] = @prefix unless prefixes
|
379
|
-
@translate[kind] = {}
|
380
|
-
}
|
381
|
-
|
382
|
-
@dirs = (dirs || {}).dup
|
383
|
-
@dirs.update SITE_DIRS unless dirs
|
384
|
-
|
385
|
-
@actions = Actions::ActionList.new
|
386
|
-
|
387
|
-
@metadata = {}
|
388
|
-
@unit_tests = []
|
389
|
-
|
390
|
-
@options = Options.new
|
391
|
-
@options.verbose = true
|
392
|
-
@options.noop = true # XXX for testing
|
393
|
-
@options.destdir = ''
|
394
|
-
|
395
|
-
@tasks = []
|
396
|
-
end
|
397
|
-
|
398
|
-
def aoki
|
399
|
-
(KINDS - [:ext]).each { |kind|
|
400
|
-
translate(kind, kind.to_s => "", :inherit => true)
|
401
|
-
__send__ kind, Dir["#{kind}/**/*"]
|
402
|
-
}
|
403
|
-
translate(:ext, "ext/*" => "", :inherit => true)
|
404
|
-
ext Dir["ext/**/*.#{Config::CONFIG['DLEXT']}"]
|
405
|
-
end
|
406
|
-
|
407
|
-
def install
|
408
|
-
puts "Installing #{name || "unknown package"} #{version}..." if options.verbose
|
409
|
-
|
410
|
-
actions.uniq!
|
411
|
-
actions.sort!
|
412
|
-
actions.directories!(options)
|
413
|
-
|
414
|
-
#pp self
|
415
|
-
|
416
|
-
actions.run :install
|
417
|
-
end
|
418
|
-
|
419
|
-
def test
|
420
|
-
unless @unit_tests.empty?
|
421
|
-
puts "Testing #{name || "unknown package"} #{version}..." if options.verbose
|
422
|
-
require 'test/unit'
|
423
|
-
unless options.noop
|
424
|
-
t = Test::Unit::AutoRunner.new(true)
|
425
|
-
t.process_args(@unit_tests)
|
426
|
-
t.run
|
427
|
-
end
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
def config
|
432
|
-
File.open("config.save", "w") { |f|
|
433
|
-
YAML.dump({:prefixes => @prefixes, :dirs => @dirs}, f)
|
434
|
-
}
|
435
|
-
end
|
436
|
-
|
437
|
-
def show
|
438
|
-
KINDS.each { |kind|
|
439
|
-
puts "#{kind}\t#{File.join(options.destdir, @prefixes[kind], @dirs[kind])}"
|
440
|
-
}
|
441
|
-
end
|
442
|
-
|
443
|
-
def translate(kind, additional_translations)
|
444
|
-
default_opts = TRANSLATE_DEFAULT_OPTIONS.dup
|
445
|
-
key_val_pairs = additional_translations.to_a
|
446
|
-
option_pairs = key_val_pairs.select{|(k,v)| Symbol === k}
|
447
|
-
default_opts.update(Hash[*option_pairs.flatten])
|
448
|
-
|
449
|
-
(key_val_pairs - option_pairs).each do |key, val|
|
450
|
-
add_translation(kind, key, val, default_opts)
|
451
|
-
end
|
452
|
-
end
|
453
|
-
|
454
|
-
def add_translation(kind, src, dest, options)
|
455
|
-
if is_glob?(src)
|
456
|
-
dirs = expand_dir_glob(src)
|
457
|
-
else
|
458
|
-
dirs = [src]
|
459
|
-
end
|
460
|
-
dirs.each do |dirname|
|
461
|
-
dirname = dirname.sub(%r{\A\./}, "").sub(%r{/\z}, "")
|
462
|
-
@translate[kind].update({dirname => [dest, options]})
|
463
|
-
end
|
464
|
-
end
|
465
|
-
|
466
|
-
def is_glob?(x)
|
467
|
-
/(^|[^\\])[*?{\[]/.match(x)
|
468
|
-
end
|
469
|
-
|
470
|
-
def expand_dir_glob(src)
|
471
|
-
Dir[src].select{|x| File.directory?(x)}
|
472
|
-
end
|
473
|
-
|
474
|
-
def clean_path(path)
|
475
|
-
path.gsub(/\A\//, '').gsub(/\/+\Z/, '').squeeze("/")
|
476
|
-
end
|
477
|
-
|
478
|
-
def parse_command_line
|
479
|
-
opts = OptionParser.new(nil, 24, ' ') { |opts|
|
480
|
-
opts.banner = "Usage: setup.rb [options] [task]"
|
481
|
-
|
482
|
-
opts.separator ""
|
483
|
-
opts.separator "Tasks:"
|
484
|
-
opts.separator " config configures paths"
|
485
|
-
opts.separator " show shows paths"
|
486
|
-
opts.separator " setup compiles ruby extentions and others XXX"
|
487
|
-
opts.separator " install installs files"
|
488
|
-
opts.separator " test runs unit tests"
|
489
|
-
|
490
|
-
opts.separator ""
|
491
|
-
opts.separator "Specific options:"
|
492
|
-
|
493
|
-
opts.on "--prefix=PREFIX",
|
494
|
-
"path prefix of target environment [#@prefix]" do |prefix|
|
495
|
-
@prefix.replace clean_path(prefix) # Shared!
|
496
|
-
end
|
497
|
-
|
498
|
-
opts.separator ""
|
499
|
-
|
500
|
-
KINDS.each { |kind|
|
501
|
-
opts.on "--#{kind}prefix=PREFIX",
|
502
|
-
"path prefix for #{kind} files [#{@prefixes[kind]}]" do |prefix|
|
503
|
-
@prefixes[kind] = clean_path(prefix)
|
504
|
-
end
|
505
|
-
}
|
506
|
-
|
507
|
-
opts.separator ""
|
508
|
-
|
509
|
-
KINDS.each { |kind|
|
510
|
-
opts.on "--#{kind}dir=PREFIX",
|
511
|
-
"directory for #{kind} files [#{@dirs[kind]}]" do |prefix|
|
512
|
-
@dirs[kind] = clean_path(prefix)
|
513
|
-
end
|
514
|
-
}
|
515
|
-
|
516
|
-
opts.separator ""
|
517
|
-
|
518
|
-
KINDS.each { |kind|
|
519
|
-
opts.on "--#{kind}=PREFIX",
|
520
|
-
"absolute directory for #{kind} files [#{File.join(@prefixes[kind], @dirs[kind])}]" do |prefix|
|
521
|
-
@prefixes[kind] = clean_path(prefix)
|
522
|
-
end
|
523
|
-
}
|
524
|
-
|
525
|
-
opts.separator ""
|
526
|
-
opts.separator "Predefined path configurations:"
|
527
|
-
opts.on "--site", "install into site-local directories (default)" do
|
528
|
-
@dirs.update SITE_DIRS
|
529
|
-
end
|
530
|
-
|
531
|
-
opts.on "--vendor", "install into distribution directories (for packagers)" do
|
532
|
-
@dirs.update VENDOR_DIRS
|
533
|
-
end
|
534
|
-
|
535
|
-
opts.separator ""
|
536
|
-
opts.separator "General options:"
|
537
|
-
|
538
|
-
opts.on "--destdir=DESTDIR",
|
539
|
-
"install all files relative to DESTDIR (/)" do |destdir|
|
540
|
-
@options.destdir = destdir
|
541
|
-
end
|
542
|
-
|
543
|
-
opts.on "--dry-run", "only display what to do if given [#{@options.noop}]" do
|
544
|
-
@options.noop = true
|
545
|
-
end
|
546
|
-
|
547
|
-
opts.on "--no-harm", "only display what to do if given" do
|
548
|
-
@options.noop = true
|
549
|
-
end
|
550
|
-
|
551
|
-
opts.on "--[no-]verbose", "output messages verbosely [#{@options.verbose}]" do |verbose|
|
552
|
-
@options.verbose = verbose
|
553
|
-
end
|
554
|
-
|
555
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
556
|
-
puts opts
|
557
|
-
exit
|
558
|
-
end
|
559
|
-
}
|
560
|
-
|
561
|
-
opts.parse! ARGV
|
562
|
-
|
563
|
-
if (ARGV - TASKS).empty? # Only existing tasks?
|
564
|
-
@tasks = ARGV
|
565
|
-
@tasks = ["install"] if @tasks.empty?
|
566
|
-
else
|
567
|
-
abort "Unknown task(s) #{(ARGV-TASKS).join ", "}."
|
568
|
-
end
|
569
|
-
end
|
570
|
-
|
571
|
-
def run_tasks
|
572
|
-
@tasks.each { |task| __send__ task }
|
573
|
-
end
|
574
|
-
end
|
575
|
-
|
576
|
-
end # module Package
|
577
|
-
|
578
|
-
#XXX incomplete setup.rb support for the hooks
|
579
|
-
require 'rbconfig'
|
580
|
-
def config(x)
|
581
|
-
Config::CONFIG[x]
|
582
|
-
end
|
583
|
-
|
584
|
-
|
585
|
-
if $0 == __FILE__
|
586
|
-
|
587
|
-
version = "4.5.1"
|
588
|
-
|
589
|
-
Package.setup("1.0") {
|
590
|
-
|
591
|
-
translate :bin, 'bin' => ''
|
592
|
-
bin *Dir['bin/**/*']
|
593
|
-
|
594
|
-
translate :lib, 'lib/reap' => "reap/#{version}"
|
595
|
-
lib *Dir['lib/**/*']
|
596
|
-
|
597
|
-
translate :doc, 'doc' => "reap/#{version}"
|
598
|
-
doc *Dir['doc/**/*']
|
599
|
-
|
600
|
-
translate :ext, 'ext' => "reap/#{version}"
|
601
|
-
ext *Dir['ext/**/*']
|
602
|
-
|
603
|
-
translate :data, 'data/reap' => "reap/#{version}"
|
604
|
-
data *Dir['data/**/*']
|
605
|
-
|
606
|
-
translate :conf, 'conf/reap' => "reap/#{version}"
|
607
|
-
conf *Dir['conf/**/*']
|
608
|
-
|
609
|
-
#translate(:lib, '' => 'fuutils', 'blerg' => '', 'blorg' => 'borg')
|
610
|
-
#lib "feeble.rb", "fooble.rb", "fuuble.rb"
|
611
|
-
#lib "fooble.rb"
|
612
|
-
#lib "blerg/foo.rb", "blorg/foo.rb"
|
613
|
-
#lib "fruubar.rb" => "fuubar.rb"
|
614
|
-
#lib "friibar.rb" => lambda{|x| "fiibar.rb"}
|
615
|
-
#lib ["stuff.orig", "core", ".bla.rb.swp"] # will be ignored
|
616
|
-
#doc "bla.orig" # will not be ignored
|
617
|
-
#doc "foo.orig" => "bla.txt" # ditto
|
618
|
-
#lib ["lfoo1", "lbar1"]
|
619
|
-
#lib ["lfoo", "lbar"] => lambda{|x| "#{x}.rb"}
|
620
|
-
#translate(:data, '_darcs' => 'DARCS')
|
621
|
-
#data "_darcs/" # just to test MkDir generation
|
622
|
-
|
623
|
-
#pp self
|
624
|
-
}
|
625
|
-
|
626
|
-
end
|
627
|
-
|
628
|
-
|
629
|
-
# vim: sw=2 sts=2 et ts=8
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# Ruby Treasures 0.4
|
2
|
-
# Copyright (C) 2002 Paul Brannan <paul@atdesk.com>
|
3
|
-
#
|
4
|
-
# You may distribute this software under the same terms as Ruby (see the file
|
5
|
-
# COPYING that was distributed with this library).
|
6
|
-
#
|
7
|
-
# Ruby Treasures 0.2
|
8
|
-
# Copyright (C) 2002 Paul Brannan <paul@atdesk.com>
|
9
|
-
#
|
10
|
-
# You may distribute this software under the same terms as Ruby (see the file
|
11
|
-
# COPYING that was distributed with this library).
|
12
|
-
#
|
13
|
-
# Run this Ruby script to prepare the RubyTreasures distribution for
|
14
|
-
# publication.
|
15
|
-
|
16
|
-
require 'find'
|
17
|
-
require 'ftools'
|
18
|
-
|
19
|
-
|
20
|
-
# Add licences to the top of every file and remove unnecessary files
|
21
|
-
|
22
|
-
license = IO.readlines('LICENSE')
|
23
|
-
ruby_license_comment = license.map { |i| i.sub(/^/, '# ') }
|
24
|
-
c_license_comment = ["/*\n"] + license.map { |i| i.sub(/^/, ' * ') } + [" */\n"]
|
25
|
-
|
26
|
-
def rm_rf(dir)
|
27
|
-
Dir.foreach(dir) do |f|
|
28
|
-
if not f =~ /\.?\.$/ then
|
29
|
-
filename = File.join(dir, f)
|
30
|
-
if File.directory?(filename) then
|
31
|
-
rm_rf(filename)
|
32
|
-
else
|
33
|
-
puts "Removing file #{filename}"
|
34
|
-
File.rm_f(filename)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
puts "Removing directory #{dir}"
|
39
|
-
Dir.rmdir(dir)
|
40
|
-
end
|
41
|
-
|
42
|
-
Find.find('.') do |file|
|
43
|
-
if File.directory?(file) then
|
44
|
-
case file
|
45
|
-
when /\/CVS$/
|
46
|
-
# Remove CVS directories
|
47
|
-
rm_rf(file)
|
48
|
-
else
|
49
|
-
# Remove empty directories
|
50
|
-
entries = Dir.entries(file)
|
51
|
-
entries.delete('.')
|
52
|
-
entries.delete('..')
|
53
|
-
entries.delete('CVS')
|
54
|
-
if entries.length == 0 then
|
55
|
-
rm_rf(file)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
else
|
59
|
-
case file
|
60
|
-
when /\.rb$/
|
61
|
-
# Add LICENSE to ruby sources
|
62
|
-
puts "Adding license to #{file}"
|
63
|
-
lines = ruby_license_comment + IO.readlines(file)
|
64
|
-
File.open(file, 'w') do |out|
|
65
|
-
lines.each do |line|
|
66
|
-
out.puts line
|
67
|
-
end
|
68
|
-
end
|
69
|
-
when /\.c$/
|
70
|
-
# Add LICENSE to C sources
|
71
|
-
puts "Adding license to #{file}"
|
72
|
-
lines = c_license_comment + IO.readlines(file)
|
73
|
-
File.open(file, 'w') do |out|
|
74
|
-
lines.each do |line|
|
75
|
-
out.puts line
|
76
|
-
end
|
77
|
-
end
|
78
|
-
when /~$/
|
79
|
-
# Remove temporary files
|
80
|
-
puts "Removing file #{file}"
|
81
|
-
File.rm_f(file)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|