Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions manifests/adopt.pp
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,7 @@
$destination = "${destination_dir}${package_name}"
notice ("Destination is ${destination}")

case $_package_type {
'tar.gz' : {
$install_command = "tar -zxf ${destination} -C ${_basedir}"
}
default : {
$install_command = "tar -zxf ${destination} -C ${_basedir}"
}
}
$install_command = ['tar', '-zxf', $destination, '-C', $_basedir]

case $ensure {
'present' : {
Expand Down
4 changes: 3 additions & 1 deletion manifests/adoptium.pp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@
}
}

$install_adoptium = ['tar', '-zxf', $destination, '-C', $_basedir]

exec { "Install Adoptium Temurin java ${version_major} ${version_minor} ${version_patch} ${version_build}" :
path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
command => "tar -zxf ${destination} -C ${_basedir}",
command => $install_adoptium,
creates => $creates_path,
require => $install_requires,
}
Expand Down
20 changes: 14 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
case $facts['os']['family'] {
'Debian': {
if $java::use_java_alternative != undef and $java::use_java_alternative_path != undef {
$command_debian = ['update-java-alternatives', '--set', $java::use_java_alternative, $java::jre_flag]
$unless_debian = [['test', '/etc/alternatives/java', '-ef', $java::use_java_alternative_path]]

exec { 'update-java-alternatives':
path => '/usr/bin:/usr/sbin:/bin:/sbin',
command => "update-java-alternatives --set ${java::use_java_alternative} ${java::jre_flag}",
unless => "test /etc/alternatives/java -ef '${java::use_java_alternative_path}'",
command => $command_debian,
unless => $unless_debian,
}
}
if $java::use_java_home != undef {
Expand All @@ -22,18 +25,23 @@
# The standard packages install alternatives, custom packages do not
# For the stanard packages java::params needs these added.
if $java::use_java_package_name != $java::default_package_name {
$command_redhat = ['alternatives', '--install', '/usr/bin/java', 'java', $java::use_java_alternative_path, '20000']
$unless_redhat = "alternatives --display java | grep -q ${java::use_java_alternative_path}"

exec { 'create-java-alternatives':
path => '/usr/bin:/usr/sbin:/bin:/sbin',
command => "alternatives --install /usr/bin/java java ${$java::use_java_alternative_path} 20000" ,
unless => "alternatives --display java | grep -q ${$java::use_java_alternative_path}",
command => $command_redhat,
unless => shell_escape($unless_redhat),
before => Exec['update-java-alternatives'],
}
}
$command_default = ['alternatives', '--set', 'java', $java::use_java_alternative_path]
$unless_default = [['test', '/etc/alternatives/java', '-ef', $java::use_java_alternative_path]]

exec { 'update-java-alternatives':
path => '/usr/bin:/usr/sbin',
command => "alternatives --set java ${$java::use_java_alternative_path}" ,
unless => "test /etc/alternatives/java -ef '${java::use_java_alternative_path}'",
command => $command_default,
unless => $unless_default,
}
}
if $java::use_java_home != undef {
Expand Down
10 changes: 5 additions & 5 deletions manifests/download.pp
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,19 @@

case $_package_type {
'bin' : {
$install_command = "sh ${destination}"
$install_command = ['sh', $destination]
}
'rpmbin' : {
$install_command = "sh ${destination} -x; rpm --force -iv sun*.rpm; rpm --force -iv ${java_se}*.rpm"
$install_command = ['sh', $destination, '-x;', 'rpm', '--force', '-iv', 'sun*.rpm;', 'rpm', '--force', '-iv', "${java_se}*.rpm"]
}
'rpm' : {
$install_command = "rpm --force -iv ${destination}"
$install_command = ['rpm', '--force', '-iv', $destination]
}
'tar.gz' : {
$install_command = "tar -zxf ${destination} -C ${_basedir}"
$install_command = ['tar', '-zxf', $destination, '-C', $_basedir]
}
default : {
$install_command = "rpm -iv ${destination}"
$install_command = ['rpm', '-iv', $destination]
}
}

Expand Down
6 changes: 3 additions & 3 deletions spec/classes/java_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
let(:params) { { 'package' => 'jre', 'java_alternative' => '/usr/bin/java', 'java_alternative_path' => '/usr/java/jre1.7.0_67/bin/java' } }

it { is_expected.to contain_package('java').with_name('jre') }
it { is_expected.to contain_exec('create-java-alternatives').with_command('alternatives --install /usr/bin/java java /usr/java/jre1.7.0_67/bin/java 20000') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('alternatives --set java /usr/java/jre1.7.0_67/bin/java') }
it { is_expected.to contain_exec('create-java-alternatives').with_command(['alternatives', '--install', '/usr/bin/java', 'java', '/usr/java/jre1.7.0_67/bin/java', '20000']) }
it { is_expected.to contain_exec('update-java-alternatives').with_command(['alternatives', '--set', 'java', '/usr/java/jre1.7.0_67/bin/java']) }
end

context 'when select passed value for CentOS 5.3' do
Expand Down Expand Up @@ -173,7 +173,7 @@

it { is_expected.to contain_package('java').with_name('custom_jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/opt/custom_jdk') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-custom_jdk --jre') }
it { is_expected.to contain_exec('update-java-alternatives').with_command(['update-java-alternatives', '--set', 'java-custom_jdk', '--jre']) }
end
context 'with missing parameters' do
let(:params) do
Expand Down
Loading