Skip to content

Commit

Permalink
Merge pull request #585 from ekohl/debian-12
Browse files Browse the repository at this point in the history
Support Debian 12 and refactor to make that easier
  • Loading branch information
praj1001 authored Mar 1, 2024
2 parents ae84592 + 00c7eb1 commit 18cac85
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 57 deletions.
60 changes: 30 additions & 30 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,23 @@
'AlmaLinux', 'Rocky', 'RedHat', 'CentOS', 'OracleLinux', 'Scientific', 'OEL', 'SLC', 'CloudLinux': {
# See PR#160 / c8e46b5 for why >= 6.3 < 7.1
if (versioncmp($facts['os']['release']['full'], '7.1') < 0) {
$jdk_package = 'java-1.7.0-openjdk-devel'
$jre_package = 'java-1.7.0-openjdk'
$java_home = '/usr/lib/jvm/java-1.7.0/'
}
else {
$jdk_package = 'java-1.8.0-openjdk-devel'
$jre_package = 'java-1.8.0-openjdk'
$java_home = '/usr/lib/jvm/java-1.8.0/'
$openjdk = '1.7.0'
} else {
$openjdk = '1.8.0'
}
$jdk_package = "java-${openjdk}-openjdk-devel"
$jre_package = "java-${openjdk}-openjdk"
$java_home = "/usr/lib/jvm/java-${openjdk}/"
}
'Fedora': {
if (versioncmp($facts['os']['release']['full'], '21') < 0) {
$jdk_package = 'java-1.7.0-openjdk-devel'
$jre_package = 'java-1.7.0-openjdk'
$java_home = "/usr/lib/jvm/java-1.7.0-openjdk-${facts['os']['architecture']}/"
}
else {
$jdk_package = 'java-1.8.0-openjdk-devel'
$jre_package = 'java-1.8.0-openjdk'
$java_home = "/usr/lib/jvm/java-1.8.0-openjdk-${facts['os']['architecture']}/"
$openjdk = '1.7.0'
} else {
$openjdk = '1.8.0'
}
$jdk_package = "java-${openjdk}-openjdk-devel"
$jre_package = "java-${openjdk}-openjdk"
$java_home = "/usr/lib/jvm/java-${openjdk}-openjdk-${facts['os']['architecture']}/"
}
'Amazon': {
$jdk_package = 'java-1.7.0-openjdk-devel'
Expand Down Expand Up @@ -62,24 +58,28 @@
default => $facts['os']['architecture']
}
case $facts['os']['release']['major'] {
'12': {
$openjdk = 17
}
'10', '11', '18.04', '18.10', '19.04', '19.10', '20.04', '22.04': {
$java = {
'jdk' => {
'package' => 'openjdk-11-jdk',
'alternative' => "java-1.11.0-openjdk-${openjdk_architecture}",
'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/bin/java",
'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/",
},
'jre' => {
'package' => 'openjdk-11-jre-headless',
'alternative' => "java-1.11.0-openjdk-${openjdk_architecture}",
'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/bin/java",
'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/",
},
}
$openjdk = 11
}
default: { fail("unsupported release ${facts['os']['release']['major']}") }
}
$java = {
'jdk' => {
'package' => "openjdk-${openjdk}-jdk",
'alternative' => "java-1.${openjdk}.0-openjdk-${openjdk_architecture}",
'alternative_path' => "/usr/lib/jvm/java-1.${openjdk}.0-openjdk-${openjdk_architecture}/bin/java",
'java_home' => "/usr/lib/jvm/java-1.${openjdk}.0-openjdk-${openjdk_architecture}/",
},
'jre' => {
'package' => "openjdk-${openjdk}-jre-headless",
'alternative' => "java-1.${openjdk}.0-openjdk-${openjdk_architecture}",
'alternative_path' => "/usr/lib/jvm/java-1.${openjdk}.0-openjdk-${openjdk_architecture}/bin/java",
'java_home' => "/usr/lib/jvm/java-1.${openjdk}.0-openjdk-${openjdk_architecture}/",
},
}
}
'OpenBSD': {
$java = {
Expand Down
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"operatingsystem": "Debian",
"operatingsystemrelease": [
"10",
"11"
"11",
"12"
]
},
{
Expand Down
75 changes: 49 additions & 26 deletions spec/classes/java_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,72 @@
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0/') }
end

context 'when selecting jdk for Debian Buster (10.0)' do
context 'on Debian Buster (10.0)' do
let(:facts) { { os: { family: 'Debian', name: 'Debian', lsb: { distcodename: 'buster' }, release: { major: '10' }, architecture: 'amd64' } } }
let(:params) { { 'distribution' => 'jdk' } }

it { is_expected.to contain_package('java').with_name('openjdk-11-jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/') }
end
context 'when selecting jdk' do
let(:params) { { 'distribution' => 'jdk' } }

context 'when selecting jre for Debian Buster (10.0)' do
let(:facts) { { os: { family: 'Debian', name: 'Debian', lsb: { distcodename: 'buster' }, release: { major: '10' }, architecture: 'amd64' } } }
let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('openjdk-11-jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/') }
end

context 'when selecting jre' do
let(:params) { { 'distribution' => 'jre' } }

it { is_expected.to contain_package('java').with_name('openjdk-11-jre-headless') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/') }
it { is_expected.to contain_package('java').with_name('openjdk-11-jre-headless') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/') }
end
end

context 'when selecting jdk for Ubuntu Bionic (18.04)' do
let(:facts) { { os: { family: 'Debian', name: 'Ubuntu', lsb: { distcodename: 'bionic' }, release: { major: '18.04' }, architecture: 'amd64' } } }
let(:params) { { 'distribution' => 'jdk' } }
context 'on Debian Bookworm (12)' do
let(:facts) { { os: { family: 'Debian', name: 'Debian', lsb: { distcodename: 'bookworm' }, release: { major: '12' }, architecture: 'amd64' } } }

context 'when selecting jdk' do
let(:params) { { 'distribution' => 'jdk' } }

it { is_expected.to contain_package('java').with_name('openjdk-17-jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64/') }
end

context 'when selecting jre' do
let(:params) { { 'distribution' => 'jre' } }

it { is_expected.to contain_package('java').with_name('openjdk-11-jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/') }
it { is_expected.to contain_package('java').with_name('openjdk-17-jre-headless') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64/') }
end
end

context 'when selecting jre for Ubuntu Bionic (18.04)' do
context 'on Ubuntu Bionic (18.04)' do
let(:facts) { { os: { family: 'Debian', name: 'Ubuntu', lsb: { distcodename: 'bionic' }, release: { major: '18.04' }, architecture: 'amd64' } } }
let(:params) { { 'distribution' => 'jre' } }

it { is_expected.to contain_package('java').with_name('openjdk-11-jre-headless') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/') }
end
context 'when selecting jdk' do
let(:params) { { 'distribution' => 'jdk' } }

context 'when selecting openjdk for Oracle Linux' do
let(:facts) { { os: { family: 'RedHat', name: 'OracleLinux', release: { full: '7.0' }, architecture: 'x86_64' } } }
it { is_expected.to contain_package('java').with_name('openjdk-11-jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/') }
end

context 'when selecting jre' do
let(:params) { { 'distribution' => 'jre' } }

it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') }
it { is_expected.to contain_package('java').with_name('openjdk-11-jre-headless') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/') }
end
end

context 'when selecting passed value for Oracle Linux' do
context 'on Oracle Linux 7.0' do
let(:facts) { { os: { family: 'RedHat', name: 'OracleLinux', release: { full: '7.0' }, architecture: 'x86_64' } } }
let(:params) { { 'distribution' => 'jre' } }

it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
context 'when selecting openjdk' do
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') }
end

context 'when selecting passed value for Oracle Linux' do
let(:params) { { 'distribution' => 'jre' } }

it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
end
end

context 'when selecting passed value for Scientific Linux' do
Expand Down

0 comments on commit 18cac85

Please sign in to comment.