error: parsing file '/var/lib/dpkg/status' near line 55497 package 'indicator-displex'

After running an upgrade from Ubuntu 11.10 (Oneiric Ocelot) to 12.04LTS (Precise Pangolin), a window popped up saying that the upgrade failed and that I should run sudo dpkg --configure -a.

Running that command gave me:

sudo dpkg --configure -a
dpkg: error: parsing file '/var/lib/dpkg/status' near line 55497 package 'indicator-displex':
 blank line in value of field 'Description

Trying to run apt-get install -f gives me many dependency errors along with that same dpkg error.


After looking at the file mentioned in the error /var/lib/dpkg/status on line 55497, I saw this:

Package: indicator-displex
Priority: optional
Section: GTK, system, admin
Installed-Size: 1524
Maintainer: Arick McNiel <arickmcniel AT yahoo DOT com>
Architecture: all
Version: 0.1
Depends: python, python-gtk2, python-central (>= 0.6.1), python-notify, python-appindicator, compiz
Size: 130748
Description: DisPlex
 AppIndicator to interface with Compiz / Xrandr / Emerald.
 .
 The Displex (indicator-displex) application provides an AppIndicator to the display
 interfaces of Compiz / Emerald / and Gnome Display Manager.  In doing so, it hopes
 to provide a product that is helpful for those applications without an AppIndicator
 interface AND to minimize icons by combinine some functionality of the
 gnome-display-manger AppIndicator icon.

 DisPlex has the following features:
 -Uses the new Ubuntu AppIndicator interface
 -Provides interface for: COMPIZ, EMERALD, GNOME Display Properties
 -Enables you to change decorators from the AppIndicator Tray
 -Enables you to activate / deactivate Compiz Effects
 -Enables you to switch window manager
 -Provides the ability to hide/show desktop icons
Homepage: https://launchpad.net/displex; http://sourceforge.net/projects/displex/

I made a backup of this file, and then opened it in a text editor. (sudo vi /var/lib/dpkg/status, then :55497 to go to that line.)

Adding a single . to the blank line before "DisPlex has the following features:" fixed the problem.

(if unfamiliar with vi... here's a hint: A to append line, add a space & period ESC to exit insert mode, then :wq to write & quit)

I was then able to run sudo dpkg --configure -a. After running sudo apt-get -f install, I saw a similar error for the file /var/lib/dpkg/available. I added a single . to this file on the line mentioned in the error, and now it mostly works.

I ran into one last problem which is the same as this bug.

Unpacking libatk-adaptor-schemas (from .../libatk-adaptor-schemas_2.4.0-1ubuntu2_amd64.deb) ...
 dpkg: error processing /var/cache/apt/archives/libatk-adaptor-schemas_2.4.0-1ubuntu2_amd64.deb (--unpack):
  trying to overwrite '/usr/share/glib-2.0/schemas/org.a11y.atspi.gschema.xml', which is also in package libatk-adaptor 2.2.1-0ubuntu1
ErrorMessage: trying to overwrite '/usr/share/glib-2.0/schemas/org.a11y.atspi.gschema.xml', which is also in package libatk-adaptor 2.2.1-0ubuntu1

To fix this problem:

sudo apt-get update
sudo apt-get dist-upgrade

you can also try running:

sudo fuser -vki /var/lib/dpkg/lock
sudo dpkg --configure -a

which works for me. It kills the process having the lock on dpkg.

(Also see https://bugs.kde.org/show_bug.cgi?id=284962 )