Skip to content

Support Debian 12 and refactor to make that easier #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 1, 2024
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
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