From c15604f2b102617e2840f90d6a8d00d9193645d7 Mon Sep 17 00:00:00 2001 From: Andy Bristol Date: Thu, 19 Jul 2018 13:25:04 -0700 Subject: [PATCH] specify subdirs of lib, bin, modules in package 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. --- distribution/packages/build.gradle | 44 ++++++++++-------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/distribution/packages/build.gradle b/distribution/packages/build.gradle index 04fa6313c0a23..034c582652c50 100644 --- a/distribution/packages/build.gradle +++ b/distribution/packages/build.gradle @@ -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 } } } @@ -333,12 +323,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) } }