1#!/usr/bin/env python3 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (c) 2020 Dmitry Kozlyuk <[email protected]> 4 5import os 6import subprocess 7import sys 8import tempfile 9 10_, tmp_root, ar, archive, output, *pmdinfogen = sys.argv 11with tempfile.TemporaryDirectory(dir=tmp_root) as temp: 12 proc = subprocess.run( 13 # Don't use "ar p", because its output is corrupted on Windows. 14 [ar, "xv", os.path.abspath(archive)], stdout=subprocess.PIPE, check=True, cwd=temp 15 ) 16 lines = proc.stdout.decode().splitlines() 17 names = [line[len("x - ") :] for line in lines] 18 paths = [os.path.join(temp, name) for name in names] 19 subprocess.run(pmdinfogen + paths + [output], check=True) 20