Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scripts/import_srpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Comment on lines +31 to +33
Copy link
Member

@glehmann glehmann Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try:
call_process(['sh', '-c', 'command -v rpm2cpio'])
except subprocess.CalledProcessError:
if shutil.which('rpm2cpio') is None:

just the same, but with just python 🙂

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)
Expand Down Expand Up @@ -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])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
call_process(['sh', '-c', 'rpm2cpio "%s" | cpio -idmv' % source_rpm_abs])
call_process(['sh', '-o', pipefail', '-c', 'rpm2cpio "%s" | cpio -idmv' % source_rpm_abs])

otherwise it won't fail if rpm2cpio fails.
Or we can use #743 — I didn't see there was already a PR for that problem 😅
It's in pure Python, but it's a much bigger change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, pipefail is a bash option, it doesn't exist on posix shell. I've actually look before writing my commit message, saying that this ignores error from rpm2cpio.
We don't know what implementation is used for sh, it might be dash on Debian, or bash on Arch Linux.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't read your comment carefully enough.

Too bad, I was liking your version better than mine, for its conciseness.

It's probably better to go with #743 then.

Copy link
Member

@dinhngtu dinhngtu Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're calling sh explicitly anyway you can just replace with /bin/bash right? Unless calling out bash is unwanted.

os.chdir('..')
os.system('mv SOURCES/*.spec SPECS/')

Expand Down