From 4ab8a7a8f9f24225f99992aefcca462e2c6bde72 Mon Sep 17 00:00:00 2001 From: Anthony PERARD Date: Wed, 6 Aug 2025 12:05:59 +0200 Subject: [PATCH] import_srpm: check command rpm2cpio|cpio `rpm2cpio` might not exist on the system, and `cpio` return the error "premature end of archive" in that case. This doesn't check if `rpm2cpio` returns an error but it's probably ok to lean on `cpio` returning an error. Also, check early if `rpm2cpio` actually exist on the system. Signed-off-by: Anthony PERARD --- scripts/import_srpm.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/import_srpm.py b/scripts/import_srpm.py index 34da7aaa..469186b8 100755 --- a/scripts/import_srpm.py +++ b/scripts/import_srpm.py @@ -28,6 +28,11 @@ def main(): }[args.verbose] logging.basicConfig(format='[%(levelname)s] %(message)s', level=loglevel) + try: + call_process(['sh', '-c', 'command -v rpm2cpio']) + except subprocess.CalledProcessError: + parser.error("Command `rpm2cpio` missing") + # check that the source RPM file exists if not os.path.isfile(args.source_rpm): parser.error("File %s does not exist." % args.source_rpm) @@ -76,7 +81,7 @@ def main(): print(" extracting SRPM...") os.chdir('SOURCES') - os.system('rpm2cpio "%s" | cpio -idmv' % source_rpm_abs) + call_process(['sh', '-c', 'rpm2cpio "%s" | cpio -idmv' % source_rpm_abs]) os.chdir('..') os.system('mv SOURCES/*.spec SPECS/')