Skip to content

Update Temurin support #722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@ jobs:
- ubuntu-2204
- ubuntu-2004
suite:
# - openjdk-11 # Debian doesn't have an 11 package
- openjdk-16
- openjdk-17
# - temurin-8-hotspot
# - temurin-11-hotspot
# - semeru-11-openj9
# - semeru-17-openj9
- corretto-8
- corretto-11
- corretto-17
- corretto-18
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby system
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This file is used to list changes made in each version of the Java cookbook.

## Unreleased

- Update Temurin support
- Add script to check for Java updates
- Remove Java 8 support

## 12.1.1 - *2024-12-05*

## 12.1.0 - *2024-12-03*
Expand Down
96 changes: 96 additions & 0 deletions bin/check_java_versions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env ruby

require 'net/http'
require 'json'
require 'uri'

TEMURIN_REPOS = {
'11' => 'adoptium/temurin11-binaries',
'17' => 'adoptium/temurin17-binaries',
}.freeze

SEMERU_REPOS = {
'11' => 'ibmruntimes/semeru11-binaries',
'17' => 'ibmruntimes/semeru17-binaries',
}.freeze

CORRETTO_REPOS = {
'11' => 'corretto-11',
'17' => 'corretto-17',
}.freeze

def get_latest_release(repo)
uri = URI("https://api.github.com/repos/#{repo}/releases/latest")
response = Net::HTTP.get_response(uri)

if response.is_a?(Net::HTTPSuccess)
JSON.parse(response.body)
else
puts "Failed to fetch release info for #{repo}: #{response.code} #{response.message}"
nil
end
end

def verify_url(url)
uri = URI(url)
response = Net::HTTP.get_response(uri)

case response
when Net::HTTPRedirection
location = response['location']
puts " ✓ URL redirects successfully to: #{location}"
true
when Net::HTTPSuccess
puts ' ✓ URL is directly accessible'
true
else
puts " ✗ URL is not accessible: #{response.code} #{response.message}"
false
end
end

def find_linux_x64_jdk(assets)
assets.find { |asset| asset['name'] =~ /OpenJDK\d+U-jdk_x64_linux_hotspot.*\.tar\.gz$/ }
end

def check_versions
puts 'Checking Temurin versions...'
puts '-' * 50

TEMURIN_REPOS.each do |version, repo|
puts "\nChecking Java #{version}..."
release = get_latest_release(repo)
next unless release

tag = release['tag_name']
puts "Latest release: #{tag}"

asset = find_linux_x64_jdk(release['assets'])
if asset
url = asset['browser_download_url']
puts "Download URL: #{url}"
if verify_url(url)
puts 'Current version in cookbook needs updating!' if url != current_url_in_cookbook(version)
end
else
puts ' ✗ No Linux x64 JDK found in release assets'
end
end
end

def current_url_in_cookbook(version)
# Read the current URLs from openjdk_helpers.rb
helpers_file = File.join(File.dirname(__FILE__), '..', 'libraries', 'openjdk_helpers.rb')
content = File.read(helpers_file)

case version
when '11'
content.match(/temurin.*when '11'\s+'(.+?)'/m)&.[](1)
when '17'
content.match(/temurin.*when '17'\s+'(.+?)'/m)&.[](1)
end
end

if __FILE__ == $PROGRAM_NAME
check_versions
end
37 changes: 21 additions & 16 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ suites:
inputs: { java_version: "17" }

# Temurin/Semeru
- name: temurin-8-hotspot
run_list:
- recipe[test::openjdk]
attributes:
version: 8
variant: hotspot
verifier:
inspec_tests: [test/integration/openjdk]
inputs: { java_version: "8" }

- name: temurin-11-hotspot
run_list:
- recipe[test::openjdk]
Expand Down Expand Up @@ -88,14 +78,29 @@ suites:
inspec_tests: [test/integration/openjdk]
inputs: { java_version: "17" }

# Corretto
- name: corretto-8
- name: temurin-11
run_list:
- recipe[test::corretto]
attributes: { version: "8" }
- recipe[test::openjdk]
attributes:
java:
version: "11"
flavor: "temurin"
verifier:
inspec_tests: [test/integration/corretto]
inputs: { java_version: "8" }
inspec_tests: [test/integration/openjdk]
inputs: { java_version: "11" }

- name: temurin-17
run_list:
- recipe[test::openjdk]
attributes:
java:
version: "17"
flavor: "temurin"
verifier:
inspec_tests: [test/integration/openjdk]
inputs: { java_version: "17" }

# Corretto
- name: corretto-11
run_list:
- recipe[test::corretto]
Expand Down
11 changes: 4 additions & 7 deletions libraries/certificate_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ def default_truststore_path(version, java_home)
if version.to_i > 8
"#{java_home}/lib/security/cacerts"
else
"#{java_home}/jre/lib/security/cacerts"
Chef::Log.fatal('Java 8 is no longer supported')
raise 'Java 8 is no longer supported'
end
end

def keystore_argument(version, cacerts, truststore_path)
if version.to_i > 8 && cacerts
'-cacerts'
else
"-keystore #{truststore_path}"
end
def keystore_argument(cacerts, truststore_path)
cacerts ? '-cacerts' : "-keystore #{truststore_path}"
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions libraries/corretto_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ def corretto_arch

def default_corretto_bin_cmds(version)
case version.to_s
when '8'
%w(appletviewer clhsdb extcheck hsdb idlj jar jarsigner java java-rmi.cgi javac javadoc javafxpackager javah javap javapackager jcmd jconsole jdb jdeps jfr jhat jinfo jjs jmap jps jrunscript jsadebugd jstack jstat jstatd keytool native2ascii orbd pack200 policytool rmic rmid rmiregistry schemagen serialver servertool tnameserv unpack200 wsgen wsimport xjc)
when '11'
%w(jaotc jar jarsigner java javac javadoc javap jcmd jconsole jdb jdeprscan jdeps jfr jhsdb jimage jinfo jjs jlink jmap jmod jps jrunscript jshell jstack jstat jstatd keytool pack200 rmic rmid rmiregistry serialver unpack200)
when '15', '17', '18'
Expand All @@ -20,8 +18,6 @@ def default_corretto_bin_cmds(version)

def default_corretto_minor(version)
case version
when '8'
'8.332.08.1'
when '11'
'11.0.15.9.1'
when '17'
Expand Down
99 changes: 41 additions & 58 deletions libraries/openjdk_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,71 +34,58 @@ def default_openjdk_install_method(version)
end
end

def default_openjdk_url(version, variant = nil)
# Always default to OpenJDK
# If the user passes variant we'll also select that variant's URL
case version
when '8'
case variant
when 'semeru'
'https://github.com/ibmruntimes/semeru8-binaries/releases/download/jdk8u322-b06_openj9-0.30.0/ibm-semeru-open-jdk_x64_linux_8u322b06_openj9-0.30.0.tar.gz'
when 'temurin'
'https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u322-b06/OpenJDK8U-jdk_x64_linux_hotspot_8u322b06.tar.gz'
def default_openjdk_url(version, variant = 'openjdk')
case variant.downcase
when 'temurin'
case version
when '11'
'https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.25%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.25_9.tar.gz'
when '17'
'https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_x64_linux_hotspot_17.0.13_11.tar.gz'
else
Chef::Log.fatal('Version specified does not have a URL value set')
raise 'Version supplied does not have a download URL set'
end
when '9'
'https://download.java.net/java/GA/jdk9/9/binaries/openjdk-9_linux-x64_bin.tar.gz'
when '10'
'https://download.java.net/java/GA/jdk10/10/binaries/openjdk-10_linux-x64_bin.tar.gz'
when '11'
case variant
when 'semeru'
when 'semeru'
case version
when '11'
'https://github.com/ibmruntimes/semeru11-binaries/releases/download/jdk-11.0.14.1%2B1_openj9-0.30.1/ibm-semeru-open-jdk_x64_linux_11.0.14.1_1_openj9-0.30.1.tar.gz'
when 'temurin'
'https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.15_10.tar.gz'
else
'https://download.java.net/java/ga/jdk11/openjdk-11_linux-x64_bin.tar.gz'
end
when '12'
'https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_linux-x64_bin.tar.gz'
when '13'
'https://download.java.net/java/GA/jdk13/5b8a42f3905b406298b72d750b6919f6/33/GPL/openjdk-13_linux-x64_bin.tar.gz'
when '14'
'https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz'
when '15'
'https://download.java.net/java/GA/jdk15/779bf45e88a44cbd9ea6621d33e33db1/36/GPL/openjdk-15_linux-x64_bin.tar.gz'
when '16'
case variant
when 'semeru'
when '16'
'https://github.com/ibmruntimes/semeru16-binaries/releases/download/jdk-16.0.2%2B7_openj9-0.27.1/ibm-semeru-open-jdk_ppc64le_linux_16.0.2_7_openj9-0.27.1.tar.gz'
when 'temurin'
'https://github.com/adoptium/temurin16-binaries/releases/download/jdk-16.0.2%2B7/OpenJDK16U-jdk_x64_linux_hotspot_16.0.2_7.tar.gz'
else
'https://download.java.net/java/GA/jdk16/7863447f0ab643c585b9bdebf67c69db/36/GPL/openjdk-16_linux-x64_bin.tar.gz'
end
when '17'
case variant
when 'semeru'
when '17'
'https://github.com/ibmruntimes/semeru17-binaries/releases/download/jdk-17.0.2%2B8_openj9-0.30.0/ibm-semeru-open-jdk_x64_linux_17.0.2_8_openj9-0.30.0.tar.gz'
when 'temurin'
'https://github.com/adoptium/temurin18-binaries/releases/download/jdk-18.0.1%2B10/OpenJDK18U-jdk_x64_linux_hotspot_18.0.1_10.tar.gz'
else
'https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz'
end
when '18'
case variant
when 'semeru'
when '18'
'https://github.com/AdoptOpenJDK/semeru18-binaries/releases/download/jdk-18.0.1%2B10_openj9-0.32.0/ibm-semeru-open-jdk_x64_linux_18.0.1_10_openj9-0.32.0.tar.gz'
when 'temurin'
'https://github.com/adoptium/temurin18-binaries/releases/download/jdk-18.0.1%2B10/OpenJDK18U-jdk_x64_linux_hotspot_18.0.1_10.tar.gz'
else
'https://download.java.net/java/GA/jdk18.0.1/3f48cabb83014f9fab465e280ccf630b/10/GPL/openjdk-18.0.1_linux-x64_bin.tar.gz'
Chef::Log.fatal('Version specified does not have a URL value set')
raise 'Version supplied does not have a download URL set'
end
else
Chef::Log.fatal('Version specified does not have a URL value set')
raise 'Version supplied does not have a download URL set'
case version
when '9'
'https://download.java.net/java/GA/jdk9/9/binaries/openjdk-9_linux-x64_bin.tar.gz'
when '10'
'https://download.java.net/java/GA/jdk10/10/binaries/openjdk-10_linux-x64_bin.tar.gz'
when '11'
'https://download.java.net/java/ga/jdk11/openjdk-11_linux-x64_bin.tar.gz'
when '12'
'https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_linux-x64_bin.tar.gz'
when '13'
'https://download.java.net/java/GA/jdk13/5b8a42f3905b406298b72d750b6919f6/33/GPL/openjdk-13_linux-x64_bin.tar.gz'
when '14'
'https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz'
when '15'
'https://download.java.net/java/GA/jdk15/779bf45e88a44cbd9ea6621d33e33db1/36/GPL/openjdk-15_linux-x64_bin.tar.gz'
when '16'
'https://download.java.net/java/GA/jdk16/7863447f0ab643c585b9bdebf67c69db/36/GPL/openjdk-16_linux-x64_bin.tar.gz'
when '17'
'https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz'
when '18'
'https://download.java.net/java/GA/jdk18.0.1/3f48cabb83014f9fab465e280ccf630b/10/GPL/openjdk-18.0.1_linux-x64_bin.tar.gz'
else
Chef::Log.fatal('Version specified does not have a URL value set')
raise 'Version supplied does not have a download URL set'
end
end
end

Expand Down Expand Up @@ -130,10 +117,6 @@ def default_openjdk_checksum(version)

def default_openjdk_bin_cmds(version)
case version
when '7'
%w(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)
when '8'
%w(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)
when '9'
%w(appletviewer idlj jaotc jar jarsigner java javac javadoc javah javap jcmd jconsole jdb jdeprscan jdeps jhsdb jimage jinfo jjs jlink jmap jmod jps jrunscript jshell jstack jstat jstatd keytool orbd pack200 policytool rmic rmid rmiregistry schemagen serialver servertool tnameserv unpack200 wsgen wsimport xjc)
when '10'
Expand Down
4 changes: 2 additions & 2 deletions resources/certificate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
action :install do
require 'openssl'

keystore_argument = keystore_argument(new_resource.java_version, new_resource.cacerts, new_resource.keystore_path)
keystore_argument = keystore_argument(new_resource.cacerts, new_resource.keystore_path)

certdata = new_resource.cert_data || fetch_certdata

Expand Down Expand Up @@ -107,7 +107,7 @@
end

action :remove do
keystore_argument = keystore_argument(new_resource.java_version, new_resource.cacerts, new_resource.keystore_path)
keystore_argument = keystore_argument(new_resource.cacerts, new_resource.keystore_path)

cmd = Mixlib::ShellOut.new("#{new_resource.java_home}/bin/keytool -list #{keystore_argument} -storepass #{new_resource.keystore_passwd} -v | grep \"#{new_resource.cert_alias}\"")
cmd.run_command
Expand Down
Loading
Loading