p4ruby 2012.2 → 2014.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +4 -18
- data/README +6 -92
- data/install.rb +162 -463
- data/p4ruby.gemspec +7 -10
- metadata +55 -77
- data/Rakefile +0 -109
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dce2dda614bba83402b98a5660980efd982ac116
|
4
|
+
data.tar.gz: 96095d48458278f90f6710bed7b49a8c585f08fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3943ab2ec560cb2173a433cf3311556fa525294adbba25f799fe915530c42c59fd37f85d10363db1c616335577d75d6012d2888beea76f0d1d46baea119164da
|
7
|
+
data.tar.gz: 07653d491f15c49c91cdb7287132c2e47e3e30fd36d0106d707d853ae7fdc2eaa06127bf71f0f0ed44a295d71a2805436dfc9af256aff6c374beea8a5f9487eb
|
data/CHANGES
CHANGED
@@ -1,24 +1,10 @@
|
|
1
1
|
|
2
2
|
= p4ruby
|
3
3
|
|
4
|
-
==
|
4
|
+
== Version 2014.1
|
5
|
+
The gem has been completely rewritten.
|
5
6
|
|
6
|
-
|
7
|
+
Now it will build from source on Windows' provided that DevKit is present (Tested on Win7)
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
* perforce ftp site has hosed 11.1 directory -- workaround hardcoded for 10.2
|
11
|
-
|
12
|
-
== version 1.0.9
|
13
|
-
|
14
|
-
* Non-universal p4api darwin libs were removed from Perforce ftp server
|
15
|
-
* Pathname changes for 1.9 (even though P4Ruby does not compile for 1.9)
|
16
|
-
|
17
|
-
== version 1.0.8
|
18
|
-
|
19
|
-
* Compensate for Perforce ftp server directory changes
|
20
|
-
|
21
|
-
== version 1.0.7
|
22
|
-
|
23
|
-
* First release.
|
9
|
+
It also builds from source on Linux and MacOSX (tested on Ubuntu and Mavericks).
|
24
10
|
|
data/README
CHANGED
@@ -1,95 +1,9 @@
|
|
1
|
+
Author: Brett Bates and Jennifer Bottom.
|
1
2
|
|
2
|
-
|
3
|
+
Credit to: James Lawrence
|
3
4
|
|
4
|
-
|
5
|
+
A readme that needs to be rewritten.
|
6
|
+
Version 2014.1
|
7
|
+
An entire rewrite of the p4ruby gem installer
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
% gem install p4ruby
|
9
|
-
|
10
|
-
Or if you are installing from the regular (non-gem) package,
|
11
|
-
|
12
|
-
% ruby install.rb
|
13
|
-
|
14
|
-
This installer downloads P4Ruby and the Perforce API, compiles P4Ruby,
|
15
|
-
and installs it. On Windows the Perforce P4Ruby Windows installer is
|
16
|
-
downloaded and executed instead. Some options are available,
|
17
|
-
|
18
|
-
% ruby install.rb --help
|
19
|
-
|
20
|
-
Usage: ruby install.rb [options]
|
21
|
-
--version NN.N Version to download, e.g. 08.1. Default finds latest.
|
22
|
-
--list-versions List available versions.
|
23
|
-
--platform PLATFORM Perforce-named platform to download. Default guesses.
|
24
|
-
--list-platforms List available platforms for the given version.
|
25
|
-
--gem Gem configuration (for the gem installer).
|
26
|
-
--uninstall Uninstall.
|
27
|
-
--local Use the files in work/distfiles (manual download).
|
28
|
-
|
29
|
-
== Links
|
30
|
-
|
31
|
-
* P4Ruby documentation 2009.1: http://perforce.com/perforce/doc.091/manuals/p4script/p4script.pdf
|
32
|
-
* Perforce documentation: http://perforce.com/perforce/technical.html
|
33
|
-
|
34
|
-
* Download (this installer only): http://rubyforge.org/frs/?group_id=6957
|
35
|
-
* Repository (this installer only): http://github.com/quix/p4ruby
|
36
|
-
* Simplified wrapper for P4Ruby: http://perforce.rubyforge.org
|
37
|
-
|
38
|
-
== Credits
|
39
|
-
|
40
|
-
=== P4Ruby
|
41
|
-
|
42
|
-
Copyright (c) 1997-2007, Perforce Software, Inc. All rights reserved.
|
43
|
-
|
44
|
-
Redistribution and use in source and binary forms, with or without
|
45
|
-
modification, are permitted provided that the following conditions
|
46
|
-
are met:
|
47
|
-
|
48
|
-
1. Redistributions of source code must retain the above copyright
|
49
|
-
notice, this list of conditions and the following disclaimer.
|
50
|
-
|
51
|
-
2. Redistributions in binary form must reproduce the above copyright
|
52
|
-
notice, this list of conditions and the following disclaimer in the
|
53
|
-
documentation and/or other materials provided with the distribution.
|
54
|
-
|
55
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
56
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
57
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
58
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE
|
59
|
-
SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
60
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
61
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
62
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
63
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
64
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
65
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
66
|
-
|
67
|
-
=== Installer and Gem
|
68
|
-
|
69
|
-
This ruby package (install.rb and associated files) was written by
|
70
|
-
James M. Lawrence.
|
71
|
-
|
72
|
-
Copyright (c) 2009 James M. Lawrence
|
73
|
-
Copyright (c) 2008 ImaginEngine, Inc.
|
74
|
-
|
75
|
-
Distributed under the MIT license.
|
76
|
-
|
77
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
78
|
-
a copy of this software and associated documentation files (the
|
79
|
-
"Software"), to deal in the Software without restriction, including
|
80
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
81
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
82
|
-
permit persons to whom the Software is furnished to do so, subject to
|
83
|
-
the following conditions:
|
84
|
-
|
85
|
-
The above copyright notice and this permission notice shall be
|
86
|
-
included in all copies or substantial portions of the Software.
|
87
|
-
|
88
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
89
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
90
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
91
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
92
|
-
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
93
|
-
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
94
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
95
|
-
SOFTWARE.
|
9
|
+
Now entirely based around p4conf.rb
|
data/install.rb
CHANGED
@@ -1,507 +1,206 @@
|
|
1
|
-
#
|
2
|
-
# Author: James M. Lawrence <quixoticsycophant@gmail.com>.
|
3
|
-
#
|
4
|
-
|
5
1
|
require 'net/ftp'
|
6
2
|
require 'rbconfig'
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require 'optparse'
|
10
|
-
require 'pathname'
|
11
|
-
require 'rubygems'
|
12
|
-
|
13
|
-
class Installer
|
14
|
-
include FileUtils
|
15
|
-
|
16
|
-
CONFIG = Config::CONFIG
|
17
|
-
BIT64 = (1.size == 8)
|
18
|
-
|
19
|
-
RB_BASENAME = Pathname.new "P4.rb"
|
20
|
-
SO_BASENAME = Pathname.new "P4.#{CONFIG['DLEXT']}"
|
3
|
+
require 'zlib'
|
4
|
+
require 'rubygems/package'
|
21
5
|
|
22
|
-
|
23
|
-
|
24
|
-
Pathname.new(CONFIG["sitearchdir"]) + SO_BASENAME,
|
25
|
-
]
|
6
|
+
BUILD_DIR = "./build"
|
7
|
+
DIST_DIR = "./dist"
|
26
8
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
]
|
9
|
+
FTP_SERVER = "ftp.perforce.com"
|
10
|
+
TOP_DIR = "perforce"
|
11
|
+
P4RUBY_FTP_DIR = "bin.tools"
|
31
12
|
|
32
|
-
|
33
|
-
SERVER_TOP_DIR = Pathname.new "perforce"
|
13
|
+
P4RUBY_ARCHIVE = "p4ruby.tgz"
|
34
14
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
}
|
87
|
-
end
|
15
|
+
class Installer
|
16
|
+
def initialize
|
17
|
+
unless File.directory?(DIST_DIR)
|
18
|
+
Dir.mkdir(DIST_DIR)
|
19
|
+
end
|
88
20
|
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
109
|
-
end
|
21
|
+
unless File.directory?(BUILD_DIR)
|
22
|
+
Dir.mkdir(BUILD_DIR)
|
23
|
+
end
|
110
24
|
|
111
|
-
|
112
|
-
|
113
|
-
|
25
|
+
@platform = guess_platform
|
26
|
+
|
27
|
+
#TODO some way of the user supplying their own ftp path/ local path for the api's
|
28
|
+
fetch
|
29
|
+
build
|
114
30
|
end
|
115
31
|
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
32
|
+
def fetch
|
33
|
+
p4_ftp = P4Ruby_FTP.new(@platform)
|
34
|
+
p4_ftp.download
|
136
35
|
end
|
137
36
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
37
|
+
def build
|
38
|
+
wd = Dir.getwd
|
39
|
+
api_dir = get_api_build_dir
|
40
|
+
Dir.chdir(get_ruby_build_dir)
|
41
|
+
puts `yes | ruby p4conf.rb -d #{api_dir}`
|
42
|
+
puts `make`
|
43
|
+
puts `ruby test.rb`
|
44
|
+
puts `make install`
|
45
|
+
#TODO Deal with known issue wheree we have to ignore -Werror in Makefile
|
46
|
+
Dir.chdir(wd)
|
142
47
|
end
|
143
48
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
49
|
+
def guess_cpu(os)
|
50
|
+
cpu = RbConfig::CONFIG['target_cpu']
|
51
|
+
case os
|
52
|
+
when :darwin, :linux
|
53
|
+
if cpu =~ /i686/
|
54
|
+
"x86"
|
55
|
+
else
|
56
|
+
cpu
|
57
|
+
end
|
58
|
+
else
|
59
|
+
case cpu
|
60
|
+
when /ia/i
|
61
|
+
'ia64'
|
62
|
+
else
|
63
|
+
cpu
|
64
|
+
end
|
65
|
+
end
|
149
66
|
end
|
150
67
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
"x86" + (BIT64 ? "_64" : "")
|
168
|
-
when %r!(ppc|sparc)!i
|
169
|
-
# note: without '_'
|
170
|
-
$1 + (BIT64 ? "64" : "")
|
171
|
-
else
|
172
|
-
""
|
173
|
-
end
|
68
|
+
def guess_platform()
|
69
|
+
case RbConfig::CONFIG["target_os"].downcase
|
70
|
+
when /nt|mswin/
|
71
|
+
"nt#{guess_cpu(:windows)}"
|
72
|
+
when /mingw/
|
73
|
+
"mingwx86"
|
74
|
+
when /darwin/
|
75
|
+
#TODO look at darwin 100, can you complile bin for 90 on 100?
|
76
|
+
"darwin90#{guess_cpu(:darwin)}"
|
77
|
+
when /solaris/
|
78
|
+
"solaris10#{guess_cpu(:solaris)}"
|
79
|
+
when /linux/
|
80
|
+
"linux26#{guess_cpu(:linux)}"
|
81
|
+
when /cygwin/
|
82
|
+
#No longer built for
|
83
|
+
end
|
174
84
|
end
|
175
|
-
end
|
176
85
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
86
|
+
def get_ruby_build_dir
|
87
|
+
Dir.foreach(BUILD_DIR) do |d|
|
88
|
+
if d =~ /p4ruby/
|
89
|
+
return File.join(BUILD_DIR,d)
|
90
|
+
end
|
91
|
+
end
|
194
92
|
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def guess_platform(opts = {})
|
198
|
-
config_os = CONFIG["target_os"].downcase
|
199
|
-
windows_cpu = BIT64 ? "x64" : "x86"
|
200
93
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
else
|
208
|
-
if match = config_os.match(%r!\A\D+!)
|
209
|
-
guess_version(match[0])
|
210
|
-
else
|
211
|
-
nil
|
212
|
-
end
|
94
|
+
def get_api_build_dir
|
95
|
+
Dir.foreach(BUILD_DIR) do |d|
|
96
|
+
if d =~ /p4api/
|
97
|
+
return File.join(Dir.getwd, BUILD_DIR,d)
|
98
|
+
end
|
99
|
+
end
|
213
100
|
end
|
214
|
-
|
101
|
+
end
|
215
102
|
|
216
|
-
|
217
|
-
install_fail {
|
218
|
-
@s.version = "<version>"
|
219
|
-
@s.platform = "<platform>"
|
220
|
-
message = %Q{
|
221
|
-
Auto-fetch not yet handled for this platform. Run:
|
222
|
-
|
223
|
-
\truby install.rb --list-platforms
|
224
|
-
|
225
|
-
to see the available platforms, then run
|
226
|
-
|
227
|
-
\truby install.rb --platform PLATFORM
|
228
|
-
|
229
|
-
with your platform.
|
230
|
-
|
231
|
-
If all of the above fails, manually fetch
|
232
|
-
|
233
|
-
\tftp://#{SERVER}/#{@s.p4api.remote}
|
234
|
-
|
235
|
-
Copy it to #{@s.p4api.local} and run install.rb --local.
|
236
|
-
}.gsub(%r!^ +(?=\S)!, "")
|
237
|
-
|
238
|
-
mkdir_p(DISTFILES_DIR)
|
239
|
-
puts message
|
240
|
-
}
|
241
|
-
end
|
103
|
+
class P4Ruby_FTP
|
242
104
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
105
|
+
def initialize(platform)
|
106
|
+
@ftp = Net::FTP.new(FTP_SERVER)
|
107
|
+
@ftp.login
|
108
|
+
@ftp.chdir(TOP_DIR)
|
247
109
|
|
248
|
-
|
249
|
-
|
250
|
-
unless result
|
251
|
-
raise "system() failed: #{args.join(" ")}"
|
252
|
-
end
|
253
|
-
}
|
254
|
-
end
|
110
|
+
@latest = latest_version
|
111
|
+
@ftp.chdir("r#{@latest}")
|
255
112
|
|
256
|
-
|
257
|
-
sys("tar", "zxvf", distfile.to_s, "-C", target_dir.to_s)
|
258
|
-
end
|
113
|
+
@platform = "bin.#{platform}"
|
259
114
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
115
|
+
if @platform =~ /nt|mingw/
|
116
|
+
@p4api_archive = "p4api.zip"
|
117
|
+
else
|
118
|
+
@p4api_archive = "p4api.tgz"
|
119
|
+
end
|
265
120
|
end
|
266
|
-
end
|
267
|
-
|
268
|
-
def fetch
|
269
|
-
@s.specs.each { |spec|
|
270
|
-
fetch_spec(spec)
|
271
|
-
}
|
272
|
-
end
|
273
121
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
nil
|
280
|
-
end
|
281
|
-
}.reject { |entry|
|
282
|
-
entry.nil?
|
283
|
-
}
|
284
|
-
end
|
285
|
-
|
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
|
122
|
+
def versions
|
123
|
+
remote_files_matching(".", /r(1\d\.\d)/) { |match|
|
124
|
+
match.captures.first
|
125
|
+
}.sort
|
126
|
+
end
|
293
127
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
128
|
+
def latest_version
|
129
|
+
versions.reverse_each{ |v|
|
130
|
+
begin
|
131
|
+
remote_files_matching("r#{v}/bin.tools",/p4ruby/) do
|
132
|
+
return v
|
133
|
+
end
|
134
|
+
rescue
|
135
|
+
next
|
136
|
+
end
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def remote_files_matching(dir, regex)
|
141
|
+
@ftp.ls(dir.to_s).map { |entry|
|
142
|
+
if match = entry.match(regex)
|
143
|
+
yield match
|
144
|
+
else
|
145
|
+
nil
|
146
|
+
end
|
147
|
+
}.reject { |entry|
|
148
|
+
entry.nil?
|
149
|
+
}
|
150
|
+
end
|
301
151
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
152
|
+
def download
|
153
|
+
begin
|
154
|
+
download_p4api
|
155
|
+
download_p4ruby
|
156
|
+
rescue => e
|
157
|
+
puts "Failed to download API or p4ruby, please compile manually"
|
307
158
|
end
|
308
|
-
rescue
|
309
|
-
next
|
310
|
-
end
|
311
|
-
}
|
312
|
-
end
|
313
|
-
|
314
|
-
def make(*args)
|
315
|
-
sys("make", *args)
|
316
|
-
end
|
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
|
358
159
|
end
|
359
|
-
end
|
360
160
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
GEM_INSTALL_FILES
|
366
|
-
else
|
367
|
-
RAW_INSTALL_FILES
|
368
|
-
end.map { |t| t.expand_path }
|
161
|
+
def download_p4api
|
162
|
+
@ftp.chdir(@platform)
|
163
|
+
@ftp.getbinaryfile(@p4api_archive, "#{DIST_DIR}/#{@p4api_archive}", 1024)
|
164
|
+
@ftp.chdir("..")
|
369
165
|
|
370
|
-
|
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
|
-
}
|
166
|
+
decompress("#{DIST_DIR}/#{@p4api_archive}","#{BUILD_DIR}/")
|
381
167
|
end
|
382
|
-
end
|
383
|
-
|
384
|
-
def find_ruby_version(spec)
|
385
|
-
remote_files_matching(spec.remote, /p4ruby\d\d.exe/) {|r_ver|
|
386
168
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
if r_ver.to_s =~ /p4ruby#{version}.exe/
|
392
|
-
return "p4ruby#{version}.exe"
|
393
|
-
end
|
169
|
+
def download_p4ruby
|
170
|
+
@ftp.chdir(P4RUBY_FTP_DIR)
|
171
|
+
@ftp.getbinaryfile(P4RUBY_ARCHIVE, "#{DIST_DIR}/#{P4RUBY_ARCHIVE}", 1024)
|
172
|
+
@ftp.chdir("..")
|
394
173
|
|
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
|
-
else
|
410
|
-
abort("Failed to find a suitable p4ruby executable for ruby #{CONFIG["MAJOR"]}.#{CONFIG["MINOR"]}")
|
174
|
+
decompress("#{DIST_DIR}/#{P4RUBY_ARCHIVE}","#{BUILD_DIR}/")
|
411
175
|
end
|
412
|
-
fetch_spec(spec)
|
413
176
|
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
177
|
+
def decompress(tgz, destination)
|
178
|
+
if tgz =~ /\.zip/
|
179
|
+
`unzip #{tgz} -d #{destination}`
|
180
|
+
return
|
181
|
+
end
|
182
|
+
Gem::Package::TarReader.new(Zlib::GzipReader.open tgz) do |tar|
|
183
|
+
tar.each do |entry|
|
184
|
+
if entry.directory?
|
185
|
+
puts "Making dir #{File.join(destination, entry.full_name)}"
|
186
|
+
unless File.exists?(File.join(destination, entry.full_name))
|
187
|
+
Dir.mkdir(File.join(destination, entry.full_name))
|
188
|
+
end
|
189
|
+
elsif entry.file?
|
190
|
+
puts "Making file #{File.join(destination, entry.full_name)}"
|
191
|
+
unless File.exists?(File.join(destination, entry.full_name))
|
192
|
+
File.open(File.join(destination, entry.full_name), "w") do |f|
|
193
|
+
f.write(entry.read)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
elsif entry.header.typeflag == '2'
|
197
|
+
#TODO remove if not necessary
|
198
|
+
binding.pry
|
199
|
+
end
|
200
|
+
end
|
429
201
|
end
|
430
|
-
end
|
431
|
-
verify_install(error)
|
432
|
-
else
|
433
|
-
install_fail(&error)
|
434
|
-
end
|
435
|
-
end
|
436
|
-
|
437
|
-
def uninstall
|
438
|
-
RAW_INSTALL_FILES.each { |file|
|
439
|
-
if file.exist?
|
440
|
-
puts "delete #{file}"
|
441
|
-
rm_f(file)
|
442
|
-
end
|
443
|
-
}
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
#
|
448
|
-
# An OpenStruct with optional lazy-evaluated fields.
|
449
|
-
#
|
450
|
-
class LazyStruct < OpenStruct
|
451
|
-
#
|
452
|
-
# For mixing into an existing OpenStruct instance singleton class.
|
453
|
-
#
|
454
|
-
module Mixin
|
455
|
-
#
|
456
|
-
# &block is evaluated when this attribute is requested. The
|
457
|
-
# same result is returned for subsquent calls, until the field
|
458
|
-
# is assigned a different value.
|
459
|
-
#
|
460
|
-
def attribute(reader, &block)
|
461
|
-
singleton = (class << self ; self ; end)
|
462
|
-
singleton.instance_eval {
|
463
|
-
#
|
464
|
-
# Define a special reader method in the singleton class.
|
465
|
-
#
|
466
|
-
define_method(reader) {
|
467
|
-
block.call.tap { |value|
|
468
|
-
#
|
469
|
-
# The value has been computed. Replace this method with a
|
470
|
-
# one-liner giving the value.
|
471
|
-
#
|
472
|
-
singleton.instance_eval {
|
473
|
-
remove_method(reader)
|
474
|
-
define_method(reader) { value }
|
475
|
-
}
|
476
|
-
}
|
477
|
-
}
|
478
|
-
|
479
|
-
#
|
480
|
-
# Revert to the old OpenStruct behavior when the writer is called.
|
481
|
-
#
|
482
|
-
writer = "#{reader}=".to_sym
|
483
|
-
define_method(writer) { |value|
|
484
|
-
singleton.instance_eval {
|
485
|
-
remove_method(reader)
|
486
|
-
remove_method(writer)
|
487
|
-
}
|
488
|
-
method_missing(writer, value)
|
489
|
-
}
|
490
|
-
}
|
491
202
|
end
|
492
|
-
end
|
493
|
-
|
494
|
-
include Mixin
|
495
203
|
end
|
496
204
|
|
497
|
-
|
498
|
-
module Kernel
|
499
|
-
unless respond_to? :tap
|
500
|
-
def tap
|
501
|
-
yield self
|
502
|
-
self
|
503
|
-
end
|
504
|
-
end
|
505
|
-
end
|
205
|
+
i = Installer.new
|
506
206
|
|
507
|
-
Installer.new.run
|
data/p4ruby.gemspec
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new { |t|
|
3
3
|
t.name = "p4ruby"
|
4
|
-
t.version = "
|
4
|
+
t.version = "2014.1"
|
5
5
|
t.summary = "Ruby interface to the Perforce API"
|
6
6
|
t.description = t.summary + "."
|
7
|
-
t.author = "Perforce Software (ruby gem by
|
8
|
-
t.email = "
|
9
|
-
t.homepage = "
|
10
|
-
|
11
|
-
t.
|
12
|
-
t.
|
13
|
-
t.add_dependency "rdoc"
|
14
|
-
t.require_paths << "ext"
|
7
|
+
t.author = "Perforce Software (ruby gem by Brett Bates and Jennifer Bottom)"
|
8
|
+
t.email = "jbottom@perforce.com"
|
9
|
+
t.homepage = "https://rubygems.org/gems/p4ruby"
|
10
|
+
|
11
|
+
t.add_runtime_dependency 'rake', '~> 0'
|
12
|
+
t.add_runtime_dependency 'test-unit', '>=0'
|
15
13
|
|
16
14
|
t.files = %w[
|
17
15
|
README
|
18
16
|
CHANGES
|
19
|
-
Rakefile
|
20
17
|
install.rb
|
21
18
|
p4ruby.gemspec
|
22
19
|
]
|
metadata
CHANGED
@@ -1,107 +1,85 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: p4ruby
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2012
|
8
|
-
- 2
|
9
|
-
version: "2012.2"
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '2014.1'
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
- Perforce Software (ruby gem by
|
6
|
+
authors:
|
7
|
+
- Perforce Software (ruby gem by Brett Bates and Jennifer Bottom)
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
20
14
|
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
25
31
|
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
31
34
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: rdoc
|
35
35
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
39
38
|
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
version: "0"
|
45
|
-
type: :runtime
|
46
|
-
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
47
41
|
description: Ruby interface to the Perforce API.
|
48
|
-
email:
|
42
|
+
email: jbottom@perforce.com
|
49
43
|
executables: []
|
50
|
-
|
51
|
-
|
52
|
-
- Rakefile
|
53
|
-
extra_rdoc_files:
|
54
|
-
- README
|
55
|
-
files:
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files:
|
56
46
|
- README
|
47
|
+
files:
|
57
48
|
- CHANGES
|
58
|
-
-
|
49
|
+
- README
|
59
50
|
- install.rb
|
60
51
|
- p4ruby.gemspec
|
61
|
-
homepage:
|
52
|
+
homepage: https://rubygems.org/gems/p4ruby
|
62
53
|
licenses: []
|
63
|
-
|
54
|
+
metadata: {}
|
64
55
|
post_install_message:
|
65
|
-
rdoc_options:
|
66
|
-
- --title
|
67
|
-
-
|
68
|
-
- --main
|
56
|
+
rdoc_options:
|
57
|
+
- "--title"
|
58
|
+
- 'P4Ruby: Ruby interface to the Perforce API'
|
59
|
+
- "--main"
|
69
60
|
- README
|
70
|
-
- --exclude
|
61
|
+
- "--exclude"
|
71
62
|
- CHANGES
|
72
|
-
- --exclude
|
73
|
-
- Rakefile
|
74
|
-
- --exclude
|
63
|
+
- "--exclude"
|
75
64
|
- install.rb
|
76
|
-
- --exclude
|
65
|
+
- "--exclude"
|
77
66
|
- p4ruby.gemspec
|
78
|
-
require_paths:
|
67
|
+
require_paths:
|
79
68
|
- lib
|
80
|
-
|
81
|
-
|
82
|
-
none: false
|
83
|
-
requirements:
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
84
71
|
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
version: "0"
|
90
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
|
-
requirements:
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
93
76
|
- - ">="
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
|
96
|
-
segments:
|
97
|
-
- 0
|
98
|
-
version: "0"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
99
79
|
requirements: []
|
100
|
-
|
101
|
-
|
102
|
-
rubygems_version: 1.8.24
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.2.2
|
103
82
|
signing_key:
|
104
|
-
specification_version:
|
83
|
+
specification_version: 4
|
105
84
|
summary: Ruby interface to the Perforce API
|
106
85
|
test_files: []
|
107
|
-
|
data/Rakefile
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
|
2
|
-
begin
|
3
|
-
require 'rubygems'
|
4
|
-
gem 'rdoc'
|
5
|
-
rescue LoadError
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'rubygems/package_task'
|
9
|
-
require 'rdoc/task'
|
10
|
-
require 'rake/contrib/rubyforgepublisher'
|
11
|
-
require 'fileutils'
|
12
|
-
|
13
|
-
include FileUtils
|
14
|
-
|
15
|
-
README = "README"
|
16
|
-
GEMSPEC = eval(File.read("p4ruby.gemspec"))
|
17
|
-
RAKEFILE = "Rakefile"
|
18
|
-
RAKEFILE_ORIG = "Rakefile.orig"
|
19
|
-
|
20
|
-
default_task_definition = %{
|
21
|
-
INSTALLER = './install.rb'
|
22
|
-
|
23
|
-
#
|
24
|
-
# default task compiles for the gem
|
25
|
-
#
|
26
|
-
task :default do
|
27
|
-
ARGV.clear
|
28
|
-
ARGV.push "--gem"
|
29
|
-
load INSTALLER
|
30
|
-
end
|
31
|
-
}
|
32
|
-
|
33
|
-
eval(default_task_definition)
|
34
|
-
|
35
|
-
task :clean => :clobber do
|
36
|
-
rm_rf ["work", "lib", "ext"]
|
37
|
-
end
|
38
|
-
|
39
|
-
task :update_docs do
|
40
|
-
ruby_path = File.join(
|
41
|
-
Config::CONFIG["bindir"],
|
42
|
-
Config::CONFIG["RUBY_INSTALL_NAME"])
|
43
|
-
|
44
|
-
help = "--help"
|
45
|
-
command = "ruby #{File.basename(INSTALLER)} #{help}"
|
46
|
-
output = `#{ruby_path} #{INSTALLER} #{help}`
|
47
|
-
|
48
|
-
# insert help output into README
|
49
|
-
replace_file(README) { |contents|
|
50
|
-
contents.sub(%r!#{command}.*?==!m) {
|
51
|
-
command + "\n\n " +
|
52
|
-
output + "\n=="
|
53
|
-
}
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
task :doc => :update_docs
|
58
|
-
task :doc => :rdoc
|
59
|
-
|
60
|
-
task :package => [:clean, :doc]
|
61
|
-
task :gem => :clean
|
62
|
-
|
63
|
-
RDoc::Task.new { |t|
|
64
|
-
t.main = README
|
65
|
-
t.rdoc_files.include([README])
|
66
|
-
t.rdoc_dir = "html"
|
67
|
-
t.title = "P4Ruby: #{GEMSPEC.summary}"
|
68
|
-
}
|
69
|
-
|
70
|
-
Gem::PackageTask.new(GEMSPEC) { |t|
|
71
|
-
t.need_tar = true
|
72
|
-
}
|
73
|
-
|
74
|
-
task :publish => :doc do
|
75
|
-
Rake::RubyForgePublisher.new('p4ruby', 'quix').upload
|
76
|
-
end
|
77
|
-
|
78
|
-
task :release do
|
79
|
-
mv(RAKEFILE, RAKEFILE_ORIG)
|
80
|
-
begin
|
81
|
-
File.open(RAKEFILE, "w") { |out|
|
82
|
-
out.puts default_task_definition.gsub(%r!^ !m, "")
|
83
|
-
}
|
84
|
-
Rake::Task[:package].invoke
|
85
|
-
ensure
|
86
|
-
mv(RAKEFILE_ORIG, RAKEFILE)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
##################################################
|
91
|
-
# util
|
92
|
-
|
93
|
-
unless respond_to? :tap
|
94
|
-
module Kernel
|
95
|
-
def tap
|
96
|
-
yield self
|
97
|
-
self
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def replace_file(file)
|
103
|
-
old_contents = File.read(file)
|
104
|
-
yield(old_contents).tap { |new_contents|
|
105
|
-
File.open(file, "w") { |output|
|
106
|
-
output.print(new_contents)
|
107
|
-
}
|
108
|
-
}
|
109
|
-
end
|