From 6cf36d0761cc4f45e4a23cd8ee860ebda3d86dda Mon Sep 17 00:00:00 2001 From: "David M. Carr" Date: Tue, 18 Mar 2014 18:01:24 -0400 Subject: [PATCH] Add support for Oracle JDK 1.8.0 (closes #147) --- .kitchen.yml | 9 +++++++++ attributes/default.rb | 20 +++++++++++++++++++ providers/ark.rb | 10 +++++++--- recipes/oracle.rb | 4 ++++ recipes/oracle_i386.rb | 4 ++++ .../oracle-8/bats/verify_oracle-8.bats | 14 +++++++++++++ 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 test/integration/oracle-8/bats/verify_oracle-8.bats diff --git a/.kitchen.yml b/.kitchen.yml index 8b9169b6..269ef7c7 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -62,6 +62,15 @@ suites: oracle: accept_oracle_download_terms: true install_flavor: oracle + - name: oracle-8 + run_list: + - recipe[java::default] + attributes: + java: + jdk_version: "8" + oracle: + accept_oracle_download_terms: true + install_flavor: oracle - name: oracle-direct run_list: - recipe[java::oracle] diff --git a/attributes/default.rb b/attributes/default.rb index 1fc07dd9..9efd933a 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -90,3 +90,23 @@ # i586 default['java']['jdk']['7']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-i586.tar.gz' default['java']['jdk']['7']['i586']['checksum'] = '909d353c1caf6b3b54cc20767a7778ef' + +# jdk8 attributes + +default['java']['jdk']['8']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac", + "javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb", + "jdeps", "jhat", "jinfo", "jjs", "jmap", "jmc", "jps", "jrunscript", "jsadebugd", "jstack", + "jstat", "jstatd", "jvisualvm", "keytool", "native2ascii", "orbd", "pack200", "policytool", + "rmic", "rmid", "rmiregistry", "schemagen", "serialver", "servertool", "tnameserv", + "unpack200", "wsgen", "wsimport", "xjc" ] + +# Oracle doesn't seem to publish SHA256 checksums for Java releases, so we use MD5 instead. +# Official checksums for the latest release can be found at http://www.oracle.com/technetwork/java/javase/downloads/javase8-binaries-checksum-2133161.html + +# x86_64 +default['java']['jdk']['8']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.tar.gz' +default['java']['jdk']['8']['x86_64']['checksum'] = '7e9e5e5229c6603a4d8476050bbd98b1' + +# i586 +default['java']['jdk']['8']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-i586.tar.gz' +default['java']['jdk']['8']['i586']['checksum'] = '45556e463a561b470bd9d0c07a73effb' diff --git a/providers/ark.rb b/providers/ark.rb index fd019f7a..94bddf44 100644 --- a/providers/ark.rb +++ b/providers/ark.rb @@ -30,13 +30,18 @@ def parse_app_dir_name url # for jdk1.6 if file_name =~ /^(jre|jdk).*$/ major_num = file_name.scan(/\d/)[0] - update_num = file_name.scan(/\d+/)[1] + update_token = file_name.scan(/u(\d+)/)[0] + update_num = update_token ? update_token[0] : "0" # pad a single digit number with a zero if update_num.length < 2 update_num = "0" + update_num end package_name = file_name.scan(/[a-z]+/)[0] - app_dir_name = "#{package_name}1.#{major_num}.0_#{update_num}" + if update_num == "00" + app_dir_name = "#{package_name}1.#{major_num}.0" + else + app_dir_name = "#{package_name}1.#{major_num}.0_#{update_num}" + end else app_dir_name = file_name.split(/(.tgz|.tar.gz|.zip)/)[0] app_dir_name = app_dir_name.split("-bin")[0] @@ -61,7 +66,6 @@ def oracle_downloaded?(download_path, new_resource) def download_direct_from_oracle(tarball_name, new_resource) download_path = "#{Chef::Config[:file_cache_path]}/#{tarball_name}" - jdk_id = new_resource.url.scan(/\/([6789]u[0-9][0-9]?-b[0-9][0-9])\//)[0][0] cookie = "oraclelicense=accept-securebackup-cookie" if node['java']['oracle']['accept_oracle_download_terms'] # install the curl package diff --git a/recipes/oracle.rb b/recipes/oracle.rb index 8ef71458..57aee491 100644 --- a/recipes/oracle.rb +++ b/recipes/oracle.rb @@ -38,6 +38,10 @@ tarball_url = node['java']['jdk']['7'][arch]['url'] tarball_checksum = node['java']['jdk']['7'][arch]['checksum'] bin_cmds = node['java']['jdk']['7']['bin_cmds'] +when "8" + tarball_url = node['java']['jdk']['8'][arch]['url'] + tarball_checksum = node['java']['jdk']['8'][arch]['checksum'] + bin_cmds = node['java']['jdk']['8']['bin_cmds'] end if tarball_url =~ /example.com/ diff --git a/recipes/oracle_i386.rb b/recipes/oracle_i386.rb index ed914f4c..50ac1284 100644 --- a/recipes/oracle_i386.rb +++ b/recipes/oracle_i386.rb @@ -37,6 +37,10 @@ tarball_url = node['java']['jdk']['7']['i586']['url'] tarball_checksum = node['java']['jdk']['7']['i586']['checksum'] bin_cmds = node['java']['jdk']['7']['bin_cmds'] +when "8" + tarball_url = node['java']['jdk']['8']['i586']['url'] + tarball_checksum = node['java']['jdk']['8']['i586']['checksum'] + bin_cmds = node['java']['jdk']['8']['bin_cmds'] end include_recipe "java::set_java_home" diff --git a/test/integration/oracle-8/bats/verify_oracle-8.bats b/test/integration/oracle-8/bats/verify_oracle-8.bats new file mode 100644 index 00000000..a9f0ba9e --- /dev/null +++ b/test/integration/oracle-8/bats/verify_oracle-8.bats @@ -0,0 +1,14 @@ +@test "installs the correct version of the jdk" { + java -version 2>&1 | grep 1.8 +} + +@test "properly sets JAVA_HOME environment variable" { + source /etc/profile.d/jdk.sh + run test -d $JAVA_HOME + [ "$status" -eq 0 ] +} + +@test "properly links jar" { + run test -L /usr/bin/jar + [ "$status" -eq 0 ] +}