I was upgrading Ubuntu packages with
sudo apt-get update sudo apt-get upgrade
The upgrade failed with a segmentation fault. I tried again, but found I had a corrupted /var/lib/dpkg/available file. I first go this error:
dpkg: parse error, in file '/var/lib/dpkg/available' near line 872 package 'ubuntu-serverguide': `Depends' field, reference to `libc6': version contains ` ' E: Sub-process /usr/bin/dpkg returned an error code (2)
I edited the available file and fixed the problem. But then I got this:
Preconfiguring packages ... dpkg: parse error, in file '/var/lib/dpkg/available' near line 872 package 'ubuntu-serverguide': field name `Conflicts8' must be followed by colon E: Sub-process /usr/bin/dpkg returned an error code (2)
I made more edits and got more errors. It then realized that the file was corrupted. Bummer.
I didn’t know how to recover. But with a little research, I discovered that apt-get doesn’t actually need the available file. You can back it up, create an empty one, and then apt-get will recreate it:
cd /var/lib/dpkg/ sudo mv available available.bak.fjl sudo touch available sudo apt-get update sudo apt-get upgrade
Presto. The upgrade succeeded and I got a fresh available file in the process. Problem solved.