Skip to content

Commit 38db5da

Browse files
author
jtimberman
committed
[COOK-2897] - add recipe for managing IBM java
1 parent 057fe87 commit 38db5da

File tree

5 files changed

+114
-32
lines changed

5 files changed

+114
-32
lines changed

README.md

+36-24
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ As of 26 March 2012 you can no longer directly download
1212
the JDK from Oracle's website without using a special cookie. This cookbook uses
1313
that cookie to download the oracle recipe on your behalf, but . . .
1414

15-
the java::oracle recipe forces you to set either override
16-
the `node['java']['oracle']['accept_oracle_download_terms']` to true or set up a
17-
private repository accessible by HTTP.
15+
the `java::oracle` recipe forces you to set either override the
16+
`node['java']['oracle']['accept_oracle_download_terms']` to true or
17+
set up a private repository accessible by HTTP.
1818

1919
Example
2020

@@ -53,7 +53,7 @@ Attributes
5353

5454
See `attributes/default.rb` for default values.
5555

56-
* `node["java"]["install_flavor"]` - Flavor of JVM you would like installed (`oracle` or
56+
* `node['java']['install_flavor']` - Flavor of JVM you would like installed (`oracle` or
5757
`openjdk`), default `openjdk`.
5858
* `node['java']['java_home']` - Default location of the "`$JAVA_HOME`".
5959
* `node['java']['tarball']` - Name of the tarball to retrieve from your corporate
@@ -69,28 +69,29 @@ packages from the system, default `false`
6969
* `node['java']['windows']['url']` - The internal location of your java install for windows
7070
* `node['java']['windows']['package_name']` - The package name used by windows_package to
7171
check in the registry to determine if the install has already been run
72+
* `node['java']['ibm']['url']` - The URL which to download the IBM
73+
JDK/SDK. See the `ibm` recipe section below.
74+
* `node['java']['ibm']['accept_ibm_download_terms']` - Indicates that
75+
you accept IBM's EULA (for `java::ibm`)
7276

7377
Recipes
7478
=======
7579

76-
default
77-
-------
80+
## default
7881

7982
Include the default recipe in a run list, to get `java`. By default
8083
the `openjdk` flavor of Java is installed, but this can be changed by
81-
using the `install_flavor` attribute. If the platform is windows it
84+
using the `install_flavor` attribute. If the platform is windows it
8285
will include the windows recipe instead.
8386

8487
OpenJDK is the default because of licensing changes made upstream by
8588
Oracle. See notes on the `oracle` recipe below.
8689

87-
openjdk
88-
-------
90+
## openjdk
8991

9092
This recipe installs the `openjdk` flavor of Java.
9193

92-
oracle
93-
------
94+
## oracle
9495

9596
This recipe installs the `oracle` flavor of Java. This recipe does not
9697
use distribution packages as Oracle changed the licensing terms with
@@ -105,19 +106,31 @@ After putting the binaries in place, the oracle recipe updates
105106
/usr/bin/java to point to the installed JDK using the
106107
`update-alternatives` script
107108

108-
oracle_i386
109-
-----------
109+
## oracle_i386
110110

111111
This recipe installs the 32-bit Java virtual machine without setting
112112
it as the default. This can be useful if you have applications on the
113113
same machine that require different versions of the JVM.
114114

115-
windows
116-
-------
115+
## windows
117116

118-
Because there is no easy way to pull the java msi off oracle's site,
117+
Because there is no easy way to pull the java msi off oracle's site,
119118
this recipe requires you to host it internally on your own http repo.
120119

120+
## ibm
121+
122+
The `java::ibm` recipe is used to install the IBM version of Java.
123+
Note that IBM requires you to create an account *and* log in to
124+
download the binary installer for your platform. You must accept the
125+
license agreement with IBM to use their version of Java. In this
126+
cookbook, you indicate this by setting
127+
`node['java']['ibm']['accept_ibm_download_terms']` to `true`. You must
128+
also host the binary on your own HTTP server to have an automated
129+
installation.
130+
131+
At this time the `java::ibm` recipe does not support multiple SDK
132+
installations.
133+
121134
Resources/Providers
122135
===================
123136

@@ -127,13 +140,13 @@ in favor of [ark](https://github.com/opscode-cookbooks/ark).
127140
By default, the extracted directory is extracted to
128141
`app_root/extracted_dir_name` and symlinked to `app_root/default`
129142

130-
# Actions
143+
## Actions
131144

132145
- `:install`: extracts the tarball and makes necessary symlinks
133146
- `:remove`: removes the tarball and run update-alternatives for all
134147
symlinked `bin_cmds`
135148

136-
# Attribute Parameters
149+
## Attribute Parameters
137150

138151
- `url`: path to tarball, .tar.gz, .bin (oracle-specific), and .zip
139152
currently supported
@@ -153,8 +166,7 @@ By default, the extracted directory is extracted to
153166
- `default`: whether this the default installation of this package,
154167
boolean true or false
155168

156-
157-
# Examples
169+
## Examples
158170

159171
# install jdk6 from Oracle
160172
java_ark "jdk" do
@@ -165,7 +177,6 @@ By default, the extracted directory is extracted to
165177
action :install
166178
end
167179

168-
169180
Usage
170181
=====
171182

@@ -195,10 +206,11 @@ files/default/tests/minitest-handler. Additional tests are always welcome.
195206
License and Author
196207
==================
197208

198-
Author:: Seth Chisamore (<[email protected]>)
199-
Author:: Bryan W. Berry (<[email protected]>)
209+
* Author: Seth Chisamore (<[email protected]>)
210+
* Author: Bryan W. Berry (<[email protected]>)
211+
* Author: Joshua Timberman (<[email protected]>)
200212

201-
Copyright:: 2008-2012, Opscode, Inc
213+
Copyright: 2008-2013, Opscode, Inc
202214

203215
Licensed under the Apache License, Version 2.0 (the "License");
204216
you may not use this file except in compliance with the License.

attributes/default.rb

+15-8
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,23 @@
4040
default['java']['java_home'] = "/usr/lib/jvm/default-java"
4141
end
4242

43+
if node['java']['install_flavor'] =~ /ibm/
44+
default['java']['ibm']['url'] = nil
45+
default['java']['ibm']['checksum'] = nil
46+
default['java']['ibm']['accept_ibm_download_terms'] = false
47+
default['java']['java_home'] = "/opt/ibm/java"
48+
end
49+
4350
# if you change this to true, you can download directly from Oracle
4451
default['java']['oracle']['accept_oracle_download_terms'] = false
4552

4653
# direct download paths for oracle, you have been warned!
4754

4855
# jdk6 attributes
49-
default['java']['jdk']['6']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "HtmlConverter", "idlj", "jar", "jarsigner",
50-
"java", "javac", "javadoc", "javah", "javap", "javaws", "jconsole", "jcontrol", "jdb", "jhat",
51-
"jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm",
52-
"keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry",
56+
default['java']['jdk']['6']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "HtmlConverter", "idlj", "jar", "jarsigner",
57+
"java", "javac", "javadoc", "javah", "javap", "javaws", "jconsole", "jcontrol", "jdb", "jhat",
58+
"jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm",
59+
"keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry",
5360
"schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc" ]
5461

5562
# x86_64
@@ -62,10 +69,10 @@
6269

6370
# jdk7 attributes
6471

65-
default['java']['jdk']['7']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac",
66-
"javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb",
67-
"jhat", "jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm",
68-
"keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry",
72+
default['java']['jdk']['7']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac",
73+
"javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb",
74+
"jhat", "jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm",
75+
"keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry",
6976
"schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc" ]
7077

7178
# x86_64

recipes/ibm.rb

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Author:: Joshua Timberman (<[email protected]>)
2+
# Cookbook Name:: java
3+
# Recipe:: ibm
4+
#
5+
# Copyright 2013, Opscode, Inc.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
require 'uri'
20+
source_url = node['java']['ibm']['url']
21+
jdk_uri = ::URI.parse(source_url)
22+
jdk_filename = ::File.basename(jdk_uri.path)
23+
24+
unless source_url =~ ::URI::ABS_URI && %w[http https].include?(jdk_uri.scheme)
25+
raise "You must set the attribute `node['java']['ibm']['url']` to a valid HTTP URI"
26+
end
27+
28+
template "#{Chef::Config[:file_cache_path]}/installer.properties" do
29+
source "ibm_jdk.installer.properties.erb"
30+
only_if { node['java']['ibm']['accept_ibm_download_terms'] }
31+
end
32+
33+
remote_file "#{Chef::Config[:file_cache_path]}/#{jdk_filename}" do
34+
source source_url
35+
mode 00755
36+
if node['java']['ibm']['checksum']
37+
checksum node['java']['ibm']['checksum']
38+
action :create
39+
else
40+
action :create_if_missing
41+
end
42+
notifies :run, "execute[install-ibm-java]", :immediately
43+
end
44+
45+
execute "install-ibm-java" do
46+
cwd Chef::Config[:file_cache_path]
47+
environment({
48+
"_JAVA_OPTIONS" => "-Dlax.debug.level=3 -Dlax.debug.all=true",
49+
"LAX_DEBUG" => "1"
50+
})
51+
command <<-EOH.gsub(/^\s+/, '')
52+
./#{jdk_filename} -f ./installer.properties -i silent
53+
EOH
54+
creates "#{node['java']['java_home']}/jre/bin/java"
55+
end
56+
57+
include_recipe "java::set_java_home"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
INSTALLER_UI=silent
2+
USER_INSTALL_DIR=<%= node['java']['java_home'] %>
3+
-fileOverwrite_<%= node['java']['java_home'] %>_uninstall/uninstall.lax=Yes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@test "check for IBM java in $JAVA_HOME" {
2+
$JAVA_HOME/bin/java -version 2>&1 | grep IBM
3+
}

0 commit comments

Comments
 (0)