/* * Copyright 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 'latest.release' } dependencies { compile project(path: ':installers:linux:universal:tar', configuration: 'archives') } ext { switch (project.correttoArch) { case 'aarch64': arch_deb = 'arm64' break; case 'x86': arch_deb = "i386" break case 'x64': arch_deb = 'amd64' break } } def jvmDir = '/usr/lib/jvm' def jdkInstallationDirName = "java-${project.version.major}-amazon-corretto" def jdkHome = "${jvmDir}/${jdkInstallationDirName}".toString() def jdkBinaryDir = "${buildRoot}/${project.correttoJdkArchiveName}" def jdkPackageName = "java-${project.version.major}-amazon-corretto-jdk" def alternativesPriority = String.format("1%2s%2s%3s", project.version.major, project.version.minor, project.version.security).replace(' ', '0') def jinfoName = ".${jdkInstallationDirName}.jinfo" 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 arch_deb 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 = from('scripts') { include '**/*.template' rename { file -> file.replace('.template', '') } filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.version + [java_home: jdkHome, alternatives_priority: alternativesPriority, jdk_tools: jdkTools.join(' ')]) } into "${buildRoot}/scripts" } /** * Inflate jinfo file used by update-java-alternatives command. * Create script copy under buildRoot/jinfo folder. See * http://manpages.ubuntu.com/manpages/xenial/man8/update-java-alternatives.8.html#files */ task inflateJinfoTemplate(type: Copy) { from('jinfo') { include '**/*.template' rename('jinfo.template', jinfoName) filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.version + [java_home : jdkHome, alternatives_priority: alternativesPriority, directory_name: jdkInstallationDirName.toString()]) expand(jdk_tools: jdkTools) } into "${buildRoot}/jinfo" } /** * Generate DEB for JDK, with package published under * distributions folder. */ task generateJdkDeb(type: Deb) { description 'Create the DEB package for Corretto JDK' dependsOn inflateDebScriptTemplate dependsOn inflateJinfoTemplate 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') requires('zlib1g') // jdk provides('java-compiler') provides('java-sdk') provides('java5-sdk') provides('java6-sdk') provides('java7-sdk') provides('java7-jdk') provides('java8-jdk') provides('java11-sdk') 17.upto(project.version.major.toInteger()) { provides("java${it}-sdk") } // TODO: Move this to the jre when splitting the fat deb provides('java-runtime') provides('java5-runtime') provides('java6-runtime') provides('java7-runtime') provides('java8-runtime') provides('java11-runtime') 17.upto(project.version.major.toInteger()) { provides("java${it}-runtime") } // TODO: Move this to the headless jre when splitting the fat deb provides('java-runtime-headless') provides('java5-runtime-headless') provides('java6-runtime-headless') provides('java7-runtime-headless') provides('java8-runtime-headless') provides('java11-runtime-headless') 17.upto(project.version.major.toInteger()) { provides("java${it}-runtime-headless") } from(jdkBinaryDir) { include(project.configurationFiles) // Deb actually uses configuationFile and not fileType see https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/118#issuecomment-656004360 // Path must be the fully qualified install path configurationFile = project.configurationFiles.collect{ "${jdkHome}/${it}" }.join("\n") into jdkHome } from(jdkBinaryDir) { into jdkHome exclude 'legal' exclude(project.configurationFiles) } // Copy legal directory specifically to set permission correctly. // See https://github.com/corretto/corretto-11/issues/129 from("${jdkBinaryDir}/legal") { into "${jdkHome}/legal" fileMode 0444 } from("${buildRoot}/jinfo") { include '**/*.jinfo' into jvmDir } } artifacts { archives generateJdkDeb }