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

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

我想知道为什么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

答案1

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-12linux-headers-3.0.0-13dist-upgradeupgrade

答案2

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

答案3

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

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

答案4

简短回答那些想要确切要点的人

apt-get update

  • update 命令会用最新的可用版本更新软件包列表
  • 它不会升级已安装的软件包,只会用新版本更新软件包列表
  • 要升级需要运行升级命令

apt-get upgrade

  • 将已安装的软件包更新为最新可用版本
  • 它将仅升级已安装的软件包至最新版本
  • 如果缺少依赖项,则将保留当前版本而不进行任何升级

apt-get dist-upgrade

  • 将已安装的软件包更新为具有所需依赖项的最新可用版本
  • 它将自动安装所需的附加软件包和依赖项,并删除已安装的软件包,以进行清晰的升级

apt-get full-upgrade

  • full-upgrade 执行升级功能,但如果需要解决软件包冲突,也可能删除已安装的软件包。

apt-get do-release-upgrade

  • 它可以升级 ubuntu 的发布版本,例如,如果你想将 ubuntu 18.04 升级到 20.04,我们可以运行 do-release-upgrade
  • 要使用此命令,系统必须先完全升级。为此,您应该先运行 sudo apt-get upgrade,然后运行 ​​sudo apt-get dist-upgrade

參考文獻:https://linuxhint.com/apt_get_upgrade_dist_upgrade/#:~:text=Unlike%20apt%2Dget%20upgrade%20command,sudo%20apt%2Dget%20dist%2Dupgrade

相关内容