/etc/apt/sources.list
会列出发布 Debian 软件包不同的仓库(或软件源)。接下来APT会从每一个软件源导入所发布的软件包列表。这个过程是通过下载 Packages.xz
或使用不同压缩方法的变体(比如Packages.gz
或者.bz2
) )文件(若是二进制包的仓库)和Sources.xz
文件(若是软件包源的仓库),并分析这两个文件内容。如果文件的旧版本已经存在,APT仅下载更新的部分(参见:TIP 增量更新)。
/etc/apt/sources.list
文件中每个有效的代码行包括对源的描述,由三个被空格分开的部分组成。
deb
” 表示二进制软件包,
deb-src
”表示源代码包。
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://
to indicate a source accessible from a web server, or with ftp://
for a source available on an FTP server. The URL can also start with cdrom:
for CD-ROM/DVD-ROM/Blu-ray disc based installations, although this is less frequent, since network-based installation methods are more and more common.
./
” 表示子目录不存在 - 这个软件源就位于给定的 URL上)。 不过一般来讲,仓库的结构类似于一个 Debian 的镜像, 包括很多分支,每一分支有很多组成部分。通常命名选定的分支(由 “codename” 来命名 - 参看附栏中的目录社区 Bruce Perens,一位有争议的领导者 或是由对应的 “suites” — stable
, testing
, unstable
),然后命名下面的组成部分(或分区)(从main
, contrib
和non-free
中选择) 来激活一个典型的 Debian 镜像。
cdrom
条目描述了你所有的CD/DVD光盘。 与其他条目不同,因为一个CD光盘需要插入光驱中,并且每次只能读一张,所以并不总是可用。因此这种仓库管理起来稍有不同,需要加在apt-cdrom
程序中,经常与add
参数一起执行。后者会要求驱动中插入光盘,并会浏览内容,寻找Packages
文件。这些文件会用于更新可用软件包的数据库(此过程由apt update
命令执行)。 自此, 如果某软件包需要光盘,APT 可发出要求插入光驱。
sources.list
文件,它被用于 Stable 版本的 Debian 系统:
例 6.1. /etc/apt/sources.list
给 Debian Stable 使用者的文件
# Security updates deb http://security.debian.org/ stretch/updates main contrib non-free deb-src http://security.debian.org/ stretch/updates main contrib non-free ## Debian mirror # Base repository deb http://deb.debian.org/debian stretch main contrib non-free deb-src http://deb.debian.org/debian stretch main contrib non-free # Stable updates deb http://deb.debian.org/debian stretch-updates main contrib non-free deb-src http://deb.debian.org/debian stretch-updates main contrib non-free # Stable backports deb http://deb.debian.org/debian stretch-backports main contrib non-free deb-src http://deb.debian.org/debian stretch-backports main contrib non-free
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.
sources.list
中所列出的第一个会被使用。因此,非官方来源的包一般在此文件末尾处。
security.debian.org
(位于 Debian 系统管理员Debian System Administrators维护的小范围网络)。其上的文档包括为那些稳定版本准备的安全更新(由 Debian 安全团队和/或软件包维护者预备)。
计划-更新proposed-updates
的子库,是由稳定更新管理员小心选定的。
计划更新
仓库里准备(由稳定发布管理员监督)。
stretch-proposed-updates
alias which is both more explicit and more consistent since jessie-proposed-updates
also exists (for the Oldstable updates):
deb http://ftp.debian.org/debian stretch-proposed-updates main contrib non-free
stable-backports
仓库存放“软件包的向后移植版本”。该术语指的是一些近期发布的软件针对旧的发行版重新编译的包,这里所指的旧发行版通常是指稳定(Stable)的发行版本。
stable-backports
里的软件包(Backports)通常是从Testing版本创建的。这确保一旦下一个稳定的Debian版本可用,所有安装的backports都可以升级到相应的稳定版本。
$
sudo apt-get install package/stretch-backports
$
sudo apt-get install -t stretch-backports package
sources.list
文件,用于系统运行 Debian 测试或非稳定 版本:
例 6.2. Debian Testing/Unstable 用户的 /etc/apt/sources.list
文件
# Unstable deb http://deb.debian.org/debian unstable main contrib non-free deb-src http://deb.debian.org/debian unstable main contrib non-free # Testing deb http://deb.debian.org/debian testing main contrib non-free deb-src http://deb.debian.org/debian testing main contrib non-free # Stable deb http://deb.debian.org/debian stable main contrib non-free deb-src http://deb.debian.org/debian stable main contrib non-free # Security updates deb http://security.debian.org/ stable/updates main contrib non-free deb http://security.debian.org/ testing/updates main contrib non-free deb-src http://security.debian.org/ stable/updates main contrib non-free deb-src http://security.debian.org/ testing/updates main contrib non-free
sources.list
文件来从非稳定安装软件包。如果这不是你所需要的,用APT::Default-Release
设置(参见 第 6.2.3 节 “系统升级”)来指示 APT 从另一分布获取软件包(一般用 测试)。
sources.list
内,并不表示该软件包可顺利使用,应加入这一个行:
deb http://deb.debian.org/debian experimental main contrib non-free
sources.list
examples in this chapter refer to package repositories hosted on deb.debian.og
. 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 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.
deb.debian.org
can try to find a better mirror in the official mirror list:
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.
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
.
mentors.debian.net
站点比较有意思(虽然它只提供源码包)。它搜集Debian开发者候选人员制作的软件包,以及那些希望创建Debian软件包又不想经历成为Debian开发者整套流程的那些志愿者的软件包。这些软件包提供时没有任何质量保证;请确保您在将它们用于生产环境之前检查它们的来源和完整性并进行测试。
sources.list
保持不变,但是 APT 被配置为把它们作为代理使用。
/etc/approx/approx.conf
中:
# <name> <repository-base-url> debian http://deb.debian.org/debian security http://security.debian.org
sources.list
file to point to the approx server:
# Sample sources.list pointing to a local approx server deb http://apt.falcot.com:9999/security stretch/updates main contrib non-free deb http://apt.falcot.com:9999/debian stretch main contrib non-free