Re: rebuild /var/lib/rpm/Packages ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 14 November 2002 10:13 am, Ed Wilts wrote:
> On Thu, Nov 14, 2002 at 02:12:47PM +0000, Andrew Mark Tze Liang Choong 
wrote:
> > i'm using psyche with synaptic as my package manager. something
> > happened - synaptic crashed and when i started it up again, it was
> > unable to start as i had two packages of krb5-workstation but
> > different versions.
> >
> > i deleted /var/lib/rpm/Packages and synaptic started again. however,
> > i now do not have a list of the installed packages on my system!!!
>
> You've done some significant damage that will take some effort to undo.
> I take it you don't have backups either?  If you do, restore that
> directory.  If you don't, your fastest way is to archive your documents
> and settings and re-install.  Failing that, you need to determine which
> package owns each and every file on your system and then issue the rpm
> command to update the database without installing the package.  If you
> exclusively installed from Red Hat, this is ugly but not impossible. 
> If you've installed from multiple places and don't have the original
> rpm files anymore, you'll be better off re-installing.
>
> > i tried rpm --initdb, rpm --rebuilddb but that doesn't have seemed to
> > work.
>
> Did you do a man on rpm to see what initdb does?  It *initializes* the
> database.  If you had anything in there before, it would certainly be
> gone now.

I have a quick hack of a script that may help.

Every rpm on the system is logged to /var/log/rpmpkgs by a daily cronjob.
You should be able to use one of the several files kept around by
logrotate, since the most recent file is liable to be empty or damaged if
the cronjob has run since the database was removed.

You'll also need access to the rpms listed in the file you want to restore
from. They can be on the hard drive, a cdrom, nfs mount, etc. For every
package listed in the rpmpkgs file, the script looks in the given search
directories, and if the package.rpm is found, runs rpm -ivh --justdb
- --force --nodeps on that package. Provided you have access to the
majority of the installed package.rpm files, it should get the database
in reasonably good shape. The script is intended for disaster recovery
only. This case seems to fit the bill, as you have no existing database
to damage. ;)

The script is available here:
http://www.tuxfan.homeip.net:8080/hacks/recover_rpm_db.sh

Usage: recover_rpm_db.sh -f [file_name] -p [path[s] to rpm files].
Where 'file_name' is a file containing a list of rpm packages
that should be included in the rpm database, and -p is the
path or paths that contain the rpm packages.

Good luck, hope you find it useful,

- -- 
- -Michael

pgp key:  http://www.tuxfan.homeip.net:8080/gpgkey.txt
Red Hat Linux 7.{2,3}|8.0 in 8M of RAM: http://www.rule-project.org/
- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE91FNjn/07WoAb/SsRAukHAJ0cxnAKAw+3x2i3revkvGsFB2DTjACbBExn
2bPWCpOyuuCbn3QgruskZXk=
=Q0pS
-----END PGP SIGNATURE-----



-- 
Psyche-list mailing list
Psyche-list@redhat.com
https://listman.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux