无法安装/删除/升级任何软件包

所以我前几天试图升级Ubuntu 11.10 64位系统时遇到了一个错误:

dpkg: ../../src/archives.c:978: tarobject: 断言 `r == stab.st_size' 失败。

于是我按照这个Ubuntu论坛的帖子这个帖子的方法进行操作。

我从info文件夹和status文件中移除了ubuntu-docs

现在每当我尝试安装/删除/升级任何软件包时都会收到一个错误提示:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/aptdaemon/worker.py", line 968, in simulate
    trans.unauthenticated = self._simulate_helper(trans)
  File "/usr/lib/python2.7/dist-packages/aptdaemon/worker.py", line 1092, in _simulate_helper
    return depends, self._cache.required_download, \
  File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 235, in required_download
    pm.get_archives(fetcher, self._list, self._records)
SystemError: E:I wasn't able to locate a file for the ubuntu-docs package. This might mean you need to manually fix this package.

当我尝试通过命令行安装ubuntu-docs时,我得到了以下输出:
 BlockquoteReading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be upgraded:
  ubuntu-docs
1 upgraded, 0 newly installed, 0 to remove and 33 not upgraded.
1 not fully installed or removed.
Need to get 1,408 kB of archives.
After this operation, 22.5 MB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ oneiric/main ubuntu-docs all 11.10.4 [1,408 kB]
Fetched 1,408 kB in 5s (265 kB/s)        
(Reading database ... 
dpkg: warning: files list file for package `ubuntu-docs' missing, assuming package has no files currently installed.
(Reading database ... 323646 files and directories currently installed.)
Preparing to replace ubuntu-docs 11.10.4 (using .../ubuntu-docs_11.10.4_all.deb) ...
Unpacking replacement ubuntu-docs ...
dpkg: ../../src/archives.c:978: tarobject: Assertion `r == stab.st_size' failed.
E: Sub-process /usr/bin/dpkg exited unexpectedly

...看起来和我开始遇到问题时差不多,所以我查看了信息--没有ubuntu-docs包,但是状态中有一个条目,所以我将其删除并再次尝试,但是只要我运行sudo dpkg --configure -aubuntu-docs的条目就会重新出现。

有什么想法吗?

编辑 (不作为评论以保存格式):

这个帖子说我需要在从状态中删除相应的行后运行sudo apt-get update。所以我先运行sudo apt-get clean,然后再运行sudo apt-get update。但是我收到了一条消息:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

在运行了sudo dpkg --configure -a之后,状态文件中包含以下内容:
Package: ubuntu-docs
Status: install reinstreq half-installed
Priority: optional
Section: doc
Version: 11.10.4

不确定是否有帮助。
3个回答

有时候,一个损坏的安装包可能会破坏你的软件包管理系统,导致你的Linux无法安装或删除任何软件包。这是我在尝试为Ubuntu安装ndas-admin后从apt-get得到的错误信息。 $sudo apt-get install mplayer(或任何软件包) 正在读取软件包列表... 完成 正在构建依赖关系树 正在读取状态信息... 完成 E: 软件包ndas-admin需要重新安装,但我找不到它的存档。(这是错误信息)
我尝试使用sudo apt-get install -f来尝试解决问题,但是得到了相同的错误。我唯一的选择就是手动编辑dpkg状态文件。
$ sudo gedit /var/lib/dpkg/status    (if you prefer you can use vi instead of gedit)
Locate the corrupt package, and remove the whole block of information about it and save the file. Mine looked like this:

Package: ndas-admin
Status: deinstall reinstreq half-configured
Priority: extra
Section: alien
Installed-Size: 100
Maintainer: root <root@ubuntu510>
Architecture: i386
Version: 1.0.2-24
Depends: libc6 (>= 2.3.4-1)
Description: Administration toosl for XIMETA,Inc NDAS device driver for Linux operating system
 ndas-admin – This program allows the user to register/enable/disable/unregister the XIMETA NDAS hard disk.
 .
 (Converted from a rpm package by alien version 8.53.)

已修复。希望能对其他人有所帮助。

遇到类似问题,我能用这种方法解决!谢谢! - student

这是对我有效的方法:
sudo dpkg --force-all -r ubuntu-docs

如果有任何问题再报告一下。 顺便说一句,解决方案已经发布在如何使dpkg重新工作?
哦对了,给你一个建议:现在每次更新系统我都需要使用Synaptic,因为ubuntu-docs总是包含在每个更新中,我需要取消勾选它 :-/。猜想我会提出另一个问题,询问如何从每个后续更新中移除特定的软件包。

可能是因为您的命令试图重复使用在您的计算机上缓存的损坏软件包。请尝试运行以下命令来清除apt缓存:
sudo apt-get clean

警告,这将删除所有缓存的软件包,所以如果您正在安装过程中,它将需要重新下载许多文件。

然后您应该能够按照正常的升级过程进行操作。


好的,所以我需要从状态文件中删除与ubuntu-docs相关的信息,然后需要使用sudo apt-get clean命令来清理。这样我就可以使用sudo dpkg -i安装任何软件包,但仍然无法升级。 - wisemonkey
如果你现在运行以下命令会发生什么?sudo apt-get -f install - ImaginaryRobots
相同的事情,我无法格式化这个,但是在这里: sudo apt-get -f install (正在读取数据库... dpkg:警告:找不到软件包“ubuntu-docs”的文件列表文件,假设该软件包当前没有安装任何文件。 (正在读取数据库...目前安装了323783个文件和目录。) 准备替换ubuntu-docs 11.10.4(使用.../ubuntu-docs_11.10.4_all.deb)... 解压缩替换的ubuntu-docs... dpkg:../../src/archives.c:978:tarobject:断言“r == stab.st_size”失败。 E:子进程/usr/bin/dpkg意外退出 - wisemonkey
我在想这是不是个bug?我不想重新安装所有东西 :-/ - wisemonkey