From 4cd98da1769cc33979aee0da0924c24ccba880a1 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 24 Feb 2024 19:56:29 +0530 Subject: 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 "", line 24, in 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: --- cerbero/hacks.py | 6 +++--- 1 file 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 -- cgit v1.2.3