Debian 管理员手册 6.5. 前置:aptitude、synaptic

ga域名注册6.5. 前置:aptitude、synaptic

APT is a C++ program whose code mainly resides in the libapt-pkg shared library. Using a shared library facilitates the creation of user interfaces (front-ends), since the code contained in the library can easily be reused. Historically, apt-get was only designed as a test front-end for libapt-pkg but its success tends to obscure this fact.

6.5.1. aptitude

aptitude is an interactive program that can be used in semi-graphical mode on the console. You can browse the list of installed and available packages, look up all the available information, and select packages to install or remove. The program is designed specifically to be used by administrators, so that its default behaviors are designed to be much more intelligent than apt-get's, and its interface much easier to understand.

The aptitude 软件包管理者

图 6.1. The aptitude 软件包管理者

When it starts, aptitude shows a list of packages sorted by state (installed, non-installed, or installed but not available on the mirrors — other sections display tasks, virtual packages, and new packages that appeared recently on mirrors). To facilitate thematic browsing, other views are available. In all cases, aptitude displays a list combining categories and packages on the screen. Categories are organized through a tree structure, whose branches can respectively be unfolded or closed with the Enter, [ and ] keys. + should be used to mark a package for installation, - to mark it for removal and _ to purge it (note that these keys can also be used for categories, in which case the corresponding actions will be applied to all the packages of the category). u updates the lists of available packages and Shift+u prepares a global system upgrade. g switches to a summary view of the requested changes (and typing g again will apply the changes), and q quits the current view. If you are in the initial view, this will effectively close aptitude.

文档 aptitude

This section does not cover the finer details of using aptitude. It rather focuses on giving you a survival kit to use it. But it is well documented and we advise you to use its complete manual available in the aptitude-doc-en package (see /usr/share/doc/aptitude/html/en/index.html) or at https://www.debian.org/doc/manuals/aptitude/).

键入 / 及搜索的键词,就能搜索软件包。键词对应至软件包的名称,也可应用于描述内容 (若前置 ~d、区块 (前置 ~s) 或文档内的其他字词。同样的键词可以筛选显示软件包的清单:键入 l 键 (如同在 limit 之内) 与其他键词。

管理 Debian 软件包的 “自动旗标” (见 第 6.2.7 节 “自动追踪已安装的软件包”),对 aptitude 而言是小事一椿。可以用 Shift+m 浏览已安装并标示为自动的软件包或以 m 键移除标示。在软件包清单内,“自动软件包” 标示为 “A”。此功能也可简单看到机器内正在使用的软件包,不必看那些程序库与相依性繁琐的细节。相关的键词可以与 l (启动筛选模式) 一起使用的是 ~i!~M。它的作用是只看已安装的软件包 (~i) 不是被标示为自动(!~M) 的软件包。

工具 在命令行接口使用 aptitude

经由命令行或交互接口可以近用 aptitude 大部分的功能。命令行看来像是 apt-get 与 apt-cache。

也能从命令行近用 aptitude 的高端功能。使用交互版相同的软件包搜索模式。例如,清除 “手动安装” 软件包、本地安装的程序不再需要程序库或 Perl 模块,就可把对应的软件包标示为自动:

# aptitude markauto '~slibs|~sperl'

从这里您可看到 aptitude 搜索模式系统的威力,即时选取 libs 与 perl 区块的所有软件包。

小心对应,部分软件包被标记为自动且其他软件包均未相依于它们,该等软件包就会被自动移除 (经过确认程序)。

6.5.1.1. 管理推荐、建议与工作

Another interesting feature of aptitude is the fact that it respects recommendations between packages while still giving users the choice not to install them on a case by case basis. For example, the gnome package recommends transmission-gtk (among others). When you select the former for installation, the latter will also be selected (and marked as automatic if not already installed on the system). Typing g will make it obvious: transmission-gtk appears on the summary screen of pending actions in the list of packages installed automatically to satisfy dependencies. However, you can decide not to install it by deselecting it before confirming the operations.

此推荐追踪功能不适用于更新。例如,若 gnome 新版建议一个不包括稍前版本的软件包,就不会安装它。然而,还是列在屏幕,管理者仍可点击并安装它。

Suggestions between packages are also taken into account, but in a manner adapted to their specific status. For example, since gnome suggests empathy, the latter will be displayed on the summary screen of pending actions (in the section of packages suggested by other packages). This way, it is visible and the administrator can decide whether to take the suggestion into account or not. Since it is only a suggestion and not a dependency or a recommendation, the package will not be selected automatically — its selection requires a manual intervention from the user (thus, the package will not be marked as automatic).

在同样的精神下,记得 aptitude 以智能的手法使用工作的概念。在屏幕的软件包清单中显示工作,可以安装或移除选定的完整工作,或浏览包括选定较小工作的软件包清单。

6.5.1.2. 较佳的解决算法

总结本段的内容,在解决困难情境时,aptitude 的演算较 apt-get 更为复杂。需要运行一组工作且可能带领至另个支离的系统,aptitude 评估若干可能的状况以递减关联的方式呈现。然而,这些算法不是失败的证明。幸运的是,总有手动选择运行的可能。现在的选择带领至矛盾的地方时,屏幕的上方就指出若干 “破碎” 的软件包 (and you can directly navigate to those packages by pressing b)。就可能以人工方式创建解决此问题的方案。尤其是,可以按 Enter 键选取近用多个可用的版本。选定的版本可以解决问题,就勇敢不迟疑地使用其功能。破碎软件包渐趋于零后,您可安全地进入待决区的摘要画面,于使用前再次确认。

说明 aptitude 的记录档

如同 dpkg,aptitude 追踪运行动作存在其记录档内 (/var/log/aptitude)。然而,两个命令分别在不同层次工作,各自的记录档有不同的信息。当 dpkg 记录对各别软件包的一步步运作,aptitude 则记录系统更新之类的高端运作。

小心,记录档只包括 aptitude 工作的摘要。若另个前端 (或即使是 dpkg 自身) 只是偶而用到,则 aptitude 的记录档将只包括工作的部分,所以不能依赖它创建系统的过去。

6.5.2. synaptic

synaptic 是 Debian 的软件包图形管理器,在 GTK+/GNOME 的基础上提供清楚有效的图形接口。它以很多的立即可用筛选器提供快速近用添加的软件包、安装软件包、可升级软件包、过时软件包等。经由这些清单浏览,选定对软件包的工作 (安装、升级、移除、清除);不会立即运行此等工作,但把它们放入工作清单。单键按下可运行的工作,接着就可运行。

synaptic 软件包管理器

图 6.2. synaptic 软件包管理器