Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Working Java 8 installation
Browse files Browse the repository at this point in the history
  • Loading branch information
petems committed May 6, 2015
1 parent ea86ac7 commit 8d63165
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 25 deletions.
File renamed without changes.
File renamed without changes.
Binary file added files/8/US_export_policy.jar
Binary file not shown.
Binary file added files/8/local_policy.jar
Binary file not shown.
30 changes: 16 additions & 14 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -64,15 +66,15 @@
}

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',
require => File[$sec_dir]
}

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',
Expand Down
27 changes: 17 additions & 10 deletions spec/classes/java_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
}
Expand All @@ -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',
}
}
Expand All @@ -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',
}
}
Expand All @@ -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
2 changes: 1 addition & 1 deletion spec/fixtures/Puppetfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mod 'boxen', '3.0.2', :github_tarball => 'boxen/puppet-boxen'
mod 'boxen', '3.10.3', :github_tarball => 'boxen/puppet-boxen'

0 comments on commit 8d63165

Please sign in to comment.