Skip to content

Commit

Permalink
Use patched nebula os package gradle plugin (elastic#100280)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
breskeby authored Oct 5, 2023
1 parent 9f72ce0 commit d214d74
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
38 changes: 25 additions & 13 deletions distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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. <[email protected]>",
"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)
Expand Down
22 changes: 16 additions & 6 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<sha256 value="d083479ca927dce2f586f779373d895e8bf668c632505740279390384edf03fa" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.breskeby" name="gradle-ospackage-plugin" version="2da19425133">
<artifact name="gradle-ospackage-plugin-2da19425133.jar">
<sha256 value="452e01bc961259e2a0f5d6f193a03cc8d29f560a433f7c8066158c97d3327af9" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="adoptium_8" name="linux" version="8u302">
<artifact name="linux-8u302-aarch64.tar.gz">
<sha256 value="f287cdc2a688c2df247ea0d8bfe2863645b73848e4e5c35b02a8a3d2d6b69551" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -69,11 +74,11 @@
<sha256 value="10fe288fd7a2cdaf5175332b73529f9abf8fd54dcfff317d6967c0c35ffb133b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="co.elastic.apm" name="elastic-apm-agent" version="1.43.0">
<artifact name="elastic-apm-agent-1.43.0.jar">
<sha256 value="a9910a9589b2cceb9a41936e297bb41c6aeef5496f7ba26017ba489291aa4aa8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="co.elastic.apm" name="elastic-apm-agent" version="1.43.0">
<artifact name="elastic-apm-agent-1.43.0.jar">
<sha256 value="a9910a9589b2cceb9a41936e297bb41c6aeef5496f7ba26017ba489291aa4aa8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="co.elastic.logging" name="ecs-logging-core" version="1.2.0">
<artifact name="ecs-logging-core-1.2.0.jar">
<sha256 value="0d6318af29848ea588b1c244834e3e762315c68de2bcfc9f1adf3f0633d22d37" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -351,6 +356,11 @@
<sha256 value="d6eb9f2f40049a7a808baf11ffba0737648e62ff52fde9271d808e5d57a27279" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.breskeby" name="gradle-ospackage-plugin" version="2da19425133">
<artifact name="gradle-ospackage-plugin-2da19425133.jar">
<sha256 value="452e01bc961259e2a0f5d6f193a03cc8d29f560a433f7c8066158c97d3327af9" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.javaparser" name="javaparser-core" version="3.18.0">
<artifact name="javaparser-core-3.18.0.jar">
<sha256 value="df7e2d5b8319efd51d015ab5071a271f8463158bc2f0979d05393fe028d856a0" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -2614,7 +2624,7 @@
<sha256 value="82f63d40db2aad15f748bf988214d44477167ec1a0388dd258c4c8a8f74797d2" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.lucene" name="lucene-analysis-stempel" version="9.8.0">
<component group="org.apache.lucene" name="lucene-analysis-stempel" version="9.8.0">
<artifact name="lucene-analysis-stempel-9.8.0.jar">
<sha256 value="4ee9f4fccd710c8d51827b54747e4134f600fd00ad96ae9c3c6d97122807e18c" origin="Generated by Gradle"/>
</artifact>
Expand Down

0 comments on commit d214d74

Please sign in to comment.