From 00570a6f0c07020186fae2aeedd2c49eb82d1e13 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Fri, 29 Sep 2023 15:47:00 +0100 Subject: [PATCH] AdoptOpenJDK --> Termurin/Semeru # Description Remove AdoptOpenJDK and replace with Adoptium Termurin & IBM Semeru ## Issues Resolved #674 ## Check List - [ ] A summary of changes made is included in the CHANGELOG under `## Unreleased` - [ ] New functionality includes testing. - [ ] New functionality has been documented in the README if applicable. --- CHANGELOG.md | 275 +++++++++--------- kitchen.yml | 77 ++--- libraries/adopt_openjdk_helpers.rb | 102 ------- libraries/openjdk_helpers.rb | 57 +++- resources/adoptopenjdk_linux_install.rb | 147 +++------- resources/openjdk_source_install.rb | 12 +- spec/libraries/adopt_openjdk_helpers_spec.rb | 159 ---------- .../adopt_openjdk_macos_helpers_spec.rb | 47 --- spec/libraries/openjdk_helpers_spec.rb | 2 +- spec/libraries/semeru_helpers_spec.rb | 73 +++++ spec/spec_helper.rb | 1 - .../cookbooks/test/recipes/adoptopenjdk.rb | 14 - .../cookbooks/test/recipes/openjdk.rb | 7 +- 13 files changed, 373 insertions(+), 600 deletions(-) delete mode 100644 libraries/adopt_openjdk_helpers.rb delete mode 100644 spec/libraries/adopt_openjdk_helpers_spec.rb delete mode 100644 spec/libraries/adopt_openjdk_macos_helpers_spec.rb create mode 100644 spec/libraries/semeru_helpers_spec.rb delete mode 100644 test/fixtures/cookbooks/test/recipes/adoptopenjdk.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index a8df71e4..baad3e85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,18 +18,22 @@ This file is used to list changes made in each version of the Java cookbook. ## 11.1.11 - *2023-04-17* +Standardise files with files in sous-chefs/repo-management + ## 11.1.10 - *2023-04-07* Standardise files with files in sous-chefs/repo-management ## 11.1.9 - *2023-04-01* -## 11.1.8 - *2023-04-01* +Standardise files with files in sous-chefs/repo-management -## 11.1.7 - *2023-04-01* +## 11.1.8 - *2023-04-01* Standardise files with files in sous-chefs/repo-management +## 11.1.7 - *2023-04-01* + Standardise files with files in sous-chefs/repo-management ## 11.1.6 - *2023-03-02* @@ -103,16 +107,19 @@ Standardise files with files in sous-chefs/repo-management - Remove testing for end of life OpenJDK suites - Primarily support OpenJDK LTS versions 11, 17 - Drop support for OpenJDK package installs for non-LTS versions - - These packages are still possible to install though they will now default to a source install + + These packages are still possible to install though they will now default to a source install - Direct Amazon users to Amazon Corretto instead of installing OpenJDK - Drop package install support for Java 8. Most supported operating systems no longer support OpenJDK 8 - - To install OpenJDK 8, a 'source' install from an internal mirror is now recommended + + To install OpenJDK 8, a 'source' install from an internal mirror is now recommended ## 10.0.1 - *2021-09-21* - Split out workflows to allow standardfiles to control markdown, yaml and delivery - Adds a "Final" workflow to set a known pass/failure hook - - This allows us to have Terraform set the Final workflow as a required check + + This allows us to have Terraform set the Final workflow as a required check ## 10.0.0 - *2021-09-02* @@ -489,9 +496,9 @@ Standardise files with files in sous-chefs/repo-management ## v1.29.0 - (11/14/2014) -- **[#216](https://github.com/agileorbit-cookbooks/java/pull/216)** - Ensure dirs, links, and jinfo files are owned correctly -- **[#217](https://github.com/agileorbit-cookbooks/java/pull/217)** - Update to Oracle JDK 8u25 -- **[#214](https://github.com/agileorbit-cookbooks/java/pull/214)** - Update to Oracle JDK 7u71-b14 +- Ensure dirs, links, and jinfo files are owned correctly +- Update to Oracle JDK 8u25 +- Update to Oracle JDK 7u71-b14 - Adding a connect_timeout option for downloading java. - Switched to chef-zero provisioner in test suites. - Adding ISSUES.md for guidance on creating new issues for the Java cookbook. @@ -509,15 +516,15 @@ Standardise files with files in sous-chefs/repo-management ## v1.26.0 - (8/16/2014) -- **[#201](https://github.com/agileorbit-cookbooks/java/pull/201)** - Allow pinning of package versions for openjdk -- **[#198](https://github.com/agileorbit-cookbooks/java/pull/198)** - Update Oracle JDK7 to version 7u67 -- **[#189](https://github.com/agileorbit-cookbooks/java/pull/184)** - Support specific version and name for Oracle RPM +- Allow pinning of package versions for openjdk +- Update Oracle JDK7 to version 7u67 +- Support specific version and name for Oracle RPM ## v1.25.0 - (8/1/2014) -- **[#189](https://github.com/agileorbit-cookbooks/java/pull/189)** - Resource ark -> attribute bin_cmds default value -- **[#168](https://github.com/agileorbit-cookbooks/java/pull/168)** - Add option to put JAVA_HOME in /etc/environment -- **[#172](https://github.com/agileorbit-cookbooks/java/pull/172)** - Allow ark to pull from http and files ending in .gz. +- Resource ark -> attribute bin_cmds default value +- Add option to put JAVA_HOME in /etc/environment +- Allow ark to pull from http and files ending in .gz. - Recommendations for inclusion in community cookbooks - Production Deployment with Oracle Java - Update testing instructions for chefdk @@ -530,15 +537,15 @@ Standardise files with files in sous-chefs/repo-management New Cookbook maintainer! **[Agile Orbit](http://agileorbit.com)** -- **[#192](https://github.com/agileorbit-cookbooks/java/pull/192)** - Bump JDK7 URLs to 7u65 -- **[#191](https://github.com/agileorbit-cookbooks/java/pull/192)** - Upgrade Oracle's Java 8 to u11 -- **[#188](https://github.com/agileorbit-cookbooks/java/pull/188)** - Allow for alternatives priority to be set from attribute. -- **[#176](https://github.com/agileorbit-cookbooks/java/pull/176)** - Change ownership of extracted files -- **[#169](https://github.com/agileorbit-cookbooks/java/pull/169)** - Add retries and retry_delay parameters to java_ark LWRP -- **[#167](https://github.com/agileorbit-cookbooks/java/pull/167)** - default: don't fail when using java 8 on windows -- **[#165](https://github.com/agileorbit-cookbooks/java/pull/165)** - Support for Server JRE -- **[#158](https://github.com/agileorbit-cookbooks/java/pull/158)** - Updated README for accepting oracle terms -- **[#157](https://github.com/agileorbit-cookbooks/java/pull/157)** -Remove VirtualBox specific box_urls +- Bump JDK7 URLs to 7u65 +- Upgrade Oracle's Java 8 to u11 +- Allow for alternatives priority to be set from attribute. +- Change ownership of extracted files +- Add retries and retry_delay parameters to java_ark LWRP +- default: don't fail when using java 8 on windows +- Support for Server JRE +- Updated README for accepting oracle terms +-Remove VirtualBox specific box_urls - List AgileOrbit as the maintainer (AgileOrbit took over from Socrata in July 2014) ## v1.23.0 - (7/25/2014) @@ -547,100 +554,100 @@ New Cookbook maintainer! **[Agile Orbit](http://agileorbit.com)** ## v1.22.0 -- **[#148](https://github.com/socrata-cookbooks/java/pull/148)** - Add support for Oracle JDK 1.8.0 -- **[#150](https://github.com/socrata-cookbooks/java/pull/150)** - Make use of Chef's cache directory instead of /tmp -- **[#151](https://github.com/socrata-cookbooks/java/pull/151)** - Update Test Kitchen suites -- **[#154](https://github.com/socrata-cookbooks/java/pull/154)** - Add safety check for JDK 8 on non-Oracle +- Add support for Oracle JDK 1.8.0 +- Make use of Chef's cache directory instead of /tmp +- Update Test Kitchen suites +- Add safety check for JDK 8 on non-Oracle ## v1.21.2 -- **[#146](https://github.com/socrata-cookbooks/java/pull/146)** - Update Oracle accept-license-terms cookie format +- Update Oracle accept-license-terms cookie format ## v1.21.0 -- **[#143](https://github.com/socrata-cookbooks/java/pull/143)** - Symlink /usr/lib/jvm/default-java for both OpenJDK and Oracle -- **[#144](https://github.com/socrata-cookbooks/java/pull/144)** - Remove /var/lib/alternatives/#{cmd} before calling alternatives (Hopefully fixes sporadic issues when setting alternatives) -- **[Make default_java_symlink conditional on set_default attribute](https://github.com/socrata-cookbooks/java/commit/e300e235a463382a5022e1dddaac674930b4d138)** +- Symlink /usr/lib/jvm/default-java for both OpenJDK and Oracle +- Remove /var/lib/alternatives/#{cmd} before calling alternatives (Hopefully fixes sporadic issues when setting alternatives) +- Make default_java_symlink conditional on set_default attribute ## v1.20.0 -- **[#137](https://github.com/socrata-cookbooks/java/pull/137)** - Create /usr/lib/jvm/default-java on Debian -- **[#138](https://github.com/socrata-cookbooks/java/pull/138)** - allow wrapping cookbook without providing templates -- **[#140](https://github.com/socrata-cookbooks/java/pull/140)** - Adds set_default attribute to toggle setting JDK as default -- **[#141](https://github.com/socrata-cookbooks/java/pull/141)** - set java_home correctly for oracle_rpm +- Create /usr/lib/jvm/default-java on Debian +- allow wrapping cookbook without providing templates +- Adds set_default attribute to toggle setting JDK as default +- set java_home correctly for oracle_rpm ## v1.19.2 -- **[#129](https://github.com/socrata-cookbooks/java/pull/129)** - Upgrade to ChefSpec 3 +- Upgrade to ChefSpec 3 - Rewrite unit tests for better coverage and to work with ChefSpec 3 (various commits) - List Socrata as the maintainer (Socrata took over from Opscode in December 2013) -- **[#133](https://github.com/socrata-cookbooks/java/pull/133)** - Allow jdk_version to be a string or number -- **[#131](https://github.com/socrata-cookbooks/java/pull/131)** - Fix JDK install on Windows -- **[Fix openjdk_packages on Arch Linux](https://github.com/socrata-cookbooks/java/commit/677bee7b9bf08988596d40ac65e75984a86bda99)** +- Allow jdk_version to be a string or number +- Fix JDK install on Windows +- Fix openjdk_packages on Arch Linux +- ## v1.19.0 Refactor the cookbook to better support wrapper cookbooks and other cookbook authoring patterns. -- **[#123](https://github.com/socrata-cookbooks/java/pull/123)** - Update documentation & add warning for issue 122 -- **[#124](https://github.com/socrata-cookbooks/java/pull/124)** - Refactor default recipe to better enable wrapper cookbooks -- **[#125](https://github.com/socrata-cookbooks/java/pull/125)** - Removes the attribute to purge deprecated packages -- **[#127](https://github.com/socrata-cookbooks/java/pull/127)** - Add safety check if attributes are unset -- **[Adds tests for directly using openjdk and oracle recipes](https://github.com/socrata-cookbooks/java/commit/794df596959d65a1a6d5f6c52688bffd8de6bff4)** -- **[Adds recipes to README](https://github.com/socrata-cookbooks/java/commit/76d52114bb9df084174d43fed143123b1cdbae16)** -- **[The Opscode CCLA is no longer required](https://github.com/socrata-cookbooks/java/commit/ce4ac25caa8383f185c25c4e32cafef8c0453376)** -- **[Adds tests for openjdk-7 and oracle-7](https://github.com/socrata-cookbooks/java/commit/9c38af241f68b3198cde4ad6fe2b4cb752062009)** -- **[#119](https://github.com/socrata-cookbooks/java/pull/119)** - Use java_home instead of java_location for update-alternatives -- **[Fix java_home for rhel and fedora](https://github.com/socrata-cookbooks/java/commit/71dadbd1bfe2eab50ff21cdab4ded97877911cc4)** +- Update documentation & add warning for issue 122 +- Refactor default recipe to better enable wrapper cookbooks +- Removes the attribute to purge deprecated packages +- Add safety check if attributes are unset +- Adds tests for directly using openjdk and oracle recipes +- Adds recipes to README +- The Opscode CCLA is no longer required +- Adds tests for openjdk-7 and oracle-7 +- Use java_home instead of java_location for update-alternatives +- Fix java_home for rhel and fedora ## v1.18.0 -- **[#118](https://github.com/socrata-cookbooks/java/pull/118)** - Upgrade to 7u51 -- **[#117](https://github.com/socrata-cookbooks/java/pull/117)** - Suggest windows and aws +- Upgrade to 7u51 +- Suggest windows and aws ## v1.17.6 -- Revert **[COOK-4165](https://tickets.opscode.com/browse/COOK-4165)** - The headers option was only added to remote_file in Chef 11.6.0, meaning this change breaks older clients. +- Revert **[COOK-4165]** - The headers option was only added to remote_file in Chef 11.6.0, meaning this change breaks older clients. ## v1.17.4 -- **[#111](https://github.com/socrata-cookbooks/java/pull/111)** - Fix alternatives for centos +- Fix alternatives for centos -- **[COOK-4165](https://tickets.opscode.com/browse/COOK-4165)** - Replace curl with remote_file with cookie header -- **[#110](https://github.com/socrata-cookbooks/java/pull/110)** - Update openjdk to use the alternatives resource +- Replace curl with remote_file with cookie header +- Update openjdk to use the alternatives resource ## v1.17.2 -- **[COOK-4136](https://tickets.opscode.com/browse/COOK-4136)** - Add md5 parameter to java_ark resource +- Add md5 parameter to java_ark resource ## v1.17.0 -- **[COOK-4114](https://tickets.opscode.com/browse/COOK-4114)** - Test Kitchen no longer works after merging Pull Request #95 for openjdk tests on Debian/Ubuntu -- **[COOK-4124](https://tickets.opscode.com/browse/COOK-4124)** - update-alternatives fails to run -- **[#81](https://github.com/socrata/java/pull/81)** - Ensure local directory hierarchy -- **[#97](https://github.com/socrata/java/pull/97)** - Expose LWRP state attributes -- **[#99](https://github.com/socrata/java/pull/99)** - support for MD5 checksum -- **[#106](https://github.com/socrata/java/pull/106)** - Fixed windows case to prevent bad java_home variable setting -- **[Update checksums to the officially-published ones from Oracle](https://github.com/socrata/java/commit/b9e1df24caeb6e22346d2d415b3b4384f15d4ffd)** -- **[Further test kitchen fixes to use the default recipe](https://github.com/socrata/java/commit/01c0b432705d9cfa6d2dfeaa380983e3f604069f)** +- Test Kitchen no longer works after merging Pull Request #95 for openjdk tests on Debian/Ubuntu +- update-alternatives fails to run +- Ensure local directory hierarchy +- Expose LWRP state attributes support for MD5 checksum +- Fixed windows case to prevent bad java_home variable setting +- Update checksums to the officially-published ones +- Further test kitchen fixes ## v1.16.4 -- **[#103](https://github.com/socrata/java/pull/103)** - set alternatives when using ibm_tar recipe -- **[#104](https://github.com/socrata/java/pull/104)** - Specify windows attributes in attribute files +- set alternatives when using ibm_tar recipe +- Specify windows attributes in attribute files ## v1.16.2 -- **[COOK-3488](https://tickets.opscode.com/browse/COOK-3488)** - set alternatives for ibm jdk -- **[COOK-3764](https://tickets.opscode.com/browse/COOK-3764)** - IBM Java installer needs 'rpm' package on Ubuntu +- set alternatives for ibm jdk +- IBM Java installer needs 'rpm' package on Ubuntu -- **[COOK-3857](https://tickets.opscode.com/browse/COOK-3857)** - do not unescape the java windows url before parsing it -- **[#95](https://github.com/socrata/java/pull/95)** - fixes update-alternatives for openjdk installs -- **[#100](https://github.com/socrata/java/pull/100)** - Use escaped quotes for Windows INSTALLDIR +- do not unescape the java windows url before parsing it +- fixes update-alternatives for openjdk installs +- Use escaped quotes for Windows INSTALLDIR ## v1.16.0 -- **[COOK-3823](https://tickets.opscode.com/browse/COOK-3823)** - Upgrade to JDK 7u45-b18 +- Upgrade to JDK 7u45-b18 ## v1.15.4 @@ -658,44 +665,42 @@ Refactor the cookbook to better support wrapper cookbooks and other cookbook aut ### FIX -- [COOK-3908] - Fixing JAVA_HOME on Ubuntu 10.04 +- Fixing JAVA_HOME on Ubuntu 10.04 ## v1.14.0 -- **[COOK-3704](https://tickets.opscode.com/browse/COOK-3704)** - Fix alternatives when the package is already installed -- **[COOK-3668](https://tickets.opscode.com/browse/COOK-3668)** - Fix a condition that would result in an error executing action `run` on resource 'bash[update-java-alternatives]' -- **[COOK-3569](https://tickets.opscode.com/browse/COOK-3569)** - Fix bad checksum length -- **[COOK-3541](https://tickets.opscode.com/browse/COOK-3541)** - Fix an issue where Java cookbook installs both JDK 6 and JDK 7 when JDK 7 is specified -- **[COOK-3518](https://tickets.opscode.com/browse/COOK-3518)** - Allow Windoes recipe to download from signed S3 url -- **[COOK-2996](https://tickets.opscode.com/browse/COOK-2996)** - Fix a failure on Centos 6.4 and Oracle JDK 7 - -- **[COOK-2793](https://tickets.opscode.com/browse/COOK-2793)** - Improve Windows support +- Fix alternatives when the package is already installed +- Fix a condition that would result in an error executing action `run` on resource 'bash[update-java-alternatives]' +- Fix bad checksum length +- Fix an issue where Java cookbook installs both JDK 6 and JDK 7 when JDK 7 is specified +- Allow Windoes recipe to download from signed S3 url +- Fix a failure on Centos 6.4 and Oracle JDK 7 +- Improve Windows support ## v1.13.0 -- **[COOK-3295](https://tickets.opscode.com/browse/COOK-3295)** - Add default `platform_family` option in Java helper -- **[COOK-3277](https://tickets.opscode.com/browse/COOK-3277)** - Fix support for Fedora - -- **[COOK-3278](https://tickets.opscode.com/browse/COOK-3278)** - Upgrade to Oracle Java 7u25 -- **[COOK-3029](https://tickets.opscode.com/browse/COOK-3029)** - Add Oracle RPM support -- **[COOK-2931](https://tickets.opscode.com/browse/COOK-2931)** - Add support for the platform `xenserver` -- **[COOK-2154](https://tickets.opscode.com/browse/COOK-2154)** - Add SmartOS support +- Add default `platform_family` option in Java helper +- Fix support for Fedora +- Upgrade to Oracle Java 7u25 +- Add Oracle RPM support +- Add support for the platform `xenserver` +- Add SmartOS support ## v1.12.0 -- [COOK-2154]: Add SmartOS support to java::openjdk recipe -- [COOK-3278]: upgrade to Oracle Java 7u25 -- [COOK-2931]: Adding support for the platform 'xenserver' (for installations of java in DOM0) -- [COOK-3277]: java cookbook fails on Fedora +- Add SmartOS support to java::openjdk recipe +- upgrade to Oracle Java 7u25 +- Adding support for the platform 'xenserver' (for installations of java in DOM0) +- java cookbook fails on Fedora ## v1.11.6 -- [COOK-2847]: Java cookbook does not have opensuse support -- [COOK-3142]: Syntax Errors spec/default_spec.rb:4-8 +- Java cookbook does not have opensuse support +- Syntax Errors spec/default_spec.rb:4-8 ## v1.11.4 -- [COOK-2989]: `bash[update-java-alternatives]` resource uses wrong attribute +- `bash[update-java-alternatives]` resource uses wrong attribute ## v1.11.2 @@ -705,96 +710,96 @@ Refactor the cookbook to better support wrapper cookbooks and other cookbook aut This version brings a wealth of tests and (backwards-compatible) refactoring, plus some new features (updated Java, IBM recipe). -- [COOK-2897]: Add ibm recipe to java cookbook -- [COOK-2903]: move java_home resources to their own recipe -- [COOK-2904]: refactor ruby_block "update-java-alternatives" -- [COOK-2905]: use platform_family in java cookbook -- [COOK-2920]: add chefspec to java cookbook -- [COOK-2902]: Refactor java cookbook -- [COOK-2900]: update JDK to JDK 7u21, 6u45 +- Add ibm recipe to java cookbook +- move java_home resources to their own recipe +- refactor ruby_block "update-java-alternatives" +- use platform_family in java cookbook +- add chefspec to java cookbook +- Refactor java cookbook +- update JDK to JDK 7u21, 6u45 ## v1.10.2 -- [COOK-2415] - Fixed deprecation warnings in ark provider and openjdk recipe by using Chef::Mixin::ShellOut instead of Chef::ShellOut +- [2415] - Fixed deprecation warnings in ark provider and openjdk recipe by using Chef::Mixin::ShellOut instead of Chef::ShellOut ## v1.10.0 -- [COOK-2400] - Allow java ark :url to be https -- [COOK-2436] - Upgrade needed for oracle jdk in java cookbook +- Allow java ark :url to be https +- Upgrade needed for oracle jdk in java cookbook ## v1.9.6 -- [COOK-2412] - add support for Oracle Linux +- add support for Oracle Linux ## v1.9.4 -- [COOK-2083] - Run set-env-java-home in Java cookbook only if necessary -- [COOK-2332] - ark provider does not allow for *.tgz tarballs to be used -- [COOK-2345] - Java cookbook fails on CentOS6 (update-java-alternatives) +- Run set-env-java-home in Java cookbook only if necessary +- ark provider does not allow for *.tgz tarballs to be used +- Java cookbook fails on CentOS6 (update-java-alternatives) ## v1.9.2 -- [COOK-2306] - FoodCritic fixes for java cookbook +- FoodCritic fixes for java cookbook ## v1.9.0 -- [COOK-2236] - Update the Oracle Java version in the Java cookbook to release 1.7u11 +- Update the Oracle Java version in the Java cookbook to release 1.7u11 ## v1.8.2 -- [COOK-2205] - Fix for missing /usr/lib/jvm/default-java on Debian +- Fix for missing /usr/lib/jvm/default-java on Debian ## v1.8.0 -- [COOK-2095] - Add windows support +- Add windows support ## v1.7.0 -- [COOK-2001] - improvements for Oracle update-alternatives - - When installing an Oracle JDK it is now registered with a higher priority than OpenJDK. (Related to COOK-1131.) - - When running both the oracle and oracle_i386 recipes, alternatives are now created for both JDKs. - - Alternatives are now created for all binaries listed in version specific attributes. (Related to COOK-1563 and COOK-1635.) - - When installing Oracke JDKs on Ubuntu, create .jinfo files for use with update-java-alternatives. Commands to set/install alternatives now only run if needed. +- improvements for Oracle update-alternatives +- When installing an Oracle JDK it is now registered with a higher priority than OpenJDK. (Related to COOK-1131.) +- When running both the oracle and oracle_i386 recipes, alternatives are now created for both JDKs. +- Alternatives are now created for all binaries listed in version specific attributes. (Related to COOK-1563 and COOK-1635.) +- When installing Oracke JDKs on Ubuntu, create .jinfo files for use with update-java-alternatives. Commands to set/install alternatives now only run if needed. ## v1.6.4 -- [COOK-1930] - fixed typo in attribute for java 5 on i586 +- fixed typo in attribute for java 5 on i586 ## v1.6.2 - whyrun support in `java_ark` LWRP - CHEF-1804 compatibility -- [COOK-1786] - install Java 6u37 and Java 7u9 -- [COOK-1819] - incorrect warning text about `node['java']['oracle']['accept_oracle_download_terms']` +- install Java 6u37 and Java 7u9 +- incorrect warning text about `node['java']['oracle']['accept_oracle_download_terms']` ## v1.6.0 -- [COOK-1218] - Install Oracle JDK from Oracle download directly -- [COOK-1631] - set JAVA_HOME in openjdk recipe -- [COOK-1655] - Install correct architecture on Amazon Linux +- Install Oracle JDK from Oracle download directly +- set JAVA_HOME in openjdk recipe +- Install correct architecture on Amazon Linux ## v1.5.4 -- [COOK-885] update alternatives called on wrong file -- [COOK-1607] use shellout instead of execute resource to update alternatives +update alternatives called on wrong file +use shellout instead of execute resource to update alternatives ## v1.5.2 -- [COOK-1200] - remove sun-java6-jre on Ubuntu before installing Oracle's Java -- [COOK-1260] - fails on Ubuntu 12.04 64bit with openjdk7 -- [COOK-1265] - Oracle Java should symlink the jar command +- remove sun-java6-jre on Ubuntu before installing Oracle's Java +- fails on Ubuntu 12.04 64bit with openjdk7 +- Oracle Java should symlink the jar command ## v1.5.0 -- [COOK-1146] - Oracle now prevents download of JDK via non-browser -- [COOK-1114] - fix File.exists? +- Oracle now prevents download of JDK via non-browser +- fix File.exists? ## v1.4.2 -- [COOK-1051] - fix attributes typo and platform case switch consistency +- fix attributes typo and platform case switch consistency ## v1.4.0 -- [COOK-858] - numerous updates: handle jdk6 and 7, switch from sun to oracle, make openjdk default, add `java_ark` LWRP. -- [COOK-942] - FreeBSD support -- [COOK-520] - ArchLinux support +- numerous updates: handle jdk6 and 7, switch from sun to oracle, make openjdk default, add `java_ark` LWRP. +- [42] - FreeBSD support +- ArchLinux support diff --git a/kitchen.yml b/kitchen.yml index 7b14a831..30ee8389 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -20,7 +20,6 @@ platforms: - name: freebsd-11 - name: freebsd-12 - name: fedora-latest - # - name: opensuse-leap-15 - name: ubuntu-18.04 - name: ubuntu-20.04 @@ -29,26 +28,26 @@ suites: - name: openjdk-11 run_list: - recipe[test::openjdk] - attributes: {version: "11"} + attributes: { version: "11" } verifier: inspec_tests: [test/integration/openjdk] - inputs: {java_version: "11"} + inputs: { java_version: "11" } - name: openjdk-16 run_list: - recipe[test::openjdk] - attributes: {version: "16"} + attributes: { version: "16" } verifier: inspec_tests: [test/integration/openjdk] - inputs: {java_version: "16"} + inputs: { java_version: "16" } - name: openjdk-17 run_list: - recipe[test::openjdk] - attributes: {version: "17"} + attributes: { version: "17" } verifier: inspec_tests: [test/integration/openjdk] - inputs: {java_version: "17"} + inputs: { java_version: "17" } # AdoptOpenJDK # Version 8 @@ -60,7 +59,8 @@ suites: variant: hotspot verifier: inspec_tests: [test/integration/adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-8-hotspot.yml] + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-8-hotspot.yml - name: adoptopenjdk-8-openj9 run_list: @@ -70,7 +70,8 @@ suites: variant: openj9 verifier: inspec_tests: [test/integration/adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-8-openj9.yml] + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-8-openj9.yml - name: adoptopenjdk-8-openj9-large-heap run_list: @@ -80,7 +81,8 @@ suites: variant: openj9-large-heap verifier: inspec_tests: [test/integration/adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-8-openj9-large-heap.yml] + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-8-openj9-large-heap.yml # Version 11 - name: adoptopenjdk-11-hotspot @@ -91,7 +93,8 @@ suites: variant: hotspot verifier: inspec_tests: [test/integration/adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-11-hotspot.yml] + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-11-hotspot.yml - name: adoptopenjdk-11-openj9 run_list: - recipe[test::adoptopenjdk] @@ -100,7 +103,8 @@ suites: variant: openj9 verifier: inspec_tests: [test/integration/adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-11-openj9.yml] + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-11-openj9.yml - name: adoptopenjdk-11-openj9-large-heap run_list: - recipe[test::adoptopenjdk] @@ -109,36 +113,41 @@ suites: variant: openj9-large-heap verifier: inspec_tests: [test/integration/adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-11-openj9-large-heap.yml] + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-11-openj9-large-heap.yml - # Version 14 - - name: adoptopenjdk-14-openj9-large-heap + # Version 17 + - name: adoptopenjdk-17-openj9-large-heap run_list: - recipe[test::adoptopenjdk] attributes: - version: 14 + version: 17 variant: openj9-large-heap verifier: inspec_tests: [test/integration/adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-14-openj9-large-heap.yml] - - name: adoptopenjdk-14-openj9 + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-17-openj9-large-heap.yml + + - name: adoptopenjdk-17-openj9 run_list: - recipe[test::adoptopenjdk] attributes: - version: 14 + version: 17 variant: openj9 verifier: inspec_tests: [test/integration/adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-14-openj9.yml] - - name: adoptopenjdk-14-hotspot + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-17-openj9.yml + - name: adoptopenjdk-17-hotspot run_list: - recipe[test::adoptopenjdk] attributes: - version: 14 + version: 17 variant: hotspot verifier: inspec_tests: [test/integration/adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-14-hotspot.yml] + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-14-hotspot.yml # 11 Removal - name: adoptopenjdk-removal-11-openj9 @@ -149,37 +158,38 @@ suites: variant: openj9 verifier: inspec_tests: [test/integration/remove-adoptopenjdk] - input_files: [test/integration/adoptopenjdk/inputs/adoptopenjdk-11-openj9.yml] + input_files: + - test/integration/adoptopenjdk/inputs/adoptopenjdk-11-openj9.yml # Corretto - name: corretto-8 run_list: - recipe[test::corretto] - attributes: {version: "8"} + attributes: { version: "8" } verifier: inspec_tests: [test/integration/corretto] - inputs: {java_version: "8"} + inputs: { java_version: "8" } - name: corretto-11 run_list: - recipe[test::corretto] - attributes: {version: "11"} + attributes: { version: "11" } verifier: inspec_tests: [test/integration/corretto] - inputs: {java_version: "11"} + inputs: { java_version: "11" } - name: corretto-17 run_list: - recipe[test::corretto] - attributes: {version: "17"} + attributes: { version: "17" } verifier: inspec_tests: [test/integration/corretto] - inputs: {java_version: "17"} + inputs: { java_version: "17" } - name: corretto-18 run_list: - recipe[test::corretto] - attributes: {version: "18"} + attributes: { version: "18" } verifier: inspec_tests: [test/integration/corretto] - inputs: {java_version: "18"} + inputs: { java_version: "18" } # Custom URL tests - name: custom-package-8 @@ -225,4 +235,5 @@ suites: checksum: 6524d85d2ce334c955a4347015567326067ef15fe5f6a805714b25cace256f40 verifier: inspec_tests: [test/integration/custom-package] - input_files: [test/integration/custom-package/inputs/openj9-large-heap-11.yml] + input_files: + [test/integration/custom-package/inputs/openj9-large-heap-11.yml] diff --git a/libraries/adopt_openjdk_helpers.rb b/libraries/adopt_openjdk_helpers.rb deleted file mode 100644 index 3a47eed1..00000000 --- a/libraries/adopt_openjdk_helpers.rb +++ /dev/null @@ -1,102 +0,0 @@ -module Java - module Cookbook - module AdoptOpenJdkHelpers - def sub_dir(url) - uri = URI.parse(url) - # get file basename without extension - basename = uri.path.split('/')[-1].gsub('.tar.gz', '') - - if basename.include?('linuxXL') # compensate for longer name - # Get version number from start of filename - if (basename.scan /\d+/)[0] == '8' - ver = basename.split('_')[5] - "jdk#{ver[0..4]}-#{ver[-3..-1]}" - else - ver = basename.split('_') - "jdk-#{ver[5]}+#{ver[6]}" - end - elsif (basename.scan /\d+/)[0] == '8' - ver = basename.split('_')[4] - "jdk#{ver[0..4]}-#{ver[-3..-1]}" - else - ver = basename.split('_') - "jdk-#{ver[4]}+#{ver[5]}" - end - end - - def default_adopt_openjdk_url(version) - case version - when '8' - { 'hotspot' => 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u242b08.tar.gz', - 'openj9' => 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08_openj9-0.18.1/OpenJDK8U-jdk_x64_linux_openj9_8u242b08_openj9-0.18.1.tar.gz', - 'openj9-large-heap' => 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08_openj9-0.18.1/OpenJDK8U-jdk_x64_linux_openj9_linuxXL_8u242b08_openj9-0.18.1.tar.gz', - } - when '11' - { 'hotspot' => 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.6_10.tar.gz', - 'openj9' => 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10_openj9-0.18.1/OpenJDK11U-jdk_x64_linux_openj9_11.0.6_10_openj9-0.18.1.tar.gz', - 'openj9-large-heap' => 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10_openj9-0.18.1/OpenJDK11U-jdk_x64_linux_openj9_linuxXL_11.0.6_10_openj9-0.18.1.tar.gz', - } - when '13' - { 'hotspot' => 'https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.2%2B8/OpenJDK13U-jdk_x64_linux_hotspot_13.0.2_8.tar.gz', - 'openj9' => 'https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.2%2B8_openj9-0.18.0/OpenJDK13U-jdk_x64_linux_openj9_13.0.2_8_openj9-0.18.0.tar.gz', - 'openj9-large-heap' => 'https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.2%2B8_openj9-0.18.0/OpenJDK13U-jdk_x64_linux_openj9_linuxXL_13.0.2_8_openj9-0.18.0.tar.gz', - } - when '14' - { - 'hotspot' => 'https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14%2B36/OpenJDK14U-jdk_x64_linux_hotspot_14_36.tar.gz', - 'openj9' => 'https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14%2B36.1_openj9-0.19.0/OpenJDK14U-jdk_x64_linux_openj9_14_36_openj9-0.19.0.tar.gz', - 'openj9-large-heap' => 'https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14%2B36.1_openj9-0.19.0/OpenJDK14U-jdk_x64_linux_openj9_linuxXL_14_36_openj9-0.19.0.tar.gz', - } - else - Chef::Log.fatal('Version specified does not have a URL value set') - end - end - - def default_adopt_openjdk_checksum(version) - case version - when '8' - { 'hotspot' => 'f39b523c724d0e0047d238eb2bb17a9565a60574cf651206c867ee5fc000ab43', - 'openj9' => 'ca785af638b24f9d4df896f5a9f557cc9f1e5fa5e2b1174d6b906e3fd5474c2e', - 'openj9-large-heap' => '6ee788d57f15cc8c326bb3468390d5e353cc1aac1925efa3f2992a93e2520d97', - } - when '11' - { 'hotspot' => '330d19a2eaa07ed02757d7a785a77bab49f5ee710ea03b4ee2fa220ddd0feffc', - 'openj9' => '1530172ee98edd129954fcdca1bf725f7b30c8bfc3cdc381c88de96b7d19e690', - 'openj9-large-heap' => '6524d85d2ce334c955a4347015567326067ef15fe5f6a805714b25cace256f40', - } - when '13' - { 'hotspot' => '9ccc063569f19899fd08e41466f8c4cd4e05058abdb5178fa374cb365dcf5998', - 'openj9' => 'aeecf6d30d0c847db81d07793cf97e5dc44890c29366d7d9f8f9f397f6c52590', - 'openj9-large-heap' => '16751b3951b808c4cb0b77d4df1a16f9bfff5b2dbc59919773e6386114e6d8d5', - } - when '14' - { 'hotspot' => '6c06853332585ab58834d9e8a02774b388e6e062ef6c4084b4f058c67f2e81b5', - 'openj9' => '106b72d565be98834ead5fea9555bd646d488a86fc4ae4dd294a38e97bf77509', - 'openj9-large-heap' => '4ee13d0689ab7a38d6abb7dee974c3b189e36f1911a0cb61c882a38e61cc8b98', - } - else - Chef::Log.fatal('Version specified does not have a checksum value set') - end - end - - def default_adopt_openjdk_bin_cmds(version) - case version - when '8' - { 'hotspot' => ['appletviewer', 'clhsdb', 'extcheck', 'hsdb', 'idlj', 'jar', 'jarsigner', 'java', 'java-rmi.cgi', 'javac', 'javadoc', 'javah', 'javap', 'jcmd', 'jconsole', 'jdb', 'jdeps', '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'], - 'openj9' => ['appletviewer', 'extcheck', 'idlj', 'jar', 'jarsigner', 'java', 'java-rmi.cgi', 'javac', 'javadoc', 'javah', 'javap', 'jcmd', 'jconsole', 'jdb', 'jdeps', 'jdmpview', 'jitserver', 'jjs', 'jmap', 'jps', 'jrunscript', 'jsadebugd', 'jstack', 'jstat', 'keytool', 'native2ascii', 'orbd', 'pack200', 'policytool', 'rmic', 'rmid', 'rmiregistry', 'schemagen', 'serialver', 'servertool', 'tnameserv', 'traceformat', 'unpack200', 'wsgen', 'wsimport', 'xjc'], - 'openj9-large-heap' => ['appletviewer', 'extcheck', 'idlj', 'jar', 'jarsigner', 'java', 'java-rmi.cgi', 'javac', 'javadoc', 'javah', 'javap', 'jcmd', 'jconsole', 'jdb', 'jdeps', 'jdmpview', 'jitserver', 'jjs', 'jmap', 'jps', 'jrunscript', 'jsadebugd', 'jstack', 'jstat', 'keytool', 'native2ascii', 'orbd', 'pack200', 'policytool', 'rmic', 'rmid', 'rmiregistry', 'schemagen', 'serialver', 'servertool', 'tnameserv', 'traceformat', 'unpack200', 'wsgen', 'wsimport', 'xjc'] } - when '11' - { 'hotspot' => %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), - 'openj9' => %w(jar jarsigner java javac javadoc javap jcmd jconsole jdb jdeprscan jdeps jdmpview jextract jimage jitserver jjs jlink jmap jmod jps jrunscript jshell jstack jstat keytool pack200 rmic rmid rmiregistry serialver traceformat unpack200), - 'openj9-large-heap' => %w(jar jarsigner java javac javadoc javap jcmd jconsole jdb jdeprscan jdeps jdmpview jextract jimage jitserver jjs jlink jmap jmod jps jrunscript jshell jstack jstat keytool pack200 rmic rmid rmiregistry serialver traceformat unpack200) } - when '13', '14' - { 'hotspot' => %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), - 'openj9' => %w(jar jarsigner java javac javadoc javap jcmd jconsole jdb jdeprscan jdeps jdmpview jextract jimage jjs jlink jmap jmod jps jrunscript jshell jstack jstat keytool pack200 rmic rmid rmiregistry serialver traceformat unpack200), - 'openj9-large-heap' => %w(jar jarsigner java javac javadoc javap jcmd jconsole jdb jdeprscan jdeps jdmpview jextract jimage jjs jlink jmap jmod jps jrunscript jshell jstack jstat keytool pack200 rmic rmid rmiregistry serialver traceformat unpack200) } - else - Chef::Log.fatal('Version specified does not have a default set of bin_cmds') - end - end - end - end -end diff --git a/libraries/openjdk_helpers.rb b/libraries/openjdk_helpers.rb index 715c5ea7..0ef5a4b3 100644 --- a/libraries/openjdk_helpers.rb +++ b/libraries/openjdk_helpers.rb @@ -5,6 +5,13 @@ def lts %w(11 17) end + # This method relies on the GitHub release artefact URL + # e.g. https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.3%2B7/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.3_7.tar.gz + def sub_dir(url) + URI.parse(url) + url.split('/')[7].split('_')[0].gsub('%2', '-').downcase + end + def default_openjdk_install_method(version) case node['platform_family'] when 'amazon' @@ -27,14 +34,33 @@ def default_openjdk_install_method(version) end end - def default_openjdk_url(version) + 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' + 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' - 'https://download.java.net/java/ga/jdk11/openjdk-11_linux-x64_bin.tar.gz' + case variant + when 'semeru' + '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' @@ -44,9 +70,32 @@ def default_openjdk_url(version) 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' + case variant + when 'semeru' + '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' - 'https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz' + case variant + when 'semeru' + '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' + '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' + end else Chef::Log.fatal('Version specified does not have a URL value set') raise 'Version supplied does not have a download URL set' diff --git a/resources/adoptopenjdk_linux_install.rb b/resources/adoptopenjdk_linux_install.rb index 126652b9..70026542 100644 --- a/resources/adoptopenjdk_linux_install.rb +++ b/resources/adoptopenjdk_linux_install.rb @@ -1,102 +1,45 @@ -provides :adoptopenjdk_linux_install -unified_mode true -include Java::Cookbook::AdoptOpenJdkHelpers - -property :variant, String, - equal_to: %w(hotspot openj9 openj9-large-heap), - default: 'openj9', - description: 'Install flavour' - -property :url, String, - default: lazy { default_adopt_openjdk_url(version)[variant] }, - description: 'The URL to download from' - -property :checksum, String, - regex: /^[0-9a-f]{32}$|^[a-zA-Z0-9]{40,64}$/, - default: lazy { default_adopt_openjdk_checksum(version)[variant] }, - description: 'The checksum for the downloaded file' - -property :java_home, String, - default: lazy { "/usr/lib/jvm/java-#{version}-adoptopenjdk-#{variant}/#{sub_dir(url)}" }, - description: 'Set to override the java_home' - -property :bin_cmds, Array, - default: lazy { default_adopt_openjdk_bin_cmds(version)[variant] }, - description: 'A list of bin_cmds based on the version and variant' - -use 'partial/_common' -use 'partial/_linux' -use 'partial/_java_home' - -action :install do - extract_dir = new_resource.java_home.split('/')[0..-2].join('/') - parent_dir = new_resource.java_home.split('/')[0..-3].join('/') - tarball_name = new_resource.url.split('/').last - - directory parent_dir do - owner new_resource.java_home_owner - group new_resource.java_home_group - mode new_resource.java_home_mode - recursive true - end - - remote_file "#{Chef::Config[:file_cache_path]}/#{tarball_name}" do - source new_resource.url - checksum new_resource.checksum - retries new_resource.retries - retry_delay new_resource.retry_delay - mode '644' - end - - archive_file "#{Chef::Config[:file_cache_path]}/#{tarball_name}" do - destination extract_dir - end - - template "/usr/lib/jvm/.java-#{new_resource.version}-adoptopenjdk-#{new_resource.variant}.jinfo" do - cookbook 'java' - source 'jinfo.erb' - owner new_resource.java_home_owner - group new_resource.java_home_group - variables( - priority: new_resource.alternatives_priority, - bin_cmds: new_resource.bin_cmds, - name: extract_dir.split('/').last, - app_dir: new_resource.java_home - ) - only_if { platform_family?('debian') } - end - - java_alternatives 'set-java-alternatives' do - java_location new_resource.java_home - bin_cmds new_resource.bin_cmds - priority new_resource.alternatives_priority - default new_resource.default - reset_alternatives new_resource.reset_alternatives - action :set - end - - node.default['java']['java_home'] = new_resource.java_home - - append_if_no_line 'Java Home' do - path '/etc/profile.d/java.sh' - line "export JAVA_HOME=#{new_resource.java_home}" - end -end - -action :remove do - extract_dir = new_resource.java_home.split('/')[0..-2].join('/') - - java_alternatives 'unset-java-alternatives' do - java_location new_resource.java_home - bin_cmds new_resource.bin_cmds - only_if { ::File.exist?(extract_dir) } - action :unset - end - - directory "AdoptOpenJDK removal of #{extract_dir}" do - path extract_dir - recursive true - only_if { ::File.exist?(extract_dir) } - action :delete - end -end +# provides :adoptopenjdk_linux_install +# unified_mode true +# include Java::Cookbook::OpenJdkHelpers + +# property :variant, String, +# equal_to: %w(hotspot openj9 openj9-large-heap), +# default: 'openj9', +# description: 'Install flavour' + +# property :url, String, +# default: lazy { default_openjdk_url(version, variant) }, +# description: 'The URL to download from' + +# property :checksum, String, +# regex: /^[0-9a-f]{32}$|^[a-zA-Z0-9]{40,64}$/, +# default: lazy { default_openjdk_checksum(version, variant) }, +# description: 'The checksum for the downloaded file' + +# property :java_home, String, +# default: lazy { "/usr/lib/jvm/java-#{version}-adoptopenjdk-#{variant}/#{sub_dir(url)}" }, +# description: 'Set to override the java_home' + +# property :bin_cmds, Array, +# default: lazy { default_openjdk_bin_cmds(version, variant) }, +# description: 'A list of bin_cmds based on the version and variant' + +# use 'partial/_common' +# use 'partial/_linux' +# use 'partial/_java_home' + +# action :install do +# template "/usr/lib/jvm/.java-#{new_resource.version}-adoptopenjdk-#{new_resource.variant}.jinfo" do +# cookbook 'java' +# source 'jinfo.erb' +# owner new_resource.java_home_owner +# group new_resource.java_home_group +# variables( +# priority: new_resource.alternatives_priority, +# bin_cmds: new_resource.bin_cmds, +# name: extract_dir.split('/').last, +# app_dir: new_resource.java_home +# ) +# only_if { platform_family?('debian') } +# end +# end diff --git a/resources/openjdk_source_install.rb b/resources/openjdk_source_install.rb index f999712e..dc119967 100644 --- a/resources/openjdk_source_install.rb +++ b/resources/openjdk_source_install.rb @@ -6,8 +6,13 @@ name_property: true, description: 'Java version to install' +property :variant, String, + equal_to: %w(opendjdk semeru temurin), + default: 'openjdk', + description: 'Install flavour' + property :url, String, - default: lazy { default_openjdk_url(version) }, + default: lazy { default_openjdk_url(version, variant) }, description: 'The URL to download from' property :checksum, String, @@ -61,6 +66,11 @@ reset_alternatives new_resource.reset_alternatives action :set end + + append_if_no_line 'Java Home' do + path '/etc/profile.d/java.sh' + line "export JAVA_HOME=#{new_resource.java_home}" + end end action :remove do diff --git a/spec/libraries/adopt_openjdk_helpers_spec.rb b/spec/libraries/adopt_openjdk_helpers_spec.rb deleted file mode 100644 index e4a0e9b0..00000000 --- a/spec/libraries/adopt_openjdk_helpers_spec.rb +++ /dev/null @@ -1,159 +0,0 @@ -require 'spec_helper' - -RSpec.describe Java::Cookbook::AdoptOpenJdkHelpers do - class DummyClass < Chef::Node - include Java::Cookbook::AdoptOpenJdkHelpers - end - - subject { DummyClass.new } - - describe '#sub_dir' do - before do - allow(subject).to receive(:[]).with('url').and_return(url) - end - - context 'AdoptOpenJDK 8 Hotspot' do - let(:url) { 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u242b08.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk8u242-b08' - end - end - - context 'OpenJDK 8 OpenJ9' do - let(:url) { 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08_openj9-0.18.1/OpenJDK8U-jdk_x64_linux_openj9_8u242b08_openj9-0.18.1.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk8u242-b08' - end - end - - context 'OpenJKDK 8 LargeHeap' do - let(:url) { 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08_openj9-0.18.1/OpenJDK8U-jdk_x64_linux_openj9_linuxXL_8u242b08_openj9-0.18.1.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk8u242-b08' - end - end - - context 'AdoptOpenJDK 11 Hotspot' do - let(:url) { 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.6_10.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk-11.0.6+10' - end - end - - context 'AdoptOpenJDK 11 OpenJ9' do - let(:url) { 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10_openj9-0.18.1/OpenJDK11U-jdk_x64_linux_openj9_11.0.6_10_openj9-0.18.1.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk-11.0.6+10' - end - end - - context 'AdoptOpenJDK 11 LargeHeap' do - let(:url) { 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10_openj9-0.18.1/OpenJDK11U-jdk_x64_linux_openj9_linuxXL_11.0.6_10_openj9-0.18.1.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk-11.0.6+10' - end - end - - context 'AdoptOpenJDK 14 Hotspot' do - let(:url) { 'https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14%2B36/OpenJDK14U-jdk_x64_linux_hotspot_14_36.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk-14+36' - end - end - - context 'AdoptOpenJDK 14 LargeHeap' do - let(:url) { 'https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14%2B36.1_openj9-0.19.0/OpenJDK14U-jdk_x64_linux_openj9_linuxXL_14_36_openj9-0.19.0.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk-14+36' - end - end - - context 'Custom URL: AdoptOpenJDK 8 Hotspot' do - let(:url) { 'https://some.custom.url/path/to/OpenJDK8U-jdk_x64_linux_hotspot_8u242b08.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk8u242-b08' - end - end - - context 'Custom URL: OpenJDK 8 OpenJ9' do - let(:url) { 'https://some.custom.url/path/to/OpenJDK8U-jdk_x64_linux_openj9_8u242b08_openj9-0.18.1.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk8u242-b08' - end - end - - context 'Custom URL: OpenJKDK 8 LargeHeap' do - let(:url) { 'https://some.custom.url/path/to/OpenJDK8U-jdk_x64_linux_openj9_linuxXL_8u242b08_openj9-0.18.1.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk8u242-b08' - end - end - - context 'Custom URL: AdoptOpenJDK 11 Hotspot' do - let(:url) { 'https://some.custom.url/path/to/OpenJDK11U-jdk_x64_linux_hotspot_11.0.6_10.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk-11.0.6+10' - end - end - - context 'Custom URL: AdoptOpenJDK 11 OpenJ9' do - let(:url) { 'https://some.custom.url/path/to/OpenJDK11U-jdk_x64_linux_openj9_11.0.6_10_openj9-0.18.1.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk-11.0.6+10' - end - end - - context 'Custom URL: AdoptOpenJDK 11 LargeHeap' do - let(:url) { 'https://some.custom.url/path/to/OpenJDK11U-jdk_x64_linux_openj9_linuxXL_11.0.6_10_openj9-0.18.1.tar.gz' } - - it 'returns the correct folder name' do - expect(subject.sub_dir(url)).to eq 'jdk-11.0.6+10' - end - end - - context 'Malformed URL' do - let(:url) { 'a\bad/path/\to\/some.tar.gz' } - - it 'throws an error' do - expect { subject.sub_dir(url) }.to raise_error(URI::InvalidURIError) - end - end - end - - describe '#default_adopt_openjdk_url' do - before do - allow(subject).to receive(:[]).with('version').and_return(version) - end - - context 'AdoptOpenJDK 11 LargeHeap' do - let(:version) { '11' } - let(:variant) { 'openj9-large-heap' } - - it 'returns the correct URL' do - expect(subject.default_adopt_openjdk_url(version)[variant]).to eq 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10_openj9-0.18.1/OpenJDK11U-jdk_x64_linux_openj9_linuxXL_11.0.6_10_openj9-0.18.1.tar.gz' - end - end - - context 'AdoptOpenJDK 11 OpenJ9' do - let(:version) { '11' } - let(:variant) { 'openj9' } - - it 'returns the correct URL' do - expect(subject.default_adopt_openjdk_url(version)[variant]).to eq 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10_openj9-0.18.1/OpenJDK11U-jdk_x64_linux_openj9_11.0.6_10_openj9-0.18.1.tar.gz' - end - end - end -end diff --git a/spec/libraries/adopt_openjdk_macos_helpers_spec.rb b/spec/libraries/adopt_openjdk_macos_helpers_spec.rb deleted file mode 100644 index 6f98ecd5..00000000 --- a/spec/libraries/adopt_openjdk_macos_helpers_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'spec_helper' - -RSpec.describe Java::Cookbook::AdoptOpenJdkMacOsHelpers do - class DummyClass < Chef::Node - include Java::Cookbook::AdoptOpenJdkMacOsHelpers - end - - subject { DummyClass.new } - - describe '#macos_java_home' do - before do - allow(subject).to receive(:[]).with('version').and_return(version) - end - - context 'adoptopenjdk14' do - let(:version) { 'adoptopenjdk14' } - - it 'returns the correct folder' do - expect(subject.macos_java_home(version)).to eq '/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home' - end - end - - context 'adoptopenjdk14-openj9-jre' do - let(:version) { 'adoptopenjdk14-openj9-jre' } - - it 'returns the correct folder' do - expect(subject.macos_java_home(version)).to eq '/Library/Java/JavaVirtualMachines/adoptopenjdk-14-openj9.jre/Contents/Home' - end - end - - context 'adoptopenjdk14-openj9-jre-large' do - let(:version) { 'adoptopenjdk14-openj9-jre-large' } - - it 'returns the correct folder' do - expect(subject.macos_java_home(version)).to eq '/Library/Java/JavaVirtualMachines/adoptopenjdk-14-openj9.jre/Contents/Home' - end - end - - context 'adoptopenjdk14-openj9-large' do - let(:version) { 'adoptopenjdk14-openj9-large' } - - it 'returns the correct folder' do - expect(subject.macos_java_home(version)).to eq '/Library/Java/JavaVirtualMachines/adoptopenjdk-14-openj9.jdk/Contents/Home' - end - end - end -end diff --git a/spec/libraries/openjdk_helpers_spec.rb b/spec/libraries/openjdk_helpers_spec.rb index 56c12c47..f57d4724 100644 --- a/spec/libraries/openjdk_helpers_spec.rb +++ b/spec/libraries/openjdk_helpers_spec.rb @@ -27,7 +27,7 @@ class DummyClass < Chef::Node end context 'Invalid OpenJDK version' do - let(:version) { '18' } + let(:version) { '18.2' } it 'should raise an error' do expect { subject.default_openjdk_url(version) } diff --git a/spec/libraries/semeru_helpers_spec.rb b/spec/libraries/semeru_helpers_spec.rb new file mode 100644 index 00000000..8910a555 --- /dev/null +++ b/spec/libraries/semeru_helpers_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' + +RSpec.describe Java::Cookbook::OpenJdkHelpers do + class DummyClass < Chef::Node + include Java::Cookbook::OpenJdkHelpers + end + + subject { DummyClass.new } + + describe '#sub_dir' do + before do + allow(subject).to receive(:[]).with('url').and_return(url) + end + + context 'OpenJDK Semeru 8' do + let(:url) { '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' } + + it 'returns the correct folder name' do + expect(subject.sub_dir(url)).to eq 'jdk8u322-b06' + end + end + + context 'Malformed URL' do + let(:url) { 'a\bad/path/\to\/some.tar.gz' } + + it 'throws an error' do + expect { subject.sub_dir(url) }.to raise_error(URI::InvalidURIError) + end + end + end + + describe '#defaul_openjdk_url' do + before do + allow(subject).to receive(:[]).with('version').and_return(version) + end + + context 'Semeru 8' do + let(:version) { '8' } + let(:variant) { 'semeru' } + + it 'returns the correct URL' do + expect(subject.default_openjdk_url(version, variant)).to eq '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' + end + end + + context 'Semeru 11' do + let(:version) { '11' } + let(:variant) { 'semeru' } + + it 'returns the correct URL' do + expect(subject.default_openjdk_url(version, variant)).to eq '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' + end + end + + context 'Semeru 16' do + let(:version) { '16' } + let(:variant) { 'semeru' } + + it 'returns the correct URL' do + expect(subject.default_openjdk_url(version, variant)).to eq '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' + end + end + + context 'Semeru 17' do + let(:version) { '17' } + let(:variant) { 'semeru' } + + it 'returns the correct URL' do + expect(subject.default_openjdk_url(version, variant)).to eq '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' + end + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5906593e..ee2b6646 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,6 @@ require 'chefspec' require 'chefspec/berkshelf' -require_relative '../libraries/adopt_openjdk_helpers' require_relative '../libraries/adopt_openjdk_macos_helpers' require_relative '../libraries/certificate_helpers' require_relative '../libraries/corretto_helpers' diff --git a/test/fixtures/cookbooks/test/recipes/adoptopenjdk.rb b/test/fixtures/cookbooks/test/recipes/adoptopenjdk.rb deleted file mode 100644 index 2c89076f..00000000 --- a/test/fixtures/cookbooks/test/recipes/adoptopenjdk.rb +++ /dev/null @@ -1,14 +0,0 @@ -apt_update - -version = node['version'] -variant = node['variant'] - -adoptopenjdk_install version do - variant variant -end - -cookbook_file '/tmp/UnlimitedSupportJCETest.jar' do - source 'UnlimitedSupportJCETest.jar' -end - -include_recipe 'test::java_cert' diff --git a/test/fixtures/cookbooks/test/recipes/openjdk.rb b/test/fixtures/cookbooks/test/recipes/openjdk.rb index 97ce6d41..6fea755a 100644 --- a/test/fixtures/cookbooks/test/recipes/openjdk.rb +++ b/test/fixtures/cookbooks/test/recipes/openjdk.rb @@ -1,3 +1,8 @@ -openjdk_install node['version'] +openjdk_install node['version'] do + variant node['variant'] if node['variant'] +end + +# openjdk || semeru || temurin +# openjdk OpenJ9 || hotspot include_recipe 'test::java_cert'