Fix extraction of notarized Elasticsearch release distribution (#49511)

This commit introduces a workaround for an issue related to our recent
notarization of distributions starting with the 6.8.5 release. An
unintended side effect of notarization was that the file entries of the
release tar all have a `./` prefix in the path. This causes a number of
issues, not least of which is that our Gradle extract tasks end up
copying an empty fileset to the destination directory. The workaround
here is imply to remove the leading `./` path segment from each file
when performing the extraction. For more details see this issue:
https://github.com/elastic/elasticsearch/issues/49417
This commit is contained in:
Mark Vieira 2019-11-22 17:19:47 -08:00 committed by GitHub
parent c9eba17517
commit 777f6d5da6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -35,12 +35,14 @@ import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.artifacts.repositories.IvyArtifactRepository;
import org.gradle.api.credentials.HttpHeaderCredentials;
import org.gradle.api.file.FileTree;
import org.gradle.api.file.RelativePath;
import org.gradle.api.plugins.ExtraPropertiesExtension;
import org.gradle.api.tasks.Sync;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.authentication.http.HttpHeaderAuthentication;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@ -145,6 +147,14 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
}
throw new IllegalStateException("unexpected file extension on [" + archivePath + "]");
});
// Workaround for https://github.com/elastic/elasticsearch/issues/49417
syncTask.eachFile(details -> {
String[] segments = details.getRelativePath().getSegments();
if (segments[0].equals(".")) {
details.setRelativePath(new RelativePath(true, Arrays.copyOfRange(segments, 1, segments.length)));
}
});
});
rootProject.getArtifacts().add(extractedConfigName,
rootProject.getLayout().getProjectDirectory().dir(extractDir),