summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-11-02 18:55:32 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-11-02 18:55:32 +0900
commit9870257fd81299c282f909d04b88d821f90b3743 (patch)
treec4b2f727e789f816eea13e4aed84f4896cfe2049
parent6c0fa8445b849680300d407efe8bca691d4e680e (diff)
downloadbuildstream-9870257fd81299c282f909d04b88d821f90b3743.tar.gz
plugins/sources/tar.py: Ignore possible leading '.' directory.
To extract the full tarball, one should set base-dir to an empty string. By ignoring the leading '.' in any archive, we make the 'base-dir' API more predictable and reliable - the default behavior of '*' is to pickup the first directory in the tarball (usually source code tarballs are encoded with one leading directory) - in the off chance that a source tarball has a leading '.' in it; that would cause the 'base-dir' default '*' glob to extract the whole thing. It seems undesirable to behave differently depending on whether a tarball was encoded with, or without a leading '.'
-rw-r--r--buildstream/plugins/sources/tar.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/buildstream/plugins/sources/tar.py b/buildstream/plugins/sources/tar.py
index bc2891e18..bf4a31da4 100644
--- a/buildstream/plugins/sources/tar.py
+++ b/buildstream/plugins/sources/tar.py
@@ -203,6 +203,12 @@ class TarSource(Source):
continue
+ # Avoid considering the '.' directory, if any is included in the archive
+ # this is to avoid the default 'base-dir: *' value behaving differently
+ # depending on whether the tarball was encoded with a leading '.' or not
+ elif member.name == '.':
+ continue
+
if dirs_only and not member.isdir():
continue