summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2020-07-08 20:18:20 +0000
committerBenjamin Schubert <contact@benschubert.me>2020-07-08 20:55:42 +0000
commitdf201d0c6b4e1838ce34fcf78382098e7c557132 (patch)
treecbfb43ed7b04a6cad4b941cd3f0b54e93920da25
parent99d827faad1d38e85532e056561a967636cfc4b5 (diff)
downloadbuildstream-bschubert/tar-filter-nondev.tar.gz
tar.py: Don't import 'dev' nodesbschubert/tar-filter-nondev
This filters out all the 'dev' nodes when extracting tar files since they are not supported by any of our backends anyways
-rw-r--r--NEWS4
-rw-r--r--src/buildstream/plugins/sources/tar.py11
2 files changed, 13 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index f82483e6e..8c97dc6e0 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,10 @@ CLI
o Add `bst source push` subcommand. This command pushes element sources to a
remote source cache.
+Plugins
+-------
+
+ o tar: filter out 'dev' nodes from the tar archives when extracting them
==================
buildstream 1.93.4
diff --git a/src/buildstream/plugins/sources/tar.py b/src/buildstream/plugins/sources/tar.py
index aba927b99..f9df802a7 100644
--- a/src/buildstream/plugins/sources/tar.py
+++ b/src/buildstream/plugins/sources/tar.py
@@ -133,10 +133,17 @@ class TarSource(DownloadableFileSource):
if self.base_dir:
base_dir = self._find_base_dir(tar, self.base_dir)
+ def filter_non_dev(tarfiles):
+ for file in tarfiles:
+ if not file.isdev():
+ yield file
+
if base_dir:
- tar.extractall(path=directory, members=self._extract_members(tar, base_dir, directory))
+ tar.extractall(
+ path=directory, members=filter_non_dev(self._extract_members(tar, base_dir, directory))
+ )
else:
- tar.extractall(path=directory)
+ tar.extractall(path=directory, members=filter_non_dev(tar.getmembers()))
except (tarfile.TarError, OSError) as e:
raise SourceError("{}: Error staging source: {}".format(self, e)) from e