目录
testing with some packages from
unstable
unstable with some packages from
experimental
|
注意 |
|---|---|
|
这一章假定最新的稳定版的代号为: |
Debian 是一个志愿者组织,它建立一致的自由软件的预编译二进制包并从档案库中分发它们。
许多远程镜像站提供了 HTTP 和 FTP 的方式来访问 Debian 档案库。也可以使用 CD-ROM/DVD 。
Debian 软件包管理系统,当使用适当时,可以让用户从档案库安装统一设置的二进制软件包 到系统中。现在,有 53039 个可用于 amd64 架构的软件包。
Debian 软件包管理系统有丰富的历史,有许多可供选择的前端用户程序和后端访问方式。现在,我们推荐下列的这些。
apt-get(8) 用于所有的命令行操作,包含软件包的安装、移除和升级。
aptitude(8) 使用一个交互式的文本界面来管理已安装的软件包和搜索可用的软件包。
表 2.1. Debian 软件包管理工具列表
| 软件包 | 流行度 | 大小 | 说明 |
|---|---|---|---|
apt
|
V:868, I:999 | 3449 |
高级软件包工具(APT), dpkg 的前端,提供了 “http”
、“ftp” 和 “file”
的档案库访问方式(包含apt-get 和 apt-cache 命令)
|
aptitude
|
V:172, I:933 | 4440 | aptitude(8) ,基于终端的交互式软件包管理工具 |
tasksel
|
V:40, I:971 | 374 | Debian 系统上对安装进行选择的工具(APT 的前端) |
unattended-upgrades
|
V:104, I:278 | 227 | 用于 APT 的增强软件包,会自动安装安全更新 |
dselect
|
V:6, I:81 | 2500 | 基于终端的软件包管理工具(之前的标准,APT 的前端和其它老的访问方式) |
dpkg
|
V:930, I:999 | 6749 | 用于 Debian 的软件包管理系统 |
synaptic
|
V:75, I:455 | 6928 | 图像化的软件包管理工具(GNOME 的 APT 前段) |
apt-utils
|
V:372, I:997 | 1088 | APT 实用程序:apt-extracttemplates(1) 、apt-ftparchive(1) 和 apt-sortpkgs(1) |
apt-listchanges
|
V:330, I:827 | 337 | 软件包历史更改提醒工具 |
apt-listbugs
|
V:7, I:12 | 388 | 在每次 APT 安装前列出严重的 bug |
apt-file
|
V:12, I:79 | 77 | APT 软件包搜索工具 —— 命令行界面 |
apt-rdepends
|
V:0, I:6 | 65 | 递归列出软件包依赖 |
下面是 Debian 系统软件包配置的一些要点。
Debian 尊重系统管理员的手动配置。换句话说,软件包配置系统不会为了方便而去更改那些配置。
每个软件包都带有使用自己的配置脚本,它使用标准用户界面 debconf(7) 来帮助软件包初始化安装过程。
Debian 开发者通过软件包配置脚本,尽力使你能有一个完美的升级体验。
系统管理员可以使用软件包工具的全部功能。但在默认的安装中会禁用那些具有安全风险的。
如果你手动激活了一些具有安全隐患的服务,你有责任遏制风险。
高深的配置可以由系统管理员手动启用。这可能会对用于系统配置的通用流行帮助程序造成干扰。
Debian 系统管理员中的新手应该保持在只进行安全更新的 stable
版本。我的意思是,最好避免下列的一些行为作为一项预防措施,直到你十分了解 Debian 系统。下面有一些提醒。
在 “/etc/apt/sources.list” 中不要包含 testing 或 unstable 。
在 “/etc/apt/sources.list” 里不要在标准的 Debian 中混合使用其它非 Debian
的档案库,例如 Ubuntu 。
不要建立 “/etc/apt/preferences” 。
不了解会造成的全部影响,就不要通过配置文件改变软件包管理工具的默认行为。
不要使用 “dpkg -i <random_package>” 安装任何软件包。
绝不使用 “dpkg --force-all -i <random_package>”
安装任何软件包。
不要删除或修改 “/var/lib/dpkg/” 中的文件。
不要让从源码直接安装的程序覆盖系统文件。
如果需要的话,将它们安装到 “/usr/local” 或 “/opt” 中。
上述对 Debian 软件包管理系统做的行为所导致的不兼容影响可能会使你的系统无法使用。
负责有关键任务的服务器的严谨的 Debian 系统系统管理员,应该使用额外的预防措施。
没有在安全的条件下使用你特定的配置进行彻底地测试,就不要从 Debian 安装任何软件包(包含安全更新)。
你作为系统管理员要对你的系统负责到底。
Debian 系统长久的稳定史并无法保证什么。
尽管我在上面进行了警告,我知道许多阅读这份文档的人还是想要使用 Debian 的 testing 或
unstable 套件来作为他们自行管理的桌面环境的主系统。这是因为这些套件运行得很好,更新频繁,并提供了最新的特性。
|
小心 |
|---|---|
|
对于你的生产服务器,建议使用带有安全更行的
|
你只需要在 “/etc/apt/sources.list”
中简单地将发行版字符串设置为套件名:“testing” 或
“unstable”;或者代号:“stretch” 或
“sid” 。这会使你享受持续升级的生活。
使用 testing 或 unstable 是 很有乐趣的,但会带来一些风险。尽管 Debian 系统的
unstable 套件在大多数时候看起来都非常稳定,但在 Debian 系统的
testing 和 unstable
套件中存在一些软件包问题,并且它们中的一部分是不容易解决的。这对你来说可能会很痛苦。有时候,你可能会有一个损坏的软件包或缺少某些功能几个星期。
这里有一些方法,可以使你简单快速地从 Debian 软件包的 bug 中恢复。
通过将 Debian 系统的 stable 套件安装到另一个分区,可以使系统能够进行双启动
使安装 CD 便于用于 救援启动
考虑安装 apt-listbugs ,这可以在升级之前检查 Debian Bug 跟踪系统(BTS) 的信息
对软件包系统的基础设施有足够的了解来解决问题
建立一个 chroot 或类似的环境来提前运行最新的系统(参见第 9.10 节 “Virtualized system”)
(如果你无法做到这些预防措施中的任何一个,那你可能还没做好使用 testing
和unstable 套件的准备。)
让我们从系统用户的角度来看看 Debian 档案库。
|
提示 |
|---|---|
|
Debian 档案库官方政策的定义参见 Debian 政策文档,第2章 —— Debian 档案库。 |
对于典型的 HTTP 访问,档案库在 “/etc/apt/sources.list”
文件中像下面那样指定,例如,现在 stable =
jessie 系统。
deb http://ftp.XX.debian.org/debian/ jessie main contrib non-free deb-src http://ftp.XX.debian.org/debian/ jessie main contrib non-free deb http://security.debian.org/ jessie/updates main contrib deb-src http://security.debian.org/ jessie/updates main contrib
请注意, “ftp.XX.debian.org” 必须使用适合你位置的镜像站 URL 替代。对于 USA,使用
“ftp.us.debian.org” ,这些 URL 可以在Debian 全球镜像站中找到。这些服务器的状态可以在
Debian 镜像检查站中查看。
这里,我倾向于使用代号 “jessie” 来代替套件名
“stable” ,以避免下一个 stable 版本发布时出现意外。
“/etc/apt/sources.list” 的含义在
sources.list(5)
中进行了描述,下面是一些要点。
“deb” 的那行定义了二进制软件包。
“deb-src” 的那行定义了源代码软件包。
第一个参数是 Debian 档案库的根 URL 。
第二个参数是发行版名称:可以使用套件名或代号。
第三个和之后的参数是 Debian 档案库的有效档案库范围名称。
“deb-src” 的那行可以安全地删掉(或者在文件开头添加 “#” 来将它注释掉),如果它只是用于
aptitude (它不访问源代码相关的元数据)。这可以加速档案库元数据的更新。 URL 可以是
“http://” 、“ftp://” 、
“file://” ……
|
提示 |
|---|---|
|
如果在上述的例子中,使用了 “ |
下面是配置文件所使用的 Debian 档案库站点的 URL 和套件名或代号的列表。
表 2.2. Debian 档案库站点列表
| 档案库 URL | 套件名(代号) | 目的 |
|---|---|---|
| http://ftp.XX.debian.org/debian/ | stable (jessie)
|
stable (jessie) release 版本 |
| http://ftp.XX.debian.org/debian/ | testing (stretch)
|
testing (stretch) release 版本 |
| http://ftp.XX.debian.org/debian/ | unstable (sid)
|
unstable (sid) release 版本 |
| http://ftp.XX.debian.org/debian/ |
experimental
|
experimental pre-release 版本(可选,只适用于开发者) |
| http://ftp.XX.debian.org/debian/ |
stable-proposed-updates
|
Updates for the next stable point release (optional) |
| http://security.debian.org/ |
stable/updates
|
用于 stable release 版本的安全更新(重要) |
| http://security.debian.org/ |
testing/updates
|
用于 testing release 版本的安全更新(重要) |
| http://ftp.XX.debian.org/debian/ |
jessie-updates
|
用于 jessie 的垃圾邮件过滤器、IM客户端等的兼容更新 |
| http://ftp.XX.debian.org/debian/ |
jessie-backports
|
用于 jessie 的较新的 backported 软件包(可选) |
|
小心 |
|---|---|
|
只有带有安全更新的纯净的 |
|
小心 |
|---|---|
|
You should basically list only one of |
|
提示 |
|---|---|
|
对于使用 |
|
注意 |
|---|---|
|
The security bugs for the |
表 2.3. Debian 归档列表
| area | 软件包数量 | 软件包组件标准 |
|---|---|---|
main
|
52177 |
遵从 Debian 自由软件指导方针(DFSG),并且不依赖于 non-free
|
contrib
|
325 |
遵从 Debian 自由软件指导方针(DFSG),但依赖于 non-free
|
non-free
|
537 | 不遵从 Debian 自由软件指导方针(DFSG) |
上述软件包的数量是用于该amd64架构的。 main 区提供 Debian 系统(参见 第 2.1.5 节 “Debian 是100% 的自由软件”)。
Debian 档案包组织通过跟踪您所浏览的带 dists 或者 pool
标记的档案包 URL 获取相关信息从而做得更好。
发行版可以用套件或代号来指定。发行版在许多文档中也被当做是套件的同义词。套件和代号的关系总结如下。
表 2.4. 套件和代号的关系
| 时间 |
suite = stable
|
suite = testing
|
suite = unstable
|
|---|---|---|---|
在 jessie 发布后
|
codename = jessie
|
codename = stretch
|
codename = sid
|
在 stretch 发布后
|
codename = stretch
|
codename = buster
|
codename = sid
|
代号的历史参见 Debian FAQ: 6.2.1 Which other codenames have been used in the past?
In the stricter Debian archive terminology, the word "section" is specifically used for the categorization of packages by the application area. (Although, the word "main section" may sometimes be used to describe the Debian archive area named as "main".)
Debian 开发者(DD)每次上传软件包到 unstable 档案库(通过 incoming 处理),都必须确保上传的软件包与最新的
unstable 档案库中的最新软件包兼容。
如果 DD 故意打破重要的库升级等的这种兼容性,这通常会在 Debian 开发者邮件列表等进行公告。
在 Debian 档案库维护脚本将软件包从 unstable 档案库移动到
testing 档案库前,档案库维护脚本不仅检查时间(约10天)和软件包的 RC bug
报告的状态,还尝试确保它们可以和最新的 testing
档案库中的软件兼容。这个过程使得testing 档案库非常正确可用。
Through the gradual archive freeze process led by the release team, the
testing archive is matured to make it completely
consistent and bug free with some manual interventions. Then the new
stable release is created by assigning the codename for
the old testing archive to the new
stable archive and creating the new codename for the new
testing archive. The initial contents of the new
testing archive is exactly the same as that of the newly
released stable archive.
unstable 和 testing
档案库都可能会遭受由以下几个因素导致的临时的小故障。
损坏的软件包被上传到档案库(多见于 unstable )
延迟接受新的软件包到档案库(多见于 unstable )
档案库时间同步问题( testing 和 unstable )
手动干预档案库,例如移除软件包(多见于 testing )等。
因此,如果你决定使用这些档案库,你应该能够修复或忍受这些类型的小故障。
|
小心 |
|---|---|
|
在新的 |
|
提示 |
|---|---|
|
跟踪 |
档案库的定义参见 Debian 政策文档。
Debian 是100%的自由软件,因为:
Debian 默认只安装自由软件,这尊重了用户的自由。
Debian 在 main 中只提供自由软件。
Debian 建议只运行来自 main 的自由软件。
在 main 中的软件包没有依赖于在 non-free 或
contrib 中的软件包。
有人想知道下列的两个事实是否互相矛盾。
“ Debian 将始终是 100% 的自由软件”。( Debian 社群契约中的第一条)
Debian servers host some non-free and
contrib packages.
因为下列原因,这并不矛盾。
Debian 系统具有100%的自由,并且它的软件包位于 Debian 服务器的 main 区域。
Debian 系统之外的软件包位于 Debian 服务器的 non-free 和
contrib 区域。
在 Debian 社群契约的第4条和第5条对这进行了明确的解释:
我们将优先考虑我们的用户及自由软件
我们由我们的用户及自由软件社群的需要所导向。我们将优先考虑他们的利益。我们将在多种计算环境中支持我们的用户的操作需要。我们不反对在 Debian 系统上使用非自由软件,我们也不会尝试向创建和使用这部分软件的用户索取费用。我们允许他人,在没有我们的资金的参与下,制造包括 Debian 以及商业软件的增值套件。为了达成这些目标,我们将提供集成的、高质量的、100%自由的软件,而不附加任何可能阻止在这些方面使用的法律限制。
哪些作品不符合我们的自由软件规范
我们明了,某些我们的用户需要使用不符合 Debian 自由软件指导方针的作品。 我们为这些作品,在我们的档案库中留出了
“contrib" 以及 “non-free"
目录。在这些目录下的软件包,并不属于 Debian 系统 尽管它们已被配置成可以在 Debian
下使用。我们鼓励光盘制造商阅读这些目录下的软件的许可证,以判断他们是否可以在光盘中发行这些软件 。所以,尽管非自由软件并非 Debian
系统的一部分,我们仍支持它们的使用,并且我们为非自由软件提供了公共资源 (诸如我们的缺陷跟踪系统以及邮件列表)。
用户应该了解使用 non-free 和 contrib
中的软件包所需要冒的风险:
使用类似的软件包会失去自由
失去 Debian 对软件包的支持(这些软件包无法访问源代码,Debian 不能进行完全的支持。)
污染你100%自由的 Debian 系统
Debian 自由软件指导方针为 Debian 设立了自由软件标准。Debian 对软件包中的软件做了最广泛的解释,包含文档、固件、logo 和图形数据。这使得 Debian 的自由软件标准非常严格。
为了满足 main 严格的自由软件标准,Debian 提供了 去掉 Mozilla 商标 的软件包(例如 Firefox 、Thunderbird 和
Seamonkey),它们移除了 logo 和一些图形数据;并将它们分别用 Iceweasel 、Icedove 和 Iceape 替代。
典型的 non-free 和 contrib
软件包包含了下列类型的自由分发的软件包:
Document packages under GNU Free
Documentation License with invariant sections such as ones for GCC
and Make. (mostly found in the non-free/doc section.)
包含没有源代码的二进制数据的固件软件包,例如在 第 9.9.6 节 “Hardware drivers and firmware”
中列出的 non-free 软件包。(多见于 non-free/kernel 部分。)
游戏和字体软件包,对商业使用和/或内容修改进行了限制。
请注意,non-free 和 contrib 软件包的数量少于
main 软件包的2%。允许访问 non-free 和
contrib 并不会模糊软件包的来源。使用
aptitude(8)
的全屏交互式界面可以提供完全的可见性和完全的控制,可以让你决定安装来自某个部分的软件包,来使你的系统保持自由。
The Debian system offers a consistent set of binary packages through its versioned binary dependency declaration mechanism in the control file fields. Here is a bit over simplified definition for them.
"Depends"
绝对的依赖,所有在这里列出的软件包都必须同时或提前安装。
"Pre-Depends"
类似于 Depends,但列出的软件包必须提前完成安装。
"Recommends"
This declares a strong, but not absolute, dependency. Most users would not want the package unless all of the packages listed in this field are installed.
"Suggests"
较弱的依赖。这个软件包的大多数用户可能会从安装所列的软件包中受益,但没有它们也可以有适当的功能。
"Enhances"
This declares a week dependency like Suggests but works in the opposite direction.
"Breaks"
表明一个软件包不兼容一些版本规范。一般的解决方法就是升级列出的所有软件包。
"Conflicts"
这表明了绝对的不兼容。为了安装这个软件包必须移除所有列出的软件包。
"Replaces"
这表明这个文件安装的文件会替代所列的软件包的文件。
"Provides"
表明这个软件包会提供所列的软件包所有的文件和功能。
|
注意 |
|---|---|
|
请注意,同时将 “Provides” 、“Conflicts” 和 “Replaces” 定义到一个虚拟的软件包是一个明智的配置。这确保了在任何一个时间只能安装一个提供该虚拟包的真正软件包。 |
包含源代码依赖关系的官方定义位于 the Policy Manual: Chapter 7 - Declaring relationships between packages。
这是 APT 提供的软件包管理的简单事件流摘要。
更新(“aptitude update” 或
“apt-get update”):
从远程档案库获取档案库元数据
重建和更新 APT 使用的本地元数据
升级(“aptitude
safe-upgrade” 和 “aptitude full-upgrade” 或
“apt-get upgrade” 和 “apt-get
dist-upgrade”):
选择候选版本,它所安装的软件包通常都是最新的可用版本(例外参见 第 2.7.3 节 “Tweaking candidate version” )
解决软件包依赖关系
如果候选版本与已安装的版本不同,会从远程档案库获取所选择的二进制软件包
解包所获取的二进制软件包
Run preinst script
安装二进制文件
Run postinst script
安装 ( “aptitude install
..." 或者 "apt-get install …” ):
选择命令行中列出的包
解决软件包依赖关系
从远程服务器获取已选二进制包
解包所获取的二进制软件包
Run preinst script
安装二进制文件
Run postinst script
移除 (“aptitude remove
…” 或 “apt-get remove …”):
选择命令行中列出的包
解决软件包依赖关系
运行 prerm 脚本
移除已安装的文件,除了配置文件
运行 postrm 脚本
Purge ("aptitude purge
…" or "apt-get purge …"):
选择命令行中列出的包
解决软件包依赖关系
运行 prerm 脚本
移除已安装的文件,包含配置文件
运行 postrm 脚本
Here, I intentionally skipped technical details for the sake of big picture.
你应该阅读优良的官方文档。第一个阅读的文档是 Debian 特定的
“/usr/share/doc/<package_name>/README.Debian”。同时也应该查询
“/usr/share/doc/<package_name>/” 中的其它文档。如果你设置 shell
为第 1.4.2 节 “定制bash”,输入下列命令。
$ cd <package_name> $ pager README.Debian $ mc
你可能需要安装以 “-doc” 后缀命名的对应文档软件包来获取详细的信息。
如果你在使用一个特定的软件包时出现了问题,一定要首先检查 Debian bug 跟踪系统(BTS) 网站。
表 2.5. 解决特定软件包问题的主要网站
| 网站 | 命令 |
|---|---|
| Debian bug 跟踪系统(BTS) 的主页 |
sensible-browser "http://bugs.debian.org/"
|
| 软件包名称已知的 bug 报告 |
sensible-browser
"http://bugs.debian.org/<package_name>"
|
| bug 编号已知的 bug 报告 |
sensible-browser
"http://bugs.debian.org/<bug_number>"
|
使用 Google 搜索,在关键字中包含
“site:debian.org”,“site:wiki.debian.org”,“site:lists.debian.org”
等等。
当你要发送一份 bug 报告时,请使用 reportbug(1) 命令。
在 Debian 系统中有许多基于 ATP 的软件包管理工具可以在 Debian
系统上进行基于仓库的软件包管理操作。在这里,我们将介绍两种基本的软件包管理工具:apt-get /
apt-cache 和 aptitude 。
对于涉及软件包安装或更新软件包元数据的软件包管理操作,你必须有 root 权限。
尽管 aptitude 是作者主要使用的一个非常好的可互动工具,但你应该知道下列警示:
不建议在新版本发布后在 stable Debian 系统上使用
aptitude 命令来进行跨版本的系统升级。
建议使用 “apt-get dist-upgrade” 来进行这个操作。参见 Bug #411280。
The aptitude command sometimes suggests mass package
removals for the system upgrade on the testing or
unstable Debian system.
这个情况吓坏了许多的系统管理员。请不要惊慌。
This seems to be caused mostly by the version skew among packages depended
or recommended by a meta-package such as gnome-core.
要解决这个问题,可以在 aptitude 命令菜单中选择 “Cancel pending actions” ,退出
aptitude,并使用 “apt-get dist-upgrade”。
apt-get 和 apt-cache 是最 基础 的基于 APT 的软件包管理工具。
apt-get 和 apt-cache 只提供命令行用户界面。
apt-get 是进行跨版本的主系统升级等操作的最合适工具。
apt-get 提供了一个强大的软件包依赖解析器。
apt-get 对硬件资源的要求不高。它消耗更少的内存并且运行速度更快。
apt-cache 提供了一个 标准的正则表达式来搜索软件包名称和描述。
apt-get 和 apt-cache 可以使用
etc/apt/preferences 来管理软件包的多个版本,但这非常繁琐。
aptitude 命令是最通用的基于 APT
的软件包管理工具。
aptitude 提供了一个全屏的交互式文本用户界面。
aptitude 同样也提供了一个命令用户界面。
aptitude 是用于日常软件包管理(例如检查已安装的软件包和搜索可用的软件包)的最合适工具。
aptitude 对硬件资源的要求更高。它消耗更多的内存并且运行速度更慢。
aptitude 提供一个增强的正则表达式来搜索所有的软件包元数据。
aptitude 可以管理软件包的多个版本,并且不使用
/etc/apt/preferences,这会十分直观。
下面是使用 aptitude(8) 和 apt-get(8) / apt-cache(8) 的命令行基本软件包管理操作。
表 2.6. 使用 aptitude(8) 和 apt-get(8) / apt-cache(8) 的命令行基本软件包管理操作
aptitude 语法
|
apt-get / apt-cache 语法
|
说明 |
|---|---|---|
aptitude update
|
apt-get update
|
更新软件包档案库元数据 |
aptitude install foo
|
apt-get install foo
|
安装 “foo” 软件包的候选版本以及它的依赖
|
aptitude safe-upgrade
|
apt-get upgrade
|
安装已安装的软件包的候选版本并且不移除任何其它的软件包 |
aptitude full-upgrade
|
apt-get dist-upgrade
|
安装已安装的软件包的候选版本,并且需要的话会移除其它的软件包 |
aptitude remove foo
|
apt-get remove foo
|
移除 “foo” 软件包,但留下配置文件
|
| N/A |
apt-get autoremove
|
移除不再需要的自动安装的软件包 |
aptitude purge foo
|
apt-get purge foo
|
清除 “foo” 软件包的配置文件
|
aptitude clean
|
apt-get clean
|
完全清除本地仓库的软件包检索文件 |
aptitude autoclean
|
apt-get autoclean
|
清除本地仓库中过时软件包的软件包检索文件 |
aptitude show foo
|
apt-cache show foo
|
显示 “foo” 软件包的详细信息
|
aptitude search <regex>
|
apt-cache search <regex>
|
搜索匹配 <regex> 的软件包 |
aptitude why <regex>
|
N/A | 解释匹配 <regex> 的软件包必须被安装的原因 |
aptitude why-not <regex>
|
N/A | 解释匹配 <regex> 的软件包不必安装的原因 |
aptitude search 'i!M'
|
apt-mark showmanual
|
列出手动安装的软件包 |
|
注意 |
|---|---|
|
Although the |
|
注意 |
|---|---|
|
因为在 |
“aptitude why <regex>” 可以通过 “aptitude -v
why <regex>” 列出更多的信息。类似的信息可以通过 “apt-cache rdepends
<package>” 获取。
当 aptitude 命令在命令行模式下启动后遇到了一些问题(例如软件包冲突),你可以在之后的提示中按下
“e” 键切换到全屏的交互模式。
你可以在 “aptitude” 后面使用的命令选项。
更多内容参见
aptitude(8)
和位于 “/usr/share/doc/aptitude/README” 的 “aptitude 用户手册”。
|
提示 |
|---|---|
|
|
要使用交互式的软件包管理,你可以像下面那样以交互模式启动 aptitude 。
$ sudo aptitude -u Password:
这将更新档案库信息的本地副本,并以菜单的形式全屏显示软件包列表。 aptitude 将它的配置放在
“~/.aptitude/config”。
|
提示 |
|---|---|
|
如果你想用 root 的配置而非使用者的,可以在上面的例子中使用 “ |
|
提示 |
|---|---|
|
|
Notable key strokes to browse status of packages and to set "planned action" on them in this full screen mode are the following.
表 2.8. aptitude 的按键绑定
| 快捷键 | 键绑定功能 |
|---|---|
F10 或 Ctrl-t
|
菜单 |
?
|
显示快捷键的 帮助(更加完整) |
F10 → 帮助 → 用户手册
|
显示用户手册 |
u
|
更新软件包档案库信息 |
+
|
标记该包以 upgrade(升级) 或者 install(安装) |
-
|
标记该包以 remove (配置保留) |
_
|
标记该包以 purge (删除配置) |
=
|
将包设定为 hold |
U
|
标记所有可升级包(动作如同 full-upgrade) |
g
|
开始 下载 并 安装 所选择包 |
q
|
退出该界面并保存变更 |
x
|
退出该界面并清除变更 |
Enter
|
查看软件包的信息 |
C
|
查看软件包的变更记录 |
l
|
变更显示软件包的限制 |
/
|
search for the first match |
\
|
重复上一个搜索 |
The file name specification of the command line and the menu prompt after
pressing "l" and "//" take the
aptitude regex as described below. Aptitude regex can explicitly match a
package name using a string started by "~n and followed
by the package name.
|
提示 |
|---|---|
|
You need to press " |
In the interactive full screen mode of aptitude(8), packages in the package list are displayed as the next example.
idA libsmbclient -2220kB 3.0.25a-1 3.0.25a-2
Here, this line means from the left as the following.
The "current state" flag (the first letter)
The "planned action" flag (the second letter)
The "automatic" flag (the third letter)
The Package name
The change in disk space usage attributed to "planned action"
The current version of the package
The candidate version of the package
|
提示 |
|---|---|
|
The full list of flags are given at the bottom of Help screen shown by pressing
" |
The candidate version is chosen according to the current local preferences (see apt_preferences(5) and 第 2.7.3 节 “Tweaking candidate version”).
Several types of package views are available under the menu
"Views".
表 2.9. List of views for aptitude
| view | 状态 | description of view |
|---|---|---|
Package View
|
Good | 参见 表 2.10 “The categorization of standard package views” (默认) |
Audit Recommendations
|
Good | list packages which are recommended by some installed packages but not yet installed |
Flat Package List
|
Good | list packages without categorization (for use with regex) |
Debtags Browser
|
Very usable | list packages categorized according to their debtags entries |
Categorical Browser
|
Deprecated |
list packages categorized according to their category (use Debtags
Browser, instead)
|
|
注意 |
|---|---|
|
Please help us improving tagging packages with debtags! |
The standard "Package View" categorizes packages somewhat
like dselect with few extra features.
表 2.10. The categorization of standard package views
| category | description of view |
|---|---|
Upgradable Packages
|
list packages organized as section →
area → package
|
New Packages
|
同上 |
Installed Packages
|
同上 |
Not Installed Packages
|
同上 |
Obsolete and Locally Created Packages
|
同上 |
Virtual Packages
|
list packages with the same function |
Tasks
|
list packages with different functions generally needed for a task |
|
提示 |
|---|---|
|
|
Aptitude offers several options for you to search packages using its regex formula.
Shell commandline:
"aptitude search '<aptitude_regex>'" to list
installation status, package name and short description of matching packages
"aptitude show '<package_name>'" to list detailed
description of the package
Interactive full screen mode:
"l" to limit package view to matching packages
"/" for search to a matching package
"\" for backward search to a matching package
"n" for find-next
"N" for find-next (backward)
|
提示 |
|---|---|
|
The string for <package_name> is treated as the exact string match to
the package name unless it is started explicitly with " |
The aptitude regex formula is mutt-like extended ERE (see 第 1.6.2 节 “正则表达式”)
and the meanings of the aptitude specific special match
rule extensions are as follows.
表 2.11. List of the aptitude regex formula
| description of the extended match rule | regex formula |
|---|---|
| match on package name |
~n<regex_name>
|
| match on description |
~d<regex_description>
|
| match on task name |
~t<regex_task>
|
| match on debtag |
~G<regex_debtag>
|
| match on maintainer |
~m<regex_maintainer>
|
| match on package section |
~s<regex_section>
|
| match on package version |
~V<regex_version>
|
| match archive | ~A{jessie,stretch,sid}
|
| match origin | ~O{debian,…}
|
| match priority | ~p{extra,important,optional,required,standard}
|
| match essential packages |
~E
|
| match virtual packages |
~v
|
| match new packages |
~N
|
| match with pending action | ~a{install,upgrade,downgrade,remove,purge,hold,keep}
|
| match installed packages |
~i
|
| match installed packages with A-mark (auto installed packages) |
~M
|
| match installed packages without A-mark (administrator selected packages) |
~i!~M
|
| match installed and upgradable packages |
~U
|
| match removed but not purged packages |
~c
|
| match removed, purged or can-be-removed packages |
~g
|
| match packages declaring a broken dependency |
~b
|
| match packages declaring broken dependency of <type> |
~B<type>
|
| match <pattern> packages declaring dependency of <type> |
~D[<type>:]<pattern>
|
| match <pattern> packages declaring broken dependency of <type> |
~DB[<type>:]<pattern>
|
| match packages to which the <pattern> matching package declares dependency <type> |
~R[<type>:]<pattern>
|
| match packages to which the <pattern> matching package declares broken dependency <type> |
~RB[<type>:]<pattern>
|
| match packages to which some other installed packages depend on |
~R~i
|
| match packages to which no other installed packages depend on |
!~R~i
|
| match packages to which some other installed packages depend or recommend on |
~R~i|~Rrecommends:~i
|
| match <pattern> package with filtered version |
~S filter <pattern>
|
| match all packages (true) |
~T
|
| match no packages (false) |
~F
|
The regex part is the same ERE as the one
used in typical Unix-like text tools using "^",
".*", "$" etc. as in
egrep(1),
awk(1)
and
perl(1).
The dependency <type> is one of (depends, predepends, recommends, suggests, conflicts, replaces, provides) specifying the package interrelationship.
The default dependency <type> is "depends".
|
提示 |
|---|---|
|
When <regex_pattern> is a null string, place " |
Here are some short cuts.
"~P<term>" ==
"~Dprovides:<term>"
"~C<term>" ==
"~Dconflicts:<term>"
"…~W term" == "(…|term)"
Users familiar with mutt pick up quickly, as mutt was the
inspiration for the expression syntax. See "SEARCHING, LIMITING, AND
EXPRESSIONS" in the "User's Manual"
"/usr/share/doc/aptitude/README".
|
注意 |
|---|---|
|
With the |
The selection of a package in aptitude not only pulls in
packages which are defined in its "Depends:" list but
also defined in the "Recommends:" list if the menu
"F10 → Options → Preferences → Dependency handling" is
set accordingly. These auto installed packages are removed automatically if
they are no longer needed under aptitude.
The flag controlling the "auto install" behavior of the
aptitude command can also be manipulated using the
apt-mark(8)
command from the apt package.
You can check package activity history in the log files.
表 2.12. The log files for package activities
| file | content |
|---|---|
/var/log/dpkg.log
|
Log of dpkg level activity for all package activities
|
/var/log/apt/term.log
|
Log of generic APT activity |
/var/log/aptitude
|
Log of aptitude command activity
|
In reality, it is not so easy to get meaningful understanding quickly out from these logs. See 第 9.2.10 节 “Recording changes in configuration files” for easier way.
Here are few examples of aptitude(8) operations.
The following command lists packages with regex matching on package names.
$ aptitude search '~n(pam|nss).*ldap' p libnss-ldap - NSS module for using LDAP as a naming service p libpam-ldap - Pluggable Authentication Module allowing LDAP interfaces
This is quite handy for you to find the exact name of a package.
The regex "~dipv6" in the "New Flat Package List" view
with "l" prompt, limits view to packages with the
matching description and let you browse their information interactively.
You can purge all remaining configuration files of removed packages.
Check results of the following command.
# aptitude search '~c'
If you think listed packages are OK to be purged, execute the following command.
# aptitude purge '~c'
You may want to do the similar in the interactive mode for fine grained control.
You provide the regex "~c" in the "New Package View" view
with "l" prompt. This limits the package view only to
regex matched packages, i.e., "removed but not purged". All these regex
matched packages can be shown by pressing "[" at top
level headings.
Then you press "_" at top level headings such as "Not
Installed Packages". Only regex matched packages under the heading are
marked to be purged by this. You can exclude some packages to be purged by
pressing "=" interactively for each of them.
This technique is quite handy and works for many other command keys.
Here is how I tidy auto/manual install status for packages (after using non-aptitude package installer etc.).
Start aptitude in interactive mode as root.
Type "u", "U", "f"
and "g" to update and upgrade package list and packages.
Type "l" to enter the package display limit as
"~i(~R~i|~Rrecommends:~i)" and type
"M" over "Installed Packages" as auto
installed.
Type "l" to enter the package display limit as
"~prequired|~pimportant|~pstandard|~E" and type
"m" over "Installed Packages" as
manual installed.
Type "l" to enter the package display limit as
"~i!~M" and remove unused package by typing
"-" over each of them after exposing them by typing
"[" over "Installed Packages".
Type "l", to enter the package display limit as
"~i"; then type "m" over
"Tasks", to mark that packages as manual installed.
Exit aptitude.
Start "apt-get -s autoremove|less" as root to check what
are not used.
Restart aptitude in interactive mode and mark needed
packages as "m".
Restart "apt-get -s autoremove|less" as root to recheck
REMOVED contain only expected packages.
Start "apt-get autoremove|less" as root to autoremove
unused packages.
The "m" action over "Tasks" is an
optional one to prevent mass package removal situation in future.
|
注意 |
|---|---|
|
When moving to a new release etc, you should consider to perform a clean installation of new system even though Debian is upgradable as described below. This provides you a chance to remove garbages collected and exposes you to the best combination of latest packages. Of course, you should make a full backup of system to a safe place (see 第 10.2 节 “Backup and recovery”) before doing this. I recommend to make a dual boot configuration using different partition to have the smoothest transition. |
You can perform system wide upgrade to a newer release by changing contents
of the "/etc/apt/sources.list" file pointing to a new
release and running the "apt-get update; apt-get
dist-upgrade" command.
To upgrade from stable to testing or
unstable, you replace
"jessie" in the
"/etc/apt/sources.list" example of 第 2.1.4 节 “Debian 档案库基础” with
"stretch" or "sid".
In reality, you may face some complications due to some package transition
issues, mostly due to package dependencies. The larger the difference of
the upgrade, the more likely you face larger troubles. For the transition
from the old stable to the new stable
after its release, you can read its new Release
Notes and follow the exact procedure described in it to minimize
troubles.
When you decide to move from stable to
testing before its formal release, there are no Release Notes to help you. The difference
between stable and testing could have
grown quite large after the previous stable release and
makes upgrade situation complicated.
You should make precautionary moves for the full upgrade while gathering latest information from mailing list and using common senses.
Read previous "Release Notes".
Backup entire system (especially data and configuration information).
Have bootable media handy for broken bootloader.
Inform users on the system well in advance.
Record upgrade activity with script(1).
Apply "unmarkauto" to required packages, e.g., "aptitude unmarkauto
vim", to prevent removal.
Minimize installed packages to reduce chance of package conflicts, e.g., remove desktop task packages.
Remove the "/etc/apt/preferences" file (disable
apt-pinning).
Try to upgrade step wise: oldstable →
stable → testing →
unstable.
Update the "/etc/apt/sources.list" file to point to new
archive only and run "aptitude update".
Install, optionally, new core packages
first, e.g., "aptitude install perl".
Run the "apt-get -s dist-upgrade" command to assess
impact.
Run the "apt-get dist-upgrade" command at last.
|
小心 |
|---|---|
|
It is not wise to skip major Debian release when upgrading between
|
|
小心 |
|---|---|
|
In previous "Release Notes", GCC, Linux Kernel, initrd-tools, Glibc, Perl, APT tool chain, etc. have required some special attention for system wide upgrade. |
For daily upgrade in unstable, see 第 2.4.3 节 “预防软件包故障”.
下面列出了一些其它的软件包管理操作,这些操作对于 aptitude 过于高级或缺失所需的功能。
表 2.13. 高级软件包管理操作
| 命令 | 操作 |
|---|---|
COLUMNS=120 dpkg -l <package_name_pattern>
|
list status of an installed package for the bug report |
dpkg -L <package_name>
|
显示一个已安装软件包的内容 |
dpkg -L <package_name> | egrep
'/usr/share/man/man.*/.+'
|
list manpages for an installed package |
dpkg -S <file_name_pattern>
|
列出匹配文件名的已安装软件包 |
apt-file search <file_name_pattern>
|
列出档案库中匹配文件名的软件包 |
apt-file list <package_name_pattern>
|
列出档案库中匹配的软件包的内容 |
dpkg-reconfigure <package_name>
|
重新配置软件包 |
dpkg-reconfigure -p=low <package_name>
|
reconfigure the exact package with the most detailed question |
configure-debian
|
以全屏菜单的形式重新配置软件包 |
dpkg --audit
|
audit system for partially installed packages |
dpkg --configure -a
|
configure all partially installed packages |
apt-cache policy <binary_package_name>
|
显示一个二进制软件包的可用版本、优先级和档案库信息 |
apt-cache madison <package_name>
|
显示一个软件包的可用版本和档案库信息 |
apt-cache showsrc <binary_package_name>
|
显示一个二进制软件包的源代码软件包信息 |
apt-get build-dep <package_name>
|
安装构建软件包所需要的软件包 |
aptitude build-dep <package_name>
|
安装构建软件包所需要的软件包 |
apt-get source <package_name>
|
(从标准档案库)下载源代码 |
dget <URL for dsc file>
|
(从其它档案库)下载源代码软件包 |
dpkg-source -x
<package_name>_<version>-<debian_version>.dsc
|
build a source tree from a set of source packages
("*.orig.tar.gz" and
"*.debian.tar.gz"/"*.diff.gz")
|
debuild binary
|
从本地的源代码树中构建软件包 |
make-kpkg kernel_image
|
从内核源代码树中构建一个内核软件包 |
make-kpkg --initrd kernel_image
|
build a kernel package from a kernel source tree with initramfs enabled |
dpkg -i
<package_name>_<version>-<debian_version>_<arch>.deb
|
安装一个本地的软件包到系统中 |
debi
<package_name>_<version>-<debian_version>_<arch>.dsc
|
安装本地软件包到系统中 |
dpkg --get-selections '*' >selection.txt
|
save dpkg level package selection state information
|
dpkg --set-selections <selection.txt
|
set dpkg level package selection state information
|
echo <package_name> hold | dpkg --set-selections
|
set dpkg level package selection state for a package to
hold (equivalent to "aptitude
hold <package_name>")
|
|
注意 |
|---|---|
|
对于一个支持多架构的软件包,你可能需要为一些命令指定架构名称。例如,使用
“ |
|
小心 |
|---|---|
|
系统管理员应该小心使用低级的软件包工具(例如 “ |
请注意以下几点。
所有的系统配置和安装命令都需要以 root 运行。
不同于使用正则表达式的 aptitude (参见 第 1.6.2 节 “正则表达式”),其它的软件包管理命令使用类似于 shell glob 的通配符(参见 第 1.5.6 节 “Shell glob”)。
apt-file(1)
由 apt-file 软件包提供,并且需要先运行 “apt-file
update”。
configure-debian(8)
由 configure-debian 软件包提供,它运行
dpkg-reconfigure(8)
作为后端。
dpkg-reconfigure(8) 使用 debconf(1) 作为后端来运行软件包脚本。
"apt-get build-dep" 、"apt-get source"
和 "apt-cache showsrc" 命令需要
"/etc/apt/sources.list" 中存在 "deb-src"
条目。
dget(1)
、debuild(1)
和
debi(1)
需要 devscripts 软件包。
See (re)packaging procedure using "apt-get source" in
第 2.7.13 节 “Porting a package to the stable system”.
make-kpkg 命令需要 kernel-package 软件包(参见
第 9.9 节 “The kernel”)。
See 第 12.11 节 “制作 Debian 包” for general packaging.
The installation of debsums enables verification of
installed package files against MD5sum values in the
"/var/lib/dpkg/info/*.md5sums" file with
debsums(1).
See 第 10.3.5 节 “The MD5 sum” for how MD5sum works.
|
注意 |
|---|---|
|
Because MD5sum database may be tampered by the intruder, debsums(1) is of limited use as a security tool. It is only good for checking local modifications by the administrator or damage due to media errors. |
许多用户更想使用 unstable,因为它有新的功能和软件包。但这会使得系统更容易遇到严重的软件包 bug 。
The installation of the apt-listbugs package safeguards
your system against critical bugs by checking Debian BTS automatically for
critical bugs when upgrading with APT system.
安装 apt-listchanges 软件包,在使用 APT 系统升级时它会在
“NEWS.Debian” 中提供重要新闻。
尽管近来浏览 Debian 网站 http://packages.debian.org/ 是搜索软件包元数据更加简单的方法,但我们依旧来看看更传统的方法。
grep-dctrl(1) 、grep-status(1) 和 grep-available(1) 命令被用来搜索具有 Debian 软件包控制文件格式的任何文件。
“dpkg -S <file_name_pattern>” 被用来搜索由
dpkg 安装的软件包中包含匹配文件的。但它会忽略维护者的脚本创建的文件。
如果你需要对 dpkg 元数据进行更复杂的搜索,你需要在 “/var/lib/dpkg/info/” 目录下运行
“grep -e regex_pattern *” 命令。这会使你在软件包脚本和安装查询文本中搜索提及的单词。
如果你想递归查找软件包依赖,你应该使用 apt-rdepends(8) 。
让我们来学习 Debian 软件包管理的内部工作原理。这应该能够帮助你独立解决一些软件包问题。
每个发行版的元数据文件都保存在 Debian 镜像站的 “dist/<codename>” 下面,例如
“http://ftp.us.debian.org/debian/”。档案库的结构可以通过网络浏览器来浏览。其中有6种关键的元数据。
表 2.14. Debian 档案库元数据的内容
| file | 位置 | content |
|---|---|---|
Release
|
top of distribution | 档案库描述和完整性信息 |
Release.gpg
|
top of distribution |
signature file for the "Release" file signed with the
archive key
|
Contents-<architecture>
|
top of distribution | 列出在相关架构中所有软件包的全部文件 |
Release
|
top of each distribution/area/architecture combination | archive description used for the rule of apt_preferences(5) |
Packages
|
top of each distribution/area/binary-architecture combination |
concatenated debian/control for binary packages
|
Sources
|
top of each distribution/area/source combination |
concatenated debian/control for source packages
|
In the recent archive, these meta data are stored as the compressed and differential files to reduce network traffic.
|
提示 |
|---|---|
|
The top level " |
每个 Debian 档案库的网址都有一个这样的 “Release” 文件,例如
“http://ftp.us.debian.org/debian/dists/unstable/Release”,内容如下。
Origin: Debian Label: Debian Suite: unstable Codename: sid Date: Sat, 14 May 2011 08:20:50 UTC Valid-Until: Sat, 21 May 2011 08:20:50 UTC Architectures: alpha amd64 armel hppa hurd-i386 i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 sparc Components: main contrib non-free Description: Debian x.y Unstable - Not Released MD5Sum: bdc8fa4b3f5e4a715dd0d56d176fc789 18876880 Contents-alpha.gz 9469a03c94b85e010d116aeeab9614c0 19441880 Contents-amd64.gz 3d68e206d7faa3aded660dc0996054fe 19203165 Contents-armel.gz ...
|
注意 |
|---|---|
|
Here, you can find my rationale to use the "suite", and "codename" in 第 2.1.4 节 “Debian 档案库基础”. The "distribution" is used when referring to both "suite" and "codename". All archive "area" names offered by the archive are listed under "Components". |
The integrity of the top level "Release" file is verified
by cryptographic infrastructure called the secure
apt.
The cryptographic signature file "Release.gpg" is created
from the authentic top level "Release" file and the
secret Debian archive key.
The public Debian archive key can be seeded into
"/etc/apt/trusted.gpg";
automatically by installing the keyring with the latest
base-files package, or
manually by gpg or apt-key tool with
the latest public archive
key posted on the ftp-master.debian.org .
The secure APT system verifies the
integrity of the downloaded top level "Release" file
cryptographically by this "Release.gpg" file and the
public Debian archive key in "/etc/apt/trusted.gpg".
The integrity of all the "Packages" and
"Sources" files are verified by using MD5sum values in
its top level "Release" file. The integrity of all
package files are verified by using MD5sum values in the
"Packages" and "Sources" files. See
debsums(1)
and 第 2.4.2 节 “验证安装的软件包文件”.
Since the cryptographic signature verification is a much more CPU intensive
process than the MD5sum value calculation, use of MD5sum value for each
package while using cryptographic signature for the top level
"Release" file provides the good security with the
performance (see 第 10.3 节 “Data security infrastructure”).
|
提示 |
|---|---|
|
The archive level " |
There are archive level "Release" files for all archive
locations specified by "deb" line in
"/etc/apt/sources.list", such as
"http://ftp.us.debian.org/debian/dists/unstable/main/binary-amd64/Release"
or
"http://ftp.us.debian.org/debian/dists/sid/main/binary-amd64/Release"
as follows.
Archive: unstable Origin: Debian Label: Debian Component: main Architecture: amd64
|
小心 |
|---|---|
|
For " |
For some archives, such as experimental, and
jessie-backports, which contain packages which
should not be installed automatically, there is an extra line, e.g.,
"http://ftp.us.debian.org/debian/dists/experimental/main/binary-amd64/Release"
as follows.
Archive: experimental Origin: Debian Label: Debian NotAutomatic: yes Component: main Architecture: amd64
Please note that for normal archives without "NotAutomatic:
yes", the default Pin-Priority value is 500, while for special
archives with "NotAutomatic: yes", the default
Pin-Priority value is 1 (see
apt_preferences(5)
and 第 2.7.3 节 “Tweaking candidate version”).
When APT tools, such as aptitude,
apt-get, synaptic,
apt-file, auto-apt, … are used, we
need to update the local copies of the meta data containing the Debian
archive information. These local copies have following file names
corresponding to the specified distribution,
area, and architecture names in the
"/etc/apt/sources.list" (see 第 2.1.4 节 “Debian 档案库基础”).
"/var/lib/apt/lists/ftp.us.debian.org_debian_dists_<distribution>_Release"
"/var/lib/apt/lists/ftp.us.debian.org_debian_dists_<distribution>_Release.gpg"
"/var/lib/apt/lists/ftp.us.debian.org_debian_dists_<distribution>_<area>_binary-<architecture>_Packages"
"/var/lib/apt/lists/ftp.us.debian.org_debian_dists_<distribution>_<area>_source_Sources"
"/var/cache/apt/apt-file/ftp.us.debian.org_debian_dists_<distribution>_Contents-<architecture>.gz"
(for apt-file)
前4中类型的文件是所有相关的 APT 命令共享的,并且可以通过 “apt-get update” 或
“aptitude update” 在命令行中进行更新。如果在
“/etc/apt/sources.list” 中有相应的 “deb”
行,则 “软件包” 元数据会进行更新。如果在
“/etc/apt/sources.list” 中有相应的
“deb-src” 行,则 “源代码” 元数据会进行更新。
The "Packages" and "Sources" meta data
contain "Filename:" stanza pointing to the file location
of the binary and source packages. Currently, these packages are located
under the "pool/" directory tree for the improved
transition over the releases.
“软件包”元数据的本地副本可以使用 aptitude
来进行交互式的搜索。专门的搜索命令
grep-dctrl(1)
可以搜索“软件包”和“源代码”元数据的本地副本。
Local copy of "Contents-<architecture>" meta data
can be updated by "apt-file update" and its location is
different from other 4 ones. See
apt-file(1).
(The auto-apt uses different location for local copy of
"Contents-<architecture>.gz" as default.)
In addition to the remotely fetched meta data, the APT tool after
lenny stores its locally generated installation state
information in the "/var/lib/apt/extended_states" which
is used by all APT tools to track all auto installed packages.
In addition to the remotely fetched meta data, the
aptitude command stores its locally generated
installation state information in the
"/var/lib/aptitude/pkgstates" which is used only by it.
All the remotely fetched packages via APT mechanism are stored in the
"/var/cache/apt/archives" until they are cleaned.
This cache file cleaning policy for aptitude can be set
under "Options" → "Preferences" and it
may be forced by its menu "Clean package cache" or
"Clean obsolete files" under
"Actions".
Debian package files have particular name structures.
表 2.15. The name structure of Debian packages
| package type | name structure |
|---|---|
The binary package (a.k.a deb)
|
<package-name>_<epoch>:<upstream-version>-<debian.version>-<architecture>.deb
|
The binary package for debian-installer (a.k.a udeb)
|
<package-name>_<epoch>:<upstream-version>-<debian.version>-<architecture>.udeb
|
| The source package (upstream source) |
<package-name>_<epoch>:<upstream-version>-<debian.version>.orig.tar.gz
|
The 1.0 source package (Debian changes)
|
<package-name>_<epoch>:<upstream-version>-<debian.version>.diff.gz
|
The 3.0 (quilt) source package (Debian changes)
|
<package-name>_<epoch>:<upstream-version>-<debian.version>.debian.tar.gz
|
| The source package (description) |
<package-name>_<epoch>:<upstream-version>-<debian.version>.dsc
|
|
提示 |
|---|---|
|
Here only the basic source package formats are described. See more on dpkg-source(1). |
表 2.16. The usable characters for each component in the Debian package names
| name component | usable characters (regex) | existence |
|---|---|---|
<package-name>
|
[a-z,A-Z,0-9,.,+,-]+
|
required |
<epoch>:
|
[0-9]+:
|
optional |
<upstream-version>
|
[a-z,A-Z,0-9,.,+,-,:]+
|
required |
<debian.version>
|
[a-z,A-Z,0-9,.,+,~]+
|
optional |
|
注意 |
|---|---|
|
You can check package version order by
dpkg(1),
e.g., " |
|
注意 |
|---|---|
|
The debian-installer (d-i) uses
|
dpkg(1) is the lowest level tool for the Debian package management. This is very powerful and needs to be used with care.
While installing package called "<package_name>",
dpkg process it in the following order.
Unpack the deb file ("ar -x" equivalent)
Execute "<package_name>.preinst" using
debconf(1)
Install the package content to the system ("tar -x"
equivalent)
Execute "<package_name>.postinst" using
debconf(1)
The debconf system provides standardized user interaction
with I18N and L10N (第 8 章 I18N 和 L10N) supports.
表 2.17. The notable files created by dpkg
| file | description of contents |
|---|---|
/var/lib/dpkg/info/<package_name>.conffiles
|
list of configuration files. (user modifiable) |
/var/lib/dpkg/info/<package_name>.list
|
list of files and directories installed by the package |
/var/lib/dpkg/info/<package_name>.md5sums
|
list of MD5 hash values for files installed by the package |
/var/lib/dpkg/info/<package_name>.preinst
|
package script to be run before the package installation |
/var/lib/dpkg/info/<package_name>.postinst
|
package script to be run after the package installation |
/var/lib/dpkg/info/<package_name>.prerm
|
package script to be run before the package removal |
/var/lib/dpkg/info/<package_name>.postrm
|
package script to be run after the package removal |
/var/lib/dpkg/info/<package_name>.config
|
package script for debconf system
|
/var/lib/dpkg/alternatives/<package_name>
|
the alternative information used by the
update-alternatives command
|
/var/lib/dpkg/available
|
the availability information for all the package |
/var/lib/dpkg/diversions
|
the diversions information used by dpkg(1) and set by dpkg-divert(8) |
/var/lib/dpkg/statoverride
|
the stat override information used by dpkg(1) and set by dpkg-statoverride(8) |
/var/lib/dpkg/status
|
the status information for all the packages |
/var/lib/dpkg/status-old
|
the first-generation backup of the "var/lib/dpkg/status"
file
|
/var/backups/dpkg.status*
|
the second-generation backup and older ones of the
"var/lib/dpkg/status" file
|
The "status" file is also used by the tools such as
dpkg(1),
"dselect update" and "apt-get -u
dselect-upgrade".
The specialized search command
grep-dctrl(1)
can search the local copies of "status" and
"available" meta data.
|
提示 |
|---|---|
|
In the debian-installer
environment, the |
The Debian system has mechanism to install somewhat overlapping programs
peacefully using
update-alternatives(8).
For example, you can make the vi command select to run
vim while installing both vim and
nvi packages.
$ ls -l $(type -p vi)
lrwxrwxrwx 1 root root 20 2007-03-24 19:05 /usr/bin/vi -> /etc/alternatives/vi
$ sudo update-alternatives --display vi
...
$ sudo update-alternatives --config vi
Selection Command
----------------------------------------------
1 /usr/bin/vim
*+ 2 /usr/bin/nvi
Enter to keep the default[*], or type selection number: 1
The Debian alternatives system keeps its selection as symlinks in
"/etc/alternatives/". The selection process uses
corresponding file in "/var/lib/dpkg/alternatives/".
Stat overrides provided by the
dpkg-statoverride(8)
command are a way to tell
dpkg(1)
to use a different owner or mode for a file when a package is installed. If
"--update" is specified and file exists, it is
immediately set to the new owner and mode.
|
小心 |
|---|---|
|
The direct alteration of owner or mode for a file owned by the package using
|
|
注意 |
|---|---|
|
I use the word file here, but in reality
this can be any filesystem object that |
File diversions provided by the
dpkg-divert(8)
command are a way of forcing
dpkg(1)
not to install a file into its default location, but to a diverted location. The use of
dpkg-divert is meant for the package maintenance
scripts. Its casual use by the system administrator is deprecated.
When running unstable system, the administrator is
expected to recover from broken package management situation.
|
小心 |
|---|---|
|
Some methods described here are high risk actions. You have been warned! |
If a desktop GUI program experienced instability after significant upstream version upgrade, you should suspect interferences with old local configuration files created by it. If it is stable under a newly created user account, this hypothesis is confirmed. (This is a bug of packaging and usually avoided by the packager.)
To recover stability, you should move corresponding local configuration files and restart the GUI program. You may need to read old configuration file contents to recover configuration information later. (Do not erase them too quickly.)
Archive level package management systems, such as aptitude(8) or apt-get(1), do not even try to install packages with overlapped files using package dependencies (see 第 2.1.6 节 “软件包依赖关系”).
Errors by the package maintainer or deployment of inconsistently mixed source of archives (see 第 2.7.2 节 “Packages from mixed source of archives”) by the system administrator may create a situation with incorrectly defined package dependencies. When you install a package with overlapped files using aptitude(8) or apt-get(1) under such a situation, dpkg(1) which unpacks package ensures to return error to the calling program without overwriting existing files.
|
小心 |
|---|---|
|
The use of third party packages introduces significant system risks via maintainer scripts which are run with root privilege and can do anything to your system. The dpkg(1) command only protects against overwriting by the unpacking. |
You can work around such broken installation by removing the old offending
package, <old-package>, first.
$ sudo dpkg -P <old-package>
When a command in the package script returns error for some reason and the script exits with error, the package management system aborts their action and ends up with partially installed packages. When a package contains bugs in its removal scripts, the package may become impossible to remove and quite nasty.
For the package script problem of "<package_name>",
you should look into following package scripts.
"/var/lib/dpkg/info/<package_name>.preinst"
"/var/lib/dpkg/info/<package_name>.postinst"
"/var/lib/dpkg/info/<package_name>.prerm"
"/var/lib/dpkg/info/<package_name>.postrm"
Edit the offending package script from the root using following techniques.
disable the offending line by preceding "#"
force to return success by appending the offending line with "||
true"
Configure all partially installed packages with the following command.
# dpkg --configure -a
Since dpkg is very low level package tool, it can
function under the very bad situation such as unbootable system without
network connection. Let's assume foo package was broken
and needs to be replaced.
You may still find cached copies of older bug free version of
foo package in the package cache directory:
"/var/cache/apt/archives/". (If not, you can download it
from archive of http://snapshot.debian.net/ or copy it
from package cache of a functioning machine.)
If you can boot the system, you may install it by the following command.
# dpkg -i /path/to/foo_<old_version>_<arch>.deb
|
提示 |
|---|---|
|
If system breakage is minor, you may alternatively downgrade the whole system as in 第 2.7.10 节 “Emergency downgrading” using the higher level APT system. |
If your system is unbootable from hard disk, you should seek other ways to boot it.
Boot the system using the debian-installer CD in rescue mode.
Mount the unbootable system on the hard disk to
"/target".
Install older version of foo package by the following.
# dpkg --root /target -i /path/to/foo_<old_version>_<arch>.deb
This example works even if the dpkg command on the hard
disk is broken.
|
提示 |
|---|---|
|
Any GNU/Linux system started by another system on hard disk, live GNU/Linux CD, bootable USB-key drive, or netboot can be used similarly to rescue broken system. |
If attempting to install a package this way fails due to some dependency
violations and you really need to do this as the last resort, you can
override dependency using dpkg's
"--ignore-depends", "--force-depends"
and other options. If you do this, you need to make serious effort to
restore proper dependency later. See
dpkg(8)
for details.
|
注意 |
|---|---|
|
If your system is seriously broken, you should make a full backup of system to a safe place (see 第 10.2 节 “Backup and recovery”) and should perform a clean installation. This is less time consuming and produces better results in the end. |
If "/var/lib/dpkg/status" becomes corrupt for any reason,
the Debian system loses package selection data and suffers severely. Look
for the old "/var/lib/dpkg/status" file at
"/var/lib/dpkg/status-old" or
"/var/backups/dpkg.status.*".
Keeping "/var/backups/" in a separate partition may be a
good idea since this directory contains lots of important system data.
For serious breakage, I recommend to make fresh re-install after making
backup of the system. Even if everything in "/var/" is
gone, you can still recover some information from directories in
"/usr/share/doc/" to guide your new installation.
Reinstall minimal (desktop) system.
# mkdir -p /path/to/old/system
Mount old system at "/path/to/old/system/".
# cd /path/to/old/system/usr/share/doc # ls -1 >~/ls1.txt # cd /usr/share/doc # ls -1 >>~/ls1.txt # cd # sort ls1.txt | uniq | less
Then you are presented with package names to install. (There may be some
non-package names such as "texmf".)
You can seek packages which satisfy your needs with
aptitude from the package description or from the list
under "Tasks".
When you encounter more than 2 similar packages and wonder which one to install without "trial and error" efforts, you should use some common sense. I consider following points are good indications of preferred packages.
Essential: yes > no
Area: main > contrib > non-free
Priority: required > important > standard > optional > extra
Tasks: packages listed in tasks such as "Desktop environment"
Packages selected by the dependency package (e.g.,
python2.4 by python)
Popcon: higher in the vote and install number
Changelog: regular updates by the maintainer
BTS: No RC bugs (no critical, no grave, and no serious bugs)
BTS: responsive maintainer to bug reports
BTS: higher number of the recently fixed bugs
BTS: lower number of remaining non-wishlist bugs
Debian being a volunteer project with distributed development model, its archive contains many packages with different focus and quality. You must make your own decision what to do with them.
|
小心 |
|---|---|
|
Installing packages from mixed source of archives is not supported by the
official Debian distribution except for officially supported particular
combinations of archives such as |
Here is an example of operations to include specific newer upstream version
packages found in unstable while tracking
testing for single occasion.
Change the "/etc/apt/sources.list" file temporarily to
single "unstable" entry.
Run "aptitude update".
Run "aptitude install <package-name>".
Recover the original "/etc/apt/sources.list" file for
testing.
Run "aptitude update".
You do not create the "/etc/apt/preferences" file nor
need to worry about apt-pinning with this manual approach. But this is very
cumbersome.
|
小心 |
|---|---|
|
When using mixed source of archives, you must ensure compatibility of packages by yourself since the Debian does not guarantee it. If package incompatibility exists, you may break system. You must be able to judge these technical requirements. The use of mixed source of random archives is completely optional operation and its use is not something I encourage you to use. |
General rules for installing packages from different archives are the following.
Non-binary packages ("Architecture: all") are safer to install.
documentation packages: no special requirements
interpreter program packages: compatible interpreter must be available
Binary packages (non "Architecture: all") usually face
many road blocks and are unsafe to
install.
|
注意 |
|---|---|
|
In order to make a package to be safer to install, some commercial non-free binary program packages may be provided with completely statically linked libraries. You should still check ABI compatibility issues etc. for them. |
|
注意 |
|---|---|
|
Except to avoid broken package for a short term, installing binary packages from officially unsupported archives is generally bad idea. This is true even if you use apt-pinning (see 第 2.7.3 节 “Tweaking candidate version”). You should consider chroot or similar techniques (see 第 9.10 节 “Virtualized system”) to run programs from different archives. |
Without the "/etc/apt/preferences" file, APT system
choses the latest available version as the candidate
version using the version string. This is the normal state and
most recommended usage of APT system. All officially supported combinations
of archives do not require the "/etc/apt/preferences"
file since some archives which should not be used as the automatic source of
upgrades are marked as NotAutomatic and
dealt properly.
|
提示 |
|---|---|
|
The version string comparison rule can be verified with, e.g.,
" |
When you install packages from mixed source of archives (see 第 2.7.2 节 “Packages from mixed source of archives”) regularly, you can
automate these complicated operations by creating the
"/etc/apt/preferences" file with proper entries and
tweaking the package selection rule for candidate
version as described in
apt_preferences(5).
This is called apt-pinning.
|
警告 |
|---|---|
|
Use of apt-pinning by a novice user is sure call for major troubles. You must avoid using apt-pinning except when you absolutely need it. |
|
小心 |
|---|---|
|
When using apt-pinning, you must ensure compatibility of packages by yourself since the Debian does not guarantee it. The apt-pinning is completely optional operation and its use is not something I encourage you to use. |
|
小心 |
|---|---|
|
Archive level Release files (see 第 2.5.3 节 “Archive level "Release" files”) are used for the rule of
apt_preferences(5).
Thus apt-pinning works only with "suite" name for normal Debian archives and security Debian archives. (This is
different from Ubuntu archives.) For example,
you can do " |
|
小心 |
|---|---|
|
When you use non-Debian archive as a part of apt-pinning, you should check what they are intended for and also check their credibility. For example, Ubuntu and Debian are not meant to be mixed. |
|
注意 |
|---|---|
|
Even if you do not create the " |
Here is a simplified explanation of apt-pinning technique.
The APT system choses the highest Pin-Priority upgrading package from available package sources
defined in the "/etc/apt/sources.list" file as the
candidate version package. If the
Pin-Priority of the package is larger than 1000, this version restriction
for upgrading is dropped to enable
downgrading (see 第 2.7.10 节 “Emergency downgrading”).
Pin-Priority value of each package is defined by "Pin-Priority" entries in
the "/etc/apt/preferences" file or uses its default
value.
表 2.18. List of notable Pin-Priority values for apt-pinning technique.
| Pin-Priority | apt-pinning effects to the package |
|---|---|
| 1001 | install the package even if this constitutes a downgrade of the package |
| 990 | used as the default for the target release archive |
| 500 | used as the default for the normal archive |
| 100 | used as the default for the NotAutomatic and ButAutomaticUpgrades archive |
| 100 | used for the installed package |
| 1 | used as the default for the NotAutomatic archive |
| -1 | never install the package even if recommended |
The target release archive can be set by several methods.
"/etc/apt/apt.conf" configuration file with
"APT::Default-Release "stable";" line
command line option, e.g., "apt-get install -t testing
some-package"
The NotAutomatic and ButAutomaticUpgrades archive is set by archive
server having its archive level Release file (see 第 2.5.3 节 “Archive level "Release" files”) containing both
"NotAutomatic: yes" and "ButAutomaticUpgrades:
yes". The NotAutomatic archive
is set by archive server having its archive level Release file containing
only "NotAutomatic: yes".
The apt-pinning situation of
<package> from multiple archive sources is displayed by
"apt-cache policy <package>".
A line started with "Package pin:" lists the package
version of pin if association just with
<package> is defined, e.g., "Package pin: 0.190".
No line with "Package pin:" exists if no association just
with <package> is defined.
The Pin-Priority value associated just with <package> is listed right
side of all version strings, e.g., "0.181 700".
"0" is listed right side of all version strings if no
association just with <package> is defined, e.g., "0.181
0".
The Pin-Priority values of archives (defined as "Package:
*" in the "/etc/apt/preferences" file) are
listed left side of all archive paths, e.g., "100
http://ftp.XX.debian.org/debian/ jessie-backports/main
Packages".
There are jessie-updates and backports.debian.org archives which
provide updgrade packages for stable
(jessie).
In order to use these archives, you list all required archives in the
"/etc/apt/sources.list" file as the following.
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free deb http://security.debian.org/ jessie/updates main contrib deb http://ftp.us.debian.org/debian/ jessie-updates main contrib non-free deb http://ftp.us.debian.org/debian/ jessie-backports main contrib non-free
There is no need to set Pin-Priority value explicitly in the
"/etc/apt/preferences" file. When newer packages become
available, the default configuration provides most reasonable upgrades (see
第 2.5.3 节 “Archive level "Release" files”).
All installed older packages are upgraded to newer ones from
jessie-updates.
Only manually installed older packages from
jessie-backports are upgraded to newer ones
from jessie-backports.
Whenever you wish to install a package named
"<package-name>" with its dependency from
jessie-backports archive manually, you use
following command while switching target release with
"-t" option.
$ sudo apt-get install -t jessie-backports <package-name>
If you wish not to pull in particular packages automatically by
"Recommends", you must create the "/etc/apt/preferences"
file and explicitly list all those packages at the top of it as the
following.
Package: <package-1> Pin: version * Pin-Priority: -1 Package: <package-2> Pin: version * Pin-Priority: -1
Here is an example of apt-pinning
technique to include specific newer upstream version packages found in
unstable regularly upgraded while tracking
testing. You list all required archives in the
"/etc/apt/sources.list" file as the following.
deb http://ftp.us.debian.org/debian/ testing main contrib non-free deb http://ftp.us.debian.org/debian/ unstable main contrib non-free deb http://security.debian.org/ testing/updates main contrib
Set the "/etc/apt/preferences" file as as the following.
Package: * Pin: release a=unstable Pin-Priority: 100
When you wish to install a package named
"<package-name>" with its dependencies from
unstable archive under this configuration, you issue the
following command which switches target release with "-t"
option (Pin-Priority of unstable becomes 990).
$ sudo apt-get install -t unstable <package-name>
With this configuration, usual execution of "apt-get
upgrade" and "apt-get dist-upgrade" (or
"aptitude safe-upgrade" and "aptitude
full-upgrade") upgrades packages which were installed from
testing archive using current testing
archive and packages which were installed from unstable
archive using current unstable archive.
|
小心 |
|---|---|
|
Be careful not to remove " |
|
提示 |
|---|---|
|
I usually edit the " |
|
提示 |
|---|---|
|
If " |
If you wish to track particular packages in unstable
automatically without initial "-t unstable" installation,
you must create the "/etc/apt/preferences" file and
explicitly list all those packages at the top of it as the following.
Package: <package-1> Pin: release a=unstable Pin-Priority: 700 Package: <package-2> Pin: release a=unstable Pin-Priority: 700
These set Pin-Priority value for each specific package. For example, in
order to track the latest unstable version of this
"Debian Reference" in English, you should have following entries in the
"/etc/apt/preferences" file.
Package: debian-reference-en Pin: release a=unstable Pin-Priority: 700 Package: debian-reference-common Pin: release a=unstable Pin-Priority: 700
|
提示 |
|---|---|
|
This apt-pinning technique is valid even when you are tracking
|
Here is another example of apt-pinning
technique to include specific newer upstream version packages found in
experimental while tracking unstable.
You list all required archives in the
"/etc/apt/sources.list" file as the following.
deb http://ftp.us.debian.org/debian/ unstable main contrib non-free deb http://ftp.us.debian.org/debian/ experimental main contrib non-free deb http://security.debian.org/ testing/updates main contrib
The default Pin-Priority value for experimental archive
is always 1 (<<100) since it is NotAutomatic archive (see 第 2.5.3 节 “Archive level "Release" files”). There is no need to set
Pin-Priority value explicitly in the
"/etc/apt/preferences" file just to use
experimental archive unless you wish to track particular
packages in it automatically for next upgrading.
The apt package comes with its own cron script
"/etc/cron.daily/apt" to support the automatic download
of packages. This script can be enhanced to perform the automatic upgrade
of packages by installing the unattended-upgrades
package. These can be customized by parameters in
"/etc/apt/apt.conf.d/02backup" and
"/etc/apt/apt.conf.d/50unattended-upgrades" as described
in "/usr/share/doc/unattended-upgrades/README".
The unattended-upgrades package is mainly intended for
the security upgrade for the stable system. If the risk
of breaking an existing stable system by the automatic
upgrade is smaller than that of the system broken by the intruder using its
security hole which has been closed by the security update, you should
consider using this automatic upgrade with configuration parameters as the
following.
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::Unattended-Upgrade "1";
If you are running an unstable system, you do not want to
use the automatic upgrade since it certainly breaks system some day. Even
for such unstable case, you may still want to download
packages in advance to save time for the interactive upgrade with
configuration parameters as the following.
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::Unattended-Upgrade "0";
If you want to limit the download bandwidth for APT to e.g. 800Kib/sec (=100kiB/sec), you should configure APT with its configuration parameter as the following.
APT::Acquire::http::Dl-Limit "800";
|
小心 |
|---|---|
|
Downgrading is not officially supported by the Debian by design. It should be done only as a part of emergency recovery process. Despite of this situation, it is known to work well in many incidents. For critical systems, you should backup all important data on the system after the recovery operation and re-install the new system from the scratch. |
You may be lucky to downgrade from newer archive to older archive to recover
from broken system upgrade by manipulating candidate
version (see 第 2.7.3 节 “Tweaking candidate version”).
This is lazy alternative to tedious actions of many "dpkg -i
<broken-package>_<old-version>.deb" commands (see
第 2.6.4 节 “Rescue with the dpkg command”).
Search lines in the "/etc/apt/sources.list" file tracking
unstable as the following.
deb http://ftp.us.debian.org/debian/ sid main contrib non-free
Replace it with the following to track testing.
deb http://ftp.us.debian.org/debian/ stretch main contrib non-free
Set the "/etc/apt/preferences" file as the following.
Package: * Pin: release a=testing Pin-Priority: 1010
Run "apt-get update; apt-get dist-upgrade" to force
downgrading of packages across the system.
Remove this special "/etc/apt/preferences" file after
this emergency downgrading.
|
提示 |
|---|---|
|
It is a good idea to remove (not purge!) as much packages to minimize dependency problems. You may need to manually remove and install some packages to get system downgraded. Linux kernel, bootloader, udev, PAM, APT, and networking related packages and their configuration files require special attention. |
Although the maintainer name listed in
"/var/lib/dpkg/available" and
"/usr/share/doc/package_name/changelog" provide some
information on "who is behind the packaging activity", the actual uploader
of the package is somewhat obscure.
who-uploads(1)
in the devscripts package identifies the actual uploader
of Debian source packages.
If you are to compile a program from source to replace the Debian package,
it is best to make it into a real local debianized package
(*.deb) and use private archive.
If you chose to compile a program from source and to install them under
"/usr/local" instead, you may need to use
equivs as a last resort to satisfy the missing package
dependency.
Package: equivs Priority: extra Section: admin Description: Circumventing Debian package dependencies This is a dummy package which can be used to create Debian packages, which only contain dependency information.
For partial upgrades of the stable system, rebuilding a
package within its environment using the source package is desirable. This
avoids massive package upgrades due to their dependencies.
Add the following entries to the "/etc/apt/sources.list"
of a stable system.
deb-src http://http.us.debian.org/debian unstable main contrib non-free
Install required packages for the compilation and download the source package as the following.
# apt-get update # apt-get dist-upgrade # apt-get install fakeroot devscripts build-essential $ apt-get build-dep foo $ apt-get source foo $ cd foo*
Update some tool chain packages such as dpkg, and
debhelper from the backport packages if they are required
for the backporting.
Execute the following.
$ dch -i
Bump package version, e.g. one appended with "+bp1" in
"debian/changelog"
Build packages and install them to the system as the following.
$ debuild $ cd .. # debi foo*.changes
Since mirroring whole subsection of Debian archive wastes disk space and
network bandwidth, deployment of a local proxy server for APT is desirable
consideration when you administer many systems on LAN. APT can be configure to use generic web (http)
proxy servers such as squid (see 第 6.10 节 “其它网络应用服务”) as described in
apt.conf(5)
and in "/usr/share/doc/apt/examples/configure-index.gz".
The "$http_proxy" environment variable can be used to
override proxy server setting in the "/etc/apt/apt.conf"
file.
There are proxy tools specially for Debian archive. You should check BTS before using them.
表 2.19. List of the proxy tools specially for Debian archive
| 软件包 | 流行度 | 大小 | 说明 |
|---|---|---|---|
approx
|
V:1, I:1 | 4721 | caching proxy server for Debian archive files (compiled OCaml program) |
apt-cacher
|
V:1, I:1 | 287 | Caching proxy for Debian package and source files (Perl program) |
apt-cacher-ng
|
V:4, I:5 | 1349 | Caching proxy for distribution of software packages (compiled C++ program) |
|
小心 |
|---|---|
|
When Debian reorganizes its archive structure, these specialized proxy tools tend to require code rewrites by the package maintainer and may not be functional for a while. On the other hand, generic web (http) proxy servers are more robust and easier to cope with such changes. |
Here is an example for creating a small public package archive compatible with the modern secure APT system (see 第 2.5.2 节 “Top level "Release" file and authenticity”). Let's assume few things.
Account name: "foo"
Host name: "www.example.com"
Required packages: apt-utils, gnupg,
and other packages
URL: "http://www.example.com/~foo/" ( →
"/home/foo/public_html/index.html")
Architecture of packages: "amd64"
Create an APT archive key of Foo on your server system as the following.
$ ssh foo@www.example.com $ gpg --gen-key ... $ gpg -K ... sec 1024D/3A3CB5A6 2008-08-14 uid Foo (ARCHIVE KEY) <foo@www.example.com> ssb 2048g/6856F4A7 2008-08-14 $ gpg --export -a 3A3CB5A6 >foo.public.key
Publish the archive key file "foo.public.key" with the
key ID "3A3CB5A6" for Foo
Create an archive tree called "Origin: Foo" as the following.
$ umask 022
$ mkdir -p ~/public_html/debian/pool/main
$ mkdir -p ~/public_html/debian/dists/unstable/main/binary-amd64
$ mkdir -p ~/public_html/debian/dists/unstable/main/source
$ cd ~/public_html/debian
$ cat > dists/unstable/main/binary-amd64/Release << EOF
Archive: unstable
Version: 4.0
Component: main
Origin: Foo
Label: Foo
Architecture: amd64
EOF
$ cat > dists/unstable/main/source/Release << EOF
Archive: unstable
Version: 4.0
Component: main
Origin: Foo
Label: Foo
Architecture: source
EOF
$ cat >aptftp.conf <<EOF
APT::FTPArchive::Release {
Origin "Foo";
Label "Foo";
Suite "unstable";
Codename "sid";
Architectures "amd64";
Components "main";
Description "Public archive for Foo";
};
EOF
$ cat >aptgenerate.conf <<EOF
Dir::ArchiveDir ".";
Dir::CacheDir ".";
TreeDefault::Directory "pool/";
TreeDefault::SrcDirectory "pool/";
Default::Packages::Extensions ".deb";
Default::Packages::Compress ". gzip bzip2";
Default::Sources::Compress "gzip bzip2";
Default::Contents::Compress "gzip bzip2";
BinDirectory "dists/unstable/main/binary-amd64" {
Packages "dists/unstable/main/binary-amd64/Packages";
Contents "dists/unstable/Contents-amd64";
SrcPackages "dists/unstable/main/source/Sources";
};
Tree "dists/unstable" {
Sections "main";
Architectures "amd64 source";
};
EOF
You can automate repetitive updates of APT archive contents on your server
system by configuring dupload.
Place all package files into
"~foo/public_html/debian/pool/main/" by executing
"dupload -t foo changes_file" in client while having
"~/.dupload.conf" containing the following.
$cfg{'foo'} = {
fqdn => "www.example.com",
method => "scpb",
incoming => "/home/foo/public_html/debian/pool/main",
# The dinstall on ftp-master sends emails itself
dinstall_runs => 1,
};
$cfg{'foo'}{postupload}{'changes'} = "
echo 'cd public_html/debian ;
apt-ftparchive generate -c=aptftp.conf aptgenerate.conf;
apt-ftparchive release -c=aptftp.conf dists/unstable >dists/unstable/Release ;
rm -f dists/unstable/Release.gpg ;
gpg -u 3A3CB5A6 -bao dists/unstable/Release.gpg dists/unstable/Release'|
ssh foo@www.example.com 2>/dev/null ;
echo 'Package archive created!'";
The postupload hook script initiated by dupload(1) creates updated archive files for each upload.
You can add this small public archive to the apt-line of your client system by the following.
$ sudo bash # echo "deb http://www.example.com/~foo/debian/ unstable main" \ >> /etc/apt/sources.list # apt-key add foo.public.key
|
提示 |
|---|---|
|
If the archive is located on the local filesystem, you can use " |
You can make a local copy of the package and debconf selection states by the following.
# dpkg --get-selections '*' > selection.dpkg # debconf-get-selections > selection.debconf
Here, "*" makes "selection.dpkg" to
include package entries for "purge" too.
You can transfer these 2 files to another computer, and install there with the following.
# dselect update # debconf-set-selections < myselection.debconf # dpkg --set-selections < myselection.dpkg # apt-get -u dselect-upgrade # or dselect install
If you are thinking about managing many servers in a cluster with
practically the same configuration, you should consider to use specialized
package such as fai to manage the whole system.
alien(1)
enables the conversion of binary packages provided in Red Hat
rpm, Stampede slp, Slackware
tgz, and Solaris pkg file formats into
a Debian deb package. If you want to use a package from
another Linux distribution than the one you have installed on your system,
you can use alien to convert it from your preferred
package format and install it. alien also supports LSB
packages.
|
警告 |
|---|---|
|
alien(1)
should not be used to replace essential system packages, such as
|
The "dpkg*.deb" package contents can be extracted without
using
dpkg(1)
on any Unix-like environment using standard
ar(1)
and
tar(1).
# ar x /path/to/dpkg_<version>_<arch>.deb # ls total 24 -rw-r--r-- 1 bozo bozo 1320 2007-05-07 00:11 control.tar.gz -rw-r--r-- 1 bozo bozo 12837 2007-05-07 00:11 data.tar.gz -rw-r--r-- 1 bozo bozo 4 2007-05-07 00:11 debian-binary # mkdir control # mkdir data # tar xvzf control.tar.gz -C control # tar xvzf data.tar.gz -C data
The other "*.deb" package contents can be extracted by
the
dpkg-deb(1)
command obtained from the "dpkg*.deb" package as above;
or using standard
ar(1)
and newer GNU
tar(1)
with the
xz(1)
decompression support similarly as above.
You can also browse package content using the mc command.
You can learn more on the package management from following documentations.
Primary documentations on the package management:
aptitude(8), dpkg(1), tasksel(8), apt-get(8), apt-config(8), apt-key(8), sources.list(5), apt.conf(5), and apt_preferences(5);
"/usr/share/doc/apt-doc/guide.html/index.html" and
"/usr/share/doc/apt-doc/offline.html/index.html" from the
apt-doc package; and
"/usr/share/doc/aptitude/html/en/index.html" from the
aptitude-doc-en package.
Official and detailed documentations on the Debian archive:
Tutorial for building of a Debian package for Debian users: