capistrano-jdk-installer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +70 -0
- data/Rakefile +1 -0
- data/capistrano-jdk-installer.gemspec +24 -0
- data/lib/capistrano-jdk-installer.rb +395 -0
- data/lib/capistrano-jdk-installer/version.rb +5 -0
- metadata +117 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Yamashita Yuu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# capistrano-jdk-installer
|
2
|
+
|
3
|
+
a capistrano recipe to download and install JDK for your projects.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano-jdk-installer'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install capistrano-jdk-installer
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
This recipes will try to do following things during Capistrano `deploy:setup`.
|
22
|
+
|
23
|
+
1. Download JDK information from [updates.jenkins-ci.org](http://updates.jenkins-ci.org/updates/hudson.tools.JDKInstaller.json)
|
24
|
+
2. Download JDK archive
|
25
|
+
3. Install JDK for your project remotely (default) and/or locally
|
26
|
+
|
27
|
+
To enable this recipe, add following in your `config/deploy.rb`.
|
28
|
+
|
29
|
+
# in "config/deploy.rb"
|
30
|
+
require 'capistrano-jdk-installer'
|
31
|
+
set(:java_version_name, "7u6")
|
32
|
+
set(:java_oracle_username, "foo@example.com") # your ID on oracle.com
|
33
|
+
set(:java_oracle_password, "setcret") # your password on oracle.com
|
34
|
+
set(:java_license_title, "Oracle Binary Code License Agreement for Java SE")
|
35
|
+
set(:java_accept_license, true)
|
36
|
+
|
37
|
+
Following options are available to manage your JDK installation.
|
38
|
+
|
39
|
+
* `:java_version_name` - preferred JDK version. this value must be defined in JSON response from `:java_installer_uri`.
|
40
|
+
* `:java_oracle_username` - your credential to be used to download JDK archive from oracle.com.
|
41
|
+
* `:java_oracle_password` - your credential to be used to download JDK archive from oracle.com.
|
42
|
+
* `:java_license_title` - the license title of JDK which you will accept.
|
43
|
+
* `:java_accept_license` - specify whether you accept the JDK license. `false` by default.
|
44
|
+
* `:java_setup_locally` - specify whether you want to setup JDK on local machine. `false` by default.
|
45
|
+
* `:java_setup_remotely` - specify whether you want to setup JDK on remote machines. `true` by default.
|
46
|
+
* `:java_installer_uri` - `http://updates.jenkins-ci.org/updates/hudson.tools.JDKInstaller.json` by default.
|
47
|
+
* `:java_installer_json_cache` - the cache file path of "hudson.tools.JDKINstaller.json".
|
48
|
+
* `:java_installer_json_expires` - the cache TTL. cache `86400` seconds by default.
|
49
|
+
* `:java_home` - the path to the `JAVA_HOME` on remote machines.
|
50
|
+
* `:java_home_local` - the path to the `JAVA_HOME` on local machine.
|
51
|
+
* `:java_cmd` - the `java` command on remote machines.
|
52
|
+
* `:java_cmd_local` - the `java` command on local machine.
|
53
|
+
* `:java_checksum_cmd` - use specified command to compare JDK archives. use `md5sum` by default.
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
1. Fork it
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
5. Create new Pull Request
|
62
|
+
|
63
|
+
## Author
|
64
|
+
|
65
|
+
- YAMASHITA Yuu (https://github.com/yyuu)
|
66
|
+
- Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano-jdk-installer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "capistrano-jdk-installer"
|
8
|
+
gem.version = Capistrano::JDKInstaller::VERSION
|
9
|
+
gem.authors = ["Yamashita Yuu"]
|
10
|
+
gem.email = ["yamashita@geishatokyo.com"]
|
11
|
+
gem.description = %q{a capistrano recipe to download and install JDK for your projects.}
|
12
|
+
gem.summary = %q{a capistrano recipe to download and install JDK for your projects.}
|
13
|
+
gem.homepage = "https://github.com/yyuu/capistrano-jdk-installer"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency('capistrano')
|
21
|
+
gem.add_dependency('json')
|
22
|
+
gem.add_dependency('net-sftp', '>= 2.0.0')
|
23
|
+
gem.add_dependency('mechanize', '>= 2.0.0')
|
24
|
+
end
|
@@ -0,0 +1,395 @@
|
|
1
|
+
require "capistrano-jdk-installer/version"
|
2
|
+
require 'capistrano/transfer'
|
3
|
+
require 'json'
|
4
|
+
require 'logger'
|
5
|
+
require 'mechanize'
|
6
|
+
require 'net/sftp'
|
7
|
+
require 'uri'
|
8
|
+
|
9
|
+
module Capistrano
|
10
|
+
module JDKInstaller
|
11
|
+
def download_archive(uri, archive)
|
12
|
+
if FileTest.exist?(archive)
|
13
|
+
logger.info("Found downloaded archive: #{archive}")
|
14
|
+
else
|
15
|
+
if java_release_license_title != java_license_title or !java_accept_license
|
16
|
+
abort("You must accept JDK license before downloading.")
|
17
|
+
end
|
18
|
+
|
19
|
+
logger.info("Download archive from #{uri}.")
|
20
|
+
unless dry_run
|
21
|
+
run_locally("mkdir -p #{File.dirname(archive)}")
|
22
|
+
page = java_mechanize_agent.get(uri)
|
23
|
+
1.upto(16) { # to avoid infinity loop...
|
24
|
+
if page.uri.host == "login.oracle.com" # login.oracle.com doesn't return proper Content-Type
|
25
|
+
page = Mechanize::Page.new(page.uri, page.response, page.body, page.code, java_mechanize_agent) if page.is_a?(Mechanize::File)
|
26
|
+
form = page.form_with
|
27
|
+
form["ssousername"] = java_oracle_username
|
28
|
+
form["password"] = java_oracle_password
|
29
|
+
page = java_mechanize_agent.submit(form)
|
30
|
+
else
|
31
|
+
page.save(archive)
|
32
|
+
logger.info("Wrote #{page.body.size} bytes to #{archive}.")
|
33
|
+
break
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def upload_archive(from, to, options={}, &block)
|
41
|
+
mode = options.delete(:mode)
|
42
|
+
execute_on_servers(options) { |servers|
|
43
|
+
targets = servers.map { |server| sessions[server] }
|
44
|
+
if dry_run
|
45
|
+
logger.debug "transfering: #{[:up, from, to, targets, options.merge(:logger => logger).inspect ] * ', '}"
|
46
|
+
else
|
47
|
+
stat = File.stat(from)
|
48
|
+
chdcksum_cmd = fetch(:java_checksum_cmd, 'md5sum')
|
49
|
+
checksum = run_locally("( cd #{File.dirname(from)} && #{checksum_cmd} #{File.basename(from)} )").strip
|
50
|
+
targets = targets.reject { |ssh|
|
51
|
+
begin
|
52
|
+
sftp = Net::SFTP::Session.new(ssh).connect!
|
53
|
+
remote_stat = sftp.stat!(to)
|
54
|
+
if stat.size == remote_stat.size
|
55
|
+
remote_checksum = ssh.exec!("( cd #{File.dirname(to)} && #{checksum_cmd} #{File.basename(to)} )").strip
|
56
|
+
checksum == remote_checksum # skip upload if file size and checksum are same between local and remote
|
57
|
+
else
|
58
|
+
false
|
59
|
+
end
|
60
|
+
rescue Net::SFTP::StatusException
|
61
|
+
false # upload again if the remote file is absent
|
62
|
+
end
|
63
|
+
}
|
64
|
+
Capistrano::Transfer.process(:up, from, to, targets, options.merge(:logger => logger), &block)
|
65
|
+
end
|
66
|
+
}
|
67
|
+
if mode
|
68
|
+
mode = mode.is_a?(Numeric) ? mode.to_s(8) : mode.to_s
|
69
|
+
run("chmod #{mode} #{to}", options)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def extract_archive(archive, destination)
|
74
|
+
case archive
|
75
|
+
when /\.bin$/
|
76
|
+
"( cd #{File.dirname(destination)} && yes | sh #{archive} )"
|
77
|
+
when /\.dmg$/
|
78
|
+
if java_update_number
|
79
|
+
pkg = File.join("/Volumes",
|
80
|
+
"JDK %d Update %02d" % [java_major_version, java_update_number],
|
81
|
+
"JDK %d Update %02d.pkg" % [java_major_version, java_update_number])
|
82
|
+
else
|
83
|
+
pkg = File.join("/Volumes",
|
84
|
+
"JDK %d" % [java_major_version],
|
85
|
+
"JDK %d" % [java_major_version])
|
86
|
+
end
|
87
|
+
execute = []
|
88
|
+
execute << "open #{archive.dump}"
|
89
|
+
execute << "( while ! test -f #{pkg.dump}; do sleep 1; done )"
|
90
|
+
execute << "open #{pkg.dump}"
|
91
|
+
execute << "( while ! test -d #{destination.dump}; do sleep 1; done )"
|
92
|
+
execute.join(' && ')
|
93
|
+
when /\.(tar\.(gz|bz2)|tgz|tbz2)$/
|
94
|
+
"tar xf #{archive} -C #{File.dirname(destination)}"
|
95
|
+
when /\.zip$/
|
96
|
+
"( cd #{File.dirname(destination)} && unzip #{archive} )"
|
97
|
+
else
|
98
|
+
abort("Unknown archive type: #{archive}")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.extended(configuration)
|
103
|
+
configuration.load {
|
104
|
+
namespace(:java) {
|
105
|
+
## JDK installation path settings
|
106
|
+
_cset(:java_tools_path) {
|
107
|
+
File.join(shared_path, 'tools', 'java')
|
108
|
+
}
|
109
|
+
_cset(:java_tools_path_local) {
|
110
|
+
File.join(File.expand_path('.'), 'tools', 'java')
|
111
|
+
}
|
112
|
+
_cset(:java_home) {
|
113
|
+
case java_deployee_platform
|
114
|
+
when /Mac OS X/i
|
115
|
+
if java_update_number
|
116
|
+
File.join("/Library", "Java", "JavaVirtualMachines",
|
117
|
+
"jdk%s_%02d.jdk" % [java_inner_version, java_update_number],
|
118
|
+
"Contents", "Home")
|
119
|
+
else
|
120
|
+
File.join("/Library", "Java", "JavaVirtualMachines",
|
121
|
+
"jdk%s.jdk" % [java_inner_version],
|
122
|
+
"Contents", "Home")
|
123
|
+
end
|
124
|
+
else
|
125
|
+
if java_update_number
|
126
|
+
File.join(java_tools_path, "jdk%s_%02d" % [java_inner_version, java_update_number])
|
127
|
+
else
|
128
|
+
File.join(java_tools_path, "jdk%s" % [java_inner_version])
|
129
|
+
end
|
130
|
+
end
|
131
|
+
}
|
132
|
+
_cset(:java_home_local) {
|
133
|
+
case java_deployer_platform
|
134
|
+
when /Mac OS X/i
|
135
|
+
if java_update_number
|
136
|
+
File.join("/Library", "Java", "JavaVirtualMachines",
|
137
|
+
"jdk%s_%02d.jdk" % [java_inner_version, java_update_number],
|
138
|
+
"Contents", "Home")
|
139
|
+
else
|
140
|
+
File.join("/Library", "Java", "JavaVirtualMachines",
|
141
|
+
"jdk%s.jdk" % [java_inner_version],
|
142
|
+
"Contents", "Home")
|
143
|
+
end
|
144
|
+
else
|
145
|
+
if java_update_number
|
146
|
+
File.join(java_tools_path_local, "jdk%s_%02d" % [java_inner_version, java_update_number])
|
147
|
+
else
|
148
|
+
File.join(java_tools_path_local, "jdk%s" % [java_inner_version])
|
149
|
+
end
|
150
|
+
end
|
151
|
+
}
|
152
|
+
_cset(:java_bin) { File.join(java_home, 'bin', 'java') }
|
153
|
+
_cset(:java_bin_local) { File.join(java_home_local, 'bin', 'java') }
|
154
|
+
_cset(:java_cmd) { "env JAVA_HOME=#{java_home} #{java_bin}" }
|
155
|
+
_cset(:java_cmd_local) { "env JAVA_HOME=#{java_home_local} #{java_bin_local}" }
|
156
|
+
|
157
|
+
## JDK version settings
|
158
|
+
_cset(:java_version_name) {
|
159
|
+
abort('You must specify JDK version explicitly.')
|
160
|
+
}
|
161
|
+
_cset(:java_version_info) {
|
162
|
+
case java_version_name
|
163
|
+
when /^(1\.4\.(\d+))(?:_([0-9]+))?$/ then [ $1, '1.4', $2, $3 ]
|
164
|
+
when /^(1\.5\.(\d+))(?:_([0-9]+))?$/ then [ $1, '5', $2, $3 ]
|
165
|
+
when /^(\d+)(?:u(\d+))?$/ then [ "1.#{$1}.0", $1, nil, $2 ]
|
166
|
+
else
|
167
|
+
abort("Could not parse JDK version name: #{java_version_name}")
|
168
|
+
end
|
169
|
+
}
|
170
|
+
_cset(:java_inner_version) { java_version_info[0] } # e.g. "1.7.0"
|
171
|
+
_cset(:java_major_version) { java_version_info[1] } # e.g. "7"
|
172
|
+
_cset(:java_minor_version) { java_version_info[2] } # e.g. nil
|
173
|
+
_cset(:java_update_number) { java_version_info[3] } # e.g. "6"
|
174
|
+
_cset(:java_version) {
|
175
|
+
"JDK #{java_major_version}"
|
176
|
+
}
|
177
|
+
_cset(:java_release) {
|
178
|
+
case java_major_version
|
179
|
+
when '1.4'
|
180
|
+
if java_update_number
|
181
|
+
"Java SE Development Kit #{java_inner_version.gsub('.', '_')}_#{java_update_number}"
|
182
|
+
else
|
183
|
+
"Java SE Development Kit #{java_inner_version.gsub('.', '_')}"
|
184
|
+
end
|
185
|
+
when '5'
|
186
|
+
if java_update_number
|
187
|
+
"Java SE Development Kit #{java_major_version}.#{java_minor_version} Update #{java_update_number}"
|
188
|
+
else
|
189
|
+
"Java SE Development Kit #{java_major_version}.#{java_minor_version}"
|
190
|
+
end
|
191
|
+
when '6', '7'
|
192
|
+
if java_update_number
|
193
|
+
"Java SE Development Kit #{java_major_version}u#{java_update_number}"
|
194
|
+
else
|
195
|
+
"Java SE Development Kit #{java_major_version}"
|
196
|
+
end
|
197
|
+
else
|
198
|
+
abort("Unknown JDK version: #{java_major_version}")
|
199
|
+
end
|
200
|
+
}
|
201
|
+
def java_platform(ostype, arch)
|
202
|
+
case ostype
|
203
|
+
when /^Darwin$/i
|
204
|
+
case arch
|
205
|
+
when /^i[3-7]86$/i, /^x86_64$/i
|
206
|
+
'Mac OS X x64'
|
207
|
+
else
|
208
|
+
"Mac OS X #{arch}"
|
209
|
+
end
|
210
|
+
when /^Linux$/i
|
211
|
+
case arch
|
212
|
+
when /^i[3-7]86$/i
|
213
|
+
'Linux x86'
|
214
|
+
when /^x86_64$/i
|
215
|
+
'Linux x64'
|
216
|
+
else
|
217
|
+
"Linux #{arch}"
|
218
|
+
end
|
219
|
+
when /^Solaris$/i
|
220
|
+
case arch
|
221
|
+
when /^sparc$/i
|
222
|
+
"Solaris SPARC"
|
223
|
+
when /^sparcv9$/i
|
224
|
+
"Solaris SPARC 64-bit"
|
225
|
+
when /^i[3-7]86$/i
|
226
|
+
"Solaris x86"
|
227
|
+
when /^x86_64$/i
|
228
|
+
"Solaris x64"
|
229
|
+
else
|
230
|
+
"Solaris #{arch}"
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
## hudson.tools.JDKInstaller.json
|
236
|
+
_cset(:java_mechanize_agent) {
|
237
|
+
Mechanize.log = ::Logger.new(STDERR)
|
238
|
+
Mechanize.log.level = ::Logger::INFO
|
239
|
+
agent = Mechanize.new { |agent|
|
240
|
+
agent.user_agent = 'Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)'
|
241
|
+
agent.cookie_jar.add!(Mechanize::Cookie.new('gpw_e24', '.', :domain => 'oracle.com', :path => '/', :secure => false, :for_domain => true))
|
242
|
+
}
|
243
|
+
agent.ssl_version = :TLSv1
|
244
|
+
agent
|
245
|
+
}
|
246
|
+
_cset(:java_installer_uri, "http://updates.jenkins-ci.org/updates/hudson.tools.JDKInstaller.json")
|
247
|
+
_cset(:java_installer_json_cache) {
|
248
|
+
File.join(java_tools_path_local, File.basename(URI.parse(java_installer_uri).path))
|
249
|
+
}
|
250
|
+
_cset(:java_installer_json_expires, 86400)
|
251
|
+
_cset(:java_installer_json) {
|
252
|
+
if File.file?(java_installer_json_cache)
|
253
|
+
refresh = File.mtime(java_installer_json_cache) + java_installer_json_expires < Time.now
|
254
|
+
else
|
255
|
+
refresh = true
|
256
|
+
end
|
257
|
+
if refresh
|
258
|
+
execute = []
|
259
|
+
execute << "mkdir -p #{File.dirname(java_installer_json_cache)}"
|
260
|
+
execute << "rm -f #{java_installer_json_cache}"
|
261
|
+
execute << "wget --no-verbose -O #{java_installer_json_cache} #{java_installer_uri}"
|
262
|
+
if dry_run
|
263
|
+
logger.debug(execute.join(' && '))
|
264
|
+
else
|
265
|
+
run_locally(execute.join(' && '))
|
266
|
+
end
|
267
|
+
end
|
268
|
+
json = File.read(java_installer_json_cache)
|
269
|
+
json = json.sub(/\A[^{]*/, '').sub(/[^}]*\z/, '') # remove leading & trailing JS code from response
|
270
|
+
JSON.load(json)
|
271
|
+
}
|
272
|
+
_cset(:java_version_data) {
|
273
|
+
version = java_installer_json['version']
|
274
|
+
abort("Unknown JSON format version: #{version}") if version != 2
|
275
|
+
regex = Regexp.new(Regexp.quote(java_version), Regexp::IGNORECASE)
|
276
|
+
data = java_installer_json['data']
|
277
|
+
data.find { |datum| regex === datum['name'].strip }
|
278
|
+
}
|
279
|
+
_cset(:java_release_data) {
|
280
|
+
regex = Regexp.new(Regexp.quote(java_release), Regexp::IGNORECASE)
|
281
|
+
releases = java_version_data['releases']
|
282
|
+
releases.find { |release| regex === release['name'].strip or regex === release['title'].strip }
|
283
|
+
}
|
284
|
+
_cset(:java_release_license_title) {
|
285
|
+
java_release_data['lictitle']
|
286
|
+
}
|
287
|
+
def java_platform_data(regex)
|
288
|
+
files = java_release_data['files']
|
289
|
+
data = files.find { |data|
|
290
|
+
regex === data['title']
|
291
|
+
}
|
292
|
+
abort("Not supported on specified JDK release: #{regex.inspect}") unless data
|
293
|
+
data
|
294
|
+
end
|
295
|
+
|
296
|
+
## settings for local machine
|
297
|
+
_cset(:java_deployer_platform) { java_platform(`uname -s`.strip, `uname -m`.strip) }
|
298
|
+
_cset(:java_deployer_archive_uri) {
|
299
|
+
regex = Regexp.new(Regexp.quote(java_deployer_platform), Regexp::IGNORECASE)
|
300
|
+
data = java_platform_data(regex)
|
301
|
+
data['filepath']
|
302
|
+
}
|
303
|
+
_cset(:java_deployer_archive) {
|
304
|
+
File.join(java_tools_path, File.basename(URI.parse(java_deployer_archive_uri).path))
|
305
|
+
}
|
306
|
+
_cset(:java_deployer_archive_local) {
|
307
|
+
File.join(java_tools_path_local, File.basename(URI.parse(java_deployer_archive_uri).path))
|
308
|
+
}
|
309
|
+
|
310
|
+
## settings for remote machines
|
311
|
+
_cset(:java_deployee_platform) { java_platform(capture('uname -s').strip, capture('uname -m').strip) }
|
312
|
+
_cset(:java_deployee_archive_uri) {
|
313
|
+
regex = Regexp.new(Regexp.quote(java_depoyee_platform), Regexp::IGNORECASE)
|
314
|
+
data = java_platform_data(regex)
|
315
|
+
data['filepath']
|
316
|
+
}
|
317
|
+
_cset(:java_deployee_archive) {
|
318
|
+
File.join(java_tools_path, File.basename(URI.parse(java_deployee_archive_uri).path))
|
319
|
+
}
|
320
|
+
_cset(:java_deployee_archive_local) {
|
321
|
+
File.join(java_tools_path_local, File.basename(URI.parse(java_deployee_archive_uri).path))
|
322
|
+
}
|
323
|
+
|
324
|
+
## license settings
|
325
|
+
_cset(:java_accept_license, false)
|
326
|
+
_cset(:java_license_title, nil)
|
327
|
+
_cset(:java_oracle_username) { abort("java_oracle_username was not set") }
|
328
|
+
_cset(:java_oracle_password) { abort("java_oracle_password was not set") }
|
329
|
+
|
330
|
+
## tasks
|
331
|
+
desc("Install java locally.")
|
332
|
+
task(:setup_locally, :except => { :no_release => true }) {
|
333
|
+
if fetch(:java_setup_locally, false)
|
334
|
+
transaction {
|
335
|
+
download_locally
|
336
|
+
install_locally
|
337
|
+
}
|
338
|
+
end
|
339
|
+
}
|
340
|
+
after 'deploy:setup', 'java:setup'
|
341
|
+
|
342
|
+
task(:download_locally, :except => { :no_release => true }) {
|
343
|
+
download_archive(java_deployer_archive_uri, java_deployer_archive_local)
|
344
|
+
}
|
345
|
+
|
346
|
+
task(:install_locally, :except => { :no_release => true}) {
|
347
|
+
command = (<<-EOS).gsub(/\s+/, ' ')
|
348
|
+
if ! test -d #{java_home_local}; then
|
349
|
+
#{extract_archive(java_deployer_archive_local, java_home_local)} &&
|
350
|
+
#{java_cmd_local} -version;
|
351
|
+
fi;
|
352
|
+
EOS
|
353
|
+
if dry_run
|
354
|
+
logger.debug(command)
|
355
|
+
else
|
356
|
+
run_locally(command)
|
357
|
+
end
|
358
|
+
}
|
359
|
+
|
360
|
+
desc("Install java.")
|
361
|
+
task(:setup, :roles => :app, :except => { :no_release => true }) {
|
362
|
+
if fetch(:java_setup_remotely, true)
|
363
|
+
transaction {
|
364
|
+
download
|
365
|
+
upload_archive(java_deployee_archive_local, java_deployee_archive)
|
366
|
+
install
|
367
|
+
}
|
368
|
+
end
|
369
|
+
}
|
370
|
+
after 'deploy:setup', 'java:setup'
|
371
|
+
|
372
|
+
task(:download, :roles => :app, :except => { :no_release => true }) {
|
373
|
+
download_archive(java_deployee_archive_uri, java_deployee_archive_local)
|
374
|
+
}
|
375
|
+
|
376
|
+
task(:install, :roles => :app, :except => { :no_release => true }) {
|
377
|
+
command = (<<-EOS).gsub(/\s+/, ' ')
|
378
|
+
if ! test -d #{java_home}; then
|
379
|
+
#{extract_archive(java_deployee_archive, java_home)} &&
|
380
|
+
#{java_cmd} -version;
|
381
|
+
fi;
|
382
|
+
EOS
|
383
|
+
run(command)
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
if Capistrano::Configuration.instance
|
392
|
+
Capistrano::Configuration.instance.extend(Capistrano::JDKInstaller)
|
393
|
+
end
|
394
|
+
|
395
|
+
# vim:set ft=ruby :
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-jdk-installer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yamashita Yuu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: net-sftp
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.0.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: mechanize
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.0.0
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.0.0
|
78
|
+
description: a capistrano recipe to download and install JDK for your projects.
|
79
|
+
email:
|
80
|
+
- yamashita@geishatokyo.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- LICENSE.txt
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- capistrano-jdk-installer.gemspec
|
91
|
+
- lib/capistrano-jdk-installer.rb
|
92
|
+
- lib/capistrano-jdk-installer/version.rb
|
93
|
+
homepage: https://github.com/yyuu/capistrano-jdk-installer
|
94
|
+
licenses: []
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.8.23
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: a capistrano recipe to download and install JDK for your projects.
|
117
|
+
test_files: []
|