Use patched nebula os package gradle plugin (#100280)

There is a bug in the nebula os package gradle plugin that breaks copy spec specific setgid handling.
We have created a patch for the plugin that we use for now to unblock us. This will be ported upstream
to the nebula main branch and part of a release but that requires some more polishing and will
be taken care of in a later PR
This commit is contained in:
Rene Groeschke 2023-10-05 07:59:10 +02:00 committed by GitHub
parent 9f72ce0278
commit d214d74000
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 19 deletions

View file

@ -42,10 +42,20 @@ import java.util.regex.Pattern
* dpkg -c path/to/elasticsearch.deb
*/
plugins {
id "com.netflix.nebula.ospackage-base" version "11.5.0"
buildscript {
repositories {
maven {
url 'https://jitpack.io'
}
mavenCentral()
}
dependencies {
classpath "com.github.breskeby:gradle-ospackage-plugin:2da19425133"
}
}
apply plugin: "com.netflix.nebula.ospackage-base"
['deb', 'rpm'].each { type ->
String packagingFiles = "build/packaging/${type}"
@ -56,14 +66,14 @@ plugins {
with copySpec {
from 'src/common'
from "src/${type}"
filter("tokens" : expansionsForDistribution(type, false), ReplaceTokens.class)
filter("tokens": expansionsForDistribution(type, false), ReplaceTokens.class)
}
into('etc/elasticsearch') {
with configFiles(type, false)
}
filter("tokens" : expansionsForDistribution(type, false), ReplaceTokens.class)
filter("tokens": expansionsForDistribution(type, false), ReplaceTokens.class)
doLast {
// create empty dirs, we set the permissions when configuring the packages
@ -92,22 +102,22 @@ def commonPackageConfig(String type, String architecture) {
if (architecture == 'x64') {
arch('amd64')
} else {
assert architecture == 'aarch64' : architecture
assert architecture == 'aarch64': architecture
arch('arm64')
}
} else {
assert type == 'rpm' : type
assert type == 'rpm': type
if (architecture == 'x64') {
arch('X86_64')
} else {
assert architecture == 'aarch64' : architecture
assert architecture == 'aarch64': architecture
arch('aarch64')
}
}
// Follow elasticsearch's file naming convention
String prefix = "${architecture == 'aarch64' ? 'aarch64-' : ''}${type}"
destinationDirectory = file("${prefix}/build/distributions")
archiveFileName.value(project.provider({ "${packageName}-${project.version}-${archString}.${type}" } ))
archiveFileName.value(project.provider({ "${packageName}-${project.version}-${archString}.${type}" }))
String packagingFiles = "build/packaging/${type}"
String scripts = "${packagingFiles}/scripts"
@ -184,9 +194,9 @@ def commonPackageConfig(String type, String architecture) {
configurationFile '/etc/elasticsearch/users_roles'
from("${packagingFiles}") {
dirMode 02750
setgid = true
into('/etc')
permissionGroup 'elasticsearch'
setgid true
includeEmptyDirs true
createDirectoryEntry true
include("elasticsearch") // empty dir, just to add directory entry
@ -243,7 +253,7 @@ def commonPackageConfig(String type, String architecture) {
user u
permissionGroup g
dirMode = mode
setgid = mode == 02750
setgid (mode == 02750)
}
}
copyEmptyDir('/var/log/elasticsearch', 'elasticsearch', 'elasticsearch', 02750)
@ -402,7 +412,7 @@ subprojects {
} else {
assert project.name.contains('rpm')
tasks.named("checkExtraction").configure {
onlyIf("rpm exists", rpmExists)
onlyIf("rpm exists", rpmExists)
final File rpmDatabase = new File(extractionDir, 'rpm-database')
commandLine 'rpm',
'--badreloc',
@ -434,9 +444,11 @@ subprojects {
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/",
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)
"License: " + expectedLicense
)
final List<String> licenseLines = Files.readAllLines(rootDir.toPath().resolve("licenses/" + licenseFilename))
final List<String> expectedLines = header + licenseLines.collect { " " + it }
assertLinesInFile(copyrightPath, expectedLines)