Recently I experienced a problem with Synaptic / apt-get, and would like to share with you a simple way to solve this problem.
APT-GET – A Great idea
APT-GET is a very good tool for working with the installation of packages. There are others, more recent, but the robustness, reliability and ease of the apt-get tool gives it a prominent place in the major distros.
Born in the Debian distro, it has been ported to the RPM packages distros by brazilian now defunct company Conectiva(it merged with Mandrake and formed Mandriva).
The apt-get tool fetches the repositories for data lists on all packages of the distribution, and builds a database listing the packages, their dependencies, which new packages are in the repository, which are deprecated, and so on.
When you do an apt-get update or press the reload button in Synaptic, lists are downloaded from various repositories, and these lists are used to build a database that lists all packages.
Well, when there is a problem at that stage of the procedure, when the lists are being downloaded or the database is being built, it can ruin everything. And it happened to me.
At the time of creating the database, there was a corruption of files. Result: Neither apt-get worked nor Synaptic.
No Panic, the solution is simple
When this happened to me, I was worried because I was not seeing a solution: Synaptic and apt-get (command line) were frozen. Not working anymore.
I thought … Format and reinstall??
Then I started to research a little deeper on the apt-get and Synaptic (or any other graphical front end, Adept, aptitude, etc …).
And the solution is pretty simple. The steps I take here are for distros that use RPM packages, but the analogy can be done for deb based distros as well.
1. Look for the following directory /var/lib/rpm
2. In that directory will be the files of the database of apt-get/synaptic. The files have the following nomenclature __db.000 and so on. Depending on the size of the repos, there can be several files like this.
3. Then, delete all the __db files that exist in that directory. Of course you must be logged in as root. And, be very careful if you do rm-f. The ideal is to use a graphical file manager here, for you to see which files you are to delete and avoid any mistakes.
4. After deleting the __db files , type the following commands: # rpm -v –rebuilddb. This will rebuild the apt-get database.
5. If all goes well you can, from now on, use the command apt-get and its graphical front-ends with no problems. And, without having to reinstall your distro.
These tips are valid for RPM-based distros: Red Hat, Mandriva, CentOS, PCLinuxOS and Fedora. But, with the due adaptations, can be done on distros with deb packages as well.