Compare commits

..

8 Commits
2.1.1 ... 2.2.0

Author SHA1 Message Date
Paula McMaw
39113d885a Merge pull request #266 from willmeek/release_2_2_0
Release prep for 2.2.0
2017-11-16 14:46:57 +00:00
Will Meek
d0c9b41d9d Release prep for 2.2.0 2017-11-16 14:33:26 +00:00
Paula McMaw
d336d79c04 Merge pull request #265 from willmeek/realpath_test_fix
Realpath test fix
2017-11-16 10:59:40 +00:00
Will Meek
e1df6498c7 Fix facter unit test when using realpath 2017-11-15 14:37:42 +00:00
Sebastian Reitenbach
e50eb64614 do not use unportable readlink utility to find the java_default_home,
use Ruby in a more portable fashion.

adapt tests as well
2017-11-15 14:37:42 +00:00
Sebastian Reitenbach
bdfc567c18 OpenBSD doesn't have /etc/environment, therefore there is no
need to fiddle with it. The default case statement, "do nothing"
is all fine here.

Facter::Util::Resolution.with_env is long time gone since
Facter > 2.x. That was even longer before introduced by me.
Remove that OpenBSD special case in the java_version fact,
and assume that $PATH is properly set in order to find
the 'java' binary.

Additionally confine the java_default_home and java_libjvm_path
to OpenBSD kernel as well. Add some flesh to the java_default_home
fact to allow it to find the java binary.
2017-11-15 14:37:42 +00:00
Michael Baker
db30eb9e2d Adding support for Ubuntu (#243)
* Translate amd64

* Fix the path creation on exec
2017-11-15 14:36:10 +00:00
Paula McMaw
d49c1f0e29 Merge pull request #264 from puppetlabs/release
2.1.1 Release Mergeback
2017-11-09 13:48:10 +00:00
11 changed files with 144 additions and 62 deletions

View File

@@ -1,3 +1,15 @@
## Supported Release [2.2.0]
### Summary
This release is a maintenance release that includes a roll up of minor changes.
#### Added
- Addition of Ubuntu for Oracle Java.
- Addition of Debian 9 in supported versions.
- Addition of OpenBSD case and use `realpath` rather than `readlink` in Java Default Home Facter fact.
#### Removed
- Removal of OpenBSD as a special case and deprecated `with_env` in Java Version Facter Facter fact.
## Supported Release 2.1.1 ## Supported Release 2.1.1
### Summary ### Summary
This release is a maintenance release that includes a roll up of minor changes. This release is a maintenance release that includes a roll up of minor changes.
@@ -256,3 +268,5 @@ Jeff McCune <jeff@puppetlabs.com>
## 2011-05-24 - Version 0.0.1 ## 2011-05-24 - Version 0.0.1
Jeff McCune <jeff@puppetlabs.com> Jeff McCune <jeff@puppetlabs.com>
* Initial release * Initial release
[2.2.0]:https://github.com/puppetlabs/puppetlabs-java/compare/2.1.1...2.2.0

View File

@@ -3,24 +3,25 @@
# Purpose: get absolute path of java system home # Purpose: get absolute path of java system home
# #
# Resolution: # Resolution:
# Uses `readlink` to resolve the path of `/usr/bin/java` then returns subsubdir # Find the real java binary, and return the subsubdir
# #
# Caveats: # Caveats:
# Requires readlink # java binary has to be found in $PATH
# #
# Notes: # Notes:
# None # None
Facter.add(:java_default_home) do Facter.add(:java_default_home) do
confine :kernel => 'Linux' confine :kernel => [ 'Linux', 'OpenBSD' ]
setcode do setcode do
if Facter::Util::Resolution.which('readlink') java_bin = Facter::Util::Resolution.which('java').to_s.strip
java_bin = Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip if java_bin.empty?
if java_bin.empty? nil
nil else
elsif java_bin =~ %r(/jre/) java_path = File.realpath(java_bin)
java_default_home = File.dirname(File.dirname(File.dirname(java_bin))) if java_path =~ %r(/jre/)
java_default_home = File.dirname(File.dirname(File.dirname(java_path)))
else else
java_default_home = File.dirname(File.dirname(java_bin)) java_default_home = File.dirname(File.dirname(java_path))
end end
end end
end end

View File

@@ -11,7 +11,7 @@
# Notes: # Notes:
# None # None
Facter.add(:java_libjvm_path) do Facter.add(:java_libjvm_path) do
confine :kernel => "Linux" confine :kernel => [ "Linux", "OpenBSD" ]
setcode do setcode do
java_default_home = Facter.value(:java_default_home) java_default_home = Facter.value(:java_default_home)
java_libjvm_file = Dir.glob("#{java_default_home}/jre/lib/**/libjvm.so") java_libjvm_file = Dir.glob("#{java_default_home}/jre/lib/**/libjvm.so")

View File

@@ -21,21 +21,7 @@ Facter.add(:java_version) do
# Additionally, facter versions prior to 2.0.1 only support # Additionally, facter versions prior to 2.0.1 only support
# positive matches, so this needs to be done manually in setcode. # positive matches, so this needs to be done manually in setcode.
setcode do setcode do
unless [ 'openbsd', 'darwin' ].include? Facter.value(:operatingsystem).downcase unless [ 'darwin' ].include? Facter.value(:operatingsystem).downcase
version = nil
if Facter::Util::Resolution.which('java')
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line }
end
version
end
end
end
Facter.add(:java_version) do
confine :operatingsystem => 'OpenBSD'
has_weight 100
setcode do
Facter::Util::Resolution.with_env("PATH" => '/usr/local/jdk-1.7.0/jre/bin:/usr/local/jre-1.7.0/bin') do
version = nil version = nil
if Facter::Util::Resolution.which('java') if Facter::Util::Resolution.which('java')
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line } Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line }

View File

@@ -44,7 +44,7 @@ class java::config ( ) {
} }
} }
} }
'OpenBSD', 'FreeBSD', 'Suse': { 'FreeBSD', 'Suse': {
if $java::use_java_home != undef { if $java::use_java_home != undef {
file_line { 'java-home-environment': file_line { 'java-home-environment':
path => '/etc/environment', path => '/etc/environment',

View File

@@ -166,6 +166,11 @@ define java::oracle (
} else { } else {
$package_type = 'rpm' $package_type = 'rpm'
} }
$creates_path = "/usr/java/${install_path}"
}
'Debian' : {
$package_type = 'tar.gz'
$creates_path = "/usr/lib/jvm/${install_path}"
} }
default : { default : {
fail ("unsupported platform ${$facts['os']['name']}") } fail ("unsupported platform ${$facts['os']['name']}") }
@@ -173,7 +178,6 @@ define java::oracle (
$os = 'linux' $os = 'linux'
$destination_dir = '/tmp/' $destination_dir = '/tmp/'
$creates_path = "/usr/java/${install_path}"
} }
default : { default : {
fail ( "unsupported platform ${$facts['kernel']}" ) } fail ( "unsupported platform ${$facts['kernel']}" ) }
@@ -183,6 +187,7 @@ define java::oracle (
case $facts['os']['architecture'] { case $facts['os']['architecture'] {
'i386' : { $arch = 'i586' } 'i386' : { $arch = 'i586' }
'x86_64' : { $arch = 'x64' } 'x86_64' : { $arch = 'x64' }
'amd64' : { $arch = 'x64' }
default : { default : {
fail ("unsupported platform ${$facts['os']['architecture']}") fail ("unsupported platform ${$facts['os']['architecture']}")
} }
@@ -205,6 +210,9 @@ define java::oracle (
'rpm' : { 'rpm' : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm" $package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
} }
'tar.gz' : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.tar.gz"
}
default : { default : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm" $package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
} }
@@ -235,6 +243,9 @@ define java::oracle (
'rpm' : { 'rpm' : {
$install_command = "rpm --force -iv ${destination}" $install_command = "rpm --force -iv ${destination}"
} }
'tar.gz' : {
$install_command = "tar -zxf ${destination} -C /usr/lib/jvm"
}
default : { default : {
$install_command = "rpm -iv ${destination}" $install_command = "rpm -iv ${destination}"
} }
@@ -260,6 +271,15 @@ define java::oracle (
creates => $creates_path, creates => $creates_path,
require => Archive[$destination] require => Archive[$destination]
} }
case $facts['os']['family'] {
'Debian' : {
file{'/usr/lib/jvm':
ensure => directory,
before => Exec["Install Oracle java_se ${java_se} ${version}"]
}
}
default : { }
}
} }
default : { default : {
fail ("unsupported platform ${$facts['kernel']}") fail ("unsupported platform ${$facts['kernel']}")

View File

@@ -1,6 +1,6 @@
{ {
"name": "puppetlabs-java", "name": "puppetlabs-java",
"version": "2.1.1", "version": "2.2.0",
"author": "puppetlabs", "author": "puppetlabs",
"summary": "Installs the correct Java package on various platforms.", "summary": "Installs the correct Java package on various platforms.",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -50,7 +50,8 @@
"operatingsystem": "Debian", "operatingsystem": "Debian",
"operatingsystemrelease": [ "operatingsystemrelease": [
"7", "7",
"8" "8",
"9"
] ]
}, },
{ {

View File

@@ -236,7 +236,7 @@ describe 'java', :type => :class do
context 'select jdk for OpenBSD' do context 'select jdk for OpenBSD' do
let(:facts) { {:osfamily => 'OpenBSD', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'OpenBSD', :architecture => 'x86_64'} }
it { is_expected.to contain_package('java').with_name('jdk') } it { is_expected.to contain_package('java').with_name('jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/local/jdk/') } it { is_expected.to_not contain_file_line('java-home-environment') }
end end
context 'select jre for OpenBSD' do context 'select jre for OpenBSD' do

View File

@@ -130,6 +130,63 @@ describe 'java::oracle', :type => :define do
end end
end end
context 'On Ubuntu 64-bit' do
let(:facts) { {:kernel => 'Linux', :os => { :family => 'Debian', :architecture => 'amd64', :name => 'Ubuntu', :release => { :full => '16.04' } } } }
context 'Oracle Java SE 6 JDK' do
let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jdk'} }
let :title do 'jdk6' end
it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('tar -zxf /tmp/jdk-6u45-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-x64.tar.gz]') }
end
context 'Oracle Java SE 7 JDK' do
let(:params) { {:ensure => 'present', :version => '7', :java_se => 'jdk'} }
let :title do 'jdk7' end
it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('tar -zxf /tmp/jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-x64.tar.gz]') }
end
context 'Oracle Java SE 8 JDK' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} }
let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('tar -zxf /tmp/jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.tar.gz]') }
end
context 'Oracle Java SE 6 JRE' do
let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jre'} }
let :title do 'jre6' end
it { is_expected.to contain_archive('/tmp/jre-6u45-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('tar -zxf /tmp/jre-6u45-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-x64.tar.gz]') }
end
context 'Oracle Java SE 7 JRE' do
let(:params) { {:ensure => 'present', :version => '7', :java_se => 'jre'} }
let :title do 'jre7' end
it { is_expected.to contain_archive('/tmp/jre-7u80-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('tar -zxf /tmp/jre-7u80-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-x64.tar.gz]') }
end
context 'select Oracle Java SE 8 JRE' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} }
let :title do 'jre8' end
it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('tar -zxf /tmp/jre-8u131-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.tar.gz]') }
end
context 'Pass URL to url parameter' do
let(:params) { {:ensure => 'present', :version_major => '8u131', :version_minor => 'b11', :java_se => 'jdk', :url => 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz'} }
let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz')}
end
end
describe 'incompatible OSes' do describe 'incompatible OSes' do
[ [
{ {

View File

@@ -1,47 +1,50 @@
require "spec_helper" require "spec_helper"
def unlink_and_delete(filename)
if File.symlink?(filename)
File.unlink(filename)
end
if File.exist?(filename)
File.delete(filename)
end
end
describe Facter::Util::Fact do describe Facter::Util::Fact do
before {
Facter.clear
Facter.fact(:kernel).stubs(:value).returns('Linux')
}
describe "java_default_home" do describe "java_default_home" do
context 'returns java home path when readlink present' do before(:each) {
context 'when java is in HOME/jre/bin/java' do Facter.clear
Facter.fact(:kernel).stubs(:value).returns('Linux')
}
context 'returns java home path when java found in PATH' do
context "when java is in /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java" do
it do it do
java_path_output = <<-EOS unlink_and_delete('./java_test')
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java File.symlink('/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java', './java_test')
EOS Facter::Util::Resolution.expects(:which).with("java").returns("./java_test")
Facter::Util::Resolution.expects(:which).with("readlink").returns(true) File.expects(:realpath).with('./java_test').returns('/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java')
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output) expect(Facter.value(:java_default_home)).to eql '/usr/lib/jvm/java-7-openjdk-amd64'
expect(Facter.value(:java_default_home)).to eql "/usr/lib/jvm/java-7-openjdk-amd64" unlink_and_delete('./java_test')
end end
end end
context 'when java is in HOME/bin/java' do
context "when java is in /usr/lib/jvm/oracle-java8-jre-amd64/bin/java" do
it do it do
java_path_output = <<-EOS unlink_and_delete('./java_test')
/usr/lib/jvm/oracle-java8-jre-amd64/bin/java File.symlink('/usr/lib/jvm/oracle-java8-jre-amd64/bin/java', './java_test')
EOS Facter::Util::Resolution.expects(:which).with("java").returns("./java_test")
Facter::Util::Resolution.expects(:which).with("readlink").returns(true) File.expects(:realpath).with('./java_test').returns('/usr/lib/jvm/oracle-java8-jre-amd64/bin/java')
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output) expect(Facter.value(:java_default_home)).to eql '/usr/lib/jvm/oracle-java8-jre-amd64'
expect(Facter.value(:java_default_home)).to eql "/usr/lib/jvm/oracle-java8-jre-amd64" unlink_and_delete('./java_test')
end end
end end
end end
context 'returns nil when readlink is present but java is not' do
it do
java_path_output = ""
Facter::Util::Resolution.expects(:which).with("readlink").returns(true)
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output)
expect(Facter.value(:java_default_home)).to be_nil
end
end
context 'returns nil when readlink not present' do context 'returns nil when java not present' do
it do it do
Facter::Util::Resolution.stubs(:exec) Facter::Util::Resolution.stubs(:exec)
Facter::Util::Resolution.expects(:which).with("readlink").at_least(1).returns(false) Facter::Util::Resolution.expects(:which).with("java").at_least(1).returns(false)
expect(Facter.value(:java_default_home)).to be_nil expect(Facter.value(:java_default_home)).to be_nil
end end
end end

View File

@@ -7,7 +7,7 @@ describe Facter::Util::Fact do
describe "java_version" do describe "java_version" do
context 'returns java version when java present' do context 'returns java version when java present' do
context 'on OpenBSD', :with_env => true do context 'on OpenBSD' do
before do before do
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD") Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
end end
@@ -61,7 +61,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
end end
context 'returns nil when java not present' do context 'returns nil when java not present' do
context 'on OpenBSD', :with_env => true do context 'on OpenBSD' do
before do before do
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD") Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
end end