Skip to content

Commit 11737b2

Browse files
authored
Merge pull request #101 from no92/tar-unpack
base: allow symlinks outside of the archive
2 parents 3fe09f2 + ac4ab62 commit 11737b2

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

xbstrap/base.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import shutil
1212
import stat
1313
import subprocess
14+
import sys
1415
import tarfile
1516
import tempfile
1617
import urllib.request
@@ -3191,7 +3192,14 @@ def pull_archive(cfg, subject):
31913192
os.mkdir(subject.prefix_dir)
31923193
with tarfile.open(subject.archive_file, "r:gz") as tar:
31933194
for info in tar:
3194-
tar.extract(info, subject.prefix_dir)
3195+
if sys.version_info >= (3, 12):
3196+
# Maybe should have a more aggressive filter, but we have
3197+
# legitimate "evil-looking" tool tars (specifically, GCC
3198+
# tarballs link to the binutils directory, which is outside
3199+
# of the root)
3200+
tar.extract(info, subject.prefix_dir, filter="fully_trusted")
3201+
else:
3202+
tar.extract(info, subject.prefix_dir)
31953203
else:
31963204
# TODO: Also support packages here.
31973205
raise GenericError("Unexpected subject for pull-archive")
@@ -3569,7 +3577,7 @@ def add_source_dependencies(s):
35693577

35703578
def add_tool_dependencies(s):
35713579
for subject_id in s.tool_stage_dependencies:
3572-
(tool_name, stage_name) = (subject_id.name, subject_id.stage)
3580+
tool_name, stage_name = (subject_id.name, subject_id.stage)
35733581
dep_tool = self._cfg.get_tool_pkg(tool_name)
35743582
if self.build_scope is not None and dep_tool not in self.build_scope:
35753583
if self.pull_out_of_scope:
@@ -3984,7 +3992,7 @@ def run_plan(self):
39843992
else:
39853993
_util.log_info("Nothing to do")
39863994
for item in printed:
3987-
(action, subject) = (item.action, item.subject)
3995+
action, subject = (item.action, item.subject)
39883996
if self.explain:
39893997
symbol = f"#{numbering[item]}"
39903998
eprint(f"{symbol:>5} ", end="")
@@ -4053,7 +4061,7 @@ def run_plan(self):
40534061

40544062
any_failed_items = False
40554063
for n, item in enumerate(scheduled):
4056-
(action, subject) = (item.action, item.subject)
4064+
action, subject = (item.action, item.subject)
40574065

40584066
# Check if any prerequisites failed; this can generally only happen with --keep-going.
40594067
any_failed_edges = False
@@ -4190,7 +4198,7 @@ def emit_progress(status):
41904198
if any_failed_items:
41914199
_util.log_info("The following steps failed:")
41924200
for item in scheduled:
4193-
(action, subject) = (item.action, item.subject)
4201+
action, subject = (item.action, item.subject)
41944202
assert item.exec_status != ExecutionStatus.NULL
41954203
if item.exec_status == ExecutionStatus.SUCCESS:
41964204
continue

xbstrap/pipeline/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def do_compute_graph(args):
209209
}
210210
)
211211
for key in plan.materialized_steps():
212-
(action, subject) = (key.action, key.subject)
212+
action, subject = (key.action, key.subject)
213213
if action == xbstrap.base.Action.WANT_TOOL:
214214
if subject in job.tools:
215215
continue
@@ -265,7 +265,7 @@ def do_compute_graph(args):
265265
plan.compute_plan(no_ordering=True)
266266

267267
for key in plan.materialized_steps():
268-
(action, subject) = (key.action, key.subject)
268+
action, subject = (key.action, key.subject)
269269
if action == xbstrap.base.Action.WANT_TOOL:
270270
if subject in item.job.tools:
271271
continue

xbstrap/vcs_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_local_commit(ref):
118118
except subprocess.CalledProcessError:
119119
return None
120120
assert len(out) == 1
121-
(commit, outref) = out[0].split(" ")
121+
commit, outref = out[0].split(" ")
122122
return commit
123123

124124
def get_remote_commit(ref):
@@ -131,7 +131,7 @@ def get_remote_commit(ref):
131131
except subprocess.CalledProcessError:
132132
return None
133133
assert len(out) == 1
134-
(commit, outref) = out[0].split("\t")
134+
commit, outref = out[0].split("\t")
135135
return commit
136136

137137
known_commit = None

0 commit comments

Comments
 (0)