0

I'm running the below command using python subprocess to extract files from rpm. But the command failes when the rpm size is more than 25 - 30 MB. Tried the command using Popen, call, with stdout as PIPE and os.system as well. This command is working fine when i run it in shell directly. The problem is only when i invoke this by some means from Python

Command:

rpm2cpio <rpm_name>.rpm| cpio -idmv

I did an strace on the process id and found that its always hung on some write system call

ps -ef | grep cpio
root      4699  4698  4 11:05 pts/0    00:00:00 rpm2cpio kernel-2.6.32-573.26.1.el6.x86_64.rpm
root      4700  4698  0 11:05 pts/0    00:00:00 cpio -idmv

strace -p 4699
Process 4699 attached
write(10, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0rc_pixelview_new"..., 8192

strace -p 4700
Process 4700 attached
write(2, "./lib/modules/2.6.32-573.26.1.el"..., 94

I have 2 questions:

  1. Can someone figure out what is the problem here? Why is it failing when the rpm size is more than 25 MB.
  2. Is there any other way i can extract the rpm contents from python?
Amal Ts
  • 857
  • 1
  • 6
  • 28
  • Please post the python code you used. Did you redirect stdout to a PIPE and then forget to read the pipe as one of the below answers suggest? We can't debug this without the code needing to be debugged. – tdelaney Jul 23 '16 at 16:37

2 Answers2

1

Your output pipe is full. The python docs note in many places not to do what you are doing:

Do not use stdout=PIPE or stderr=PIPE with this function as that can deadlock based on the child process output volume. Use Popen with the communicate() method when you need pipes.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
0

If all you want is the payload of a *.rpm package, then do the computations to find the beginning of the compressed cpio payload and do the operations directly in python.

See How do I extract the contents of an rpm? for a rpm2cpio.sh shell script that documents the necessary computations. The only subtlety is ensuring that the padding (needed for alignment) between the signature and metadata headers is correct.

Community
  • 1
  • 1
Jeff Johnson
  • 2,310
  • 13
  • 23