p4ruby 1.0.0 → 1.0.1
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/README +11 -31
- data/install.rb +141 -96
- data/p4ruby.gemspec +1 -1
- metadata +3 -3
data/README
CHANGED
@@ -3,24 +3,7 @@
|
|
3
3
|
|
4
4
|
This is only an installer for the P4Ruby package by Perforce Software.
|
5
5
|
|
6
|
-
|
7
|
-
Perforce, with minor changes. Tony Smith's original P4Ruby public
|
8
|
-
depot is here
|
9
|
-
http://public.perforce.com/guest/tony_smith/perforce/API/Ruby/index.html
|
10
|
-
with documentation
|
11
|
-
http://public.perforce.com/guest/tony_smith/perforce/API/Ruby/main/doc/index.html.
|
12
|
-
Changes in the new package are described here
|
13
|
-
http://perforce.com/perforce/doc.081/user/p4rubynotes.txt.
|
14
|
-
|
15
|
-
<b>Note:</b> For Windows, this installer currently only supports the
|
16
|
-
cygwin version. If you are installing cygwin for the first time,
|
17
|
-
select ruby along with g++ (in the Devel category) inside the cygwin
|
18
|
-
installer (http://cygwin.com).
|
19
|
-
|
20
|
-
Users may be interested in a simplified interface to Perforce at
|
21
|
-
http://perforce.rubyforge.org (shameless plug, sorry).
|
22
|
-
|
23
|
-
=== Install
|
6
|
+
== Install
|
24
7
|
|
25
8
|
% gem install p4ruby
|
26
9
|
|
@@ -40,25 +23,22 @@ installs it. Some options are available,
|
|
40
23
|
--list-platforms List available platforms for the given version.
|
41
24
|
--gem Gem configuration (for the gem installer).
|
42
25
|
--uninstall Uninstall.
|
26
|
+
--local Use the local files in work/distfiles (for manual download)
|
43
27
|
|
44
|
-
|
45
|
-
|
46
|
-
If you are on a case-sensitive filesystem, be aware that 'P4' must be
|
47
|
-
capitalized in the <em>require</em> line,
|
48
|
-
|
49
|
-
require 'P4'
|
50
|
-
|
51
|
-
=== Download (this installer only)
|
28
|
+
== Download (this installer only)
|
52
29
|
|
53
30
|
* http://rubyforge.org/frs/?group_id=6957
|
54
31
|
|
55
|
-
|
32
|
+
== Links
|
56
33
|
|
57
|
-
* http://
|
34
|
+
* Tony Smith's original P4Ruby {public depot}[http://public.perforce.com/guest/tony_smith/perforce/API/Ruby/index.html] and {documentation}[http://public.perforce.com/guest/tony_smith/perforce/API/Ruby/main/doc/index.html].
|
35
|
+
* Changes[http://perforce.com/perforce/doc.081/user/p4rubynotes.txt] in the Perforce P4Ruby official package.
|
36
|
+
* {Repository (this installer only)}[http://github.com/quix/p4ruby]
|
37
|
+
* Users may be interested in a simplified interface to P4Ruby at http://perforce.rubyforge.org.
|
58
38
|
|
59
|
-
|
39
|
+
== Credits
|
60
40
|
|
61
|
-
|
41
|
+
=== P4Ruby
|
62
42
|
|
63
43
|
Copyright (c) 1997-2007, Perforce Software, Inc. All rights reserved.
|
64
44
|
|
@@ -85,7 +65,7 @@ capitalized in the <em>require</em> line,
|
|
85
65
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
86
66
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
87
67
|
|
88
|
-
|
68
|
+
=== Installer and Gem
|
89
69
|
|
90
70
|
This ruby package (install.rb and associated files) was written by
|
91
71
|
James M. Lawrence, Copyright (c) 2008 ImaginEngine, Inc. Distributed
|
data/install.rb
CHANGED
@@ -7,18 +7,24 @@ require 'rbconfig'
|
|
7
7
|
require 'ostruct'
|
8
8
|
require 'fileutils'
|
9
9
|
require 'optparse'
|
10
|
+
require 'pathname'
|
10
11
|
|
11
12
|
class Installer
|
12
13
|
include FileUtils
|
13
14
|
|
15
|
+
CONFIG = Config::CONFIG
|
16
|
+
|
14
17
|
def parse_command_line
|
15
18
|
OptionParser.new("Usage: ruby install.rb [options]", 24, "") { |parser|
|
16
|
-
parser.on(
|
17
|
-
|
19
|
+
parser.on(
|
20
|
+
"--version NN.N",
|
21
|
+
"Version to download, e.g. 08.1. Default finds latest.") {
|
18
22
|
|version|
|
19
23
|
@s.version = version
|
20
24
|
}
|
21
|
-
parser.on(
|
25
|
+
parser.on(
|
26
|
+
"--list-versions",
|
27
|
+
"List available versions.") {
|
22
28
|
@s.list_versions = true
|
23
29
|
}
|
24
30
|
parser.on(
|
@@ -27,16 +33,26 @@ class Installer
|
|
27
33
|
|platform|
|
28
34
|
@s.platform = platform
|
29
35
|
}
|
30
|
-
parser.on(
|
31
|
-
|
36
|
+
parser.on(
|
37
|
+
"--list-platforms",
|
38
|
+
"List available platforms for the given version.") {
|
32
39
|
@s.list_platforms = true
|
33
40
|
}
|
34
|
-
parser.on(
|
41
|
+
parser.on(
|
42
|
+
"--gem",
|
43
|
+
"Gem configuration (for the gem installer).") {
|
35
44
|
@s.gem = true
|
36
45
|
}
|
37
|
-
parser.on(
|
46
|
+
parser.on(
|
47
|
+
"--uninstall",
|
48
|
+
"Uninstall.") {
|
38
49
|
@s.uninstall = true
|
39
50
|
}
|
51
|
+
parser.on(
|
52
|
+
"--local",
|
53
|
+
"Use the local files in work/distfiles (for manual download)") {
|
54
|
+
@s.local = true
|
55
|
+
}
|
40
56
|
parser.parse(ARGV)
|
41
57
|
}
|
42
58
|
end
|
@@ -52,28 +68,36 @@ class Installer
|
|
52
68
|
elsif @s.list_versions
|
53
69
|
list_versions
|
54
70
|
elsif @s.platform
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
71
|
+
if @s.platform =~ %r!\Ant!
|
72
|
+
windows_install
|
73
|
+
else
|
74
|
+
fetch
|
75
|
+
build
|
76
|
+
install
|
77
|
+
end
|
59
78
|
else
|
60
79
|
platform_fail
|
61
80
|
end
|
62
81
|
end
|
63
82
|
|
64
83
|
def config
|
84
|
+
if CONFIG["LIBRUBYARG_SHARED"].empty?
|
85
|
+
raise "error: ruby must be configured with --enable-shared"
|
86
|
+
end
|
65
87
|
@s.server = "ftp.perforce.com"
|
66
|
-
@s.server_top_dir = "perforce"
|
88
|
+
@s.server_top_dir = Pathname.new "perforce"
|
67
89
|
|
68
|
-
@s.work_dir = "work"
|
69
|
-
@s.distfiles_dir =
|
70
|
-
@s.build_dir =
|
90
|
+
@s.work_dir = Pathname.new "work"
|
91
|
+
@s.distfiles_dir = @s.work_dir + "distfiles"
|
92
|
+
@s.build_dir = @s.work_dir + "build"
|
71
93
|
|
72
|
-
@s.p4api = LazyStruct.new.tap { |t| t.file = "p4api.tgz" }
|
73
|
-
@s.p4ruby = LazyStruct.new.tap { |t| t.file = "p4ruby.tgz" }
|
94
|
+
@s.p4api = LazyStruct.new.tap { |t| t.file = Pathname.new "p4api.tgz" }
|
95
|
+
@s.p4ruby = LazyStruct.new.tap { |t| t.file = Pathname.new "p4ruby.tgz" }
|
74
96
|
@s.specs = [ @s.p4ruby, @s.p4api ]
|
75
97
|
@s.specs.each { |spec|
|
76
|
-
spec.local
|
98
|
+
spec.attribute(:local) {
|
99
|
+
@s.distfiles_dir + spec.file
|
100
|
+
}
|
77
101
|
}
|
78
102
|
|
79
103
|
unless @s.platform
|
@@ -89,53 +113,66 @@ class Installer
|
|
89
113
|
end
|
90
114
|
|
91
115
|
@s.attribute(:version_dir) {
|
92
|
-
|
116
|
+
@s.server_top_dir + "r#{@s.version}"
|
93
117
|
}
|
94
118
|
@s.p4api.attribute(:remote) {
|
95
|
-
|
119
|
+
@s.version_dir + "bin.#{@s.platform}" + @s.p4api.file
|
96
120
|
}
|
97
121
|
@s.p4ruby.attribute(:remote) {
|
98
|
-
|
122
|
+
@s.version_dir + "tools" + @s.p4ruby.file
|
99
123
|
}
|
100
124
|
@s.attribute(:ftp) {
|
101
125
|
Net::FTP.new(@s.server).tap { |t| t.passive = true ; t.login }
|
102
126
|
}
|
103
127
|
end
|
104
128
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
when %r!(mswin|mingw)!i
|
111
|
-
"nt"
|
112
|
-
when %r!darwin!i
|
113
|
-
"darwin80"
|
114
|
-
when %r!linux!i
|
115
|
-
"linux" +
|
116
|
-
if match = `uname -a`.match(%r!linux\s+\S+\s+(\d+)\.(\d+)!i)
|
117
|
-
match.captures.join
|
118
|
-
else
|
119
|
-
"26"
|
120
|
-
end
|
121
|
-
end
|
129
|
+
def find_os_version(os)
|
130
|
+
if match = `uname -a`.match(%r!#{os}\s+\S+\s+(\d+)\.(\d+)!i)
|
131
|
+
match.captures.join
|
132
|
+
end
|
133
|
+
end
|
122
134
|
|
123
|
-
|
124
|
-
|
135
|
+
def guess_platform(opts = {})
|
136
|
+
config_os = CONFIG["target_os"].downcase
|
137
|
+
bit64 = (1.size == 8)
|
138
|
+
windows_cpu = (bit64 ? "x64" : "x86")
|
139
|
+
|
140
|
+
if config_os =~ %r!cygwin!i
|
141
|
+
"cygwin" + windows_cpu
|
142
|
+
elsif config_os =~ %r!(mswin|mingw)!i
|
143
|
+
"nt" + windows_cpu
|
144
|
+
elsif @s.local
|
145
|
+
"<local>"
|
125
146
|
else
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
"x86" + bit64
|
134
|
-
when %r!darwin!
|
135
|
-
if `uname -a`.chomp =~ %r!86\Z!
|
136
|
-
"x86" + bit64
|
147
|
+
if (match = config_os.match(%r!\A\D+!)).nil?
|
148
|
+
nil
|
149
|
+
else
|
150
|
+
os = match[0]
|
151
|
+
version = find_os_version(os)
|
152
|
+
if version.nil?
|
153
|
+
nil
|
137
154
|
else
|
138
|
-
|
155
|
+
cpu =
|
156
|
+
case CONFIG["target_cpu"]
|
157
|
+
when %r!ia!i
|
158
|
+
"ia64"
|
159
|
+
when %r!86!
|
160
|
+
"x86" + (bit64 ? "_64" : "") # note: with '_'
|
161
|
+
when %r!(ppc|sparc)!i
|
162
|
+
$1 + (bit64 ? "64" : "") # note: without '_'
|
163
|
+
else
|
164
|
+
""
|
165
|
+
end
|
166
|
+
|
167
|
+
available_platforms = platforms
|
168
|
+
platform = nil
|
169
|
+
version.to_i.downto(0) { |n|
|
170
|
+
platform = [os, n.to_s, cpu].join
|
171
|
+
if available_platforms.include? platform
|
172
|
+
break
|
173
|
+
end
|
174
|
+
}
|
175
|
+
platform
|
139
176
|
end
|
140
177
|
end
|
141
178
|
end
|
@@ -159,7 +196,7 @@ class Installer
|
|
159
196
|
|
160
197
|
\tftp://#{@s.server}/#{@s.p4api.remote}
|
161
198
|
|
162
|
-
Copy it to #{@s.p4api.local} and run install.rb
|
199
|
+
Copy it to #{@s.p4api.local} and run install.rb --local.
|
163
200
|
}.gsub(%r!^ +(?=\S)!, "")
|
164
201
|
|
165
202
|
mkdir_p(@s.distfiles_dir)
|
@@ -178,11 +215,17 @@ class Installer
|
|
178
215
|
sys("tar", "zxvf", distfile, "-C", target_dir)
|
179
216
|
end
|
180
217
|
|
181
|
-
def
|
182
|
-
@s.
|
218
|
+
def fetch_spec(spec)
|
219
|
+
unless @s.local
|
183
220
|
mkdir_p(File.dirname(spec.local))
|
184
221
|
puts "downloading ftp://#{@s.server}/#{spec.remote} ..."
|
185
222
|
@s.ftp.getbinaryfile(spec.remote, spec.local)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def fetch
|
227
|
+
@s.specs.each { |spec|
|
228
|
+
fetch_spec(spec)
|
186
229
|
}
|
187
230
|
end
|
188
231
|
|
@@ -228,19 +271,19 @@ class Installer
|
|
228
271
|
versions.last
|
229
272
|
end
|
230
273
|
|
231
|
-
def
|
232
|
-
|
233
|
-
contents.sub(%r!^LIBS = .*?$!) { |match|
|
234
|
-
match + " -lruby"
|
235
|
-
}
|
236
|
-
}
|
274
|
+
def make(*args)
|
275
|
+
sys("make", *args)
|
237
276
|
end
|
238
277
|
|
239
|
-
def
|
240
|
-
|
241
|
-
|
242
|
-
|
278
|
+
def ruby(*args)
|
279
|
+
exe = File.join(
|
280
|
+
CONFIG["bindir"],
|
281
|
+
CONFIG["RUBY_INSTALL_NAME"])
|
282
|
+
sys(exe, *args)
|
283
|
+
end
|
243
284
|
|
285
|
+
def build
|
286
|
+
rm_rf(@s.build_dir)
|
244
287
|
mkdir_p(@s.build_dir)
|
245
288
|
|
246
289
|
@s.specs.each { |spec|
|
@@ -248,39 +291,28 @@ class Installer
|
|
248
291
|
}
|
249
292
|
|
250
293
|
Dir.chdir(@s.build_dir) {
|
251
|
-
api_dir =
|
252
|
-
p4ruby_dir =
|
294
|
+
api_dir = Pathname.glob("p4api*").last
|
295
|
+
p4ruby_dir = Pathname.glob("p4ruby*").last
|
253
296
|
Dir.chdir(p4ruby_dir) {
|
254
|
-
|
255
|
-
fix_makefile
|
297
|
+
ruby("p4conf.rb", "--apidir", "../#{api_dir}")
|
256
298
|
make
|
257
299
|
}
|
258
|
-
@s.p4ruby_build_dir =
|
300
|
+
@s.p4ruby_build_dir = @s.build_dir + p4ruby_dir
|
259
301
|
}
|
260
302
|
end
|
261
303
|
|
262
|
-
def make(*args)
|
263
|
-
exe =
|
264
|
-
if RUBY_PLATFORM =~ %r!mswin!i
|
265
|
-
"nmake"
|
266
|
-
else
|
267
|
-
"make"
|
268
|
-
end
|
269
|
-
sys(exe, *args)
|
270
|
-
end
|
271
|
-
|
272
304
|
def install
|
273
305
|
if @s.gem
|
274
|
-
rb_file = "lib
|
306
|
+
rb_file = Pathname.new("lib") + "P4.rb"
|
275
307
|
rm_f(rb_file)
|
276
308
|
mkdir_p(File.dirname(rb_file))
|
277
|
-
cp(
|
309
|
+
cp(@s.p4ruby_build_dir + rb_file, rb_file)
|
278
310
|
|
279
|
-
dlext =
|
280
|
-
so_file = "ext
|
311
|
+
dlext = CONFIG["DLEXT"]
|
312
|
+
so_file = Pathname.new("ext") + "P4.#{dlext}"
|
281
313
|
rm_f(so_file)
|
282
314
|
mkdir_p(File.dirname(so_file))
|
283
|
-
cp(
|
315
|
+
cp(@s.p4ruby_build_dir + so_file.basename, so_file)
|
284
316
|
else
|
285
317
|
Dir.chdir(@s.p4ruby_build_dir) {
|
286
318
|
make "install"
|
@@ -288,9 +320,30 @@ class Installer
|
|
288
320
|
end
|
289
321
|
end
|
290
322
|
|
323
|
+
def windows_install
|
324
|
+
#
|
325
|
+
# p4ruby is where the p4api is located on the perforce server
|
326
|
+
# -- switcharoo --
|
327
|
+
#
|
328
|
+
spec = @s.p4api
|
329
|
+
|
330
|
+
version = [CONFIG["MAJOR"], CONFIG["MINOR"]].join
|
331
|
+
spec.file = "p4ruby#{version}.exe"
|
332
|
+
fetch_spec(spec)
|
333
|
+
|
334
|
+
if system(spec.local, "/S", "/v/qn")
|
335
|
+
puts "Installed files:"
|
336
|
+
puts installed_p4ruby_files
|
337
|
+
else
|
338
|
+
puts "**** The P4Ruby installer failed!"
|
339
|
+
puts "**** Re-run it manually here: "
|
340
|
+
puts File.expand_path(spec.local)
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
291
344
|
def installed_p4ruby_files
|
292
|
-
[
|
293
|
-
|
345
|
+
[ Pathname.new(CONFIG["sitelibdir"]) + "P4.rb" ] +
|
346
|
+
Pathname.glob(Pathname.new(CONFIG["sitearchdir"]) + "P4.*")
|
294
347
|
end
|
295
348
|
|
296
349
|
def uninstall
|
@@ -363,13 +416,5 @@ class LazyStruct < OpenStruct
|
|
363
416
|
include Mixin
|
364
417
|
end
|
365
418
|
|
366
|
-
|
367
|
-
old_contents = File.read(file)
|
368
|
-
yield(old_contents).tap { |new_contents|
|
369
|
-
File.open(file, "w") { |output|
|
370
|
-
output.print(new_contents)
|
371
|
-
}
|
372
|
-
}
|
373
|
-
end
|
374
|
-
|
419
|
+
STDOUT.sync = true
|
375
420
|
Installer.new.run
|
data/p4ruby.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: p4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Perforce Software (ruby gem by James M. Lawrence)
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-02 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements: []
|
57
57
|
|
58
58
|
rubyforge_project: p4ruby
|
59
|
-
rubygems_version: 1.
|
59
|
+
rubygems_version: 1.3.0
|
60
60
|
signing_key:
|
61
61
|
specification_version: 2
|
62
62
|
summary: Ruby interface to the Perforce API
|