什么是“ dist-upgrade”,为什么它比“ upgrade”更多升级?


395

我想知道为什么upgrade有时不希望升级系统的某些部分,而有时却想要dist-upgrade。这是运行后的示例apt-get upgrade

apt-get upgrade

rimmer@rimmer-Lenovo-IdeaPad-S10-2:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have been kept back:
  linux-generic linux-headers-generic linux-image-generic
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

apt-get dist-upgrade

rimmer@rimmer-Lenovo-IdeaPad-S10-2:~$ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  linux-headers-3.0.0-13 linux-headers-3.0.0-13-generic
  linux-image-3.0.0-13-generic
The following packages will be upgraded:
  linux-generic linux-headers-generic linux-image-generic
3 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 48.5 MB of archives.
After this operation, 215 MB of additional disk space will be used.
Do you want to continue [Y/n]?

换句话说,为什么不能执行此操作upgrade

Answers:


327

apt-get手册

upgrade
   upgrade is used to install the newest versions of all packages
   currently installed on the system from the sources enumerated in
   /etc/apt/sources.list. Packages currently installed with new
   versions available are retrieved and upgraded; under no
   circumstances are currently installed packages removed, or packages
   not already installed retrieved and installed. New versions of
   currently installed packages that cannot be upgraded without
   changing the install status of another package will be left at
   their current version. An update must be performed first so that
   apt-get knows that new versions of packages are available.

dist-upgrade
   dist-upgrade in addition to performing the function of upgrade,
   also intelligently handles changing dependencies with new versions
   of packages; apt-get has a "smart" conflict resolution system, and
   it will attempt to upgrade the most important packages at the
   expense of less important ones if necessary. So, dist-upgrade
   command may remove some packages. The /etc/apt/sources.list file
   contains a list of locations from which to retrieve desired package
   files. See also apt_preferences(5) for a mechanism for overriding
   the general settings for individual packages.

apt从14.04开始使用更新的工具:

full-upgrade
   full-upgrade performs the function of upgrade but may also remove
   installed packages if that is required in order to resolve a
   package conflict.

你的具体情况,我明白了,例如,linux-headers是由双方提供了一个虚拟包linux-headers-3.0.0-12,并linux-headers-3.0.0-13和这听起来像那种软件包安装和删除所处理的dist-upgrade,而不是通过upgrade


4
我不认为full-upgrade可以选择apt-get14.04.1。
2015年

我也不知道apt,但是根据他链接的手册页,这似乎是完全不同的命令
BlueWizard 2015年

18
@nobar您看不到,因为它是...的选择,apt而不是apt-get... :-)尝试man apt
哈斯图

好的,我进行了搜索,发现的最早的链接是Ubuntu 15.10(于2014年底发布,通过Jessie测试是合理的)manpages.ubuntu.com/manpages/wily/en/man8/apt.8.html
Z玻色子

6
@Zboson是的,14.04并不是在2011年问世,而是在2014年4月问世了。
tgies

137

apt-get upgrade仅限于将软件包替换为较新版本的情况,但无需添加或删除软件包。例如,新版本的Firefox应该可以通过安装apt-get upgrade

但是apt-get upgrade,当更新版本需要添加或删除时,它将拒绝工作。例如,当您linux-image-3.2.0-10-generic安装并linux-image-3.2.0-11-generic出现内核时,该linux-image-generic软件包将更新为依赖于较新的版本。为了安装新内核,您需要运行apt-get dist-upgrade

请注意,如何apt-get upgrade表示内核软件包已经存在held back。这就是使用的提示apt-get dist-upgrade


2
完善!:D还有两个问题... Ubuntu中的图形更新管理器使用了什么?推荐什么?
THpubs 2012年

11
图形实用程序update-manager不能apt-get直接使用。而是与称为的后端一起使用aptdaemon。的标准功能update-manager是的upgradedist-upgrade模式的混合apt-get:它可以添加但不能删除软件包-在需要删除时调用“部分升级”工具。使用命令行时,请使用apt-get upgrade。如果您看到报告说软件包已被“保留”,请运行apt-get dist-upgrade以获取其余更新。
pablomme 2012年

33

基本上,升级只会将现有软件包从一个版本升级到另一个版本。即使升级其他软件包,也不会安装或删除软件包。对于内核更新,升级linux-generic软件包需要安装新的linux-3.0.0-13-generic软件包,并且由于upgrade拒绝安装或删除软件包,因此它拒绝升级linux-generic。

有时,程序包之间的各种不兼容性会要求删除某些程序包以升级其他程序包,而这也需要进行dist-upgrade。内核更新由于其处理方式而始终需要dist-upgrade。每次都会创建一个全新的内核包,而不是更新内核包,并且将内核元包更新为依赖于新的内核包而不是旧的内核包。这样做是为了保留旧的内核版本,以防万一启动新内核时出现问题,可以从启动菜单中选择旧内核并进行恢复。


2
最佳要点。不过,如何保留一定的包装?
0xC0000022L

11

apt-get upgrade命令通常只会安装对当前安装的软件包的更新(或修复)。例如,通常会使用此命令安装新版本的Mozilla Firefox

但是apt-get upgrade一般安装新版本,其中的重大变化(包括去除包或GRUB更新是必需的)。例如,当有新的Linux内核(linux-image-3.xx-xx-generic等)可用时,将不会安装该软件包。

为了安装新内核,您需要运行apt-get dist-upgrade。当您运行时apt-get upgrade,系统会通知您,因为它表示某些软件包已被保留。这是您使用的提示:apt-get dist-upgrade


12
这是误导。dist-upgrade除非sources.list进行了相应的修改,否则不会升级到新版本(即使那样,在Ubuntu中也不支持这种升级方式)。当安装了新内核时dist-upgrade,这不是Ubuntu新版本。这只是一个新包装。此外,“或需要GRUB更新”的声明是错误的。sudo apt-get upgrade只要必须删除GRUB并安装新的软件包,在必须更新GRUB的情况下,它完全能够升级软件包。update-grub像往常一样自动运行。
Eliah Kagan

2
您应该编写自己的答案,因为这并没有使我明白。
david6 2013年

2
除了Eliah提到的内容外,最重要的一点是apt-get upgrade不会删除或添加软件包。如果某个程序包的修复程序需要一个新程序包,则更新将被保留。 pablomme的答案(您对此进行了修改以使其准确性降低)更好,我建议读者继续阅读。
Chan-Ho Suh

1
更正:apt-get upgrade永远不会安装删除任何软件包。内核升级被打包为新软件包,因此,apt-get upgrade将永远不会升级内核。内核升级确实会进行“重大”更改(例如GRUB配置)的事实并不是upgrade和区别的原因dist-upgrade
Mikko Rantalainen'9

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.