Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 84a2725

Browse files
committed
v2.1.0
* Added checksum check on downloaded archive * New `check_checksum` parameter * Refactoring * Better support of Mageia Linux
1 parent 371da7f commit 84a2725

File tree

10 files changed

+277
-214
lines changed

10 files changed

+277
-214
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
###2.1.0
2+
3+
* Added checksum check on downloaded archive
4+
* Java 7u60+ only for now. Contact me if you want to **HELP** me supporting older versions :)
5+
* New `check_checksum` parameter
6+
* Refactoring
7+
* Better support of Mageia Linux
8+
19
###2.0.0
210

311
* Support tar.gz format

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This module downloads the desired Java version from Oracle's website and install
2020

2121
Java SE archives are available from the Oracle [Java SE Downloads](http://www.oracle.com/technetwork/java/javase/downloads/index.html) and Oracle [Java Archive](http://www.oracle.com/technetwork/java/archive-139210.html) pages.
2222

23-
This module is suitable for pretty much any Linux system. It currently supports all released versions from Java SE 7 on.
23+
This module is suitable for pretty much any Linux system. It currently supports all released Java SE versions from JSE 7 on.
2424

2525
##Setup
2626

@@ -70,6 +70,15 @@ class { '::oracle_java':
7070
}
7171
```
7272

73+
Disable checksum validation
74+
75+
```puppet
76+
class { '::oracle_java':
77+
78+
check_checksum => false
79+
}
80+
```
81+
7382
##Usage
7483

7584
####Class: `oracle_java`
@@ -92,9 +101,12 @@ What envionment type to install. Valid values are 'jre' and 'jdk'. Defaults to '
92101

93102
What format of installation archive to retrieve. Valid values are 'rpm' and 'tar.gz'. Default depends on the platform
94103

104+
#####`check_checksum`
105+
Enable checksum validation on downloaded archives. Boolean value. Defaults to 'true'
106+
95107
##Limitations
96108

97-
* Prior to Java 8u20, two different releases of the same Java series could not cohabit on the same system when installed from RPM. Each new version would override the previous one. This does not happen with tar.gz archives.
109+
* Prior to Java 8u20, two different releases of the same Java series could not cohabit on the same system when installed from RPM. Each new version would override the previous one. This does not happen with tar.gz archives however.
98110

99111
##Credits
100112

manifests/checksums.pp

Lines changed: 162 additions & 159 deletions
Large diffs are not rendered by default.

manifests/download.pp

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,52 @@
11
# == Class: oracle_java::download
2+
#
3+
# This class is used to download and check the appropriate Java archive file
4+
#
25
class oracle_java::download {
36
# The base class must be included first
47
if !defined(Class['oracle_java']) {
58
fail('You must include the oracle_java base class before using any oracle_java sub class')
69
}
710

8-
# get checksums list
9-
include oracle_java::checksums
10-
1111
# make sure install/download directory exists
1212
file { '/usr/java':
1313
ensure => directory,
1414
mode => '0755',
1515
owner => 'root',
1616
group => 'root'
17-
} ->
17+
}
18+
19+
# get checksums list
20+
include oracle_java::checksums
21+
1822
# download archive
19-
archive { "/usr/java/${oracle_java::filename}":
20-
cookie => "oraclelicense=accept-securebackup-cookie",
21-
source => $oracle_java::downloadurl,
22-
checksum => $oracle_java::checksums::checksum,
23-
checksum_type => 'md5',
24-
cleanup => false
23+
# WITH checksum check
24+
if $oracle_java::check_checksum {
25+
# TEMPORARY CONDITIONAL BLOCK, until I finally gather checksums for all supported Java versions
26+
if $oracle_java::maj_version == '8' or ($oracle_java::maj_version == '7' and $oracle_java::min_version >= '60') {
27+
archive { "/usr/java/${oracle_java::filename}":
28+
cookie => "oraclelicense=accept-securebackup-cookie",
29+
source => $oracle_java::downloadurl,
30+
checksum => $oracle_java::checksums::checksum,
31+
checksum_type => 'md5',
32+
cleanup => false,
33+
require => File['/usr/java']
34+
}
35+
} else {
36+
archive { "/usr/java/${oracle_java::filename}":
37+
cookie => "oraclelicense=accept-securebackup-cookie",
38+
source => $oracle_java::downloadurl,
39+
cleanup => false,
40+
require => File['/usr/java']
41+
}
42+
}
43+
} else {
44+
# WITHOUT checksum check
45+
archive { "/usr/java/${oracle_java::filename}":
46+
cookie => "oraclelicense=accept-securebackup-cookie",
47+
source => $oracle_java::downloadurl,
48+
cleanup => false,
49+
require => File['/usr/java']
50+
}
2551
}
2652
}

manifests/init.pp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# envionment type to install (valid: 'jre'|'jdk')
1111
# [*format*]
1212
# archive format (valid: 'rpm'|'tar.gz')
13+
# [*check_checksum*]
14+
# enable checksum validation on downloaded archives (boolean)
1315
#
1416
# === Actions:
1517
#
@@ -29,11 +31,12 @@
2931
# format => 'rpm'
3032
# }
3133
#
32-
class oracle_java ($version = '8', $type = 'jre', $format = undef) {
34+
class oracle_java ($version = '8', $type = 'jre', $format = undef, $check_checksum = true) {
3335
if !$format {
34-
case $::osfamily {
35-
/RedHat|Suse/ : { $format_real = 'rpm' }
36-
default : { $format_real = 'tar.gz' }
36+
if $::osfamily =~ /RedHat|Suse/ or $::operatingsystem == 'Mageia' {
37+
$format_real = 'rpm'
38+
} else {
39+
$format_real = 'tar.gz'
3740
}
3841
} else {
3942
$format_real = $format
@@ -43,6 +46,7 @@
4346
validate_re($version, '^([0-9]|[0-9]u[0-9]{1,2})$', '$version must be formated as \'major\'u\'minor\' or just \'major\'')
4447
validate_re($type, '^(jre|jdk)$', '$type must be either \'jre\' or \'jdk\'')
4548
validate_re($format_real, '^(rpm|tar\.gz)$', '$format must be either \'rpm\' or \'tar.gz\'')
49+
validate_bool($check_checksum)
4650

4751
# set to latest release if no minor version was provided
4852
if $version == '8' {
@@ -52,33 +56,42 @@
5256
} else {
5357
$version_real = $version
5458
}
55-
59+
5660
# translate system architecture to expected value
5761
case $::architecture {
5862
/x86_64|amd64/ : { $arch = 'x64' }
5963
'x86' : { $arch = 'i586' }
6064
default : { fail("oracle_java does not support architecture ${::architecture} (yet)") }
6165
}
6266

63-
# determine build numbers, checksums, etc.
64-
include oracle_java::javalist
67+
# get major/minor version numbers
68+
$array_version = split($version_real, 'u')
69+
$maj_version = $array_version[0]
70+
$min_version = $array_version[1]
71+
72+
# remove extra particle if minor version is 0
73+
$version_final = delete($oracle_java::version_real, 'u0')
74+
$longversion = $min_version ? {
75+
'0' => "${oracle_java::type}1.${maj_version}.0",
76+
/^[0-9]$/ => "${oracle_java::type}1.${maj_version}.0_0${min_version}",
77+
default => "${oracle_java::type}1.${maj_version}.0_${min_version}"
78+
}
6579

66-
# define installer filename and download URL
67-
$filename = "${type}-${oracle_java::javalist::version_final}-linux-${arch}.${format_real}"
68-
$downloadurl = "http://download.oracle.com/otn-pub/java/jdk/${oracle_java::javalist::version_final}${oracle_java::javalist::build}/${filename}"
80+
# define installer filename
81+
$filename = "${type}-${version_final}-linux-${arch}.${format_real}"
82+
83+
# define download URL
84+
include oracle_java::javalist
85+
$downloadurl = "http://download.oracle.com/otn-pub/java/jdk/${version_final}${oracle_java::javalist::build}/${filename}"
6986

7087
# define package name
71-
if $oracle_java::javalist::maj_version == '8' and $oracle_java::javalist::min_version >= '20' {
72-
$packagename = $oracle_java::javalist::longversion
88+
if $maj_version == '8' and $min_version >= '20' {
89+
$packagename = $longversion
7390
} else {
7491
$packagename = $type
7592
}
7693

77-
# include classes as required
78-
if !defined(Class['archive']) {
79-
include archive
80-
}
81-
94+
# annnnd... let's go
8295
include oracle_java::download
8396
include oracle_java::install
8497
Class['oracle_java::download'] ~> Class['oracle_java::install']

manifests/install.pp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# == Class: oracle_java::install
2+
#
3+
# This class is a wrapper to either install or extract the downloaded Java archive file
4+
#
25
class oracle_java::install {
36
# The base class must be included first
47
if !defined(Class['oracle_java']) {
58
fail('You must include the oracle_java base class before using any oracle_java sub class')
69
}
710

11+
# dependency
12+
if !defined(Class['archive']) {
13+
include archive
14+
}
15+
816
case $oracle_java::format_real {
917
'rpm' : { contain oracle_java::install::rpm }
1018
'tar.gz' : { contain oracle_java::install::targz }

manifests/install/rpm.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# == Class: oracle_java::install::rpm
2+
#
3+
# This class is used to install the RPM version of Java
4+
#
25
class oracle_java::install::rpm {
36
# The base class must be included first
47
if !defined(Class['oracle_java']) {

manifests/install/targz.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# == Class: oracle_java::install::targz
2+
#
3+
# This class is used to extract the tar.gz version of Java
4+
#
25
class oracle_java::install::targz {
36
# The base class must be included first
47
if !defined(Class['oracle_java']) {

manifests/javalist.pp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# == Class: oracle_java::javalist
2+
#
3+
# This class associates a Java version number with its build number
4+
#
25
class oracle_java::javalist {
3-
# get major/minor version numbers
4-
$array_version = split($oracle_java::version_real, 'u')
5-
$maj_version = $array_version[0]
6-
$min_version = $array_version[1]
7-
86
# associate build number to release version
9-
case $maj_version {
7+
case $oracle_java::maj_version {
108
8 : {
11-
case $min_version {
9+
case $oracle_java::min_version {
1210
'25' : { $build = '-b17' }
1311
'20' : { $build = '-b26' }
1412
'11' : { $build = '-b12' }
@@ -18,7 +16,7 @@
1816
}
1917
}
2018
7 : {
21-
case $min_version {
19+
case $oracle_java::min_version {
2220
'72' : { $build = '-b14' }
2321
'71' : { $build = '-b14' }
2422
'67' : { $build = '-b01' }
@@ -48,15 +46,7 @@
4846
}
4947
}
5048
default : {
51-
fail("oracle_java module does not support Java SE version ${maj_version} (yet)")
49+
fail("oracle_java module does not support Java SE version ${oracle_java::maj_version} (yet)")
5250
}
5351
}
54-
55-
# remove extra particle if minor version is 0
56-
$version_final = delete($oracle_java::version_real, 'u0')
57-
$longversion = $min_version ? {
58-
'0' => "${oracle_java::type}1.${maj_version}.0",
59-
/^[0-9]$/ => "${oracle_java::type}1.${maj_version}.0_0${min_version}",
60-
default => "${oracle_java::type}1.${maj_version}.0_${min_version}"
61-
}
6252
}

metadata.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"project_page": "https://github.com/tOnI0/aco-oracle_java",
66
"source": "git://github.com/tOnI0/aco-oracle_java.git",
77
"summary": "Puppet module to install Oracle Java on Linux systems",
8-
"version": "2.0.0",
9-
"tags": ["rpm","jre","jdk","oracle","java"],
8+
"version": "2.1.0",
9+
"tags": ["jre","jdk","oracle","java"],
1010
"dependencies": [
1111
{
1212
"name": "puppetlabs/stdlib",
@@ -125,13 +125,10 @@
125125
]
126126
},
127127
{
128-
"operatingsystem": "Mageia"
129-
},
130-
{
131-
"operatingsystem": "Mandriva"
132-
},
133-
{
134-
"operatingsystem": "Mandrake"
128+
"operatingsystem": "Mageia",
129+
"operatingsystemrelease": [
130+
"4"
131+
]
135132
}
136133
]
137134
}

0 commit comments

Comments
 (0)