dpkg退出并错误解析文件`/ var / lib / dpkg / status`,该怎么办?


12

尝试安装任何软件时,都会遇到此错误,因此无法更新。

Preconfiguring packages ...
dpkg: error: parsing file '/var/lib/dpkg/status' near line 51245 package 'oracle-xe':
 mixed non-coinstallable and coinstallable package instances present
N: Ignoring file 'gcl' in directory '/etc/apt/sources.list.d/' as it has no filename extension
N: Ignoring file 'gcl' in directory '/etc/apt/sources.list.d/' as it has no filename extension
E: Sub-process /usr/bin/dpkg returned an error code (2)

Answers:


27

幸运的你!您有备份!甚至,它们每天都在您不知情的情况下制成!因此,要恢复文件,只需运行:

sudo rm /var/lib/dpkg/status
sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status
sudo apt-get update

做完了!

如果您需要更旧的文件,则还有更多选择:

ls /var/backups/dpkg.status*
/var/backups/dpkg.status.0     /var/backups/dpkg.status.4.gz
/var/backups/dpkg.status.1.gz  /var/backups/dpkg.status.5.gz
/var/backups/dpkg.status.2.gz  /var/backups/dpkg.status.6.gz
/var/backups/dpkg.status.3.gz

只需使用gunzip以下命令解压缩它们:

gunzip -c /var/backups/dpkg.status.6.gz > /var/lib/dpkg/status

如果备份不好,则另一种方法是列出doc目录内容:

sudo -i
ls /usr/share/doc | \
      grep -v [A-Z] | \
      grep -v '^texmf$' | \
      grep -v '^debian$' | \
      awk '{print $1 " install"}' | \
      dpkg --set-selections

http://www.debianhelp.co.uk/debianproblem.htm


2
谢谢上帝,我还有另一个老样子来做康复。在cp右边之后,输入sudo dpkg --configure -a解决所有问题!谢谢!
罗伯特
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.