summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorL. E. Segovia <amy@centricular.com>2024-02-03 11:40:01 +0000
committerNirbheek Chauhan <nirbheek@centricular.com>2024-02-09 15:20:22 +0530
commit9edf7272e13c46469203423f711eaf3cb2a122cb (patch)
tree48766e24a576df4650c4e80bbd76c315c5327111
parentbd04c7e6078d5ff6bd97c22d68d4d5b60c0d3bef (diff)
cerbero: Fix GNU tar --checkpoint compatibility with macOS
macOS tar cannot take --checkpoint. However, Homebrewed GNU tar can. Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1348>
-rw-r--r--cerbero/packages/disttarball.py6
-rw-r--r--cerbero/utils/shell.py5
2 files changed, 10 insertions, 1 deletions
diff --git a/cerbero/packages/disttarball.py b/cerbero/packages/disttarball.py
index 29dd3658..f05ae986 100644
--- a/cerbero/packages/disttarball.py
+++ b/cerbero/packages/disttarball.py
@@ -175,7 +175,11 @@ class DistTarball(PackagerBase):
shell.new_call(compress_cmd)
def _write_tar(self, filename, package_prefix, files):
- tar_cmd = [shell.get_tar_cmd(), '-C', self.prefix, '--checkpoint=.250']
+ tar = shell.get_tar_cmd()
+ tar_cmd = [tar, '-C', self.prefix]
+ # --checkpoint is only supported by GNU tar
+ if tar == shell.HOMEBREW_TAR or (self.config.platform != Platform.DARWIN and tar == shell.TAR):
+ tar_cmd.append('--checkpoint=.250')
# ensure we provide a unique list of files to tar to avoid
# it creating hard links/copies
files = sorted(set(files))
diff --git a/cerbero/utils/shell.py b/cerbero/utils/shell.py
index 4e31464a..ff0729d5 100644
--- a/cerbero/utils/shell.py
+++ b/cerbero/utils/shell.py
@@ -42,6 +42,7 @@ from cerbero.errors import CommandError, FatalError
PATCH = 'patch'
TAR = 'tar'
+HOMEBREW_TAR = 'gtar'
TARBALL_SUFFIXES = ('tar.gz', 'tgz', 'tar.bz2', 'tbz2', 'tar.xz')
SUBPROCESS_EXCEPTIONS = (FileNotFoundError, PermissionError, subprocess.CalledProcessError)
@@ -662,6 +663,10 @@ def get_tar_cmd():
# https://github.com/msys2/MSYS2-packages/issues/1548
if DISTRO == Distro.MSYS2:
return 'bsdtar'
+ # Allow using Homebrewed tar since it's GNU compatible
+ # (macOS uses FreeBSD tar)
+ elif shutil.which(HOMEBREW_TAR):
+ return HOMEBREW_TAR
else:
return TAR