apt-get upgarde 和dist-upgrade的差別


Debian/Ubuntu Linux都使用apt,升級時都是:

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

 

安裝或升級系統分下面幾個步驟。

第一步,獲得最近的軟件包的列表;列表中包含一些包的信息,比如這個包是否更新過。

第二步,如果這個包沒有發布更新,就不管它;

            如果發布了更新,就把包下載到電腦上,並安裝。

 

apt-get update對應的就是第一步。

apt-get upgrade 與apt-get dist-upgrade對應的是第二步。

 

由於包與包之間存在各種依賴關系。upgrade只是簡單的更新包,不管這些依賴,它不和添加包,或是刪除包。而dist-upgrade可以根據依賴關系的變化,添加包,刪除包。

 

一般在運行upgrade或dist-upgrade之間,要運行update.



但是常常有人會問,
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

What Doesn't Kill Me Makes Me Stronger


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM