diff --git a/files/US_export_policy.jar b/files/7/US_export_policy.jar similarity index 100% rename from files/US_export_policy.jar rename to files/7/US_export_policy.jar diff --git a/files/local_policy.jar b/files/7/local_policy.jar similarity index 100% rename from files/local_policy.jar rename to files/7/local_policy.jar diff --git a/files/8/US_export_policy.jar b/files/8/US_export_policy.jar new file mode 100644 index 0000000..251b102 Binary files /dev/null and b/files/8/US_export_policy.jar differ diff --git a/files/8/local_policy.jar b/files/8/local_policy.jar new file mode 100644 index 0000000..1c58939 Binary files /dev/null and b/files/8/local_policy.jar differ diff --git a/manifests/init.pp b/manifests/init.pp index 0bb3bfe..cf8b7b2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,49 +4,51 @@ # # include java class java ( - $java_major_version = '7', + $update_major_version = '7', $update_version = '71', $base_download_url = 'https://s3.amazonaws.com/boxen-downloads/java' ) { include boxen::config - $new_java_version = "1.${java_major_version}.${update_version}" - $java_package_name = "${java_major_version}u${update_version}-macosx-x64.dmg" + $new_java_version = "1.${update_major_version}.${update_version}" + $java_package_name = "${update_major_version}u${update_version}-macosx-x64.dmg" $jre_url = "${base_download_url}/jre-${java_package_name}" $jdk_url = "${base_download_url}/jdk-${java_package_name}" $wrapper = "${boxen::config::bindir}/java" - $jdk_dir = "/Library/Java/JavaVirtualMachines/jdk1.${java_major_version}.0_${update_version}.jdk" + $jdk_dir = "/Library/Java/JavaVirtualMachines/jdk1.${update_major_version}.0_${update_version}.jdk" $sec_dir = "${jdk_dir}/Contents/Home/jre/lib/security" if ((versioncmp($::macosx_productversion_major, '10.10') >= 0) and - (versioncmp($update_version, '71') < 0) and $java_major_version == '7') + (versioncmp($update_version, '71') < 0) and $update_major_version == '7') { fail('Yosemite Requires Java 7 with a patch level >= 71 (Bug JDK-8027686)') } if ((versioncmp($::macosx_productversion_major, '10.10') >= 0) and - (versioncmp($update_version, '20') < 0) and $java_major_version == '8') + (versioncmp($update_version, '20') < 0) and $update_major_version == '8') { fail('Yosemite Requires Java 8 with a patch level >= 20 (Bug JDK-8027686)') } - if (versioncmp($::java_version, $new_java_version) < 0) { + $java_version_installed = regsubst($::java_version, '_', '.') + $java_version_potential = "1.${update_major_version}.0.${update_version}" + $java_version_drift = versioncmp($java_version_installed, $java_version_potential) + + if ($java_version_drift) + { package { - "jre-${java_major_version}u${update_version}.dmg": + "jre-${update_major_version}u${update_version}.dmg": ensure => present, alias => 'java-jre', provider => pkgdmg, source => $jre_url ; - "jdk-${java_major_version}u${update_version}.dmg": + "jdk-${update_major_version}u${update_version}.dmg": ensure => present, alias => 'java', provider => pkgdmg, source => $jdk_url ; } } - else { - notify { "You requested ${new_java_version} be installed, but you already have ${::java_version} which is more recent!": } - } file { $wrapper: source => 'puppet:///modules/java/java.sh', @@ -64,7 +66,7 @@ } file { "${sec_dir}/local_policy.jar": - source => 'puppet:///modules/java/local_policy.jar', + source => "puppet:///modules/java/${update_major_version}/local_policy.jar", owner => 'root', group => 'wheel', mode => '0664', @@ -72,7 +74,7 @@ } file { "${sec_dir}/US_export_policy.jar": - source => 'puppet:///modules/java/US_export_policy.jar', + source => "puppet:///modules/java/${update_major_version}/US_export_policy.jar", owner => 'root', group => 'wheel', mode => '0664', diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index 8bc760d..f21cdef 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -34,7 +34,7 @@ let(:facts) { default_test_facts.merge({ :macosx_productversion_major => '10.10' }) } let(:params) { { - :java_major_version => '7', + :update_major_version => '7', :update_version => '51', } } @@ -48,7 +48,7 @@ let(:facts) { default_test_facts.merge({ :macosx_productversion_major => '10.10' }) } let(:params) { { - :java_major_version => '8', + :update_major_version => '8', :update_version => '11', } } @@ -61,11 +61,14 @@ end context 'doesnt install java if newer version already present' do - context "java 7" do - let(:facts) { default_test_facts.merge({ :java_version => '1.7.0_72' }) } + context "trying to install Java 7 when Java 8 already installed" do + let(:facts) { default_test_facts.merge({ + :java_version => '1.8.0_21', + }) + } let(:params) { { - :java_major_version => '7', + :update_major_version => '7', :update_version => '71', } } @@ -74,18 +77,22 @@ should_not contain_package('jre-7u71.dmg') end end - context "java 8" do - let(:facts) { default_test_facts.merge({ :java_version => '1.8.0_22' }) } + context "trying to install Java 7 when a higher patch version already installed" do + let(:facts) { default_test_facts.merge({ + :java_version => '1.7.0_71', + }) + } let(:params) { { - :java_major_version => '8', - :update_version => '21', + :update_major_version => '7', + :update_version => '20', } } it do should contain_class('boxen::config') - should_not contain_package('jre-8u21.dmg') + should_not contain_package('jre-7u20.dmg') end end end + end diff --git a/spec/fixtures/Puppetfile b/spec/fixtures/Puppetfile index a649dda..b6e1e86 100644 --- a/spec/fixtures/Puppetfile +++ b/spec/fixtures/Puppetfile @@ -1 +1 @@ -mod 'boxen', '3.0.2', :github_tarball => 'boxen/puppet-boxen' +mod 'boxen', '3.10.3', :github_tarball => 'boxen/puppet-boxen'