diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-11-17 17:32:52 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-11-17 17:32:52 +0900 |
commit | 28328cde18b14677030235baecea29e38900f75f (patch) | |
tree | 54e3cb1ed9d1101fb5eea2b5a2367c496ac319ed /buildstream/plugins/sources/tar.py | |
parent | 1e9207723ad5ad56731bd23eb696dfaf6e8af593 (diff) | |
download | buildstream-28328cde18b14677030235baecea29e38900f75f.tar.gz |
plugins/sources/tar.py: Consider link names in extraction
When extracting files from a base directory, we are normalizing
the TarInfo file names so we need to also normalize the link names
in the case of links and symlinks.
Fixes issue #155
Diffstat (limited to 'buildstream/plugins/sources/tar.py')
-rw-r--r-- | buildstream/plugins/sources/tar.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/buildstream/plugins/sources/tar.py b/buildstream/plugins/sources/tar.py index 6a6cdd330..a93183ab0 100644 --- a/buildstream/plugins/sources/tar.py +++ b/buildstream/plugins/sources/tar.py @@ -96,6 +96,19 @@ class TarSource(DownloadableFileSource): # Now extract only the paths which match the normalized path if member.path.startswith(base_dir): + + # If it's got a link name, give it the same treatment, we + # need the link targets to match up with what we are staging + # + # NOTE: Its possible this is not perfect, we may need to + # consider links which point outside of the chosen + # base directory. + # + if member.linkname: + if member.linkname.startswith('./'): + member.linkname = member.linkname[2:] + member.linkname = member.linkname[l:] + member.path = member.path[l:] yield member |