Yum completely broken after deleting something

General support questions
Post Reply
Roshke
Posts: 2
Joined: 2016/08/06 00:34:21
Contact:

Yum completely broken after deleting something

Post by Roshke » 2016/08/06 00:37:23

Hi, I've been clearing up files on my server and I accidentally deleted a few things that belong to yum, I think that one of them was a file named "Packages" over 100mb.
Now when I try to use yum I get this:

Code: Select all

[root@fr1 ~]# yum
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 298, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 115, in main
    base.getOptionsConfig(args)
  File "/usr/share/yum-cli/cli.py", line 229, in getOptionsConfig
    self.conf
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 911, in <lambda>
    conf = property(fget=lambda self: self._getConfig(),
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 300, in _getConfig
    startupconf = config.readStartupConfig(fn, root)
  File "/usr/lib/python2.6/site-packages/yum/config.py", line 896, in readStartupConfig
    startupconf.releasever = _getsysver(startupconf.installroot, startupconf.distroverpkg)
  File "/usr/lib/python2.6/site-packages/yum/config.py", line 1047, in _getsysver
    hdr = idx.next()
StopIteration

Code: Select all

[root@fr1 ~]# rpm -q yum
package yum is not installed
I even tried reinstalling yum

Code: Select all

[root@fr1 ~]# rpm -Uvh http://mirror.centos.org/centos/6/os/i386/Packages/yum-3.2.29-73.el6.centos.noarch.rpm
Retrieving http://mirror.centos.org/centos/6/os/i386/Packages/yum-3.2.29-73.el6.centos.noarch.rpm
warning: /var/tmp/rpm-tmp.peVxnX: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
        /usr/bin/python is needed by yum-3.2.29-73.el6.centos.noarch
        pygpgme is needed by yum-3.2.29-73.el6.centos.noarch
        python >= 2.4 is needed by yum-3.2.29-73.el6.centos.noarch
        python(abi) = 2.6 is needed by yum-3.2.29-73.el6.centos.noarch
        python-iniparse is needed by yum-3.2.29-73.el6.centos.noarch
        python-sqlite is needed by yum-3.2.29-73.el6.centos.noarch
        python-urlgrabber >= 3.9.1-10 is needed by yum-3.2.29-73.el6.centos.noarch
        rpm >= 0:4.4.2 is needed by yum-3.2.29-73.el6.centos.noarch
        rpm-python is needed by yum-3.2.29-73.el6.centos.noarch
        yum-metadata-parser >= 1.1.0 is needed by yum-3.2.29-73.el6.centos.noarch
        yum-plugin-fastestmirror is needed by yum-3.2.29-73.el6.centos.noarch


mbjsbj
Posts: 8
Joined: 2013/08/06 01:32:45
Location: Atlanta, GA

Re: Yum completely broken after deleting something

Post by mbjsbj » 2016/08/06 15:23:29

So, I posted some info, but found something better (so I deleted my last post). It looks as if you are missing some dependencies. Here is where I would start (after a backup of course):

1.) Download the listed dependencies listed on the error from the CentOS site (via wget or option of your choice):
http://mirror.centos.org/centos/6/os/x8 ... x86_64.rpm
http://mirror.centos.org/centos/6/os/x8 ... x86_64.rpm
http://mirror.centos.org/centos/6/os/x8 ... x86_64.rpm
http://mirror.centos.org/centos/6/os/x8 ... x86_64.rpm
http://mirror.centos.org/centos/6/os/x8 ... noarch.rpm


2.) Install it via rpm:
rpm -ivh pygpgme-0.1-18.20090824bzr68.el6.x86_64.rpm
rpm -ivh python-2.6.6-64.el6.x86_64.rpm
Keep going until you get all of these installed

You will likely run into having to install dependencies for each of these rpm packages, but be patient and keep at it you will eventually get it! You should be able to find the dependency files here: http://mirror.centos.org/centos/6/os/x86_64/Packages/

3.) Try installing yum again. Repeat process until it installs.


Let me know how it goes!

User avatar
TrevorH
Site Admin
Posts: 33218
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Yum completely broken after deleting something

Post by TrevorH » 2016/08/06 15:57:18

The "missing" dependencies would be due to the fact that he's wiped out the rpm database "Packages" file that tells it what packages are (were) installed. This now means that rpm thinks that nothing at all is installed even though it is. The best solution would be to break out the backups and restore the file /var/lib/rpm/Packages from there - in fact, probably better to back up the current /var/lib/rpm directory completely and then restore all of it from the backup so it's in sync. Otherwise, it's reinstall time - I just tested to see if rpm --rebuilddb would recover the file with decent contents and it does not - it recreates it but it's empty and useless.

So: restore from backups or reinstall or, if you have an *identical* system then you could possibly copy the Packages file from that to the broken one but that would be very error prone and only to be done as a last resort.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: Yum completely broken after deleting something

Post by avij » 2016/08/06 16:35:23

I agree with TrevorH that a backup + reinstall would probably be the best choice, but if you want to try an alternative, my previous instructions for recreating the database from scratch may be of help. Good luck.

Roshke
Posts: 2
Joined: 2016/08/06 00:34:21
Contact:

Re: Yum completely broken after deleting something

Post by Roshke » 2016/08/07 12:23:52

I found my yum log files which has all of my installations, updates etc... I've tried to reinstall the packages and follow this tutorial http://www.zedt.eu/tech/linux/recover-f ... in-centos/ but unfortunately I didn't succeed so I decided to go fresh again with a reinstall. Backed up all my important data, reinstalled the machine and reinstalled the packages I had with the list.
I'm up and running again, thanks everyone who helped! ((;

Post Reply