p4ruby 2012.1Beta → 2012.2.beta
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.
- data/install.rb +434 -433
- data/p4ruby.gemspec +1 -1
- metadata +63 -49
data/install.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author: James M. Lawrence <quixoticsycophant@gmail.com>.
|
3
3
|
#
|
4
|
-
#Updated by Brett Bates and Jennifer Bottom.
|
5
4
|
|
6
5
|
require 'net/ftp'
|
7
6
|
require 'rbconfig'
|
@@ -12,214 +11,213 @@ require 'pathname'
|
|
12
11
|
require 'rubygems'
|
13
12
|
|
14
13
|
class Installer
|
15
|
-
|
16
|
-
|
17
|
-
CONFIG = Config::CONFIG
|
18
|
-
BIT64 = (1.size == 8)
|
19
|
-
|
20
|
-
RB_BASENAME = Pathname.new "P4.rb"
|
21
|
-
SO_BASENAME = Pathname.new "P4.#{CONFIG['DLEXT']}"
|
22
|
-
|
23
|
-
RAW_INSTALL_FILES = [
|
24
|
-
Pathname.new(CONFIG["sitelibdir"]) + RB_BASENAME,
|
25
|
-
Pathname.new(CONFIG["sitearchdir"]) + SO_BASENAME,
|
26
|
-
]
|
27
|
-
|
28
|
-
GEM_INSTALL_FILES = [
|
29
|
-
Pathname.new("lib") + RB_BASENAME,
|
30
|
-
Pathname.new("ext") + SO_BASENAME,
|
31
|
-
]
|
32
|
-
|
33
|
-
SERVER = "ftp.perforce.com"
|
34
|
-
SERVER_TOP_DIR = Pathname.new "perforce"
|
35
|
-
|
36
|
-
# Mysterious "ghost" releases which lack files
|
37
|
-
HOSED_VERSIONS = %w[09.3 11.1]
|
38
|
-
|
39
|
-
P4API_REMOTE_BASENAME = Pathname.new "p4api.tgz"
|
40
|
-
P4RUBY_REMOTE_BASENAME = Pathname.new "p4ruby.tgz"
|
41
|
-
|
42
|
-
WORK_DIR = Pathname.new "work"
|
43
|
-
DISTFILES_DIR = WORK_DIR + "distfiles"
|
44
|
-
BUILD_DIR = WORK_DIR + "build"
|
45
|
-
|
46
|
-
def parse_command_line
|
47
|
-
OptionParser.new("Usage: ruby install.rb [options]", 24, "") {
|
48
|
-
|parser|
|
49
|
-
parser.on(
|
50
|
-
"--version NN.N",
|
51
|
-
"Version to download, e.g. 08.1. Default finds latest.") {
|
52
|
-
|version|
|
53
|
-
@s.version = version
|
54
|
-
}
|
55
|
-
parser.on(
|
56
|
-
"--list-versions",
|
57
|
-
"List available versions.") {
|
58
|
-
@s.list_versions = true
|
59
|
-
}
|
60
|
-
parser.on(
|
61
|
-
"--platform PLATFORM",
|
62
|
-
"Perforce-named platform to download. Default guesses.") {
|
63
|
-
|platform|
|
64
|
-
@s.platform = platform
|
65
|
-
}
|
66
|
-
parser.on(
|
67
|
-
"--list-platforms",
|
68
|
-
"List available platforms for the given version.") {
|
69
|
-
@s.list_platforms = true
|
70
|
-
}
|
71
|
-
parser.on(
|
72
|
-
"--gem",
|
73
|
-
"Gem configuration (for the gem installer).") {
|
74
|
-
@s.gem_config = true
|
75
|
-
}
|
76
|
-
parser.on(
|
77
|
-
"--uninstall",
|
78
|
-
"Uninstall.") {
|
79
|
-
@s.uninstall = true
|
80
|
-
}
|
81
|
-
parser.on(
|
82
|
-
"--local",
|
83
|
-
"Use the files in work/distfiles (manual download).") {
|
84
|
-
@s.local = true
|
85
|
-
}
|
86
|
-
parser.parse(ARGV)
|
87
|
-
}
|
88
|
-
end
|
89
|
-
|
90
|
-
def run
|
91
|
-
@s = LazyStruct.new
|
92
|
-
parse_command_line
|
93
|
-
config
|
94
|
-
if @s.uninstall
|
95
|
-
uninstall
|
96
|
-
elsif @s.list_platforms
|
97
|
-
puts platforms
|
98
|
-
elsif @s.list_versions
|
99
|
-
puts versions
|
100
|
-
elsif @s.platform.nil?
|
101
|
-
platform_fail
|
102
|
-
elsif @s.platform =~ %r!\Ant!
|
103
|
-
windows_install
|
104
|
-
else
|
105
|
-
fetch
|
106
|
-
build
|
107
|
-
install
|
108
|
-
verify_install
|
109
|
-
end
|
110
|
-
end
|
14
|
+
include FileUtils
|
111
15
|
|
112
|
-
|
113
|
-
|
114
|
-
raise "error: ruby must be configured with --enable-shared"
|
115
|
-
end
|
16
|
+
CONFIG = Config::CONFIG
|
17
|
+
BIT64 = (1.size == 8)
|
116
18
|
|
117
|
-
|
118
|
-
|
119
|
-
t.login
|
120
|
-
}
|
19
|
+
RB_BASENAME = Pathname.new "P4.rb"
|
20
|
+
SO_BASENAME = Pathname.new "P4.#{CONFIG['DLEXT']}"
|
121
21
|
|
122
|
-
|
123
|
-
|
124
|
-
|
22
|
+
RAW_INSTALL_FILES = [
|
23
|
+
Pathname.new(CONFIG["sitelibdir"]) + RB_BASENAME,
|
24
|
+
Pathname.new(CONFIG["sitearchdir"]) + SO_BASENAME,
|
25
|
+
]
|
125
26
|
|
126
|
-
|
127
|
-
|
128
|
-
|
27
|
+
GEM_INSTALL_FILES = [
|
28
|
+
Pathname.new("lib") + RB_BASENAME,
|
29
|
+
Pathname.new("ext") + SO_BASENAME,
|
30
|
+
]
|
129
31
|
|
130
|
-
|
131
|
-
|
132
|
-
spec.local = DISTFILES_DIR + spec.basename
|
133
|
-
}
|
134
|
-
|
135
|
-
unless @s.version
|
136
|
-
@s.version = latest_version
|
137
|
-
end
|
32
|
+
SERVER = "ftp.perforce.com"
|
33
|
+
SERVER_TOP_DIR = Pathname.new "perforce"
|
138
34
|
|
139
|
-
|
35
|
+
# Mysterious "ghost" releases which lack files
|
36
|
+
HOSED_VERSIONS = %w[09.3 11.1]
|
140
37
|
|
141
|
-
|
142
|
-
|
38
|
+
P4API_REMOTE_BASENAME = Pathname.new "p4api.tgz"
|
39
|
+
P4RUBY_REMOTE_BASENAME = Pathname.new "p4ruby.tgz"
|
40
|
+
|
41
|
+
WORK_DIR = Pathname.new "work"
|
42
|
+
DISTFILES_DIR = WORK_DIR + "distfiles"
|
43
|
+
BUILD_DIR = WORK_DIR + "build"
|
44
|
+
|
45
|
+
def parse_command_line
|
46
|
+
OptionParser.new("Usage: ruby install.rb [options]", 24, "") {
|
47
|
+
|parser|
|
48
|
+
parser.on(
|
49
|
+
"--version NN.N",
|
50
|
+
"Version to download, e.g. 08.1. Default finds latest.") {
|
51
|
+
|version|
|
52
|
+
@s.version = version
|
53
|
+
}
|
54
|
+
parser.on(
|
55
|
+
"--list-versions",
|
56
|
+
"List available versions.") {
|
57
|
+
@s.list_versions = true
|
58
|
+
}
|
59
|
+
parser.on(
|
60
|
+
"--platform PLATFORM",
|
61
|
+
"Perforce-named platform to download. Default guesses.") {
|
62
|
+
|platform|
|
63
|
+
@s.platform = platform
|
64
|
+
}
|
65
|
+
parser.on(
|
66
|
+
"--list-platforms",
|
67
|
+
"List available platforms for the given version.") {
|
68
|
+
@s.list_platforms = true
|
69
|
+
}
|
70
|
+
parser.on(
|
71
|
+
"--gem",
|
72
|
+
"Gem configuration (for the gem installer).") {
|
73
|
+
@s.gem_config = true
|
74
|
+
}
|
75
|
+
parser.on(
|
76
|
+
"--uninstall",
|
77
|
+
"Uninstall.") {
|
78
|
+
@s.uninstall = true
|
79
|
+
}
|
80
|
+
parser.on(
|
81
|
+
"--local",
|
82
|
+
"Use the files in work/distfiles (manual download).") {
|
83
|
+
@s.local = true
|
84
|
+
}
|
85
|
+
parser.parse(ARGV)
|
86
|
+
}
|
143
87
|
end
|
144
88
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
89
|
+
def run
|
90
|
+
@s = LazyStruct.new
|
91
|
+
parse_command_line
|
92
|
+
config
|
93
|
+
if @s.uninstall
|
94
|
+
uninstall
|
95
|
+
elsif @s.list_platforms
|
96
|
+
puts platforms
|
97
|
+
elsif @s.list_versions
|
98
|
+
puts versions
|
99
|
+
elsif @s.platform.nil?
|
100
|
+
platform_fail
|
101
|
+
elsif @s.platform =~ %r!\Ant!
|
102
|
+
windows_install
|
103
|
+
else
|
104
|
+
fetch
|
105
|
+
build
|
106
|
+
install
|
107
|
+
verify_install
|
108
|
+
end
|
150
109
|
end
|
151
110
|
|
111
|
+
def config
|
112
|
+
if CONFIG["LIBRUBYARG_SHARED"].empty?
|
113
|
+
raise "error: ruby must be configured with --enable-shared"
|
114
|
+
end
|
115
|
+
|
116
|
+
@s.ftp = Net::FTP.new(SERVER).tap { |t|
|
117
|
+
t.passive = true
|
118
|
+
t.login
|
119
|
+
}
|
120
|
+
|
121
|
+
@s.p4api = LazyStruct.new.tap { |t|
|
122
|
+
t.basename = P4API_REMOTE_BASENAME
|
123
|
+
}
|
124
|
+
|
125
|
+
@s.p4ruby = LazyStruct.new.tap { |t|
|
126
|
+
t.basename = P4RUBY_REMOTE_BASENAME
|
127
|
+
}
|
128
|
+
|
129
|
+
@s.specs = [@s.p4ruby, @s.p4api]
|
130
|
+
@s.specs.each { |spec|
|
131
|
+
spec.local = DISTFILES_DIR + spec.basename
|
132
|
+
}
|
133
|
+
|
134
|
+
unless @s.version
|
135
|
+
@s.version = latest_version
|
136
|
+
end
|
137
|
+
|
138
|
+
@s.version_dir = SERVER_TOP_DIR + "r#{@s.version}"
|
152
139
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
140
|
+
unless @s.platform
|
141
|
+
@s.platform = guess_platform
|
142
|
+
end
|
143
|
+
|
144
|
+
if @s.platform =~ /nt/
|
145
|
+
@s.p4api.remote = @s.version_dir + "bin.#{@s.platform}"
|
146
|
+
else
|
147
|
+
@s.p4api.remote = @s.version_dir + "bin.#{@s.platform}" + @s.p4api.basename
|
148
|
+
@s.p4ruby.remote = @s.version_dir + "bin.tools" + @s.p4ruby.basename
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
def guess_cpu
|
155
|
+
if CONFIG["target_os"] =~ /darwin/i
|
156
|
+
if CONFIG["build"] =~ /i686|x86_64/
|
157
|
+
"x86_64"
|
158
|
+
else
|
159
|
+
"x86"
|
160
|
+
end
|
161
|
+
else
|
162
|
+
case CONFIG["target_cpu"]
|
163
|
+
when %r!ia!i
|
164
|
+
"ia64"
|
165
|
+
when %r!86!
|
166
|
+
# note: with '_'
|
167
|
+
"x86" + (BIT64 ? "_64" : "")
|
168
|
+
when %r!(ppc|sparc)!i
|
169
|
+
# note: without '_'
|
170
|
+
$1 + (BIT64 ? "64" : "")
|
171
|
+
else
|
172
|
+
""
|
173
|
+
end
|
174
|
+
end
|
175
175
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
nil
|
176
|
+
|
177
|
+
def guess_version(os)
|
178
|
+
if match = `uname -a`.match(%r!#{os}\s+\S+\s+(\d+)\.(\d+)!i)
|
179
|
+
version = match.captures.join
|
180
|
+
cpu = guess_cpu
|
181
|
+
platforms = self.platforms
|
182
|
+
built_platforms = (0..version.to_i).map { |n|
|
183
|
+
[os, n.to_s, cpu].join
|
184
|
+
}.select { |platform|
|
185
|
+
platforms.include? platform
|
186
|
+
}
|
187
|
+
if os =~ /darwin/
|
188
|
+
built_platforms.last
|
189
|
+
else
|
190
|
+
built_platforms.last
|
191
|
+
end
|
192
|
+
else
|
193
|
+
nil
|
194
|
+
end
|
196
195
|
end
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
196
|
+
|
197
|
+
def guess_platform(opts = { })
|
198
|
+
config_os = CONFIG["target_os"].downcase
|
199
|
+
windows_cpu = BIT64 ? "x64" : "x86"
|
200
|
+
|
201
|
+
if config_os =~ %r!cygwin!i
|
202
|
+
"cygwin" + windows_cpu
|
203
|
+
elsif config_os =~ %r!(mswin|mingw)!i
|
204
|
+
"nt" + windows_cpu
|
205
|
+
elsif @s.local
|
206
|
+
"<local>"
|
207
|
+
else
|
208
|
+
if match = config_os.match(%r!\A\D+!)
|
209
|
+
guess_version(match[0])
|
210
|
+
else
|
211
|
+
nil
|
212
|
+
end
|
213
|
+
end
|
215
214
|
end
|
216
|
-
end
|
217
215
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
216
|
+
def platform_fail
|
217
|
+
install_fail {
|
218
|
+
@s.version = "<version>"
|
219
|
+
@s.platform = "<platform>"
|
220
|
+
message = %Q{
|
223
221
|
Auto-fetch not yet handled for this platform. Run:
|
224
222
|
|
225
223
|
\truby install.rb --list-platforms
|
@@ -236,275 +234,278 @@ class Installer
|
|
236
234
|
|
237
235
|
Copy it to #{@s.p4api.local} and run install.rb --local.
|
238
236
|
}.gsub(%r!^ +(?=\S)!, "")
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
end
|
244
|
-
|
245
|
-
def install_fail
|
246
|
-
yield
|
247
|
-
exit(1)
|
248
|
-
end
|
249
|
-
|
250
|
-
def sys(*args)
|
251
|
-
system(*args).tap { |result|
|
252
|
-
unless result
|
253
|
-
raise "system() failed: #{args.join(" ")}"
|
254
|
-
end
|
255
|
-
}
|
256
|
-
end
|
257
|
-
|
258
|
-
def unpack(distfile, target_dir)
|
259
|
-
sys("tar", "zxvf", distfile.to_s, "-C", target_dir.to_s)
|
260
|
-
end
|
261
|
-
|
262
|
-
def fetch_spec(spec)
|
263
|
-
unless @s.local
|
264
|
-
mkdir_p(spec.local.dirname)
|
265
|
-
puts "downloading ftp://#{SERVER}/#{spec.remote} ..."
|
266
|
-
@s.ftp.getbinaryfile(spec.remote.to_s, spec.local.to_s)
|
237
|
+
|
238
|
+
mkdir_p(DISTFILES_DIR)
|
239
|
+
puts message
|
240
|
+
}
|
267
241
|
end
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
}.reject { |platform|
|
292
|
-
platform =~ %r!java!
|
293
|
-
}.sort
|
294
|
-
end
|
295
|
-
|
296
|
-
def versions
|
297
|
-
remote_files_matching(SERVER_TOP_DIR, %r!r([0-8]\d\.\d)!) { |match|
|
298
|
-
match.captures.first
|
299
|
-
}.reject { |version|
|
300
|
-
HOSED_VERSIONS.include? version
|
301
|
-
}.sort
|
302
|
-
end
|
303
|
-
|
304
|
-
def latest_version
|
305
|
-
versions.reverse_each{ |v|
|
306
|
-
begin
|
307
|
-
remote_files_matching("#{SERVER_TOP_DIR}/r#{v}/bin.tools",/p4ruby/) do
|
308
|
-
return v
|
242
|
+
|
243
|
+
def install_fail
|
244
|
+
yield
|
245
|
+
exit(1)
|
246
|
+
end
|
247
|
+
|
248
|
+
def sys(*args)
|
249
|
+
system(*args).tap { |result|
|
250
|
+
unless result
|
251
|
+
raise "system() failed: #{args.join(" ")}"
|
252
|
+
end
|
253
|
+
}
|
254
|
+
end
|
255
|
+
|
256
|
+
def unpack(distfile, target_dir)
|
257
|
+
sys("tar", "zxvf", distfile.to_s, "-C", target_dir.to_s)
|
258
|
+
end
|
259
|
+
|
260
|
+
def fetch_spec(spec)
|
261
|
+
unless @s.local
|
262
|
+
mkdir_p(spec.local.dirname)
|
263
|
+
puts "downloading ftp://#{SERVER}/#{spec.remote} ..."
|
264
|
+
@s.ftp.getbinaryfile(spec.remote.to_s, spec.local.to_s)
|
309
265
|
end
|
310
|
-
rescue
|
311
|
-
next
|
312
|
-
end
|
313
|
-
}
|
314
|
-
end
|
315
|
-
|
316
|
-
def make(*args)
|
317
|
-
sys("make", *args)
|
318
|
-
end
|
319
|
-
|
320
|
-
def ruby(*args)
|
321
|
-
exe = Pathname.new(CONFIG["bindir"]) + CONFIG["RUBY_INSTALL_NAME"]
|
322
|
-
sys(exe.to_s, *args)
|
323
|
-
end
|
324
|
-
|
325
|
-
def build
|
326
|
-
puts "building..."
|
327
|
-
rm_rf(BUILD_DIR)
|
328
|
-
mkdir_p(BUILD_DIR)
|
329
|
-
|
330
|
-
@s.specs.each { |spec|
|
331
|
-
unpack(spec.local, BUILD_DIR)
|
332
|
-
}
|
333
|
-
|
334
|
-
Dir.chdir(BUILD_DIR) {
|
335
|
-
api_dir = Pathname.glob("p4api*").last
|
336
|
-
p4ruby_dir = Pathname.glob("p4ruby*").last
|
337
|
-
Dir.chdir(p4ruby_dir) {
|
338
|
-
ruby("p4conf.rb", "--apidir", "../#{api_dir}")
|
339
|
-
make
|
340
|
-
}
|
341
|
-
@s.p4ruby_build_dir = BUILD_DIR + p4ruby_dir
|
342
|
-
}
|
343
|
-
end
|
344
|
-
|
345
|
-
def raw_install_to_gem_install
|
346
|
-
RAW_INSTALL_FILES.zip(GEM_INSTALL_FILES) { |source, dest|
|
347
|
-
mkdir_p(dest.dirname)
|
348
|
-
puts "move #{source} --> #{dest}"
|
349
|
-
mv(source, dest)
|
350
|
-
}
|
351
|
-
end
|
352
|
-
|
353
|
-
def install
|
354
|
-
puts "installing..."
|
355
|
-
Dir.chdir(@s.p4ruby_build_dir) {
|
356
|
-
make("install")
|
357
|
-
}
|
358
|
-
if @s.gem_config
|
359
|
-
raw_install_to_gem_install
|
360
266
|
end
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
if @s.gem_config
|
367
|
-
GEM_INSTALL_FILES
|
368
|
-
else
|
369
|
-
RAW_INSTALL_FILES
|
370
|
-
end.map { |t| t.expand_path }
|
371
|
-
|
372
|
-
if files.all? { |t| t.exist? }
|
373
|
-
puts "Installed files:"
|
374
|
-
puts files
|
375
|
-
elsif on_error
|
376
|
-
install_fail(&on_error)
|
377
|
-
else
|
378
|
-
install_fail {
|
379
|
-
puts "These files were supposed to be installed, but were not:"
|
380
|
-
puts files
|
381
|
-
puts "Install failed!"
|
382
|
-
}
|
267
|
+
|
268
|
+
def fetch
|
269
|
+
@s.specs.each { |spec|
|
270
|
+
fetch_spec(spec)
|
271
|
+
}
|
383
272
|
end
|
384
|
-
end
|
385
273
|
|
386
|
-
|
387
|
-
|
274
|
+
def remote_files_matching(dir, regex)
|
275
|
+
@s.ftp.ls(dir.to_s).map { |entry|
|
276
|
+
if match = entry.match(regex)
|
277
|
+
yield match
|
278
|
+
else
|
279
|
+
nil
|
280
|
+
end
|
281
|
+
}.reject { |entry|
|
282
|
+
entry.nil?
|
283
|
+
}
|
284
|
+
end
|
388
285
|
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
286
|
+
def platforms
|
287
|
+
remote_files_matching(@s.version_dir, %r!bin\.(\w+)!) { |match|
|
288
|
+
match.captures.first
|
289
|
+
}.reject { |platform|
|
290
|
+
platform =~ %r!java!
|
291
|
+
}.sort
|
292
|
+
end
|
396
293
|
|
397
|
-
|
398
|
-
|
399
|
-
|
294
|
+
def versions
|
295
|
+
remote_files_matching(SERVER_TOP_DIR, %r!r([0-8]\d\.\d)!) { |match|
|
296
|
+
match.captures.first
|
297
|
+
}.reject { |version|
|
298
|
+
HOSED_VERSIONS.include? version
|
299
|
+
}.sort
|
300
|
+
end
|
400
301
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
302
|
+
def latest_version
|
303
|
+
versions.reverse_each { |v|
|
304
|
+
begin
|
305
|
+
remote_files_matching("#{SERVER_TOP_DIR}/r#{v}/bin.tools", /p4ruby/) do
|
306
|
+
return v
|
307
|
+
end
|
308
|
+
rescue
|
309
|
+
next
|
310
|
+
end
|
311
|
+
}
|
312
|
+
end
|
313
|
+
|
314
|
+
def make(*args)
|
315
|
+
sys("make", *args)
|
413
316
|
end
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
317
|
+
|
318
|
+
def ruby(*args)
|
319
|
+
exe = Pathname.new(CONFIG["bindir"]) + CONFIG["RUBY_INSTALL_NAME"]
|
320
|
+
sys(exe.to_s, *args)
|
321
|
+
end
|
322
|
+
|
323
|
+
def build
|
324
|
+
puts "building..."
|
325
|
+
rm_rf(BUILD_DIR)
|
326
|
+
mkdir_p(BUILD_DIR)
|
327
|
+
|
328
|
+
@s.specs.each { |spec|
|
329
|
+
unpack(spec.local, BUILD_DIR)
|
330
|
+
}
|
331
|
+
|
332
|
+
Dir.chdir(BUILD_DIR) {
|
333
|
+
api_dir = Pathname.glob("p4api*").last
|
334
|
+
p4ruby_dir = Pathname.glob("p4ruby*").last
|
335
|
+
Dir.chdir(p4ruby_dir) {
|
336
|
+
ruby("p4conf.rb", "--apidir", "../#{api_dir}")
|
337
|
+
make
|
338
|
+
}
|
339
|
+
@s.p4ruby_build_dir = BUILD_DIR + p4ruby_dir
|
340
|
+
}
|
341
|
+
end
|
342
|
+
|
343
|
+
def raw_install_to_gem_install
|
344
|
+
RAW_INSTALL_FILES.zip(GEM_INSTALL_FILES) { |source, dest|
|
345
|
+
mkdir_p(dest.dirname)
|
346
|
+
puts "move #{source} --> #{dest}"
|
347
|
+
mv(source, dest)
|
348
|
+
}
|
349
|
+
end
|
350
|
+
|
351
|
+
def install
|
352
|
+
puts "installing..."
|
353
|
+
Dir.chdir(@s.p4ruby_build_dir) {
|
354
|
+
make("install")
|
355
|
+
}
|
356
|
+
if @s.gem_config
|
357
|
+
raw_install_to_gem_install
|
432
358
|
end
|
433
|
-
end
|
434
|
-
verify_install(error)
|
435
|
-
else
|
436
|
-
install_fail(&error)
|
437
359
|
end
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
360
|
+
|
361
|
+
def verify_install(on_error = nil)
|
362
|
+
puts "verifying..."
|
363
|
+
files =
|
364
|
+
if @s.gem_config
|
365
|
+
GEM_INSTALL_FILES
|
366
|
+
else
|
367
|
+
RAW_INSTALL_FILES
|
368
|
+
end.map { |t| t.expand_path }
|
369
|
+
|
370
|
+
if files.all? { |t| t.exist? }
|
371
|
+
puts "Installed files:"
|
372
|
+
puts files
|
373
|
+
elsif on_error
|
374
|
+
install_fail(&on_error)
|
375
|
+
else
|
376
|
+
install_fail {
|
377
|
+
puts "These files were supposed to be installed, but were not:"
|
378
|
+
puts files
|
379
|
+
puts "Install failed!"
|
380
|
+
}
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
def find_ruby_version(spec)
|
385
|
+
remote_files_matching(spec.remote, /p4ruby\d\d.exe/) { |r_ver|
|
386
|
+
|
387
|
+
#Find the latest version of p4ruby for this version of ruby
|
388
|
+
v_max = CONFIG["MAJOR"]
|
389
|
+
v_min = CONFIG["MINOR"]
|
390
|
+
version = [v_max, v_min].join
|
391
|
+
if r_ver.to_s =~ /p4ruby#{version}.exe/
|
392
|
+
return "p4ruby#{version}.exe"
|
393
|
+
end
|
394
|
+
|
395
|
+
}
|
396
|
+
nil
|
397
|
+
end
|
398
|
+
|
399
|
+
def windows_install
|
400
|
+
#
|
401
|
+
# For Windows, p4ruby is located in the p4api directory on the
|
402
|
+
# perforce server -- switcharoo --
|
403
|
+
#
|
404
|
+
spec = @s.p4api
|
405
|
+
|
406
|
+
p4ruby_exe = find_ruby_version(spec)
|
407
|
+
if p4ruby_exe && !(spec.remote.to_s =~ /p4ruby/)
|
408
|
+
spec.remote += p4ruby_exe.to_s
|
409
|
+
spec.local = 'p4ruby18.exe'
|
410
|
+
else
|
411
|
+
abort("Failed to find a suitable p4ruby executable for ruby #{CONFIG["MAJOR"]}.#{CONFIG["MINOR"]}")
|
412
|
+
end
|
413
|
+
fetch_spec(spec)
|
414
|
+
|
415
|
+
error = lambda {
|
416
|
+
puts "The Perforce P4Ruby Windows installer failed!"
|
417
|
+
puts "You may re-run it manually here:"
|
418
|
+
puts spec.local.expand_path
|
419
|
+
}
|
420
|
+
|
421
|
+
puts "running Perforce P4Ruby Windows installer..."
|
422
|
+
if system(spec.local.to_s, "/S", "/v/qn")
|
423
|
+
if @s.gem_config
|
424
|
+
sleep(1)
|
425
|
+
raw_install_to_gem_install
|
426
|
+
sleep(1)
|
427
|
+
unless system(spec.local, "/V", "/x", "/S", "/v/qn")
|
428
|
+
# We don't much care if this fails; just write to the log
|
429
|
+
puts "Note: the Perforce P4Ruby Windows uninstaller failed."
|
430
|
+
end
|
431
|
+
end
|
432
|
+
verify_install(error)
|
433
|
+
else
|
434
|
+
install_fail(&error)
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
def uninstall
|
439
|
+
RAW_INSTALL_FILES.each { |file|
|
440
|
+
if file.exist?
|
441
|
+
puts "delete #{file}"
|
442
|
+
rm_f(file)
|
443
|
+
end
|
444
|
+
}
|
445
|
+
end
|
448
446
|
end
|
449
447
|
|
450
448
|
#
|
451
449
|
# An OpenStruct with optional lazy-evaluated fields.
|
452
450
|
#
|
453
451
|
class LazyStruct < OpenStruct
|
454
|
-
#
|
455
|
-
# For mixing into an existing OpenStruct instance singleton class.
|
456
|
-
#
|
457
|
-
module Mixin
|
458
452
|
#
|
459
|
-
#
|
460
|
-
# same result is returned for subsquent calls, until the field
|
461
|
-
# is assigned a different value.
|
453
|
+
# For mixing into an existing OpenStruct instance singleton class.
|
462
454
|
#
|
463
|
-
|
464
|
-
singleton = (class << self ; self ; end)
|
465
|
-
singleton.instance_eval {
|
455
|
+
module Mixin
|
466
456
|
#
|
467
|
-
#
|
457
|
+
# &block is evaluated when this attribute is requested. The
|
458
|
+
# same result is returned for subsquent calls, until the field
|
459
|
+
# is assigned a different value.
|
468
460
|
#
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
#
|
461
|
+
def attribute(reader, &block)
|
462
|
+
singleton = (
|
463
|
+
class << self;
|
464
|
+
self;
|
465
|
+
end)
|
475
466
|
singleton.instance_eval {
|
476
|
-
|
477
|
-
|
467
|
+
#
|
468
|
+
# Define a special reader method in the singleton class.
|
469
|
+
#
|
470
|
+
define_method(reader) {
|
471
|
+
block.call.tap { |value|
|
472
|
+
#
|
473
|
+
# The value has been computed. Replace this method with a
|
474
|
+
# one-liner giving the value.
|
475
|
+
#
|
476
|
+
singleton.instance_eval {
|
477
|
+
remove_method(reader)
|
478
|
+
define_method(reader) { value }
|
479
|
+
}
|
480
|
+
}
|
481
|
+
}
|
482
|
+
|
483
|
+
#
|
484
|
+
# Revert to the old OpenStruct behavior when the writer is called.
|
485
|
+
#
|
486
|
+
writer = "#{reader}=".to_sym
|
487
|
+
define_method(writer) { |value|
|
488
|
+
singleton.instance_eval {
|
489
|
+
remove_method(reader)
|
490
|
+
remove_method(writer)
|
491
|
+
}
|
492
|
+
method_missing(writer, value)
|
493
|
+
}
|
478
494
|
}
|
479
|
-
|
480
|
-
}
|
481
|
-
|
482
|
-
#
|
483
|
-
# Revert to the old OpenStruct behavior when the writer is called.
|
484
|
-
#
|
485
|
-
writer = "#{reader}=".to_sym
|
486
|
-
define_method(writer) { |value|
|
487
|
-
singleton.instance_eval {
|
488
|
-
remove_method(reader)
|
489
|
-
remove_method(writer)
|
490
|
-
}
|
491
|
-
method_missing(writer, value)
|
492
|
-
}
|
493
|
-
}
|
495
|
+
end
|
494
496
|
end
|
495
|
-
|
496
|
-
|
497
|
-
include Mixin
|
497
|
+
|
498
|
+
include Mixin
|
498
499
|
end
|
499
500
|
|
500
501
|
# version < 1.8.7 compatibility
|
501
502
|
module Kernel
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
503
|
+
unless respond_to? :tap
|
504
|
+
def tap
|
505
|
+
yield self
|
506
|
+
self
|
507
|
+
end
|
506
508
|
end
|
507
|
-
end
|
508
509
|
end
|
509
510
|
|
510
511
|
Installer.new.run
|
data/p4ruby.gemspec
CHANGED
metadata
CHANGED
@@ -1,56 +1,59 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: p4ruby
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: -711907940
|
5
|
+
prerelease: 7
|
6
|
+
segments:
|
7
|
+
- 2012
|
8
|
+
- 2
|
9
|
+
- beta
|
10
|
+
version: 2012.2.beta
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Perforce Software (ruby gem by James M. Lawrence)
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-10-11 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: rake
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rdoc
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
33
24
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
38
32
|
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rdoc
|
39
36
|
prerelease: false
|
40
|
-
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
38
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
46
48
|
description: Ruby interface to the Perforce API.
|
47
49
|
email: p4ruby@perforce.com
|
48
50
|
executables: []
|
49
|
-
|
51
|
+
|
52
|
+
extensions:
|
50
53
|
- Rakefile
|
51
|
-
extra_rdoc_files:
|
54
|
+
extra_rdoc_files:
|
52
55
|
- README
|
53
|
-
files:
|
56
|
+
files:
|
54
57
|
- README
|
55
58
|
- CHANGES
|
56
59
|
- Rakefile
|
@@ -58,10 +61,11 @@ files:
|
|
58
61
|
- p4ruby.gemspec
|
59
62
|
homepage: http://p4ruby.rubyforge.org
|
60
63
|
licenses: []
|
64
|
+
|
61
65
|
post_install_message:
|
62
|
-
rdoc_options:
|
66
|
+
rdoc_options:
|
63
67
|
- --title
|
64
|
-
-
|
68
|
+
- "P4Ruby: Ruby interface to the Perforce API"
|
65
69
|
- --main
|
66
70
|
- README
|
67
71
|
- --exclude
|
@@ -72,25 +76,35 @@ rdoc_options:
|
|
72
76
|
- install.rb
|
73
77
|
- --exclude
|
74
78
|
- p4ruby.gemspec
|
75
|
-
require_paths:
|
79
|
+
require_paths:
|
76
80
|
- lib
|
77
81
|
- ext
|
78
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
83
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
92
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
93
|
+
requirements:
|
94
|
+
- - ">"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 25
|
97
|
+
segments:
|
98
|
+
- 1
|
99
|
+
- 3
|
100
|
+
- 1
|
89
101
|
version: 1.3.1
|
90
102
|
requirements: []
|
103
|
+
|
91
104
|
rubyforge_project: p4ruby
|
92
|
-
rubygems_version: 1.8.
|
105
|
+
rubygems_version: 1.8.24
|
93
106
|
signing_key:
|
94
107
|
specification_version: 3
|
95
108
|
summary: Ruby interface to the Perforce API
|
96
109
|
test_files: []
|
110
|
+
|