Skip to content

Commit

Permalink
Fix older versions of tar not working when creating an archive (C…
Browse files Browse the repository at this point in the history
…herry-pick of #11413) (#11418)

[ci skip-rust]
[ci skip-build-wheels]
  • Loading branch information
Eric-Arellano committed Feb 4, 2021
1 parent 78a9966 commit 1a6b67d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/python/pants/core/util_rules/archive.py
Expand Up @@ -53,8 +53,13 @@ class TarBinary(BinaryPath):
def create_archive_argv(self, request: "CreateArchive") -> Tuple[str, ...]:
# Note that the parent directory for the output_filename must already exist.
#
# The `a` arg means `tar` will choose the compression based on the file ending.
return (self.path, "caf", request.output_filename, *request.snapshot.files)
# We do not use `-a` (auto-set compression) because it does not work with older tar
# versions. Not all tar implementations will support these compression formats - in that
# case, the user will need to choose a different format.
compression = {ArchiveFormat.TGZ: "z", ArchiveFormat.TBZ2: "j", ArchiveFormat.TXZ: "J"}.get(
request.format, ""
)
return (self.path, f"c{compression}f", request.output_filename, *request.snapshot.files)

def extract_archive_argv(self, *, archive_path: str, output_dir: str) -> Tuple[str, ...]:
# Note that the `output_dir` must already exist.
Expand Down

0 comments on commit 1a6b67d

Please sign in to comment.