Move rpm2cpio to one line

The split of the extract package in two different calls to subprocess
doesn't work for all packages so it's better to get back to just one
call with shell=True.
This commit is contained in:
Daniel Garcia Moreno 2024-01-30 12:06:14 +01:00
parent 9ab9c5d0f1
commit 53ecedf6d7
3 changed files with 11 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import mmap
import os
from pathlib import Path, PurePath
import re
from shlex import quote
import shutil
import stat
import subprocess
@ -580,10 +581,8 @@ class Pkg(AbstractPkg):
subprocess.check_output('rpm2archive - | tar -xz && chmod -R +rX .', shell=True, env=ENGLISH_ENVIROMENT,
stderr=stderr, stdin=rpm_data)
else:
stdout = subprocess.check_output(['rpm2cpio', str(filename)], env=ENGLISH_ENVIROMENT,
stderr=stderr)
subprocess.check_output('cpio -id && chmod -R +rX .', shell=True, env=ENGLISH_ENVIROMENT,
stderr=stderr, input=stdout)
command_str = f'rpm2cpio {quote(str(filename))} | cpio -id ; chmod -R +rX .'
subprocess.check_output(command_str, shell=True, env=ENGLISH_ENVIROMENT, stderr=stderr)
self.extracted = True
return dirname

View File

@ -1,6 +1,9 @@
import pytest
import rpm
from rpmlint.pkg import parse_deps, rangeCompare
from Testing import get_tested_package
def test_parse_deps():
for (arg, exp) in (
@ -19,3 +22,8 @@ def test_range_compare():
('foo', rpm.RPMSENSE_EQUAL, (1, '0.5', None))),
):
assert not rangeCompare(req, prov)
@pytest.mark.parametrize('package', ['binary/python311-pytest-xprocess'])
def test_extract(package, tmp_path):
get_tested_package(package, tmp_path)