Skip to content

Commit 4ab8a7a

Browse files
committed
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 <[email protected]>
1 parent 47b4417 commit 4ab8a7a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/import_srpm.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def main():
2828
}[args.verbose]
2929
logging.basicConfig(format='[%(levelname)s] %(message)s', level=loglevel)
3030

31+
try:
32+
call_process(['sh', '-c', 'command -v rpm2cpio'])
33+
except subprocess.CalledProcessError:
34+
parser.error("Command `rpm2cpio` missing")
35+
3136
# check that the source RPM file exists
3237
if not os.path.isfile(args.source_rpm):
3338
parser.error("File %s does not exist." % args.source_rpm)
@@ -76,7 +81,7 @@ def main():
7681
print(" extracting SRPM...")
7782

7883
os.chdir('SOURCES')
79-
os.system('rpm2cpio "%s" | cpio -idmv' % source_rpm_abs)
84+
call_process(['sh', '-c', 'rpm2cpio "%s" | cpio -idmv' % source_rpm_abs])
8085
os.chdir('..')
8186
os.system('mv SOURCES/*.spec SPECS/')
8287

0 commit comments

Comments
 (0)