|
@@ -46,24 +46,24 @@ plugins {
|
|
|
id "nebula.ospackage-base" version "8.6.1"
|
|
|
}
|
|
|
|
|
|
-void addProcessFilesTask(String type, boolean oss, boolean jdk) {
|
|
|
- String packagingFiles = "build/packaging/${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}"
|
|
|
+['deb', 'rpm'].each { type ->
|
|
|
+ String packagingFiles = "build/packaging/${type}"
|
|
|
|
|
|
- String taskName = "process${oss ? 'Oss' : ''}${jdk ? '' : 'NoJdk'}${type.capitalize()}Files"
|
|
|
+ String taskName = "process${type.capitalize()}Files"
|
|
|
tasks.register(taskName, Copy) {
|
|
|
into packagingFiles
|
|
|
|
|
|
with copySpec {
|
|
|
from 'src/common'
|
|
|
from "src/${type}"
|
|
|
- filter("tokens" : expansionsForDistribution(type, oss, jdk), ReplaceTokens.class)
|
|
|
+ filter("tokens" : expansionsForDistribution(type, false), ReplaceTokens.class)
|
|
|
}
|
|
|
|
|
|
into('etc/elasticsearch') {
|
|
|
- with configFiles(type, oss, jdk)
|
|
|
+ with configFiles(type, false)
|
|
|
}
|
|
|
|
|
|
- filter("tokens" : expansionsForDistribution(type, oss, jdk), ReplaceTokens.class)
|
|
|
+ filter("tokens" : expansionsForDistribution(type, false), ReplaceTokens.class)
|
|
|
|
|
|
doLast {
|
|
|
// create empty dirs, we set the permissions when configuring the packages
|
|
@@ -78,25 +78,16 @@ void addProcessFilesTask(String type, boolean oss, boolean jdk) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-addProcessFilesTask('deb', true, true)
|
|
|
-addProcessFilesTask('deb', true, false)
|
|
|
-addProcessFilesTask('deb', false, true)
|
|
|
-addProcessFilesTask('deb', false, false)
|
|
|
-addProcessFilesTask('rpm', true, true)
|
|
|
-addProcessFilesTask('rpm', true, false)
|
|
|
-addProcessFilesTask('rpm', false, true)
|
|
|
-addProcessFilesTask('rpm', false, false)
|
|
|
-
|
|
|
// Common configuration that is package dependent. This can't go in ospackage
|
|
|
// since we have different templated files that need to be consumed, but the structure
|
|
|
// is the same
|
|
|
-Closure commonPackageConfig(String type, boolean oss, boolean jdk, String architecture) {
|
|
|
+def commonPackageConfig(String type, String architecture) {
|
|
|
return {
|
|
|
onlyIf {
|
|
|
OS.current().equals(OS.WINDOWS) == false
|
|
|
}
|
|
|
- dependsOn "process${oss ? 'Oss' : ''}${jdk ? '' : 'NoJdk'}${type.capitalize()}Files"
|
|
|
- packageName "elasticsearch${oss ? '-oss' : ''}"
|
|
|
+ dependsOn "process${type.capitalize()}Files"
|
|
|
+ packageName "elasticsearch"
|
|
|
if (type == 'deb') {
|
|
|
if (architecture == 'x64') {
|
|
|
arch('amd64')
|
|
@@ -114,11 +105,10 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit
|
|
|
}
|
|
|
}
|
|
|
// Follow elasticsearch's file naming convention
|
|
|
- String jdkString = jdk ? "" : "no-jdk-"
|
|
|
- String prefix = "${architecture == 'aarch64' ? 'aarch64-' : ''}${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}"
|
|
|
+ String prefix = "${architecture == 'aarch64' ? 'aarch64-' : ''}${type}"
|
|
|
destinationDirectory = file("${prefix}/build/distributions")
|
|
|
- archiveFileName.value(project.provider({ "${packageName}-${project.version}-${jdkString}${archString}.${type}" } ))
|
|
|
- String packagingFiles = "build/packaging/${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}"
|
|
|
+ archiveFileName.value(project.provider({ "${packageName}-${project.version}-${archString}.${type}" } ))
|
|
|
+ String packagingFiles = "build/packaging/${type}"
|
|
|
|
|
|
String scripts = "${packagingFiles}/scripts"
|
|
|
preInstall file("${scripts}/preinst")
|
|
@@ -133,22 +123,20 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit
|
|
|
// specify it again explicitly for copying common files
|
|
|
into('/usr/share/elasticsearch') {
|
|
|
into('bin') {
|
|
|
- with binFiles(type, oss, jdk)
|
|
|
+ with binFiles(type, false)
|
|
|
}
|
|
|
from(rootProject.projectDir) {
|
|
|
include 'README.asciidoc'
|
|
|
fileMode 0644
|
|
|
}
|
|
|
into('lib') {
|
|
|
- with libFiles(oss)
|
|
|
+ with libFiles(false)
|
|
|
}
|
|
|
into('modules') {
|
|
|
with modulesFiles('linux-' + ((architecture == 'x64') ? 'x86_64' : architecture))
|
|
|
}
|
|
|
- if (jdk) {
|
|
|
- into('jdk') {
|
|
|
- with jdkFiles(project, 'linux', architecture)
|
|
|
- }
|
|
|
+ into('jdk') {
|
|
|
+ with jdkFiles(project, 'linux', architecture)
|
|
|
}
|
|
|
// we need to specify every intermediate directory in these paths so the package managers know they are explicitly
|
|
|
// intended to manage them; otherwise they may be left behind on uninstallation. duplicate calls of the same
|
|
@@ -178,7 +166,7 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit
|
|
|
assert type == 'rpm'
|
|
|
into('/usr/share/elasticsearch') {
|
|
|
from(rootProject.file('licenses')) {
|
|
|
- include oss ? 'SSPL-1.0+ELASTIC-LICENSE-2.0.txt' : 'ELASTIC-LICENSE-2.0.txt'
|
|
|
+ include 'ELASTIC-LICENSE-2.0.txt'
|
|
|
rename { 'LICENSE.txt' }
|
|
|
}
|
|
|
fileMode 0644
|
|
@@ -189,12 +177,10 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit
|
|
|
configurationFile '/etc/elasticsearch/elasticsearch.yml'
|
|
|
configurationFile '/etc/elasticsearch/jvm.options'
|
|
|
configurationFile '/etc/elasticsearch/log4j2.properties'
|
|
|
- if (oss == false) {
|
|
|
- configurationFile '/etc/elasticsearch/role_mapping.yml'
|
|
|
- configurationFile '/etc/elasticsearch/roles.yml'
|
|
|
- configurationFile '/etc/elasticsearch/users'
|
|
|
- configurationFile '/etc/elasticsearch/users_roles'
|
|
|
- }
|
|
|
+ configurationFile '/etc/elasticsearch/role_mapping.yml'
|
|
|
+ configurationFile '/etc/elasticsearch/roles.yml'
|
|
|
+ configurationFile '/etc/elasticsearch/users'
|
|
|
+ configurationFile '/etc/elasticsearch/users_roles'
|
|
|
from("${packagingFiles}") {
|
|
|
dirMode 02750
|
|
|
into('/etc')
|
|
@@ -213,7 +199,7 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit
|
|
|
createDirectoryEntry true
|
|
|
fileType CONFIG | NOREPLACE
|
|
|
}
|
|
|
- String envFile = expansionsForDistribution(type, oss, jdk)['path.env']
|
|
|
+ String envFile = expansionsForDistribution(type, false)['path.env']
|
|
|
configurationFile envFile
|
|
|
into(new File(envFile).getParent()) {
|
|
|
fileType CONFIG | NOREPLACE
|
|
@@ -261,10 +247,10 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit
|
|
|
copyEmptyDir('/usr/share/elasticsearch/plugins', 'root', 'root', 0755)
|
|
|
|
|
|
// the oss package conflicts with the default distribution and vice versa
|
|
|
- conflicts('elasticsearch' + (oss ? '' : '-oss'))
|
|
|
+ conflicts('elasticsearch-oss')
|
|
|
|
|
|
into '/usr/share/elasticsearch'
|
|
|
- with noticeFile(oss, jdk)
|
|
|
+ with noticeFile(false)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -300,17 +286,13 @@ ospackage {
|
|
|
into '/usr/share/elasticsearch'
|
|
|
}
|
|
|
|
|
|
-Closure commonDebConfig(boolean oss, boolean jdk, String architecture) {
|
|
|
+Closure commonDebConfig(String architecture) {
|
|
|
return {
|
|
|
- configure(commonPackageConfig('deb', oss, jdk, architecture))
|
|
|
+ configure(commonPackageConfig('deb', architecture))
|
|
|
|
|
|
// jdeb does not provide a way to set the License control attribute, and ospackage
|
|
|
// silently ignores setting it. Instead, we set the license as "custom field"
|
|
|
- if (oss) {
|
|
|
- customFields['License'] = 'ASL-2.0'
|
|
|
- } else {
|
|
|
- customFields['License'] = 'Elastic-License'
|
|
|
- }
|
|
|
+ customFields['License'] = 'Elastic-License'
|
|
|
|
|
|
archiveVersion = project.version.replace('-', '~')
|
|
|
packageGroup 'web'
|
|
@@ -323,46 +305,23 @@ Closure commonDebConfig(boolean oss, boolean jdk, String architecture) {
|
|
|
|
|
|
into('/usr/share/lintian/overrides') {
|
|
|
from('src/deb/lintian/elasticsearch')
|
|
|
- if (oss) {
|
|
|
- rename('elasticsearch', 'elasticsearch-oss')
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
tasks.register('buildAarch64Deb', Deb) {
|
|
|
- configure(commonDebConfig(false, true, 'aarch64'))
|
|
|
+ configure(commonDebConfig('aarch64'))
|
|
|
}
|
|
|
|
|
|
tasks.register('buildDeb', Deb) {
|
|
|
- configure(commonDebConfig(false, true, 'x64'))
|
|
|
-}
|
|
|
-
|
|
|
-tasks.register('buildAarch64OssDeb', Deb) {
|
|
|
- configure(commonDebConfig(true, true, 'aarch64'))
|
|
|
+ configure(commonDebConfig('x64'))
|
|
|
}
|
|
|
|
|
|
-tasks.register('buildOssDeb', Deb) {
|
|
|
- configure(commonDebConfig(true, true, 'x64'))
|
|
|
-}
|
|
|
-
|
|
|
-tasks.register('buildNoJdkDeb', Deb) {
|
|
|
- configure(commonDebConfig(false, false, 'x64'))
|
|
|
-}
|
|
|
-
|
|
|
-tasks.register('buildOssNoJdkDeb', Deb) {
|
|
|
- configure(commonDebConfig(true, false, 'x64'))
|
|
|
-}
|
|
|
-
|
|
|
-Closure commonRpmConfig(boolean oss, boolean jdk, String architecture) {
|
|
|
+Closure commonRpmConfig(String architecture) {
|
|
|
return {
|
|
|
- configure(commonPackageConfig('rpm', oss, jdk, architecture))
|
|
|
+ configure(commonPackageConfig('rpm', architecture))
|
|
|
|
|
|
- if (oss) {
|
|
|
- license 'ASL 2.0'
|
|
|
- } else {
|
|
|
- license 'Elastic License'
|
|
|
- }
|
|
|
+ license 'Elastic License'
|
|
|
|
|
|
packageGroup 'Application/Internet'
|
|
|
requires '/bin/bash'
|
|
@@ -384,27 +343,11 @@ Closure commonRpmConfig(boolean oss, boolean jdk, String architecture) {
|
|
|
}
|
|
|
|
|
|
tasks.register('buildAarch64Rpm', Rpm) {
|
|
|
- configure(commonRpmConfig(false, true, 'aarch64'))
|
|
|
+ configure(commonRpmConfig('aarch64'))
|
|
|
}
|
|
|
|
|
|
tasks.register('buildRpm', Rpm) {
|
|
|
- configure(commonRpmConfig(false, true, 'x64'))
|
|
|
-}
|
|
|
-
|
|
|
-tasks.register('buildAarch64OssRpm', Rpm) {
|
|
|
- configure(commonRpmConfig(true, true, 'aarch64'))
|
|
|
-}
|
|
|
-
|
|
|
-tasks.register('buildOssRpm', Rpm) {
|
|
|
- configure(commonRpmConfig(true, true, 'x64'))
|
|
|
-}
|
|
|
-
|
|
|
-tasks.register('buildNoJdkRpm', Rpm) {
|
|
|
- configure(commonRpmConfig(false, false, 'x64'))
|
|
|
-}
|
|
|
-
|
|
|
-tasks.register('buildOssNoJdkRpm', Rpm) {
|
|
|
- configure(commonRpmConfig(true, false, 'x64'))
|
|
|
+ configure(commonRpmConfig('x64'))
|
|
|
}
|
|
|
|
|
|
Closure dpkgExists = { it -> new File('/bin/dpkg-deb').exists() || new File('/usr/bin/dpkg-deb').exists() || new File('/usr/local/bin/dpkg-deb').exists() }
|
|
@@ -481,15 +424,9 @@ subprojects {
|
|
|
Path copyrightPath
|
|
|
String expectedLicense
|
|
|
String licenseFilename
|
|
|
- if (project.name.contains('oss-')) {
|
|
|
- copyrightPath = packageExtractionDir.toPath().resolve("usr/share/doc/elasticsearch-oss/copyright")
|
|
|
- expectedLicense = "ASL-2.0"
|
|
|
- licenseFilename = "SSPL-1.0+ELASTIC-LICENSE-2.0.txt"
|
|
|
- } else {
|
|
|
- copyrightPath = packageExtractionDir.toPath().resolve("usr/share/doc/elasticsearch/copyright")
|
|
|
- expectedLicense = "Elastic-License"
|
|
|
- licenseFilename = "ELASTIC-LICENSE-2.0.txt"
|
|
|
- }
|
|
|
+ copyrightPath = packageExtractionDir.toPath().resolve("usr/share/doc/elasticsearch/copyright")
|
|
|
+ expectedLicense = "Elastic-License"
|
|
|
+ licenseFilename = "ELASTIC-LICENSE-2.0.txt"
|
|
|
final List<String> header = Arrays.asList("Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/",
|
|
|
"Copyright: Elasticsearch B.V. <info@elastic.co>",
|
|
|
"License: " + expectedLicense)
|
|
@@ -504,11 +441,7 @@ subprojects {
|
|
|
onlyIf rpmExists
|
|
|
doLast {
|
|
|
String licenseFilename
|
|
|
- if (project.name.contains('oss-')) {
|
|
|
- licenseFilename = "SSPL-1.0+ELASTIC-LICENSE-2.0.txt"
|
|
|
- } else {
|
|
|
- licenseFilename = "ELASTIC-LICENSE-2.0.txt"
|
|
|
- }
|
|
|
+ licenseFilename = "ELASTIC-LICENSE-2.0.txt"
|
|
|
final List<String> licenseLines = Files.readAllLines(rootDir.toPath().resolve("licenses/" + licenseFilename))
|
|
|
final Path licensePath = packageExtractionDir.toPath().resolve("usr/share/elasticsearch/LICENSE.txt")
|
|
|
assertLinesInFile(licensePath, licenseLines)
|
|
@@ -544,11 +477,7 @@ subprojects {
|
|
|
exec.standardOutput = output
|
|
|
doLast {
|
|
|
String expectedLicense
|
|
|
- if (project.name.contains('oss-')) {
|
|
|
- expectedLicense = "ASL-2.0"
|
|
|
- } else {
|
|
|
- expectedLicense = "Elastic-License"
|
|
|
- }
|
|
|
+ expectedLicense = "Elastic-License"
|
|
|
final Pattern pattern = Pattern.compile("\\s*License: (.+)")
|
|
|
final String info = output.toString('UTF-8')
|
|
|
final String[] actualLines = info.split("\n")
|
|
@@ -581,11 +510,7 @@ subprojects {
|
|
|
doLast {
|
|
|
String license = output.toString('UTF-8')
|
|
|
String expectedLicense
|
|
|
- if (project.name.contains('oss-')) {
|
|
|
- expectedLicense = "ASL 2.0"
|
|
|
- } else {
|
|
|
- expectedLicense = "Elastic License"
|
|
|
- }
|
|
|
+ expectedLicense = "Elastic License"
|
|
|
if (license != expectedLicense) {
|
|
|
throw new GradleException("expected license [${expectedLicense}] for [${-> buildDist.get().outputs.files.singleFile}] but was [${license}]")
|
|
|
}
|