env2mfile: Split detect_cross_debianlike()

Separating the part that runs dpkg-architecture from the part that
interprets its results will make it easier to unit-test the latter.

Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie 2024-10-02 12:38:01 +01:00 committed by Jussi Pakkanen
parent ed1d626c35
commit 6224a7f48e
1 changed files with 3 additions and 0 deletions

View File

@ -171,6 +171,9 @@ def detect_cross_debianlike(options: T.Any) -> MachineInfo:
cmd = ['dpkg-architecture', '-a' + options.debarch]
output = subprocess.check_output(cmd, universal_newlines=True,
stderr=subprocess.DEVNULL)
return dpkg_architecture_to_machine_info(output, options)
def dpkg_architecture_to_machine_info(output: str, options: T.Any) -> MachineInfo:
data = {}
for line in output.split('\n'):
line = line.strip()