新聞中心
-
6.1. 寫入
sources.list文件 -
- 6.1.1. 句法
- 6.1.2. 給Stable 使用者的倉庫
- 6.1.3. 給測試/非穩(wěn)定 版本用戶的倉庫
- 6.1.4. Using Alternate Mirrors
-
6.1.5. 非官方來源:
mentors.debian.net - 6.1.6. Debian 軟件包 緩存 代理
-
6.2.
aptitude、apt-get和apt命令 -
- 6.2.1. 開端
- 6.2.2. 安裝和卸載
- 6.2.3. 系統(tǒng)升級
- 6.2.4. 配置選項
- 6.2.5. 包的優(yōu)先級管理
- 6.2.6. 在多個發(fā)行版工作
- 6.2.7. 自動追蹤已安裝的軟件包
-
6.3.
apt-cache命令 -
6.4. The
apt-fileCommand -
6.5. 前置:
aptitude、synaptic -
-
6.5.1.
aptitude -
6.5.2.
synaptic
-
6.5.1.
- 6.6. 檢查軟件包真?zhèn)?
- 6.7. 升級至下個穩(wěn)定發(fā)行版
-
- 6.7.1. 建議進(jìn)程
- 6.7.2. 處理升級后的問題
- 6.7.3. Cleaning Up after an Upgrade
- 6.8. 保持系統(tǒng)在最新狀態(tài)
- 6.9. 自動升級
-
-
6.9.1. 配置
dpkg - 6.9.2. 配置 APT
-
6.9.3. 配置
debconf - 6.9.4. 處理命令行接口
- 6.9.5. 神奇的組合
-
6.9.1. 配置
- 6.10. 搜索軟件包
What makes Debian so popular with administrators is how easily software can be installed and how easily the whole system can be updated. This unique advantage is largely due to the
APT program, which Falcot Corp administrators studied with enthusiasm. APT is the abbreviation for Advanced Package Tool. What makes this program “advanced” is its approach to packages. It doesn't simply evaluate them individually, but it considers them as a whole and produces the best possible combination of packages depending on what is available and compatible according to dependencies.

站在用戶的角度思考問題,與客戶深入溝通,找到和林格爾網(wǎng)站設(shè)計與和林格爾網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都做網(wǎng)站、成都網(wǎng)站建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名與空間、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務(wù)覆蓋和林格爾地區(qū)。
詞匯 軟件源和源代碼軟件包
The word
source can be ambiguous. A "source package" — a package containing the source code of a program — should not be confused with a "package source" — a repository (website, FTP server, CD-ROM, local directory, etc.) which contains packages. APT needs to be given a “l(fā)ist of package sources (repositories)”: the file
/etc/apt/sources.list will list the different repositories that publish Debian packages. APT will then import the list of packages published by each of these sources. This operation is achieved by downloading
Packages.xz files or a variant such as
Packages.gz or
.bz2 (using a different compression method) in case of a source of binary packages and by analyzing their contents. In case of a source of source packages, APT downloads
Sources.xz files or a variant using a different compression method. When an old copy of these files is already present, APT can update it by only downloading the differences (see sidebar
TIP Incremental updates).
回到基礎(chǔ) gzip, bzip2, LZMA 和XZ 壓縮
文件名后綴
.gz 表示文件經(jīng)過
gzip工具的壓縮。
gzip 是一個經(jīng)典的 Unix 命令,用于快速高效壓縮文件。一些新的壓縮工具更為有效,但需要更多內(nèi)存和時間來完成壓縮和解壓。按照出現(xiàn)的次序,這些工具有:
bzip2 (生成文件名后綴為
.bz2),
lzma(生成文件名后綴為
.lzma)和
xz(生成文件名后綴為
.xz)。
6.1. 寫入sources.list文件
6.1.1. 句法
Each active line in the
/etc/apt/sources.list file represents a package source (repository) and is made of at least three parts separated by spaces. For a complete description of the file format and the accepted entry compositions see
sources.list(5).
例 6.1. Example entry format in /etc/apt/sources.list
deb url distribution component1 component2 component3 [..] componentX deb-src url distribution component1 component2 component3 [..] componentX
第一個區(qū)域指示源的類型:
-
deb - package source (repository) of binary packages
-
deb-src - package source (repository) of source packages
The second field gives the base URL of the source. Combined with the filenames listed in the
Packages.xz files, it must give a full and valid URL. This can consist in a Debian mirror or in any other package archive set up by a third party. The URL can start with
file:// to indicate a local source installed in the system's file hierarchy, with
http:// or
https:// to indicate a source accessible from a web server server, or with
ftp:// or
ftps:// for a source available on an FTP server. The URL can also start with
cdrom: for CD-ROM/DVD/Blu-ray disc based installations, although this is less frequent, since network-based installation methods are eventually more common. The syntax of the last field depends on the structure of the repository. In the simplest case, you can simply indicate a subdirectory (with a required trailing slash) of the desired source. This is often a simple “
./” which refers to the absence of a subdirectory. The packages are then directly at the specified URL. But in the most common case, the repositories will be structured like a Debian mirror, with multiple distributions, each having multiple components. In those cases, name the chosen distribution by its “codename” — see the list in sidebar
社區(qū) Bruce Perens,一位有爭議的領(lǐng)導(dǎo)者 — or by the corresponding “suite”
oldstable,
stable,
testing,
unstable) and then the components to enable. A typical Debian mirror provides the components
main,
contrib, and
non-free.
關(guān)鍵詞 main, contrib 和 non-free 存檔
Debian uses three components to differentiate packages according to the licenses chosen by the authors of each work.
Main gathers all packages which fully comply with the Debian Free Software Guidelines. The
non-free component is different because it contains software which does not (entirely) conform to these principles but which can, nevertheless, be distributed without restrictions. This archive, which is not officially part of Debian, is a service for users who could need some of those programs and, nowadays, also require the firmware for their hardware. However, Debian always recommends giving priority to free software. The existence of this component represents a considerable problem for Richard M. Stallman and keeps the Free Software Foundation from recommending Debian to users.
Contrib (contributions) is a set of open source software which cannot function without some non-free elements — these elements can be software from the
non-free section, or non-free files such as game ROMs, BIOS of consoles, etc. — or some elements, not available from the Debian
main archive at all. The
contrib component also includes free software whose compilation requires proprietary elements. This was initially the case for the OpenOffice.org office suite, which used to require a proprietary Java environment.
TIP Files in /etc/apt/sources.list.d/
如果很多個軟件包的源庫在被引用,將它們分成多個文件會很實用。每一部分存在
/etc/apt/sources.list.d/文件名.list (參見邊欄
基本 結(jié)尾是
.d 的文件夾名稱)。
cdrom 條目描述了你所有的CD/DVD光盤。 與其他條目不同,因為一個CD光盤需要插入光驅(qū)中,并且每次只能讀一張,所以并不總是可用。因此這種倉庫管理起來稍有不同,需要加在
apt-cdrom 程序中,經(jīng)常與
add 參數(shù)一起執(zhí)行。后者會要求驅(qū)動中插入光盤,并會瀏覽內(nèi)容,尋找
Packages 文件。這些文件會用于更新可用軟件包的數(shù)據(jù)庫(此過程由
apt update 命令執(zhí)行)。 自此, 如果某軟件包需要光盤,APT 可發(fā)出要求插入光驅(qū)。
6.1.2. 給Stable 使用者的倉庫
下面是一個標(biāo)準(zhǔn)的
sources.list文件,它被用于
Stable 版本的 Debian 系統(tǒng):
例 6.2. /etc/apt/sources.list 給 Debian Stable 使用者的文件
# Security updates deb http://security.debian.org/ buster/updates main contrib non-free deb-src http://security.debian.org/ buster/updates main contrib non-free ## Debian mirror # Base repository deb https://deb.debian.org/debian buster main contrib non-free deb-src https://deb.debian.org/debian buster main contrib non-free # Stable updates deb https://deb.debian.org/debian buster-updates main contrib non-free deb-src https://deb.debian.org/debian buster-updates main contrib non-free # Stable backports deb https://deb.debian.org/debian buster-backports main contrib non-free deb-src https://deb.debian.org/debian buster-backports main contrib non-free
This file lists all sources of packages associated with the
Buster version of Debian (the current
Stable suite as of this writing). In the example above, we opted to name “buster” explicitly instead of using the corresponding “stable“ aliases (
stable,
stable-updates,
stable-backports) because we don't want to have the underlying distribution changed outside of our control when the next stable release comes out. 大多數(shù)軟件包來源于“基礎(chǔ)倉庫”,它擁有所有的軟件包,但極少更新(大概每兩個月根據(jù)“點發(fā)布”更新)。其他倉庫不完全(不包括所有軟件包),不過可以支持更新(軟件包是較新版本)。接下來的幾章將會介紹這些倉庫管理的目的和規(guī)則。 請注意,當(dāng)你所需要的軟件包版本存在于幾個倉庫中時,在文件
sources.list中所列出的第一個會被使用。因此,非官方來源的包一般在此文件末尾處。 本節(jié)提到的
穩(wěn)定Stable 對于
Oldstable 一樣適用。后者只是同時維護(hù)的較舊
Stable 版本。
6.1.2.1. 安全更新
Debian takes security seriously. Known software vulnerabilities in Debian are tracked in the Security Bug Tracker and usually get fixed in a reasonable timeframe. The security updates are not hosted on the usual network of Debian mirrors but on
security.debian.org, a small set of machines maintained by the Debian System Administrators. This archive contains security updates prepared by the Debian Security Team and/or by package maintainers for the
Stable and
Oldstable distribution. The server can also host security updates for
Testing but this doesn't happen very often since those updates tend to reach the
Testing suite via the regular flow of updates coming from
Unstable. For serious issues, the security team issues a
Debian Security Advisory ( DSA) and announces it together with the security update on the
debian-security-announce@lists.debian.org mailing list (archive).
6.1.2.2. 穩(wěn)定更新
穩(wěn)定更新對安全性不敏感,在下一個穩(wěn)定版本點發(fā)布前,它還是很重要,需要推送給使用者。 This repository will typically contain fixes for critical and serious bugs which could not be fixed before release or which have been introduced by subsequent updates. Depending on the urgency, it can also contain updates for packages that have to evolve over time, like
spamassassin's spam detection rules,
clamav's virus database, the daylight-saving time rules of all timezones (
tzdata), the ESR version of Firefox (
firefox-esr) or cryptographic keyrings like
debian-archive-keyring. In practice, this repository is a subset of the
proposed-updates repository, carefully selected by the Stable Release Managers. All updates are announced on the
debian-stable-announce@lists.debian.org mailing list (archive) and will be included in the next
Stable point release anyway.
deb https://deb.debian.org/debian buster-updates main contrib non-free
6.1.2.3. 計劃更新
一旦發(fā)布,
穩(wěn)定分布只每兩個月更新一次。接下來的更新在
計劃更新倉庫里準(zhǔn)備(由穩(wěn)定發(fā)布管理員監(jiān)督)。 這個倉庫中通常有安全更新和穩(wěn)定更新的文檔,還有更多:軟件包維護(hù)者可能在這里修復(fù)一些不需要馬上發(fā)布的重要的漏洞。 Anyone can use this repository to test those updates before their official publication. The extract below uses the
buster-proposed-updates alias which is both more explicit and more consistent since
stretch-proposed-updates also exists (for the
Oldstable updates):
deb https://deb.debian.org/debian buster-proposed-updates main contrib non-free
6.1.2.4. 向后移植到穩(wěn)定版(Stable Backports)
stable-backports倉庫存放“軟件包的向后移植版本”。該術(shù)語指的是一些近期發(fā)布的軟件針對舊的發(fā)行版重新編譯的包,這里所指的舊發(fā)行版通常是指
穩(wěn)定(Stable)的發(fā)行版本。 When the distribution becomes a little dated, numerous software projects have released new versions that are not integrated into the current
Stable suite, which is only modified to address the most critical problems, such as security issues. Since the
Testing and
Unstable suites can be more risky, package maintainers sometimes voluntarily offer recompilations of recent software applications for
Stable, which has the advantage to users and system administrators to limit potential instability to a small number of chosen packages. The page https://backports.debian.org provides more information. Backports from
stable-backports are only created from packages available in
Testing. This ensures that all installed backports will be upgradable to the corresponding stable version once the next stable release of Debian is available. Even though this repository provides newer versions of packages,
APT will not install them unless you give explicit instructions to do so (or unless you have already done so with a former version of the given backport):
$sudo apt-get install package/buster-backports$sudo apt-get install -t buster-backports package
6.1.3. 給測試/非穩(wěn)定 版本用戶的倉庫
下面是一個標(biāo)準(zhǔn)
sources.list文件,用于系統(tǒng)運(yùn)行 Debian
測試或
非穩(wěn)定 版本:
例 6.3. Debian Testing/Unstable 用戶的 /etc/apt/sources.list文件
# Unstable deb https://deb.debian.org/debian unstable main contrib non-free deb-src https://deb.debian.org/debian unstable main contrib non-free # Testing deb https://deb.debian.org/debian testing main contrib non-free deb-src https://deb.debian.org/debian testing main contrib non-free # Testing security updates deb http://security.debian.org/ testing-security main contrib non-free deb-src http://security.debian.org/ testing-security main contrib non-free # Stable deb https://deb.debian.org/debian stable main contrib non-free deb-src https://deb.debian.org/debian stable main contrib non-free # Stable security updates deb http://security.debian.org/ stable/updates main contrib non-free deb-src http://security.debian.org/ stable/updates main contrib non-free
NOTE Layout of security repositories
Starting with Debian 11
Bullseye, the codename of the repository providing security updates has been renamed from
codename/updates into
codename-security to avoid the confusion with
codename-updates (see 第 6.1.2.2 節(jié) “穩(wěn)定更新”). With this
sources.list file APT will install packages from the
Unstable suite. If that is not desired, use the
APT::Default-Release setting (see 第 6.2.3 節(jié) “系統(tǒng)升級”) to instruct APT to pick packages from another suite (most likely
Testing in this case). 應(yīng)該納入這些典藏庫,即使一個也該這么做。
測試版 用戶將感謝管理者從
不穩(wěn)定版 中挑選修改過的軟件包,當(dāng)
測試版 受到錯誤的干擾時。反過來說,被無預(yù)期錯誤干擾的
不穩(wěn)定版 用戶,可能降級至他們 (若以此工作) 使用的
測試版 軟件包。 The inclusion of
Stable is more debatable but it often gives access to some packages, which have been removed from the development versions. It also ensures that you get the latest updates for packages, which have not been modified since the last stable release.
6.1.3.1. 實驗 倉庫
實驗性 典藏所的軟件包是所有 Debian 鏡射站的內(nèi)容,包括因為品質(zhì)關(guān)系尚未被納入
不穩(wěn)定版 的軟件包 — 通常是發(fā)展中的軟件版本或前置版 (alpha、beta、待發(fā)布…)。修改過的軟件包多少有點問題,可送至此處。在高端用戶的協(xié)助下,維護(hù)者努力找出該等問題。經(jīng)過第一階段后,把軟件包移至
不穩(wěn)定版,更多的用戶以更詳細(xì)的方式測試它。 不在乎系統(tǒng)崩盤并有能力自行修復(fù)的用戶,就會取用
實驗性 的軟件包。用戶導(dǎo)入此等軟件包并測試其功能、檢查是否滿足其需求。這就是 Debian 的訴求,加入 APT 的
sources.list 內(nèi),并不表示該軟件包可順利使用,應(yīng)加入這一個行:
deb https://deb.debian.org/debian experimental main contrib non-free
6.1.4. Using Alternate Mirrors
The
sources.list examples in this chapter refer to package repositories hosted on
deb.debian.org. Those URLs will redirect you to servers which are close to you and which are managed by Content Delivery Networks ( CDN) whose main role is to store multiple copies of the files across the world, and to deliver them as fast as possible to users. The CDN companies that Debian is working with are Debian partners who are offering their services freely to Debian. While none of those servers are under direct control of Debian, the fact that the whole archive is sealed by GPG signatures makes it a non-issue. Picky users who are not satisfied with the performance of
deb.debian.org can try to find a better mirror in the official mirror list: → https://www.debian.org/mirror/list But when you don't know which mirror is best for you, this list is of not much use. Fortunately for you, Debian maintains DNS entries of the form
ftp.country-code.debian.org (e.g.
ftp.us.debian.org for the USA,
ftp.fr.debian.org for France, etc.) which are covering many countries and which are pointing to one (or more) of the best mirrors available within that country. As an alternative to
deb.debian.org, there used to be
httpredir.debian.org. This service would identify a mirror close to you (among the list of official mirrors, using GeoIP mainly) and would redirect APT's requests to that mirror. This service has been deprecated due to reliability concerns and now
httpredir.debian.org provides the same CDN-based service as
deb.debian.org.
6.1.5. 非官方來源: mentors.debian.net
There are numerous non-official sources of Debian packages set up by advanced users who have recompiled some software (Ubuntu made this popular with their Personal Package Archive ( PPA) service, by programmers who make their creation available to all, and even by Debian developers who offer pre-versions of their package online. The
mentors.debian.net site is interesting (although it only provides source packages), since it gathers packages created by candidates to the status of official Debian developer or by volunteers who wish to create Debian packages without going through that process of integration. These packages are made available without any guarantee regarding their quality; make sure that you check their origin and integrity and then test them before you consider using them in production.
社區(qū) debian.net 站點
debian.net 域名不是一個 Debian 項目的官方源。每個 Debian 開發(fā)者都可基于自己用途而使用此域名。這些網(wǎng)址包含一些非官方服務(wù)(有時為個人站點),其主機(jī)不屬于項目本身而由 Debian 開發(fā)者設(shè)置,甚至還有將要遷移到
debian.org的項目原型。有兩個理由來解釋為什么這些項目原型會留在
debian.net:或者是沒有人做出足夠的努力將其遷移到官方服務(wù)( 位于
debian.org 域名上,具備一定維護(hù)保證),或者是服務(wù)爭議太大以至于無法官方化。 安裝一個包意味著需要給包的創(chuàng)建者以 root 權(quán)限,因為其決定了以該身份運(yùn)行的初始化腳本的內(nèi)容。官方的 Debian 包由志愿者創(chuàng)建,志愿者經(jīng)過指派和評估,且能封裝軟件包,因而軟件包的來源與完整性可以確認(rèn)。 In general, be wary of a package whose origin you don't know and which isn't hosted on one of the official Debian servers: evaluate the degree to which you can trust the creator, and check the integrity of the package.
進(jìn)階舊包版本: snapshot.debian.org
The
snapshot.debian.org service, introduced in April 2010, can be used to “go backwards in time” and to find an old version of a package not longer contained in the Debian archives. It can be used, for example, to identify which version of a package introduced a regression, and more concretely, to come back to the former version while waiting for the regression fix.
6.1.6. Debian 軟件包 緩存 代理
當(dāng)一整個網(wǎng)絡(luò)的機(jī)器被配置為使用同樣的遠(yuǎn)程服務(wù)器并下載同樣的更新包時,管理員會知曉有一個當(dāng)作網(wǎng)絡(luò)-本地間緩存器的中介代理是有好處的(參見側(cè)邊欄
術(shù)語 緩存)。 您可以配置 APT 使用一個“標(biāo)準(zhǔn)”的代理(參見第 6.2.4 節(jié) “配置選項” 獲取 APT 相關(guān)內(nèi)容,參見第 11.6 節(jié) “HTTP/FTP Proxy”獲取代理相關(guān)內(nèi)容),Debian 體系提供了一個解決問題的更佳手段。本段中所述的專用軟件比普通的代理緩存更加智能,因為它們可依賴于 APT 軟件源的特定結(jié)構(gòu)(例如,它們了解單獨的文件在什么時間廢棄與否,并由此來調(diào)整在保持階段的時間)。
apt-cacher與
apt-cacher-ng的工作方式類似代理緩存服務(wù)器。對于外部請求,APT 的
sources.list 保持不變,但是 APT 被配置為把它們作為代理使用。 另一方面,
approx,工作方式則類似一個 HTTP 服務(wù)器,其在它的頂級 URL 地址上“鏡像”任意數(shù)量的遠(yuǎn)程軟件源。這些頂級目錄與遠(yuǎn)程 URL 之間的映射存儲于
/etc/approx/approx.conf中:
#debian https://deb.debian.org/debian security http://security.debian.org
approx runs by default on port 9999 via a systemd socket and requires the users to adjust their
sources.list file to point to the approx server:
# Sample sources.list pointing to a local approx server deb http://localhost:9999/security buster/updates main contrib non-free deb http://localhost:9999/debian buster main contrib non-free
標(biāo)題名稱:【Debian管理員手冊】第?6?章?維護(hù)和更新:APT工具
文章位置:http://www.dlmjj.cn/article/cdphjgp.html


咨詢
建站咨詢
