[应该忽略的!]软件包安装、删除出错的终极解决方法!

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
cnkilior
论坛版主
帖子: 4984
注册时间: 2007-08-05 17:40

[应该忽略的!]软件包安装、删除出错的终极解决方法!

#1

帖子 cnkilior » 2009-07-05 22:03

注意:你应该先去寻找其他解决方法,无效再来尝试本方法!!

本方法适用于任何软件包安装,删除时报告的类似于:“post-xxxxx失败”,以及其他错误。


---------言归正传---------

原理:dpkg之所以能够对每个包的状态了如指掌,完全是因为dpkg数据库--->>/var/lib/dpkg/status
这个文本文件中记录了软件仓库中曾经安装过的软件包的安装状态。
所以,只需要改动这个文件就能够改变软件包的状态。

软件包的状态:
1、not-installed
The package is not installed on your system.
2、config-files
Only the configuration files of the package exist on the system.
3、half-installed
The installation of the package has been started, but not com-
pleted for some reason.
4、unpacked
The package is unpacked, but not configured.
5、half-configured
The package is unpacked and configuration has been started, but
not yet completed for some reason.
6、 triggers-awaited
The package awaits trigger processing by another package.
7、 triggers-pending
The package has been triggered.
8、 installed
The package is unpacked and configured OK.
以上请详细参考man dpkg
根据以上状态:half-installed和half-configured是常见的错误状态,不完全配置,或者不完全安装。

还需要注意的是:
软件包还有一个选择状态:
1、install
The package is selected for installation.
2、deinstall
The package is selected for deinstallation (i.e. we want to
remove all files, except configuration files).
3、purge The package is selected to be purged (i.e. we want to remove
everything, even configuration files).
最后组合起来的错误状态大概就有6种,安装、删除出错都会将软件包的状态标记成其中之一!
它们的状态都要被修改成:install ok installed ; deinstall ok not-installed或purge ok not-installed。

最后需要注意的是:
软件包除了处在not-install 的状态,其余状态都是有完整的描述的。
要将错误状态修改成installed状态,需要查看一下软件包的描述是否有。(这个一般是有的)
要将错误状态修改成not-install状态,需要删除软件包的描述,删除Section行下面的全部。(不要把别人的删掉)

例子:
Package: libexempi3
Status: purge ok half-installed
Priority: optional
Section: libs
Installed-Size: 748
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: i386
Source: exempi
Version: 2.0.2-2
Depends: libc6 (>= 2.4), libexpat1 (>= 1.95.8), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.2.1)
Description: library to parse XMP metadata (Library)
Exempi is a library to parse XMP metadata as defined by the
specification.
.
XMP (Extensible Metadata Platform) facilitates embedding metadata in files
using a subset of RDF. Most notably XMP supports embedding metadata in PDF
and many image formats, though it is designed to support nearly any file type.
Original-Maintainer: Asheesh Laroia <asheesh@asheesh.org>
Homepage: http://libopenraw.freedesktop.org/wiki/Exempi
显然这个状态是有错误的。只要修改成:
Package: libexempi3
Status: purge ok not-installed
Priority: optional
Section: libs
这个软件包的状态就修改好了,不会再报错了。

好了,写了这么多了,最后一个警告:编辑这个文件之前记得备份!

------此方法绝无毒副作用,可放心使用----
头像
Jacob Anubis
帖子: 189
注册时间: 2009-04-08 20:44
来自: 三维空间

Re: [应该忽略的!]软件包安装、删除出错的终极解决方法!

#2

帖子 Jacob Anubis » 2009-07-05 22:23

:em11
如果只是遇见,不能停留,不如不遇见!
头像
hcym
帖子: 15634
注册时间: 2007-05-06 2:46

Re: [应该忽略的!]软件包安装、删除出错的终极解决方法!

#3

帖子 hcym » 2009-07-05 22:31

我这精简的只能用:$ gdebi package.deb 安装

其他一概不灵光

:em04
头像
cnkilior
论坛版主
帖子: 4984
注册时间: 2007-08-05 17:40

Re: [应该忽略的!]软件包安装、删除出错的终极解决方法!

#4

帖子 cnkilior » 2009-07-05 23:02

各位童孩请无视楼上!
头像
missing
帖子: 1470
注册时间: 2008-03-28 20:52
系统: QNX

Re: [应该忽略的!]软件包安装、删除出错的终极解决方法!

#5

帖子 missing » 2009-07-05 23:05

學習一下(*^_^*)
missing is i missing you...
头像
hcym
帖子: 15634
注册时间: 2007-05-06 2:46

Re: [应该忽略的!]软件包安装、删除出错的终极解决方法!

#6

帖子 hcym » 2009-07-05 23:08

就是不懂啊

直接装deb

代码: 全选

dpkg: 在 <包状态和进度文件描述符> 时,无法读取文件描述符的标志位: 错误的文件描述符
非得把旧版本删净才行

gdebi就方便多了

:em06
头像
AngelMAX
帖子: 2228
注册时间: 2009-02-25 18:18

Re: [应该忽略的!]软件包安装、删除出错的终极解决方法!

#7

帖子 AngelMAX » 2009-07-05 23:33

cnkilior 写了:各位童孩请无视楼上!
回应楼主,已经对其进行无视处理,询问是否加入总是无视名单?
:em04
在中国搞IT的谁不知道Ctrl+C,Ctrl+V啊~
头像
yescookie
帖子: 172
注册时间: 2008-09-19 17:59

Re: [应该忽略的!]软件包安装、删除出错的终极解决方法!

#8

帖子 yescookie » 2010-09-04 23:37

:em11 感觉LZ,解决了困扰我很久的问题啊!
xiaobangdelei
帖子: 43
注册时间: 2009-05-15 1:20

Re: [应该忽略的!]软件包安装、删除出错的终极解决方法!

#9

帖子 xiaobangdelei » 2011-03-05 3:23

mark一下,好文,但还是没有解决我得问题!viewtopic.php?f=77&t=320093
回复