I get this error: dpkg: unrecoverable fatal error, aborting: files list file for package `fonts-tlwg-kinnari' contains empty filename

Solution 1:

This is a bug reported at launchpad.

The error shown will be either:

files list file for package '*' is missing final newline

Or:

files list file for package '*' contains an empty filename

Where * start is a random but steady "per install" package name.

Solution:

Donwload the .deb

sudo apt-get download fonts-tlwg-kinnari

Run this code

sudo dpkg -c /var/cache/apt/archives/fonts-tlwg-kinnari_1%3a0.5.1-3_all.deb  | awk '{if ($6 == "./") { print "/."; } \
else if (substr($6, length($6), 1) == "/") \
{print substr($6, 2, length($6) - 2); } \
else { print substr($6, 2, length($6) - 1);}}' > /var/lib/dpkg/info/fonts-tlwg-kinnari.list 

You can read more at launchpad

Solution 2:

Another option from Adrian's answer above is this:

sudo rm /var/lib/dpkg/info/fonts-tlwg-kinnari.list

and then

sudo apt-get install --reinstall fonts-tlwg-kinnari

Basically, this error means something got corrupted on your filesystem. It's a bad sign, and these list files are needed for the package manager to figure out what is and isn't safe to upgrade.

This regeneration of the list file is the best option, but it's not 100% safe.

Either way, keep in mind that something went wrong with your drive, and watch out for more errors.

Solution 3:

Adrian Cid Almaguer's answer is the only thing that worked for me, the general idea being "recreate the missing file from the .deb package".

A note though: check first in /var/cache/apt/archives/ and /var/lib/dpkg/info to see if the .deb file already exists. If so, just use that instead of doing the sudo apt-get download.

Also, sudo dpkg ... | awk ... | sudo tee /var/lib/dpkg/info/example.list is likely to work better for most people; the sudo tee combination overcoming the permissions problem > redirection encounters.

Solution 4:

I finally had some time to fix this on my own. For future reference

I moved all the linux* files to somewhere else. ex: ~/ (home) sudo mv /var/lib/dpkg/info/linux* ./

sudo dpkg --configure -a
sudo apt update
sudo apt upgrade

That fixed it