piping output from curl to rpm2cpio

0

I download alot of srpms to rummage through, I used to go through a long winded approach,

root@server$ curl rpm -o file.rpm
root@server$ rpm2cpio file.rpm | cpio -id

but that leaves behind an ugly file.rpm so I tried a single pipeline

root@server$ curl rpm | rpm2cpio - | cpio -id

According to the curl manpage curl outputs to stdout by default and the rpm2cpio man page says that if the only argument is '-' that it will read from stdin.

However I keep getting errors:

error: rpm2cpio: headerRead failed: hdr blob(23176): BAD, read returned 2696
error reading header from package
cpio: premature end of archive
  0 5468k    0 13257    0     0  21912      0  0:04:15 --:--:--  0:04:15 29791
curl: (23) Failed writing body (379 != 1348)

if I try catting the downloaded file into the pipeline instead of using curl it works.

Now I am aware there are a number of ways around this, and when I can be bothered I'll probably script this. I was just curious as to why rpm doesn't like the rpm outputted by curl.

Any Ideas?

peteches

Posted 2013-01-21T09:06:01.407

Reputation: 204

Answers

-1

Turns out that both curl and wget send a bunch of other stuff to stdout as well as the file being retrieved, hence the errors when rpm2cpio is called on the stream.

Explicitly using the flag -o - removes that extra stuff and it works fine now.

peteches

Posted 2013-01-21T09:06:01.407

Reputation: 204