-_, ar, archive, output, *pmdinfogen = sys.argv
-with tempfile.TemporaryDirectory() as temp:
- proc = subprocess.run(
- # Don't use "ar p", because its output is corrupted on Windows.
- [ar, "xv", os.path.abspath(archive)], stdout=subprocess.PIPE, check=True, cwd=temp
+_, tmp_root, ar, archive, output, *pmdinfogen = sys.argv
+with tempfile.TemporaryDirectory(dir=tmp_root) as temp:
+ run_ar = lambda command: subprocess.run(
+ [ar, command, os.path.abspath(archive)],
+ stdout=subprocess.PIPE, check=True, cwd=temp