Thursday, 2011-02-03 08:29 MST

Recovering Lost Libraries

No, this is not about finding the library at Alexandria. Sorry. It's about recovering from accidentally deleting some libraries on a Debian based system, in my case Ubuntu 10.10. Which I did a few days ago. Oops.

Running aptitude reinstall <package-name> will re-install a package, restoring deleted files. OK, that's kewl enough. But which ones?

To find that out you need to know which ones are corrupted or missing. To do that, install the package "debsums".

# aptitude show debsums
Package: debsums                         
New: yes
State: not installed
Version: 2.0.48+nmu1
Priority: optional
Section: universe/admin
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Uncompressed Size: 274k
Depends: perl (>= 5.8.0-3), ucf (>= 0.28), debconf (>= 0.5) | debconf-2.0
Description: tool for verification of installed package files against MD5 checksums
 debsums can verify the integrity of installed package files against MD5
 checksums installed by the package, or generated from a .deb archive.

#

Simply run that against every package to get a list of packages to reinstall:

for i in $(pre | cut -f1 ) ; do debsums -c $i | grep missing ; done

And reinstall as needed.

You can narrow your search by feeding regular experessions to pre, e.g.:

for i in $(pre '^[n-o]'| cut -f1 | sort) ; do debsums -c $i | grep missing ; done

Unfortunately some packages don't deposit md5sums where debsums can find them. "binutils" and "bogofilter" are two. I suppose you could reinstall those just in case. If you use a local package cache program like "apt-cache", the download process should go quickly for packages already in the cache.

Better than that, install "debsums" now. It adds a configuration item to force generation of md5sums when packages are installed. See the file /etc/apt/apt.conf.d/90debsums.


Posted by Charles Curley | Permanent link | File under: linux