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

Commit ee12128

Browse files
committed
v1.1.1
* Add parameters validation * Updated documentation * Minor refactoring
1 parent 422f9b7 commit ee12128

File tree

4 files changed

+45
-32
lines changed

4 files changed

+45
-32
lines changed

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
###1.1.0
1+
###1.1.1
2+
3+
* Add parameters validation
4+
* Updated documentation
5+
* Minor refactoring
26

3-
Support release
7+
###1.1.0
48

59
* Add support for Java SE 6 series
610

711
###1.0.1
812

9-
Support release
10-
1113
* Add support for Java '7u65' and '8u11'
1214

1315
###1.0.0

Modulefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name 'aco-oracle_java'
2-
version '1.1.0'
2+
version '1.1.1'
33
source 'git://github.com/tOnI0/aco-oracle_java.git'
44
author 'Antoine Cotten'
55
license 'Apache License, Version 2.0'

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ The oracle_java module allows you to install the Oracle JRE or JDK of your choic
1616

1717
##Module description
1818

19-
Oracle provides a RPM version of both its JRE and JDK for every Java release. These packages 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. This module simply downloads the desired Java version and installs it on the target system. It is especially intended for systems which do not need to have several Java versions installed in parallel and for users looking for an easy way to update their Java environment.
19+
Oracle provides a RPM version of both its JRE and JDK for every Java release. These packages 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.
20+
This module simply downloads the desired Java version and installs it on the target system. It is especially intended for systems which do not need to have several Java versions installed in parallel and for users looking for an easy way to update their Java environment.
21+
It currently supports all released versions from Java SE 6 on.
2022

2123
##Setup
2224

2325
oracle_java will affect the following parts of your system:
2426

2527
* jre/jdk package
28+
* 'java' alternative
2629

2730
Including the main class is enough to install the latest version of the Oracle JRE.
2831

@@ -86,6 +89,7 @@ This module relies almost entirely on all the nice information found on [Ivan Dy
8689

8790
##To Do
8891

92+
* Add Oracle Java as a 'java' alternative (will craft a dedicated module for that purpose)
8993
* Allow the manipulation of Java related environment variables
9094
* Propose an alternative based on tar.gz archives, also available from Oracle's archives
9195

manifests/init.pp

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# === Requires
1717
#
1818
# - puppetlabs/stdlib module
19+
# - 'wget' and 'sed' packages
1920
#
2021
# === Sample Usage:
2122
#
@@ -25,12 +26,9 @@
2526
# }
2627
#
2728
class oracle_java ($version = '8', $type = 'jre') {
28-
# translate system architecture to expected value
29-
case $::architecture {
30-
'x86_64' : { $arch = 'x64' }
31-
'x86' : { $arch = 'i586' }
32-
default : { fail("Unsupported architecture ${arch}") }
33-
}
29+
# parameters validation
30+
validate_re($version, '^([0-9]|[0-9]u[0-9][0-9])$', '$version must be formated as \'major\'u\'minor\' or just \'major\'')
31+
validate_re($type, '^(jre|jdk)$', '$type must be either \'jre\' or \'jdk\'')
3432

3533
# set to latest release if no minor version was provided
3634
if $version == '8' {
@@ -55,7 +53,7 @@
5553
'11' : { $build = '-b12' }
5654
'5' : { $build = '-b13' }
5755
'0' : { $build = '-b132' }
58-
default : { fail("Unexisting update number ${min_version}") }
56+
default : { fail("Unexisting Java SE ${maj_version} update number ${min_version}") }
5957
}
6058
}
6159
7 : {
@@ -82,7 +80,7 @@
8280
'2' : { $build = '-b13' }
8381
'1' : { $build = '-b08' }
8482
'0' : { $build = '' }
85-
default : { fail("Unexisting update number ${min_version}") }
83+
default : { fail("Unexisting Java SE ${maj_version} update number ${min_version}") }
8684
}
8785
}
8886
6 : {
@@ -126,29 +124,31 @@
126124
'2' : { $build = '' }
127125
'1' : { $build = '' }
128126
'0' : { $build = '' }
129-
default : { fail("Unexisting update number ${min_version}") }
127+
default : { fail("Unexisting Java SE ${maj_version} update number ${min_version}") }
130128
}
131129
}
132130
default : {
133-
fail("Unsupported or unexisting version ${version}")
131+
fail("oracle_java module does not support Java SE version ${maj_version} (yet)")
134132
}
135133
}
136134

137135
# remove extra particle if minor version is 0
138136
$version_final = delete($version_real, 'u0')
139137

138+
# translate system architecture to expected value
139+
case $::architecture {
140+
'x86_64' : { $arch = 'x64' }
141+
'x86' : { $arch = 'i586' }
142+
default : { fail("oracle_java does not support architecture ${arch} (yet)") }
143+
}
144+
140145
# define installer filename and download URL
141146
$filename = $maj_version ? {
142147
'6' => "${type}-${version_final}-linux-${arch}-rpm.bin",
143148
default => "${type}-${version_final}-linux-${arch}.rpm"
144149
}
145150
$downloadurl = "http://download.oracle.com/otn-pub/java/jdk/${version_final}${build}/${filename}"
146151

147-
# required packages
148-
if !defined(Package['wget']) {
149-
package { 'wget': ensure => present }
150-
}
151-
152152
# make sure install/download directory exists
153153
file { '/usr/java':
154154
ensure => directory,
@@ -177,17 +177,13 @@
177177
}
178178
# the procedure is a bit more complicated for older versions...
179179
# RPM files are packaged into a BIN archive which needs to be extracted
180-
else {
181-
# sed is required
182-
if !defined(Package['sed']) {
183-
package { 'sed': ensure => present }
184-
}
185-
180+
else {
186181
# translate system architecture one more time
187182
$arch_final = $::architecture ? {
188183
'x86_64' => 'amd64',
189184
default => $arch
190185
}
186+
191187
# the extracted file includes the 'new' arch string
192188
$filename_extract = "${type}-${version_final}-linux-${arch_final}.rpm"
193189

@@ -197,17 +193,28 @@
197193
creates => "/usr/java/${filename_extract}",
198194
command => "sed -ni '/exit 0/,\${//!p}' ${filename}; chmod +x ${filename}; ./${filename}",
199195
require => [Package['sed'], Exec['downloadRPM']]
200-
} ->
201-
package { $type:
202-
ensure => latest,
203-
source => "/usr/java/${filename_extract}",
204-
provider => rpm
205196
} ~>
197+
# remove undesired extra RPMs
206198
exec { 'cleanupRPM':
207199
path => '/bin',
208200
cwd => '/usr/java',
209201
refreshonly => true,
210202
command => 'rm -f sun-javadb-*.rpm'
203+
} ->
204+
package { $type:
205+
ensure => latest,
206+
source => "/usr/java/${filename_extract}",
207+
provider => rpm
208+
}
209+
}
210+
211+
# define required packages, they are be required by exec resources
212+
if !defined(Package['wget']) {
213+
package { 'wget': ensure => present }
214+
}
215+
if $maj_version < 7 {
216+
if !defined(Package['sed']) {
217+
package { 'sed': ensure => present }
211218
}
212219
}
213220
}

0 commit comments

Comments
 (0)