查看文章
 
Debian 软件包管理-介绍 apt-get
2008年12月04日 星期四 13:43
Debian 软件包管理系统由几个不同的工具组成。命令行工具 apt-get 是安装新软件包的最简单方法。例如,要
安装程序 Xsnow,可以 root 用户的身份执行以下操作:
# apt-get install xsnow
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
xsnow
0 packages upgraded, 1 newly installed, 0 to remove and 10 not upgraded.
Need to get 17.8kB of archives. After unpacking 42.0kB will be used.
Get:1 http://ftp-mirror.internap.com stable/non-free xsnow 1.40-6 [17.8kB]
Fetched 17.8kB in 0s (18.4kB/s)
Selecting previously deselected package xsnow.
(Reading database ... 5702 files and directories currently installed.)
Unpacking xsnow (from .../archives/xsnow_1.40-6_i386.deb) ...
Setting up xsnow (1.40-6) ...
浏览这个输出,您可以看到即将安装 Xsnow,然后从 Web 上获取它,解包,最后设置。

如果 apt-get 发觉您要安装的软件包依赖其它一些软件包,它会自动获取并安装这些软件包。在上一个示例中
,只安装了 Xsnow,这是因为它的所有相关性都已满足。
然而,有时候 apt-get 需要获取的软件包列表会很大,所以一般最好在安装前先查看将要安装的文件。-s 选项
正好做这一工作。例如,在我们的一个系统上,如果我们试图安装图形电子邮件程序 balsa:
# apt-get -s install balsa
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
esound esound-common gdk-imlib1 gnome-bin gnome-libs-data imlib-base libart2
libaudiofile0 libesd0 libglib1.2 libgnome32 libgnomesupport0 libgnomeui32
libgnorba27 libgnorbagtk0 libgtk1.2 libjpeg62 liborbit0 libpng2 libproplist0
libtiff3g libungif3g zlib1g
The following NEW packages will be installed:
balsa esound esound-common gdk-imlib1 gnome-bin gnome-libs-data imlib-base
libart2 libaudiofile0 libesd0 libglib1.2 libgnome32 libgnomesupport0
libgnomeui32 libgnorba27 libgnorbagtk0 libgtk1.2 libjpeg62 liborbit0 libpng2
libproplist0 libtiff3g libungif3g zlib1g
0 packages upgraded, 24 newly installed, 0 to remove and 10 not upgraded.
然后它会列出软件包将安装和配置(或设置)的顺序。

因为 apt-get 会自动为您获取软件包,所以它必须知道在哪里能找到那些还没有安装的软件包。这一信息在
/etc/apt/sources.list 中。尽管您可以手工编辑这个文件(请参阅 sources.list 手册页),但您会发现使用一个交
互工具会更方便:
# apt-setup
这个工具遍历可以找到 Debian 软件包的位置,如 CDROM、Web 站点和 ftp 站点。当您完成后,它将更改写
到您的 /etc/apt/sources.list 文件,这样 apt-get 可以在您请求这些软件包时找到它们。

有些软件包使用名为 debconf 的系统用于其配置步骤。那些使用 debconf 的软件包可以用各种方式询问其配置
问题,询问方式可以是:在文本终端中、通过图形界面或通过 Web 页面等。要配置一个这样的软件包,可以
使用 dpkg-reconfigure 命令。您甚至可以用它来确保所有的 debconf 软件包都已完全配置。
# dpkg-reconfigure --all
debconf: package "3c5x9utils" is not installed or does not use debconf
debconf: package "3dchess" is not installed or does not use debconf
debconf: package "9menu" is not installed or does not use debconf
debconf: package "9wm" is not installed or does not use debconf
debconf: package "a2ps" is not installed or does not use debconf
debconf: package "a2ps-perl-ja" is not installed or does not use debconf
debconf: package "aalib-bin" is not installed or does not use debconf
这会产生一个很长的、未使用 debconf 的软件包列表,但它也会找到使用 debconf 的软件包,并且以易于使用
的格式让您回答每个软件包提出的问题。

目前我们所评论 Debian 软件包管理工具最适于处理有较长软件包列表的多步操作。但它们不包括软件包管理
的某些具体操作。对于这一类工作,您可以使用 dpkg。
例如,要获得软件包的完整状态和描述,可以使用 -s 选项:
# dpkg -s xsnow
Package: xsnow
Status: install ok installed
Priority: optional
Section: non-free/x11
Installed-Size: 41
Maintainer: Martin Schulze < joey@debian.org>
Version: 1.40-6
Depends: libc6, xlib6g (>= 3.3-5)
Descrīption: Brings Christmas to your desktop
Xsnow is the X-windows application that will let it snow on the
root window, in between and on windows. Santa and his reindeer
will complete your festive-season feeling.


因为 .deb 软件包含有文件,所以您可能会想到应该有办法列出软件包内的文件。哦,没错;只要用 -L 选项:
# dpkg -L xsnow
/.
/usr
/usr/doc
/usr/doc/xsnow
/usr/doc/xsnow/copyright
/usr/doc/xsnow/readme.gz
/usr/doc/xsnow/changelog.Debian.gz
/usr/X11R6
/usr/X11R6/bin
/usr/X11R6/bin/xsnow
/usr/X11R6/man
/usr/X11R6/man/man6
/usr/X11R6/man/man6/xsnow.6.gz
要用其它方法,并且要找出哪个软件包含有一个特定的文件,可以使用 -S 选项:
# dpkg -S /usr/doc/xsnow/copyright
xsnow: /usr/doc/xsnow/copyright
软件包的名称刚好在冒号的左边。

通常,apt-get 已经知道您可能需要的所有 Debian 软件包。如果它不知道,您或许能在这些 Debian 软件包列
表中(或 Web 上的其它地方)找到该软件包。
如果您已经找到并下载了一个 .deb 文件,您可以用 -i 选项安装它:
# dpkg -i /tmp/dl/xsnow_1.40-6_i386.deb
如果您找不到希望看到的 .deb 文件,但却发现了 .rpm 文件或一些其它类型的软件包,您或许可以使用 alien
。 alien 程序可以将软件包从各种格式转换成 .deb。


类别:linux-ubuntu-embedded system||添加到搜藏 |分享到i贴吧|浏览(224)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu