Skip to content

Commit 4117e05

Browse files
teknomar7majormoses
authored andcommitted
Fix for issue 538 to paramaterize file_cache_path references (sous-chefs#554)
* Fix for issue 538 to paramaterize file_cache_path references * Add changelog and bump version * Fix trailing spaces * Updating changelog date
1 parent 3df3999 commit 4117e05

11 files changed

Lines changed: 32 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ This file is used to list changes made in each version of the Java cookbook.
66

77
- Upgrade circleci orb to version 2 and add yamllint and markdown lint
88

9+
## 4.2.0 - 2019-07-15
10+
11+
- Fix for issue 538
12+
- Added "download_path" node attribute defaulting to file_cache_path
13+
- Replaced all hardcoded instances of file_cache_path with the node attribute
14+
915
## 4.1.0 - 2019-05-08
1016

1117
- Added new install flavor "corretto" for Amazon's Corretto distribution of OpenJDK

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Chef 13.4+
9090

9191
See `attributes/default.rb` for default values.
9292

93+
- `node['java']['download_path']` - Location to download and extract the tarball
9394
- `node['java']['install_flavor']` - Flavor of JVM you would like installed (`oracle`, `oracle_rpm`, `openjdk`, `adoptopenjdk`, `ibm`, `windows`), default `openjdk` on Linux/Unix platforms, `windows` on Windows platforms.
9495
- `node['java']['install_type']` - Type of Java installation, defauls to jdk, needed for JCE to find the install path of jar's for JDK/JRE installation.
9596
- `node['java']['jdk_version']` - JDK version to install, defaults to `'6'`.

attributes/default.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# limitations under the License.
1919

2020
# default jdk attributes
21+
default['java']['download_path'] = Chef::Config[:file_cache_path]
2122
default['java']['jdk_version'] = '8'
2223
default['java']['arch'] = node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i586'
2324
default['java']['openjdk_packages'] = []

metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
license 'Apache-2.0'
55
description 'Recipes and resources for installing Java and managing certificates'
66
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7-
version '4.1.0'
7+
version '4.2.0'
88

99
supports 'debian'
1010
supports 'ubuntu'

recipes/ibm.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
only_if { platform_family?('debian') && jdk_filename !~ /archive/ }
3939
end
4040

41-
template "#{Chef::Config[:file_cache_path]}/installer.properties" do
41+
template "#{node['java']['download_path']}/installer.properties" do
4242
source 'ibm_jdk.installer.properties.erb'
4343
only_if { node['java']['ibm']['accept_ibm_download_terms'] }
4444
end
4545

46-
remote_file "#{Chef::Config[:file_cache_path]}/#{jdk_filename}" do
46+
remote_file "#{node['java']['download_path']}/#{jdk_filename}" do
4747
source source_url
4848
mode '0755'
4949
if node['java']['ibm']['checksum']
@@ -70,7 +70,7 @@
7070
end
7171

7272
execute 'install-ibm-java' do
73-
cwd Chef::Config[:file_cache_path]
73+
cwd node['java']['download_path']
7474
environment('_JAVA_OPTIONS' => '-Dlax.debug.level=3 -Dlax.debug.all=true',
7575
'LAX_DEBUG' => '1')
7676
command "./#{jdk_filename} -f ./installer.properties -i silent"

recipes/ibm_tar.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
raise "The attribute `node['java']['ibm']['url']` must specify a .tar.gz file"
3636
end
3737

38-
remote_file "#{Chef::Config[:file_cache_path]}/#{jdk_filename}" do
38+
remote_file "#{node['java']['download_path']}/#{jdk_filename}" do
3939
source source_url
4040
mode '0755'
4141
if node['java']['ibm']['checksum']
@@ -69,7 +69,7 @@
6969
end
7070

7171
execute 'untar-ibm-java' do
72-
cwd Chef::Config[:file_cache_path]
72+
cwd node['java']['download_path']
7373
command "tar xzf ./#{jdk_filename} -C #{node['java']['java_home']} --strip 1"
7474
notifies :set, 'java_alternatives[set-java-alternatives]', :immediately
7575
notifies :write, 'log[jdk-version-changed]', :immediately

recipes/windows.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
s3_remote_path = node['java']['windows']['remote_path']
3434

3535
uri = ::URI.parse(node['java']['windows']['url'])
36-
cache_file_path = File.join(Chef::Config[:file_cache_path], File.basename(::URI.unescape(uri.path)))
36+
cache_file_path = File.join(node['java']['download_path'], File.basename(::URI.unescape(uri.path)))
3737

3838
if s3_bucket && s3_remote_path
3939
aws_s3_file cache_file_path do

resources/adoptopenjdk_install.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
end.run_action(:create)
4242

4343
unless ::File.exist?(app_dir)
44-
download_path = "#{Chef::Config[:file_cache_path]}/#{tarball_name}"
44+
download_path = "#{node['java']['download_path']}/#{tarball_name}"
4545
if adoptopendjk_downloaded?(download_path, new_resource)
4646
Chef::Log.debug('AdoptOpenJDK tarball already downloaded, not downloading again')
4747
else
4848
Chef::Log.debug("downloading tarball from #{URI.parse(new_resource.url).host}")
49-
remote_file "#{Chef::Config[:file_cache_path]}/#{tarball_name}" do
49+
remote_file "#{node['java']['download_path']}/#{tarball_name}" do
5050
source new_resource.url
5151
checksum new_resource.checksum
5252
retries new_resource.retries
@@ -62,17 +62,17 @@
6262
action :nothing
6363
end.run_action(:install)
6464

65-
cmd = shell_out(%(tar xvzf "#{Chef::Config[:file_cache_path]}/#{tarball_name}" -C "#{Chef::Config[:file_cache_path]}" --no-same-owner)
65+
cmd = shell_out(%(tar xvzf "#{node['java']['download_path']}/#{tarball_name}" -C "#{node['java']['download_path']}" --no-same-owner)
6666
)
6767
unless cmd.exitstatus == 0
6868
Chef::Application.fatal!("Failed to extract file #{tarball_name}!")
6969
end
7070

7171
cmd = shell_out(
72-
%(mv "#{Chef::Config[:file_cache_path]}/#{app_dir_name}" "#{app_dir}" )
72+
%(mv "#{node['java']['download_path']}/#{app_dir_name}" "#{app_dir}" )
7373
)
7474
unless cmd.exitstatus == 0
75-
Chef::Application.fatal!(%( Command \' mv "#{Chef::Config[:file_cache_path]}/#{app_dir_name}" "#{app_dir}" \' failed ))
75+
Chef::Application.fatal!(%( Command \' mv "#{node['java']['download_path']}/#{app_dir_name}" "#{app_dir}" \' failed ))
7676
end
7777

7878
# change ownership of extracted files

resources/certificate.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
certdata = new_resource.cert_data || fetch_certdata
4242

4343
hash = OpenSSL::Digest::SHA512.hexdigest(certdata)
44-
certfile = "#{Chef::Config[:file_cache_path]}/#{certalias}.cert.#{hash}"
44+
certfile = "#{node['java']['download_path']}/#{certalias}.cert.#{hash}"
4545
cmd = Mixlib::ShellOut.new("#{keytool} -list -keystore #{truststore} -storepass #{truststore_passwd} -rfc -alias \"#{certalias}\"")
4646
cmd.run_command
4747
keystore_cert = cmd.stdout.match(/^[-]+BEGIN.*END(\s|\w)+[-]+$/m).to_s
@@ -111,7 +111,7 @@
111111
end
112112
end
113113

114-
FileUtils.rm_f("#{Chef::Config[:file_cache_path]}/#{certalias}.cert.*")
114+
FileUtils.rm_f("#{node['java']['download_path']}/#{certalias}.cert.*")
115115
end
116116

117117
action_class do

resources/jce.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
recursive true
3737
end
3838

39-
r = remote_file "#{Chef::Config[:file_cache_path]}/jce.zip" do
39+
r = remote_file "#{node['java']['download_path']}/jce.zip" do
4040
source jce_url
4141
checksum jce_checksum
4242
headers(
@@ -87,7 +87,7 @@
8787
find ./ -name '*.jar' | xargs -I JCE_JAR mv JCE_JAR #{jce_home}/#{jdk_version}/
8888
chmod -R 0644 #{jce_home}/#{jdk_version}/*.jar
8989
EOF
90-
cwd Chef::Config[:file_cache_path]
90+
cwd node['java']['download_path']
9191
creates ::File.join(jce_home, jdk_version, 'US_export_policy.jar')
9292
end
9393

0 commit comments

Comments
 (0)