summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2024-02-24 19:56:29 +0530
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2024-04-25 20:23:56 +0000
commita1d586093a61eaf536ea53cb565689b89c84b4fc (patch)
treec75effaf69b3ebb89b0ec2c5fb084332f7c4cbd6
parente8adedfcc17975c1608d2730d90b609e586b725a (diff)
cerbero: Fix shutil.rmtree hack to passthrough unknown kwargs
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/1402>
-rw-r--r--cerbero/hacks.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/cerbero/hacks.py b/cerbero/hacks.py
index adf51079..ca1619f6 100644
--- a/cerbero/hacks.py
+++ b/cerbero/hacks.py
@@ -108,7 +108,7 @@ import shutil
from shutil import rmtree as shutil_rmtree
from cerbero.utils.shell import new_call as shell_call
-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
@@ -133,9 +133,9 @@ def rmtree(path, ignore_errors=False, onerror=None):
shell_call('rm -rf ' + path)
# 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