什么是“dist-upgrade”,为什么升级超过“升级”?

344

我想知道为什么 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 执行此操作?

    
Richard Rodriguez 22.11.2011 - 07:03

4 答案

285

来自 apt-get manual :

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.

从14.04开始提供较新的 apt 工具:

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-12linux-headers-3.0.0-13 提供的虚拟包,这听起来像 dist-upgrade 处理的包安装和删除类型,但不是 upgrade

    
给出答案 jcollado 22.11.2011 - 07:57
118

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 的提示。

    
给出答案 pablomme 27.01.2012 - 17:34
32

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

有时,软件包之间的各种不兼容性需要删除一些软件包才能升级其他软件包,这也需要进行dist-upgrade。内核更新将始终需要dist-upgrade,因为它们的处理方式。而不是让内核包得到更新,每次都会创建一个全新的内核包,内核元数据包会更新,以取决于新的内核包而不是旧内核包。这样做是为了保留旧内核版本,以便在引导新内核时出现问题,您可以从启动菜单中选择旧内核并恢复。

    
给出答案 psusi 22.11.2011 - 15:45
11

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

但是 apt-get upgrade NOT 通常会安装新版本,其中包含主要更改(包括删除软件包或GRUB更新)。例如,当一个新的Linux内核(linux-image-3.x.x-xx-generic等)可用时,将不会安装该软件包。

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

    
给出答案 david6 28.01.2012 - 01:55

阅读有关标签的其他问题