|
41 | 41 |
|
42 | 42 | ruby_block "update-java-alternatives" do
|
43 | 43 | block do
|
44 |
| - require "fileutils" |
45 |
| - arch = node['kernel']['machine'] =~ /x86_64/ ? "x86_64" : "i386" |
46 |
| - Chef::Log.debug("glob is #{java_home_parent}/java*#{version}*openjdk*") |
47 |
| - jdk_home = Dir.glob("#{java_home_parent}/java*#{version}*openjdk{,-#{arch}}")[0] |
48 |
| - Chef::Log.debug("jdk_home is #{jdk_home}") |
49 |
| - # delete the symlink if it already exists |
50 |
| - if File.exists? java_home |
51 |
| - FileUtils.rm_f java_home |
52 |
| - end |
53 |
| - FileUtils.ln_sf jdk_home, java_home |
54 |
| - |
55 | 44 | if platform?("ubuntu", "debian") and version == 6
|
56 |
| - # specific to Ubuntu, this finds the file which specifies all |
57 |
| - # the symlinks to be updated |
58 |
| - java_link_name = Dir.glob("#{java_home_parent}/.java*#{version}*openjdk.jinfo")[0] |
59 |
| - java_link_name = File.basename(java_link_name).split('.')[1..-2].join('.') |
60 |
| - cmd = Chef::ShellOut.new( |
61 |
| - "update-java-alternatives -s #{java_link_name}" |
62 |
| - ).run_command |
63 |
| - unless cmd.exitstatus == 0 or cmd.exitstatus == 2 |
64 |
| - Chef::Application.fatal!("Failed to update-alternatives for openjdk!") |
65 |
| - end |
| 45 | + run_context = Chef::RunContext.new(node, {}) |
| 46 | + r = Chef::Resource::Execute.new("update-java-alternatives", run_context) |
| 47 | + r.command "update-java-alternatives -s java-6-openjdk" |
| 48 | + r.returns [0,2] |
| 49 | + r.run_action(:create) |
66 | 50 | else
|
| 51 | + # have to do this on ubuntu for version 7 because Ubuntu does |
| 52 | + # not currently set jdk 7 as the default jvm on installation |
| 53 | + require "fileutils" |
| 54 | + arch = node['kernel']['machine'] =~ /x86_64/ ? "x86_64" : "i386" |
| 55 | + Chef::Log.debug("glob is #{java_home_parent}/java*#{version}*openjdk*") |
| 56 | + jdk_home = Dir.glob("#{java_home_parent}/java*#{version}*openjdk{,-#{arch}}")[0] |
| 57 | + Chef::Log.debug("jdk_home is #{jdk_home}") |
| 58 | + # delete the symlink if it already exists |
| 59 | + if File.exists? java_home |
| 60 | + FileUtils.rm_f java_home |
| 61 | + end |
| 62 | + FileUtils.ln_sf jdk_home, java_home |
| 63 | + |
67 | 64 | cmd = Chef::ShellOut.new(
|
68 | 65 | %Q[ update-alternatives --install /usr/bin/java java #{java_home}/bin/java 1;
|
69 | 66 | update-alternatives --set java #{java_home}/bin/java ]
|
|
0 commit comments