Skip to content

Commit

Permalink
Fix extraction of notarized Elasticsearch release distribution (elast…
Browse files Browse the repository at this point in the history
…ic#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:
elastic#49417
  • Loading branch information
mark-vieira authored Nov 23, 2019
1 parent c9eba17 commit 777f6d5
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
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;
Expand Down Expand Up @@ -145,6 +147,14 @@ private void setupRootDownload(Project rootProject, ElasticsearchDistribution di
}
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),
Expand Down

0 comments on commit 777f6d5

Please sign in to comment.