Centos 6.0 damaged rpm

Trying to reinstall a damaged rpm file.  To do this I checked the install.log file for the version that was installed initially and found the following:

Installing rpm-libs-4.8.0-12.el6.x86_64
Installing rpm-4.8.0-12.el6.x86_64
Installing rpm-python-4.8.0-12.el6.x86_64
Installing rpm-build-4.8.0-12.el6.x86_64

So I downloaded rpm-4.8.0-12.el6.x86_64 but when I tried executing rpm2cpio I get the errors outlined below.  

[mop@localhost rpm]$ ls -al
total 4740
drwxr-xr-x   2 root    root       4096 Sep 21 09:43 .
drwxr-xr-x. 47 mop mop   12288 Sep 21 09:56 ..
-rw-r--r--   1 root    root     917116 Nov 24  2010 rpm-4.8.0-12.el6.x86_64.rpm
-rw-r--r--   1 root    root    3789304 Sep 27  2013 rpm-4.8.0-37.el6.src.rpm
-rw-r--r--   1 root    root     125220 Jul  3  2011 rpm-build-4.8.0-12.el6.x86_64.rpm
-rw-r--r--   1 root    root          0 Sep 21 09:25 rpm.cpio
[mop@localhost rpm]$ sudo rpm2cpio rpm-4.8.0-12.el6.x86_64.rpm | cpio -dim
Error: header not recognized
cpio: premature end of archive
[mop@localhost rpm]$ 

Open in new window

How to resolve?
Who is Participating?
gheistConnect With a Mentor Commented:
Use RHEL 6U5 media to upgrade your system. It will add missing rpm too..

Without RPM you need to get CPIO on other system and then extract good CPIO with permissions on this broken systems.

Also post "locate rpm" and "yum reinstall rpm" outputs.
nociSoftware EngineerCommented:
is the disk you downloaded it to full?...
Anyway you can download a new one from the CentOS downloads:

You can find a replacement with:

and download it. The hash verification should match your system (check while installing).
simon3270Connect With a Mentor Commented:
Or you may have to add the 'c' flag to cpio (so "cpio -cdim"). This uses an alternative cpio data structure where the header is all printable ASCII characters (by default it is a binary format).
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

why don't you try direct command

#rpm -ivh <pkg> --force

use --force in case you really need it. else try without that.

As others pointed out, could you make clear what it is you are trying to do?

rpm2cpio is often used to construct a stream type of package versus the RPM
It might also be used if you want to alter the location where the files will be stored.

try rpm --list rpm-4.8.0-12.el6.x86_64.rpm to see whether you get the listing of the files, or you get an error that the RPM is corrupt.
nociConnect With a Mentor Software EngineerCommented:
It actually may be damaged as the file is a tad longer if downloaded:

-rw-r-----   1 nico users     922940 Sep 22 21:19 rpm-4.8.0-37.el6.x86_64.rpm

Here are chksums:

$ sha1sum Downloads/rpm-4.8.0-37.el6.x86_64.rpm
3c54ce1e59320e506ab34ee221c67c9583d0fdc0  rpm-4.8.0-37.el6.x86_64.rpm
$ md5sum Downloads/rpm-4.8.0-37.el6.x86_64.rpm
cdc80dbbf61a49b9beb6c825ef46e615  rpm-4.8.0-37.el6.x86_64.rpm
$ sha224sum Downloads/rpm-4.8.0-37.el6.x86_64.rpm
17258d1a8d552f08cf4122af55f8cd411b9c15f41a5df92fcab5565b  rpm-4.8.0-37.el6.x86_64.rpm
forums_mpAuthor Commented:
As others pointed out, could you make clear what it is you are trying to do

Open in new window

I'm using a laptop that lacks an rpm file.  "file doesn't exist' basically.  Turns out hosed up the python (looks like python was overwritten with a newer version) version among other things.

Simply put I'm in the position this individual is in (http://deadlockprocess.wordpress.com/2010/07/18/how-to-reinstall-rpm-and-yum-without-rpm-and-yum-in-centosrhel/) and I'm trying to mimick his/her steps - except I'm RHEL/centos 6
nociSoftware EngineerCommented:
You should still check the rpm file, as it seems a few bytes short and the procedure you mention should work too (adjust for other version no's).
Instead of running the command through sudo, elevate your rights first sudo bash
Then run the rpm2cpio RPM-*.rpm |cpio -dim

See if that also has errors.

What error do you get when you run rpm -qa?

It might be that your rpm index is corrupt rather than the rpm command itself.
Error is from cpio

Verify package with rpm (should be signed by CentOS)
nociSoftware EngineerCommented:
gheist, his rpm program doesn't work he wants to recover it... and gets errors.
Chicken & Egg problem.
I doubt RPM binary is broke before seeing strong errors saying that.
rpm2cpio calls the same chicken egg, so it is a nogo too
The issue might be that the DB become corrupt.
i.e. /var/lib/rpm the db files are messed up.

There is a way to recreate them using rpm --rebuilddb after the __db.* files were deleted. (instructions locatable using any search engine with "RPM repair corrupt db"

Before running the above, what errors if any do you get from rpm --qa?
forums_mpAuthor Commented:
For those not fully convinced that rpm is corrupt or non-existent, here goes
[root@localhost bin]# rpm -qa
bash: rpm: command not found
[root@localhost bin]# 
[root@localhost bin]# rpm
bash: rpm: command not found
[root@localhost bin]# 
[root@localhost bin]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.0 (Santiago)
[root@localhost bin]# 

Open in new window

Same errors if I run as myself versus root
noci:  Seems odd there's no 6.0 from the link you provided ( http://rpmfind.net/linux/rpm2html/search.php?query=rpm&submit=Search+...&system=centos&arch=x86_64).   Wondering if I could get away with using 6.5.    I'll search for v6.0 in the interim
RPM command not found means the command I not found based on the existing defined PATHAN.

Usually one presumes that /bin /usr/bin  is part of the PATH definition.

Do which rpm
Try /usr/bin/rpm or /bin/rpm

The other option is for you to unpack the RPM on another system to a separate location and then transfer the data to this one.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.