APT

Jump to: navigation, search

APT - 高级软件包工具

APT 是一个在基于Debian的发行版中普遍使用的软件包管理器,其能够简单快速地安装和删除软件包。它会根据依赖关系自动启动下载并安装所需软件包的依赖的包。

安装 APT

APT 包含在最新版本的 openSUSE当中,但并不默认安装。如需安装APT,只需打开 YaST,在YaST的软件管理模块中的搜索一栏输入 apt 并安装。然后最新的apt以及所需的库等将被安装到您的系统中去。您可能同样需要搜索安装apt的图形界面:synaptic(新立得)。一旦 APT 和新立得安装成功,您就要用您喜欢的编辑器编辑 /etc/apt/sources.list ,该文件包含了一个软件安装源列表。

可以参阅以下样板文件

# A very basic sources.list file.
#
# Fastest repository comes first, with netselect it is possible to determine
# the fastest repository easily.
#
# Visit http://software.opensuse.org/download/ to determine which additional
# components are available.  Some examples are given below, just uncomment
# the line to enable it.
#
# The apt format:
# repomd http://download.opensuse.org/distribution/10.3/repo/oss/suse/ /
#
# Notice from the example above that repomd is the repository type for OpenSuSE YAST repositories.
# This data type is followed by the URL of the repository.
# The directory URL should be the directory path to the folder that is directly above the repodata folder on the server.
# In other words, the http://download.opensuse.org/distribution/10.3/repo/oss/suse/ folder contains the repodata folder.
# The line is ended with a space and another / to indicate that our repodata is located in this folder.
#
# Have a lot of fun with APT!



#Main 10.3 Repository
repomd http://ftp5.gwdg.de/pub/opensuse/distribution/10.3/repo/oss/suse/ /
repomd http://ftp5.gwdg.de/pub/opensuse/distribution/10.3/repo/non-oss/suse/ /

#VideoLAN
repomd http://download.videolan.org/pub/vlc/SuSE/10.3/ /

#NVIDIA
repomd http://download.nvidia.com/opensuse/10.3/ /

#Packman
repomd http://packman.unixheads.com/suse/10.3/ /

#APT for RPM
repomd http://download.opensuse.org/repositories/home:/rbos/openSUSE_10.3/ /

请参考 软件源来获取一个可用的软件源列表。

当您修改软件源之后,请使用apt-get update来获取一个所有可用软件包的列表。如果某个安装过程失败了,您可以使用apt-get -f install命令来修复所有损坏的依赖关系。


自动更新

如果想要每日自动刷新可用包列表,请编辑/etc/sysconfig/autoupdate,加入以下语句

AUTOUPDATE_ENABLE=yes


使用APT

APT有命令行模式和图形模式( 新立得)。您可以按如下指导在命令行下使用APT或是直接使用 新立得

APT有两个主要的命令:apt-getapt-cache。如果您已经安装了APT,那么您可以使用apt-cache search来搜索软件包。提示:在搜索软件包之前您需要在网上获得一个当前可用包的列表。您可以使用apt-get update命令来完成获得列表的工作。请注意,apt-get update命令并不会安装任何东西,该命令只会获取一个所有可用包的列表。因为这个列表更新频繁,所以建议您每周运行一次这个命令。

zero:~ # apt-get update
Get:1 http://ftp.gwdg.de SuSE/9.1-i386 release [12.4kB]
Fetched 12.4kB in 3s (3539B/s)
Get:1 http://ftp.gwdg.de SuSE/9.1-i386/suser-guru pkglist [265kB]
Get:2 http://ftp.gwdg.de SuSE/9.1-i386/suser-guru release [135B]
Get:3 http://ftp.gwdg.de SuSE/9.1-i386/packman pkglist [199kB]
Get:4 http://ftp.gwdg.de SuSE/9.1-i386/packman release [132B]
Get:5 http://ftp.gwdg.de SuSE/9.1-i386/packman-i686 pkglist [68.3k]
..............
Get:16 http://ftp.gwdg.de SuSE/9.1-i386/security-prpm release [138B]
Fetched 1746kB in 2m56s (9887B/s)
Reading Package Lists... Done
Building Dependency Tree... Done

使用apt-get install命令即可安装安装包。示例:如果您想搜索gaim,可以使用如下命令:

zero:~ # apt-cache search gaim
bitlbee - An IRC to other chat networks gateway
gaim-devel - Development environment for gaim
gaim-guifications - Guifications plugin for Gaim
gaim-perl - Perl bindings for gaim
gaim-tcl - Tcl/Tk bindings for gaim
OpenOffice_org - A Free Office Suite (the Language Independent part)
gaim - A multi-protocol Instant Messenger client
gaim-vv - Gaim is Compatible with the AOL Instant Messenger
linphone-im - A modified version of Linphone 

使用apt-cache search命令后会列出所有相符合的软件包的名称,并附带一小段的说明。现在假设您想要安装gaim-guifications

zero:~ # apt-get install gaim-guifications
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
gaim-guifications
0 upgraded,aptnewly installed, 0 removed and 354 not upgraded.
Need to get 150kB of archives.
After unpacking 520kB of additional disk space will be used.
Get:1 http://ftp.gwdg.de SuSE/9.1-i386/suser-guru gaim-guifications 2.8-1.guru.suse91 [150kB]
Fetched 150kB in 8s (17.6kB/s)
Committing changes...
Preparing... ########################################### [100%]
1:gaim-guifications ########################################### [100%]

当您在使用apt-get install命令的时候,它会检查软件包是否已经被安装。如果软件包已经被安装,它则会检查当前是否有更新的版本。如果该软件有更新的版本可用,它会自动获取并安装该软件的更新版本。例如想要安装mplayer的时候:

zero:~ # apt-cache search mplayer
kplayer - KDE Media Player based on MPlayer
mplayerplug-in - MPlayer Plugin for Netscape/Mozilla
xine-skins - Skins for xine-ui
MPlayer - Movie Player
libpostproc - The postproc library of MPlayer
live - live.com librarys
transcode - a linux video stream processing utility
libvisual-plugins - sound visualisation library plugins
MPlayer-suite - A virtual package to obtain MPlayer and many of the plugins
xmms-mplayer - Use xmms as a frontend for MPlayer
mpav - MPlayer Audio Visualization
xmmsmplayer - XMMS MPlayer Input Plugin
kmenc15 - Kde frontend to mencoder
zero:~ # apt-get install MPlayer-suite
Reading Package Lists... Done
Building Dependency Tree... Done
MPlayer-suite is already the newest version.
0 upgraded, 0 newly installed, 0 removed and 354 not upgraded.


参考


外部链接