DPKG Warning – Files List File for Package Missing

dpkgsoftware installation

I want to install Open JDK or Oracle JDK to my machine but I got an error during installation. The error is:

Selecting previously unselected package oracle-java8-installer.
dpkg: warning: files list file for package 'unity-scope-gourmet' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'unity-scope-guayadeque' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'unity-scope-gmusicbrowser' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'unity-scope-manpages' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'unity-scope-firefoxbookmarks' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'unity-scope-gdrive' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'unity-scope-home' missing; assuming package has no files currently installed
E: Sub-process /usr/bin/dpkg returned an error code (2)

I searched on Google and try to something for install/reinstall this packages. Finally i try to remove Unity. I faced this error for my every tries. I am using Xmonad. How can I fix this issue?

Best Answer

One loop over the seven packages' names to recreate the list-file for each package.

But first run

sudo apt-get autoclean

to remove unneeded DEBs in /var/cache/apt/archives. This is necessary that the following commands work properly.

arch="$(dpkg --print-architecture)"
for p in
  unity-scope-gourmet unity-scope-guayadeque unity-scope-gmusicbrowser
  unity-scope-manpages unity-scope-firefoxbookmarks unity-scope-gdrive
  unity-scope-home
do
    find /var/cache/apt/archives -type f -name "${p}_*_${arch}.deb" -exec dpkg-deb --fsys-tarfile {} \; -quit | tar t | cut -f2- -d. | sed 's|^/$|/.|;s|/$||' | sudo tee "/var/lib/dpkg/info/$p.list" > /dev/null
done
sudo chmod -R a+r /var/lib/dpkg/info

Some tests later, the command

sudo apt-get install --reinstall unity-scope-gourmet unity-scope-guayadeque unity-scope-gmusicbrowser unity-scope-manpages unity-scope-firefoxbookmarks unity-scope-gdrive unity-scope-home

should also help.