Skip to content

Commit

Permalink
specify subdirs of lib, bin, modules in package (#32253)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andyb-elastic authored Jul 23, 2018
1 parent 2632d1d commit 2329b52
Showing 1 changed file with 14 additions and 30 deletions.
44 changes: 14 additions & 30 deletions distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,32 +125,22 @@ Closure commonPackageConfig(String type, boolean oss) {
fileMode 0644
}
into('lib') {
with copySpec {
with libFiles
// we need to specify every intermediate directory so we iterate through the parents; duplicate calls with the same part are fine
eachFile { FileCopyDetails fcp ->
String[] segments = fcp.relativePath.segments
for (int i = segments.length - 2; i > 0 && segments[i] != 'lib'; --i) {
directory('/' + segments[0..i].join('/'), 0755)
}
fcp.mode = 0644
}
}
with libFiles
}
into('modules') {
with copySpec {
with modulesFiles(oss)
// we need to specify every intermediate directory so we iterate through the parents; duplicate calls with the same part are fine
eachFile { FileCopyDetails fcp ->
String[] segments = fcp.relativePath.segments
for (int i = segments.length - 2; i > 0 && segments[i] != 'modules'; --i) {
directory('/' + segments[0..i].join('/'), 0755)
}
if (segments[-2] == 'bin') {
fcp.mode = 0755
} else {
fcp.mode = 0644
}
with modulesFiles(oss)
}
// 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
// directory are fine
eachFile { FileCopyDetails fcp ->
String[] segments = fcp.relativePath.segments
for (int i = segments.length - 2; i > 2; --i) {
directory('/' + segments[0..i].join('/'), 0755)
if (segments[-2] == 'bin') {
fcp.mode = 0755
} else {
fcp.mode = 0644
}
}
}
Expand Down Expand Up @@ -334,12 +324,6 @@ Closure commonRpmConfig(boolean oss) {

// without this the rpm will have parent dirs of any files we copy in, eg /etc/elasticsearch
addParentDirs false

// Declare the folders so that the RPM package manager removes
// them when upgrading or removing the package
directory('/usr/share/elasticsearch/bin', 0755)
directory('/usr/share/elasticsearch/lib', 0755)
directory('/usr/share/elasticsearch/modules', 0755)
}
}

Expand Down

0 comments on commit 2329b52

Please sign in to comment.