summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2024-02-24 19:56:29 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2024-03-05 17:24:29 +0530
commit4cd98da1769cc33979aee0da0924c24ccba880a1 (patch)
tree47f080968446e412cf64de9a2d20bd7f823bd194
parent8ea3a35d4f0a34ab9693dbf89a5fbbfe39908bf1 (diff)
cerbero: Fix shutil.rmtree hack to passthrough unknown kwargs1.24.0
Android tarball creation was broken for a while on Fedora because a new kwarg was added in Python 3.12 ``` Traceback (most recent call last): File "<string>", line 24, in <module> File "/home/nirbheek/projects/repos/cerbero.git/cerbero/main.py", line 224, in main Main(sys.argv[1:]) File "/home/nirbheek/projects/repos/cerbero.git/cerbero/main.py", line 52, in __init__ self.run_command() File "/home/nirbheek/projects/repos/cerbero.git/cerbero/main.py", line 192, in run_command res = commands.run(command, self.config, self.args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nirbheek/projects/repos/cerbero.git/cerbero/commands/__init__.py", line 79, in run return _commands[command].run(config, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nirbheek/projects/repos/cerbero.git/cerbero/commands/package.py", line 156, in run paths = pkg.pack( ^^^^^^^^^ File "/home/nirbheek/projects/repos/cerbero.git/cerbero/packages/disttarball.py", line 73, in pack runtime = self._create_tarball(output_dir, PackageType.RUNTIME, dist_files, force, package_prefix) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nirbheek/projects/repos/cerbero.git/cerbero/packages/android.py", line 32, in _create_tarball return super()._create_tarball(output_dir, package_type, files, force, package_prefix) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nirbheek/projects/repos/cerbero.git/cerbero/packages/disttarball.py", line 152, in _create_tarball self._write_tar(filename, package_prefix, files) File "/home/nirbheek/projects/repos/cerbero.git/cerbero/packages/disttarball.py", line 213, in _write_tar with tempfile.TemporaryDirectory() as d: File "/usr/lib64/python3.12/tempfile.py", line 946, in __exit__ self.cleanup() File "/usr/lib64/python3.12/tempfile.py", line 950, in cleanup self._rmtree(self.name, ignore_errors=self._ignore_cleanup_errors) File "/usr/lib64/python3.12/tempfile.py", line 930, in _rmtree _shutil.rmtree(name, onexc=onexc) TypeError: rmtree() got an unexpected keyword argument 'onexc' ``` Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1384>
-rw-r--r--cerbero/hacks.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/cerbero/hacks.py b/cerbero/hacks.py
index ebc5fa29..daf62efc 100644
--- a/cerbero/hacks.py
+++ b/cerbero/hacks.py
@@ -114,7 +114,7 @@ import shutil
from shutil import rmtree as shutil_rmtree
-def rmtree(path, ignore_errors=False, onerror=None):
+def rmtree(path, ignore_errors=False, onerror=None, **kwargs):
"""
shutil.rmtree often fails with access denied. On Windows this happens when
a file is readonly. On Linux this can happen when a directory doesn't have
@@ -144,9 +144,9 @@ def rmtree(path, ignore_errors=False, onerror=None):
# We try to not use `rm` because on Windows because it's about 20-30x slower
if not onerror:
- shutil_rmtree(path, ignore_errors, onerror=force_removal)
+ shutil_rmtree(path, ignore_errors=ignore_errors, onerror=force_removal, **kwargs)
else:
- shutil_rmtree(path, ignore_errors, onerror)
+ shutil_rmtree(path, ignore_errors=ignore_errors, onerror=onerror, **kwargs)
shutil.rmtree = rmtree