Skip to content

Commit 1091ec1

Browse files
specify subdirs of lib, bin, modules in package (#32253)
Explicitly include all subdirectories of these folders in /usr/share/elasticsearch in package distributions so that they are managed by the package manager. This change does really have an effect in the 7.x series, where there are no subdirectories in bin, and we were already doing this in lib and modules. It does have an effect in the 6.x series where the bin/x-pack subdirectory was not previously tracked by the package manager and could be left behind on removal in rpm distributions.
1 parent 4804da0 commit 1091ec1

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

distribution/packages/build.gradle

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,32 +125,22 @@ Closure commonPackageConfig(String type, boolean oss) {
125125
fileMode 0644
126126
}
127127
into('lib') {
128-
with copySpec {
129-
with libFiles(oss)
130-
// we need to specify every intermediate directory so we iterate through the parents; duplicate calls with the same part are fine
131-
eachFile { FileCopyDetails fcp ->
132-
String[] segments = fcp.relativePath.segments
133-
for (int i = segments.length - 2; i > 0 && segments[i] != 'lib'; --i) {
134-
directory('/' + segments[0..i].join('/'), 0755)
135-
}
136-
fcp.mode = 0644
137-
}
138-
}
128+
with libFiles(oss)
139129
}
140130
into('modules') {
141-
with copySpec {
142-
with modulesFiles(oss)
143-
// we need to specify every intermediate directory so we iterate through the parents; duplicate calls with the same part are fine
144-
eachFile { FileCopyDetails fcp ->
145-
String[] segments = fcp.relativePath.segments
146-
for (int i = segments.length - 2; i > 0 && segments[i] != 'modules'; --i) {
147-
directory('/' + segments[0..i].join('/'), 0755)
148-
}
149-
if (segments[-2] == 'bin') {
150-
fcp.mode = 0755
151-
} else {
152-
fcp.mode = 0644
153-
}
131+
with modulesFiles(oss)
132+
}
133+
// we need to specify every intermediate directory in these paths so the package managers know they are explicitly
134+
// intended to manage them; otherwise they may be left behind on uninstallation. duplicate calls of the same
135+
// directory are fine
136+
eachFile { FileCopyDetails fcp ->
137+
String[] segments = fcp.relativePath.segments
138+
for (int i = segments.length - 2; i > 2; --i) {
139+
directory('/' + segments[0..i].join('/'), 0755)
140+
if (segments[-2] == 'bin') {
141+
fcp.mode = 0755
142+
} else {
143+
fcp.mode = 0644
154144
}
155145
}
156146
}
@@ -333,12 +323,6 @@ Closure commonRpmConfig(boolean oss) {
333323

334324
// without this the rpm will have parent dirs of any files we copy in, eg /etc/elasticsearch
335325
addParentDirs false
336-
337-
// Declare the folders so that the RPM package manager removes
338-
// them when upgrading or removing the package
339-
directory('/usr/share/elasticsearch/bin', 0755)
340-
directory('/usr/share/elasticsearch/lib', 0755)
341-
directory('/usr/share/elasticsearch/modules', 0755)
342326
}
343327
}
344328

0 commit comments

Comments
 (0)