]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
add a workaround for missing user= parameter in subprocess.run on python 3.8
authorJoerg Behrmann <behrmann@physik.fu-berlin.de>
Fri, 13 May 2022 07:27:18 +0000 (09:27 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 14 May 2022 09:01:45 +0000 (11:01 +0200)
Fixes: #967
mkosi/backend.py

index 2f35b065dff5c2bd0422e41e3877fdc3439633ae..56db6839a407d108ee827439c724b6889bc08b42 100644 (file)
@@ -764,6 +764,14 @@ def run(
         # output.
         stdout = sys.stderr
 
+    # This is a workaround for copy_git_files, which uses the user= option to
+    # subprocess.run, which is only available starting with Python 3.9
+    # TODO: remove this branch once mkosi defaults to at least Python 3.9
+    if "user" in kwargs and sys.version_info < (3, 9):
+        user = kwargs.pop("user")
+        user = f"#{user}" if isinstance(user, int) else user
+        cmdline = ["sudo", "-u", user] + cmdline
+
     cm = do_delay_interrupt if delay_interrupt else do_noop
     try:
         with cm():