当我们安装一个安装失败的软件包时究竟会发生什么deb
,以及如何apt-get -f
补救这种情况(而不是在安装开始时发生这种情况)?
例子:
1)我们安装从https://github.com/getferdi/ferdi/releases/tag/v5.3.3下载的 ferdi 包:
$ dpkg -i ferdi.deb
Selecting previously unselected package ferdi.
(Reading database ... 180829 files and directories currently installed.)
Preparing to unpack .../ferdi_5.3.3_amd64.deb ...
Unpacking ferdi (5.3.3-157) ...
dpkg: dependency problems prevent configuration of ferdi:
ferdi depends on gconf2; however:
Package gconf2 is not installed.
ferdi depends on gconf-service; however:
Package gconf-service is not installed.
ferdi depends on libappindicator1; however:
Package libappindicator1 is not installed.
dpkg: error processing package ferdi (--install):
dependency problems - leaving unconfigured
Processing triggers for mime-support (3.64) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Errors were encountered while processing:
ferdi
正如我们所见,由于缺少依赖项,包没有正确安装。
2)然而修复损坏的包很容易成功:
$ apt-get --fix-broken --yes install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
gconf-service gconf2 libappindicator1 libdbusmenu-gtk4 libindicator7
Suggested packages:
gconf-defaults-service
The following NEW packages will be installed:
gconf-service gconf2 libappindicator1 libdbusmenu-gtk4 libindicator7
0 upgraded, 5 newly installed, 0 to remove and 53 not upgraded.
1 not fully installed or removed.
Need to get 993 kB of archives.
After this operation, 1,539 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian unstable/main amd64 gconf-service amd64 3.2.6-6 [415 kB]
Get:2 http://deb.debian.org/debian unstable/main amd64 gconf2 amd64 3.2.6-6 [426 kB]
Get:3 http://deb.debian.org/debian stable/main amd64 libdbusmenu-gtk4 amd64 18.10.20180917~bzr490+repack1-1 [45.7 kB]
Get:4 http://deb.debian.org/debian stable/main amd64 libindicator7 amd64 0.5.0-4 [53.0 kB]
Get:5 http://deb.debian.org/debian stable/main amd64 libappindicator1 amd64 0.4.92-7 [53.3 kB]
Fetched 993 kB in 1s (1,071 kB/s)
Selecting previously unselected package gconf-service.
(Reading database ... 181193 files and directories currently installed.)
Preparing to unpack .../gconf-service_3.2.6-6_amd64.deb ...
Unpacking gconf-service (3.2.6-6) ...
Selecting previously unselected package gconf2.
Preparing to unpack .../gconf2_3.2.6-6_amd64.deb ...
Unpacking gconf2 (3.2.6-6) ...
Selecting previously unselected package libdbusmenu-gtk4:amd64.
Preparing to unpack .../libdbusmenu-gtk4_18.10.20180917~bzr490+repack1-1_amd64.deb ...
Unpacking libdbusmenu-gtk4:amd64 (18.10.20180917~bzr490+repack1-1) ...
Selecting previously unselected package libindicator7:amd64.
Preparing to unpack .../libindicator7_0.5.0-4_amd64.deb ...
Unpacking libindicator7:amd64 (0.5.0-4) ...
Selecting previously unselected package libappindicator1:amd64.
Preparing to unpack .../libappindicator1_0.4.92-7_amd64.deb ...
Unpacking libappindicator1:amd64 (0.4.92-7) ...
Setting up libindicator7:amd64 (0.5.0-4) ...
Setting up gconf-service (3.2.6-6) ...
Setting up libdbusmenu-gtk4:amd64 (18.10.20180917~bzr490+repack1-1) ...
Setting up libappindicator1:amd64 (0.4.92-7) ...
Setting up gconf2 (3.2.6-6) ...
Setting up ferdi (5.3.3-157) ...
Processing triggers for man-db (2.9.0-1) ...
Processing triggers for libc-bin (2.29-2) ...
- 为什么在 期间没有安装缺少的依赖项
dpkg -i
? - 为什么
apt-get -f
能够轻松解决? - 这是可以做的事情,还是会导致系统损坏?
编辑: 请参阅下面的@thorian93 答案。另请参阅https://askubuntu.com/a/795048/1002165
据我所知
dpkg
,没有依赖解析。这就是为什么您最终会收到损坏的包裹。无论如何都会安装该软件包,但它在该状态下不起作用。入口
apt
:apt
读取dpkg
数据库,找到损坏的包和丢失的依赖项。与依赖项解析apt
一样,它会扫描其配置的镜像以查找依赖项并安装它们。回答你的第三个问题:这样做是可以的,尽管我建议
apt
首先安装包,或者至少使用gdebi
,它也能够进行依赖解析。