Friday, October 12, 2012

Fixing another /var/lib/dpkg/status corruption

This has happened a few times on my debian/ubuntu/apt based system, sending me searching for answers. I always end up hacking the file to make it work, which makes me a bit uneasy, but it is in fact apparently the only choice in many of these situations. This "database" is just a plain text file.

Sometimes the problem is obvious, but often it is not. For example, here is my latest error message:
dpkg-query: error: parsing file '/var/lib/dpkg/status' near line 7848 package 'fontconfig': field name `
There is no ` character anywhere near line 7848, field name or otherwise.

The easiest solution to this, and similar, issues is to remove the whole section belonging to the package named. So in this case I remove everything starting at the line containing
Package: fontconfig
down to, and including, the next blank line.

But wow apt/dpkg no longer no longer knows the status of your fontconfig package. The easiest way to solve that is just re-install it. (sudo apt-get install fontconfig)

Make a backup of the status file first, if you're nervous.

No comments:

Post a Comment