0

I have an Ubuntu installation where /var/lib/dpkg is empty. Every apt-get command fails with this error :

E: Impossible de verrouiller /var/lib/dpkg/status - open (2: Aucun fichier ou dossier de ce type)

(can not lock /var/lib/dpkg/status)

Which is not unexpected as the folder is empty.

How can I totally uninstall and reinstall dpkg?

Hennes
  • 4,772
  • 1
  • 18
  • 29
Sylario
  • 101
  • 1
  • 11
  • Please run `LANG=C apt-get update` and update your question with the error message in a locale everybody here can read. – dawud Jul 28 '13 at 16:13

1 Answers1

0

You don't need to reinstall dpkg, what you need to do is to recover the database of package selections.

This is a use case where a backup might be useful.

If you don't have backups, you can try to copy an old status file from var/backups/dpkg.status.* to the original location in /var/lib/dpkg and run

# apt-get clean && apt-get update

If you can't recover an old status file, you can still try to rebuild one:

# ls /usr/share/doc | grep -Ev '([A-Z]|^texmf$|^debian$)' | awk '{print $1 " install"}' | dpkg --set-selections
# dselect --expert
dawud
  • 14,918
  • 3
  • 41
  • 61