歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> apt-get upgarde和dist-upgrade的差別

apt-get upgarde和dist-upgrade的差別

日期:2017/2/27 16:02:06   编辑:Linux教程
Debian/Ubuntu Linux都使用apt,升級時都是:

apt-get update
apt-get upgrade
apt-get dist-upgrade

但是常常有人會問,
upgrade和dist-upgrade有何不同,仔細查查,似乎大家對upgrade和dist-upgrade的解釋都有點不同,在此也紀錄自己的看法.

我認為apt-get
upgrade和dist-upgrade的差別:

upgrade:系統將現有的Package升級,如果有相依性的問題,而此相依性需要安裝其它新的Package或影響到其它Package的相依性時,此Package就不會被升級,會保留下來.

dist-upgrade:可以聰明的解決相依性的問題,如果有相依性問題,需要安裝/移除新的Package,就會試著去安裝/移除它.
(所以通常這個會被認為是有點風險的升級)

apt-get upgrade 和 apt-get dist-upgrade 本質上是沒有什麼不同的。

只不過,dist-upgrade
會識別出當依賴關系改變的情形並作出處理,而upgrade對此情形不處理。

例如軟件包 a 原先依賴 b c d,但是在源裡面可能已經升級了,現在是 a 依賴 b c
e。這種情況下,dist-upgrade 會刪除 d 安裝 e,並把 a 軟件包升級,而 upgrade 會認為依賴關系改變而拒絕升級 a
軟件包。

man 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
That which didn't kill me makes me stronger
Copyright © Linux教程網 All Rights Reserved