Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
# remove the deprecated Ubuntu jdk packages
default['java']['remove_deprecated_packages'] = false

# default jdk attributes
# default jdk/jre attributes
default['java']['install_flavor'] = "openjdk"
default['java']['jdk_version'] = '6'
default['java']['jre_version'] = '6'
default['java']['arch'] = kernel['machine'] =~ /x86_64/ ? "x86_64" : "i586"
default['java']['bin_cmds'] = ['java','jar']

Expand Down
19 changes: 13 additions & 6 deletions providers/ark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def download_jdk(tarball_name, new_resource)
tmpdir = Dir.mktmpdir
case tarball_name
when /^.*\.bin/
Chef::Log.debug("Extracting #{tarball_name} to #{tmpdir}")
cmd = Chef::ShellOut.new(
%Q[ cd "#{tmpdir}";
cp "#{Chef::Config[:file_cache_path]}/#{tarball_name}" . ;
Expand All @@ -129,18 +130,23 @@ def download_jdk(tarball_name, new_resource)
end
end

cmd = Chef::ShellOut.new(
if not ( tarball_name =~ /^.*rpm\.bin/ )
Chef::Log.debug("mv #{tmpdir}/#{app_dir_name} to #{app_dir}")
cmd = Chef::ShellOut.new(
%Q[ mv "#{tmpdir}/#{app_dir_name}" "#{app_dir}" ]
).run_command
unless cmd.exitstatus == 0
Chef::Application.fatal!(%Q[ Command \' mv "#{tmpdir}/#{app_dir_name}" "#{app_dir}" \' failed ])
end
unless cmd.exitstatus == 0
Chef::Application.fatal!(%Q[ Command \' mv "#{tmpdir}/#{app_dir_name}" "#{app_dir}" \' failed ])
end
end

FileUtils.rm_r tmpdir
new_resource.updated_by_last_action(true)
end

#update-alternatives
if new_resource.default
if not ( tarball_name =~ /^.*rpm\.bin/ )
#update-alternatives
if new_resource.default
Chef::Log.debug "app_home is #{app_home} and app_dir is #{app_dir}"
current_link = ::File.symlink?(app_home) ? ::File.readlink(app_home) : nil
if current_link != app_dir
Expand All @@ -167,6 +173,7 @@ def download_jdk(tarball_name, new_resource)
end
end
end
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion recipes/oracle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
url tarball_url
checksum tarball_checksum
app_home java_home
bin_cmds [ "java" ]
bin_cmds [ "java", "javac" ]
action :install
end

59 changes: 59 additions & 0 deletions recipes/oracle_jre.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
# Cookbook Name:: java
# Recipe:: oracle
#
# Copyright 2011, Bryan w. Berry
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


java_home = node['java']["java_home"]
arch = node['java']['arch']
jre_version = node['java']['jre_version']

#convert version number to a string if it isn't already
if jre_version.instance_of? Fixnum
jre_version = jre_version.to_s
end

case jre_version
when "6"
tarball_url = node['java']['jre']['6'][arch]['url']
tarball_checksum = node['java']['jre']['6'][arch]['checksum']
when "7"
tarball_url = node['java']['jre']['7'][arch]['url']
tarball_checksum = node['java']['jre']['7'][arch]['checksum']
end

ruby_block "set-env-java-home" do
block do
ENV["JAVA_HOME"] = java_home
end
end

file "/etc/profile.d/jre.sh" do
content <<-EOS
export JAVA_HOME=#{node['java']["java_home"]}
EOS
mode 0755
end


java_ark "jre" do
url tarball_url
checksum tarball_checksum
app_home java_home
bin_cmds [ "java" ]
action :install
end