APT HOWTO
第五章 获取软件包信息
有些基于APT系统的前端程序,能十分方便地获得系统软件包列表,列表包括可安装或已安装的软件包,还可以显示某软件包属于哪个域(section),它的优先级(priority)是多少,它的说明文档,等等。
但是...在此我们想的学习如何使用APT本身来完成。你如何找出你想要安装的软件包的名称?
我们完成这个任务的方法有很多。我们从apt-cache开始,APT系统使用这个程序来维护它的数据库。下面我们通过一些实际操作来对它做个概览。
5.1 获得软件包名称
==================
假设你十分怀念玩Atari 2600的好日子,你决定用APT安装一个Atari emulator,随后再下载几个游戏,你可以这样:
[root]@[/] # apt-cache search atari
atari-fdisk-cross - Partition editor for Atari (running on non-Atari)
circuslinux - The clowns are trying to pop balloons to score points!
madbomber - A Kaboom! clone
tcs - Character set translator.
atari800 - Atari emulator for svgalib/X/curses
stella - Atari 2600 Emulator for X windows
xmess-x - X binaries for Multi-Emulator Super System
我们找到了几个相关的软件包,以及有关的简单描述。想进一步获得某个软件包的详细信息,你可以运行:
[root]@[/] # apt-cache show stella
Package: stella
Priority: extra
Section: non-free/otherosfs
Installed-Size: 830
Maintainer: Tom Lear
Architecture: i386
Version: 1.1-2
Depends: libc6 (>= 2.1), libstdc++2.10, xlib6g (>= 3.3.5-1)
Filename: dists/potato/non-free/binary-i386/otherosfs/stella_1.1-2.deb
Size: 483430
MD5sum: 11b3e86a41a60fa1c4b334dd96c1d4b5
Des cription: Atari 2600 Emulator for X windows
Stella is a portable emulator of the old Atari 2600 video-game console
written in C++. You can play most Atari 2600 games with it. The latest
news, code and binaries for Stella can be found at:
http://www4.ncsu.edu/~bwmott/2600
屏幕上显示出这个软件包的详细信息及其用途的完整描述。如果你的系统中已安装了某个软件包而系统又搜索到它的新版本,系统会将它们的详细信息一并列出。如下例:
[root]@[/] # apt-cache show lilo
Package: lilo
Priority: important
Section: base
Installed-Size: 271
Maintainer: Russell Coker
Architecture: i386
Version: 1:21.7-3
Depends: libc6 (>= 2.2.1-2), debconf (>=0.2.26), logrotate
Suggests: lilo-doc
Conflicts: manpages (<<1.29-3)
Filename: pool/main/l/lilo/lilo_21.7-3_i386.deb
Size: 143052
MD5sum: 63fe29b5317fe34ed8ec3ae955f8270e
Des cription: LInux LOader - The Classic OS loader can load Linux and others
This Package contains lilo (the installer) and boot-record-images to
install Linux, OS/2, DOS and generic Boot Sectors of other OSes.
.
You can use Lilo to manage your Master Boot Record (with a simple text screen)
or call Lilo from other Boot-Loaders to jump-start the Linux kernel.
Package: lilo
Status: install ok installed
Priority: important
Section: base
Installed-Size: 190
Maintainer: Vincent Renardias
Version: 1:21.4.3-2
Depends: libc6 (>= 2.1.2)
Recommends: mbr
Suggests: lilo-doc
Des cription: LInux LOader - The Classic OS loader can load Linux and others
This Package contains lilo (the installer) and boot-record-images to
install Linux, OS/2, DOS and generic Boot Sectors of other OSes.
.
You can use Lilo to manage your Master Boot Record (with a simple text screen)
or call Lilo from other Boot-Loaders to jump-start the Linux kernel.
注意,首先列出的是可用软件包,接着列出的是已安装软件包。获取某个软件包的常规信息可运行:
[root]@[/] # apt-cache showpkg penguin-command
Package: penguin-command
Versions:
1.4.5-1(/var/lib/apt/lists/download.sourceforge.net_debian_dists_unstable_main_binary-i386_Packages)(/var/lib/dpkg/status)
Reverse Depends:
Dependencies:
1.4.5-1 - libc6 (2 2.2.1-2) libpng2 (0 (null)) libsdl-mixer1.1 (2 1.1.0) libsdl1.1 (0 (null)) zlib1g (2 1:1.1.3)
Provides:
1.4.5-1 -
Reverse Provides:
如果仅想了解某软件包的与哪些软件包关联,可运行:
[root]@[/] # apt-cache depends penguin-command
penguin-command
Depends: libc6
Depends: libpng2
Depends: libsdl-mixer1.1
Depends: libsdl1.1
Depends: zlib1g
总之,有一系列工具可帮助我们找到我们想要的软件包。
5.2 使用dpkg查找软件包名称
==========================
另一个定位软件包的方法是知道软件包中某个关键文件的名称。例如,你编译时需要某个头文件,查找提供该文件的软件包,你可以运行:
[root]@[/] # dpkg -S stdio.h
libc6-dev: /usr/include/stdio.h
libc6-dev: /usr/include/bits/stdio.h
perl: /usr/lib/perl/5.6.0/CORE/nostdio.h
或者:
[root]@[/] # dpkg -S /usr/include/stdio.h
libc6-dev: /usr/include/stdio.h
在清理硬盘空间时,了解系统中已安装软件的软件包名称十分有用,你可以运行:
[root]@[/] # dpkg -l | grep mozilla
ii mozilla-browse 0.9.6-7 Mozilla Web Browser
这个命令的缺点是它会“截断”软件包的名字。在上例中,软件包的全称是mozilla-browser,解决这个问题可以使用COLUMNS环境变量:
[kov]@[couve] $ COLUMNS=132 dpkg -l | grep mozilla
ii mozilla-browser 0.9.6-7 Mozilla Web Browser - core and browser
网友评论:
- · Linux Serial Programming HOWTO (2)
- · 自己动手制作Knoppix中文版
- · Samba HOWTO (4)
- · Samba HOWTO (3)
- · Vim 中文文档
- · Samba HOWTO (2)
- · Debian APT HOWTO(三)
- · Cosixlinux3.1[发行版]
- · LINUX 常见问题1000个详细解答 (1)
- · CRUX Linux
- · 用硬盘安装Yoper linux
- · Debian APT HOWTO(一)
- · Samba HOWTO (1)
- · Linux Serial Programming HOWTO (1)
- · 详解Linux 2.6内核新变化

投稿指南


