Whenever I type sudo apt-get remove
and then press the Tab key for auto-completion I get the following message:
grep-status: /var/lib/dpkg/status:15945: expected a colon
.
I don't see anything especially strange at line 15945 in the status file. It's a dot character in the description field of a mono library package and inserting a colon did not help. Removing the line containing the dot did not work either. Overwriting the file with status-old resulted in the same message.
Is there some way to rebuild the status file?
You should be able to work with a previous known good status file and update from there. Every time you do an install or a update, the status file is saved to a gzipped backup under /var/backups. Doing an ls -l dpkg * on the directory shows:
There's also a backup of the file created in the /var/lib/dpkg/ directory named status-old. Doing an ls -l status* on the directory shows:
So, to recover from a corruption, you should be able to do the following:
1. Make a backup of the corrupt status file:
2. Copy an recent dpkg status file into place from either of the sources above:
either
or
3. Then run apt-get update:
That should do it.
I have finally fixed my system of this. Restoring a backup of the status file didn't work as I've had the issue for so long, it's in all of my backups.
The fix involves grepping for the actual formatting breaks and fixing them manually. It's not as hard as it sounds.
http://thepcspy.com/read/fixing-dpkg-status-corruption/
Try a "dpkg -P " for the offending package. That will purge it from the local repository, removing all traces. On my system, that was the fix for removed (but not yet purged) packages that produced that error.
I was able to fix this problem by removing the packages which had corrupted entries in the status file.
The accepted solution via pcregrep didn't work (pcregrep didn't find anything).
In this case I would back up the corrupted
/var/lib/dpkg/status
file and then correct it manually (around the lines 1888 and 9550) using the information fromThis has been a bug (supposed to be fixed): Launchpad Bug 613018
Upstream: Debian Bug 590885
This should be a workaround (backup, "fix" version string):
Son of a...
Okay, the actual error was on line 15266 despite it being reported some 700 lines further down. The problematic entry in the status file was caused by a deb I installed to get my Lexmark printer working a long time ago. The entry was for the package
lexmark-inkjet-08-driver
. The Description field did not have a.
in the place of a line break. This caused the parsing error.To find this, I resorted to a shotgun troubleshooting method and started trying things pretty much randomly. One of my goofy attempts was
grep-status -P e
figuring that e was the most common letter in the alphabet. Dumb, I know, but the last status record printed out before it complained about a missing colon was for the lexmark package and I noticed the lack of a.
character after a few minutes of staring at the screen.If possible, I would like another answer that could describe a better method for finding this sort of issue in case someone runs into a similar problem in the future. Thanks.
Because my status-old was too problematic even with
apt-get update
,This worked pretty well for me:
(as root)
CREDIT: http://alvinalexander.com/blog/post/linux-unix/how-remove-non-printable-ascii-characters-file-unix
If you're curious what's changed or where would be the damage: (possibly long)