Skip to content

Conversation

tperard
Copy link
Member

@tperard tperard commented Aug 6, 2025

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.

@stormi stormi requested a review from glehmann August 6, 2025 10:20
`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]>
@tperard tperard force-pushed the apd/check-rpm2cpio branch from 69af6cc to 4ab8a7a Compare August 6, 2025 11:44
@@ -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.

Comment on lines +31 to +33
try:
call_process(['sh', '-c', 'command -v rpm2cpio'])
except subprocess.CalledProcessError:
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 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants