-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pakage Corretto generic linux as deb.
- Loading branch information
Showing
5 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,9 @@ allprojects { | |
maintainer: 'Amazon Corretto Team <[email protected]>', | ||
buildHost : 'build.amazon.com' | ||
] | ||
jdkTools = ['java', 'keytool', 'rmid', 'rmiregistry', 'jjs', 'pack200', 'unpack200', 'javac', 'jaotc', 'jlink', | ||
'jmod', 'jhsdb', 'jar', 'jarsigner', 'javadoc', 'javap', 'jcmd', 'jconsole', 'jdb', 'jdeps', 'jdeprscan', | ||
'jimage', 'jinfo', 'jmap', 'jps', 'jrunscript', 'jshell', 'jstack', 'jstat', 'jstatd', 'rmic', 'serialver'] | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright (c) 2019, Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Amazon designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
plugins { | ||
id 'nebula.ospackage' version '5.2.0' | ||
} | ||
|
||
dependencies { | ||
compile project(path: ':installers:linux:universal:tar', configuration: 'archives') | ||
} | ||
|
||
def jvmDir = '/usr/lib/jvm' | ||
def jdkInstallationDirName = "java-${project.version.major}-amazon-corretto" | ||
def jdkHome = "${jvmDir}/${jdkInstallationDirName}".toString() | ||
def jdkBinaryDir = "${buildRoot}/amazon-corretto-${project.version.full}-linux-x64" | ||
def jdkPackageName = "java-${project.version.major}-amazon-corretto-jdk" | ||
|
||
ospackage { | ||
// Valid version must start with a digit and only contain [A-Za-z0-9.+:~-] | ||
// See http://manpages.ubuntu.com/manpages/artful/en/man5/deb-version.5.html | ||
version project.version.upstream | ||
release project.version.revision | ||
|
||
url "${packageInfo.url}" | ||
vendor "${packageInfo.vendor}" | ||
packager "${packageInfo.packager}" | ||
license "${packageInfo.license}" | ||
buildHost "${packageInfo.buildHost}" | ||
maintainer "${packageInfo.maintainer}" | ||
packageGroup 'java' | ||
priority 'optional' | ||
user 'root' | ||
permissionGroup 'root' | ||
epoch 1 | ||
arch 'amd64' | ||
multiArch SAME | ||
} | ||
|
||
/** | ||
* Uncompress and copy the universal Corretto artifact | ||
* tar for DEB packaging. | ||
*/ | ||
task extractUniversalTar(type: Copy) { | ||
dependsOn project.configurations.compile | ||
from tarTree(project.configurations.compile.singleFile) | ||
into buildRoot | ||
} | ||
|
||
/** | ||
* Populate version numbers, java home and alternatives | ||
* priority to postin_jdk.sh.template and preun_jdk.sh.template. | ||
* Create script copies under build root scripts folder. | ||
*/ | ||
task inflateDebScriptTemplate(type: Copy) { | ||
dependsOn extractUniversalTar | ||
// In trusty repo, openjdk7 has priority 1071 and openjdk6 has 1061 | ||
// Corretto uses the same priority in both rpm and deb | ||
def priority = String.format("1%2s%2s%3s", project.version.major, project.version.minor, project.version.security).replace(' ', '0') | ||
from('scripts') { | ||
include '**/*.template' | ||
rename { file -> file.replace('.template', '') } | ||
filter(org.apache.tools.ant.filters.ReplaceTokens, | ||
tokens: project.version + [java_home: jdkHome, alternatives_priority: priority, | ||
jdk_tools: jdkTools.join(' ')]) | ||
} | ||
into "${buildRoot}/scripts" | ||
} | ||
|
||
/** | ||
* Generate DEB for JDK, with package published under | ||
* distributions folder. | ||
*/ | ||
task generateJdkDeb(type: Deb) { | ||
description 'Create the DEB package for Corretto JDK' | ||
dependsOn inflateDebScriptTemplate | ||
|
||
packageName jdkPackageName | ||
packageDescription "Amazon Corretto\'s packaging of the OpenJDK ${project.version.major} code." | ||
summary "Amazon Corretto ${project.version.major} development environment" | ||
|
||
postInstall file("$buildRoot/scripts/postin_jdk.sh") | ||
preUninstall file("$buildRoot/scripts/preun_jdk.sh") | ||
|
||
requires('java-common') | ||
provides('java-compiler') | ||
provides('java-runtime') | ||
provides('java-sdk') | ||
|
||
provides('java11-sdk') | ||
provides('java11-runtime') | ||
|
||
from(jdkBinaryDir) { | ||
into jdkHome | ||
} | ||
} | ||
|
||
artifacts { | ||
archives generateJdkDeb | ||
} |
19 changes: 19 additions & 0 deletions
19
installers/linux/universal/deb/scripts/postin_jdk.sh.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# postinst script for Corretto | ||
# | ||
# summary of how this script can be called: | ||
# * <postinst> `configure' <most-recently-configured-version> | ||
# for details, see https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or | ||
# the debian-policy package | ||
|
||
|
||
# Note that Nebula gradle-ospackage-plugin default and only support `configure` option for post installation script. | ||
|
||
for i in @jdk_tools@; do | ||
if [ -e @java_home@/bin/$i ]; then | ||
cmd="update-alternatives --install /usr/bin/$i $i @java_home@/bin/$i @alternatives_priority@" | ||
if [ -e @java_home@/man/man1/$i.1 ]; then | ||
cmd="$cmd --slave /usr/share/man/man1/$i.1 $i.1 @java_home@/man/man1/$i.1" | ||
fi | ||
$cmd | ||
fi | ||
done |
18 changes: 18 additions & 0 deletions
18
installers/linux/universal/deb/scripts/preun_jdk.sh.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# postrm script for Corretto | ||
# | ||
# summary of how this script can be called: | ||
# * <postrm> `remove' | ||
# for details, see https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or | ||
# the debian-policy package | ||
|
||
case "$1" in | ||
remove | deconfigure) | ||
for i in @jdk_tools@; do | ||
if [ -e @java_home@/bin/$i ]; then | ||
update-alternatives --remove $i @java_home@/bin/$i | ||
fi | ||
done | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters