/etc/apt/sources.list
will list the different repositories (or “sources”) 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
or a variant using a different compression method (such as Packages.gz
or .bz2
) files (in case of a source of binary packages) and Sources.xz
or a variant (in case of a source of source packages) and by analyzing their contents. When an old copy of these files is already present, APT can update it by only downloading the differences (see sidebar TIP Incremental upgrade).
/etc/apt/sources.list
文件中每个有效的代码行包括对源的描述,由三个被空格分开的部分组成。
deb
” 表示二进制软件包,
deb-src
”表示源代码包。
Packages.gz
中给出的文件名,必须是有效URL的全称):此区域存在于一个 Debian 镜像或其他任何由第三方所建的软件源文档中。这个 URL 可以用 file://
起始来表示系统里安装了本地仓库,或以 http://
表示仓库可通过网络服务器来获取,或用 ftp://
表示软件源在一个 FTP 服务器上。URL 还可以用 起始表示从 cdrom:
开始安装。因基于网络的安装愈来愈流行,这个方法已不那么常用了。
./
” 表示子目录不存在 - 这个软件源就位于给定的 URL上)。 不过一般来讲,仓库的结构类似于一个 Debian 的镜像, 包括很多分支,每一分支有很多组成部分。通常命名选定的分支(由 “codename” 来命名 - 参看附栏中的目录社区 Bruce Perens,一位有争议的领导者 或是由对应的 “suites” — stable
, testing
, unstable
),然后命名下面的组成部分(或分区)(从main
, contrib
和non-free
中选择) 来激活一个典型的 Debian 镜像。
cdrom
entries describe the CD/DVD-ROMs you have. Contrary to other entries, a CD-ROM is not always available since it has to be inserted into the drive and since only one disc can be read at a time. For those reasons, these sources are managed in a slightly different way, and need to be added with the apt-cdrom
program, usually executed with the add
parameter. The latter will then request the disc to be inserted in the drive and will browse its contents looking for Packages
files. It will use these files to update its database of available packages (this operation is usually done by the apt update
command). From then on, APT can require the disc to be inserted if it needs one of its packages.
sources.list
for a system running the Stable version of Debian:
例 6.1. /etc/apt/sources.list
给 Debian Stable 使用者的文件
# Security updates deb http://security.debian.org/ jessie/updates main contrib non-free deb-src http://security.debian.org/ jessie/updates main contrib non-free ## Debian mirror # Base repository deb http://ftp.debian.org/debian jessie main contrib non-free deb-src http://ftp.debian.org/debian jessie main contrib non-free # Stable updates deb http://ftp.debian.org/debian jessie-updates main contrib non-free deb-src http://ftp.debian.org/debian jessie-updates main contrib non-free # Stable backports deb http://ftp.debian.org/debian jessie-backports main contrib non-free deb-src http://ftp.debian.org/debian jessie-backports main contrib non-free
stable
, stable-updates
, stable-backports
)来命名。
sources.list
中所列出的第一个会被使用。因此,非官方来源的包一般在此文件末尾处。
security.debian.org
(位于 Debian 系统管理员Debian System Administrators维护的小范围网络)。其上的文档包括为那些稳定版本准备的安全更新(由 Debian 安全团队和/或软件包维护者预备)。
计划-更新proposed-updates
的子库,是由稳定更新管理员小心选定的。
计划更新
仓库里准备(由稳定发布管理员监督)。
jessie-proposed-updates
alias which is both more explicit and more consistent since wheezy-proposed-updates
also exists (for the Oldstable updates):
deb http://ftp.debian.org/debian jessie-proposed-updates main contrib non-free
stable-backports
repository hosts “package backports”. The term refers to a package of some recent software which has been recompiled for an older distribution, generally for Stable.
stable-backports
repository is now available on the usual Debian mirrors. But backports for Squeeze are still hosted on a dedicated server (backports.debian.org
), and requires the following sources.list
entry:
deb http://backports.debian.org/debian-backports squeeze-backports main contrib non-free
stable-backports
are always 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.
$
sudo apt-get install package/jessie-backports
$
sudo apt-get install -t jessie-backports package
sources.list
文件,用于系统运行 Debian 测试或非稳定 版本:
例 6.2. /etc/apt/sources.list
file for users of Debian Testing/Unstable
↵ # Unstable↵ deb http://ftp.debian.org/debian unstable main contrib non-free↵ deb-src http://ftp.debian.org/debian unstable main contrib non-free↵ ↵ # Testing↵ deb http://ftp.debian.org/debian testing main contrib non-free↵ deb-src http://ftp.debian.org/debian testing main contrib non-free↵ ↵ # Stable↵ deb http://ftp.debian.org/debian stable main contrib non-free↵ deb-src http://ftp.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 节 “System Upgrade”)来指示 APT 从另一分布获取软件包(一般用 测试)。
sources.list
file does not lead to the systematic use of its packages. The line to be added is:
deb http://ftp.debian.org/debian experimental main contrib non-free↵
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.
sources.list
is left unchanged, but APT is configured to use them as proxy for outgoing requests.
/etc/approx/approx.conf
:
↵ # <name> <repository-base-url>↵ debian http://ftp.debian.org/debian↵ security http://security.debian.org↵
inetd
Super-Server”)默认在9999端口运行,并需要用户调整sources.list
文件来指向 approx 服务器:
# 指向本地 approx 服务器的sources.list 范例 deb http://apt.falcot.com:9999/security jessie/updates main contrib non-free deb http://apt.falcot.com:9999/debian jessie main contrib non-free