本版版主招募中

 
标题: [原创]APT HOWTO 简单翻译
无双
荣誉斑竹
Rank: 14Rank: 14Rank: 14Rank: 14
天才猪



UID 4
精华 84
积分 5863
帖子 11390
活跃指数 0
LU金币 4248 个
LU金条 0 个
阅读权限 200
注册 2003-9-16
来自 杭州
 
发表于 2003-10-26 11:43  资料  个人空间  主页 短消息  加为好友 
无双 www.loveunix.net 转载请注明出处

apt是debian下的包管理工具 可以方便的管理各软件包安装和升级
你几千不用考虑包依赖关系 如果有网络的话 那么更不用考虑频频换光盘
并且由于debian的sid几千每天都在更新 所以你不用考虑自己编译软件包 等几天就可以了
更有FANS把APT移植到了其它的rpm平台上
但是apt是命令行下的东东 功能强大那命令也比较多 所以翻译一下
让大家理解这个先进的包管理系统

目录如下
http://www.debian.org/doc/manuals/apt-howt...n.html#contents

CODE

Contents

   * 1 Introduction(介绍)

   * 2 Basic Configuration(基本配置)
         o 2.1 The /etc/apt/sources.list file(apt安装源配置文件)
         o 2.2 How to use APT locally
         o 2.3 Deciding which mirror is the best to include in the sources.list file: netselect, netselect-apt(查找最快的包下载站点)
         o 2.4 Adding a CD-ROM to the sources.list file(向安装源中添加CDROM)

   * 3 Managing packages(包管理系统)
         o 3.1 Updating the list of available packages(更新包列表)
         o 3.2 Installing packages(安装包)
         o 3.3 Removing packages(删除包)
         o 3.4 Upgrading packages(升级包)
         o 3.5 Upgrading to a new release(升级到一个新的版本)
         o 3.6 Removing unused package files: apt-get clean and autoclean
(删除不用的包)
         o 3.7 Using APT with dselect(通过dselect来使用apt)
         o 3.8 How to keep a mixed system(臬使用混合的系统)
         o 3.9 How to upgrade packages from specific versions of Debian(怎样从一个特殊版本的debian中升级)
         o 3.10 How to keep specific versions of packages installed (complex)(臬保持特殊版本的包)

   * 4 Very useful helpers(有用的帮助)
         o 4.1 How to install locally compiled packages: equivs(怎样安装本地编译包)
         o 4.2 Removing unused locale files: localepurge(清除不用的locale文件)
         o 4.3 How to know what packages may be upgraded(臬知道哪些包会被升级)

   * 5 Getting information about packages.(得到包的信息)
         o 5.1 Discovering package names(根据包名查找)
         o 5.2 Using dpkg to find package names(使用dpkg查找包名)
         o 5.3 How to install packages "on demand"(怎样安装需要的包)
         o 5.4 How to discover to which package a file belongs(臬查找哪个文件在哪个包中)
         o 5.5 How to keep informed about the changes in the packages.

   * 6 Working with source packages(使用源码包)
         o 6.1 Downloading source packages(下载源码包)
         o 6.2 Packages needed for compiling a source package(编译源码包需要的包)

   * 7 How to deal with errors(错误)
         o 7.1 Common errors(通常)
         o 7.2 Where can I find help?(臬查获帮助)

   * 8 What distributions support APT?(哪些版本支持apt)
   * 9 Credits(信誉)
   * 10 New versions of this tutorial(本文新版)





不要问我结果 我只研究过程与思路
无双客栈
顶部
无双
荣誉斑竹
Rank: 14Rank: 14Rank: 14Rank: 14
天才猪



UID 4
精华 84
积分 5863
帖子 11390
活跃指数 0
LU金币 4248 个
LU金条 0 个
阅读权限 200
注册 2003-9-16
来自 杭州
 
发表于 2003-10-26 11:51  资料  个人空间  主页 短消息  加为好友 
PT HOWTO
Chapter 1 - Introduction


GNU/LINUX原始时代是从tar.gz安装软件,用户必须编译每个程序。当debian出现后 它决定添加一个包管理系统,管理系统内所有的软件包,这个包管理系统的名字叫dpkg,它比RH决定创建rpm系统还要早

再后来 DEBIAN的开发者决定增加一个更方便的锭管理工具,它可以自动处理包的依赖性
并处理在升级软件包时配置文件的配置,因此 ,debian主导了apt(高级包管理系统)的诞生
而apt也被引入到其它发行版本中如使用rpm的系统

这篇谙不会说明apt-rpm系统的说明 下一版可能会有

In the beginning there was the .tar.gz. Users had to compile each program that they wanted to use on their GNU/Linux systems. When Debian was created, it was deemed necessary that the system include a method of managing the packages installed on the machine. The name dpkg was given to this system. Thus the famous `package' first came into being on GNU/Linux, a while before Red Hat decided to create their own `rpm' system.

A new dilemma quickly took hold of the minds of the makers of GNU/Linux. They needed a rapid, practical, and efficient way to install packages that would manage dependencies automatically and take care of their configuration files while upgrading. Here again, Debian led the way and gave birth to APT, the Advanced Packaging Tool, which has since been ported by Conectiva for use with rpm and has been adopted by some other distributions.

This manual makes no attempt to address apt-rpm, as the Conectiva port of APT is known, but "patches" to this document which do so would be welcome.

This manual is based on the next Debian release, Sarge.





不要问我结果 我只研究过程与思路
无双客栈
顶部
无双
荣誉斑竹
Rank: 14Rank: 14Rank: 14Rank: 14
天才猪



UID 4
精华 84
积分 5863
帖子 11390
活跃指数 0
LU金币 4248 个
LU金条 0 个
阅读权限 200
注册 2003-9-16
来自 杭州
 
发表于 2003-10-26 12:42  资料  个人空间  主页 短消息  加为好友 
APT HOWTO
Chapter 2 - Basic Configuration

2.1 /etc/apt/sources.list文件

作为它操作的一部分,APT使用一个文件来列出它的包的安装地址,这个文件就是/etc/apt/sources.list

此文件的格式如下
[code[
deb http://site.http.org/debian distribution section1 section2 section3
deb-src http://site.http.org/debian distribution section1 section2 section3
[/code]
每行的第一个单词是deb或deb-src,说明包的类型是什么(二进制包还是源码包,源码包需要编译),
我们经常看到sources.list的配置文件如下
CODE

    # See sources.list(5) for more information, especialy
    # Remember that you can only use http, ftp or file URIs
    # CDROMs are managed through the apt-cdrom tool.
    deb http://http.us.debian.org/debian stable main contrib non-free
    deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
    deb http://security.debian.org stable/updates main contrib non-free
   
    # Uncomment if you want the apt-get source function to work
    #deb-src http://http.us.debian.org/debian stable main contrib non-free
    #deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free

这些行使用于debian系统的基本安装,第一行指向官方包目录,第二行指向非US包目录 第三行是用于debian的安全更新
后面两行已被注掉了(在行首使用#表示注掉),所以apt-get不会理它,这两行是deb-src行,表示它们指向debian的源码包,如果你经常下程序源码来测试或重编译,那就把前面那个#号云掉
/etc/apt/sources.list里面可以包含几种类型,APT知道臬处理这些目录类型,就我所知的有http,ftp ,file(这个指本地的,如一个安装DEBIAN光盘的目录),还有ssh
在自己修改完/etc/apt/sources.list后可不要忘记运行apt-get update命令,只有运行它后APT才会根据你的修改更新它的包列表



臬在本地使用apt
有时你有很多.deb包,你想使用APT来自动处理这些包的依赖性
那么
创建一个目录并把所有你想自动处理的的.deb放到里面去
如下
#mkdir /root/debs/
如果你想修改包控制文件中定义,可以创建一个覆盖文件。在这个文件内你可以定义那些需要覆盖的内容,格式如下
CODE

    包名 优先级 分支

包名就是要修改的包的包名, 优先级是low, medium high, 分支是要把它放到哪个分支中(如games develop )。文件名不要紧。
如果没有创建这个覆盖文件那么使用dpkg-scanpackages时使用/dev/null代替
在/root目录操作
CODE

    # dpkg-scanpackages debs file | gzip > debs/Packages.gz

file就是前面创建的那个覆盖文件
上面那个他们会生成一个Packages.gz文件,里面包含所有的包信息,这些信息将会被APT使用.要使用这些包 ,最后只要执行下面这个命令
CODE

    deb file:/root debs/

以后就使用使用APT命令来操作它们了。你同样可以使用相同的步骤来创建一个源码包仓库,只是,你需要的是把 .orig.tar.gz, .dsc and .diff.gz 放在那个目录下,并用Sources.gz 代替Packages.gz。使用的程序是dpkg-scansources 命令行如下
CODE

    # dpkg-scansources debs | gzip > debs/Sources.gz

dpkg-scansources 不需要覆盖文件 看好了,操作完后往sources.list添加一行
CODE

    deb-src file:/root debs/



2.3 使用netselect,netselect-apt为sources.list查找最快的映象
新手们经常感到奇怪的是“要把哪个DEBIAN映象放到sources.list”有很多方法来决定是哪个映象。老鸟们则经常写一个ping脚本,通过ping时间在几个mirror间确定
但是 现在有了一个叫netselect.的东东,为所有新手与老手准备
安装
# apt-get install netselect
执行
不带参数执行会返回一个帮助列表,后面跟用空格分开的一个或多个站点 会返回最快站点的得分,这些得分根据ping时间与路由跳数,还有下载速度
看下面这个例子
# netselect ftp.debian.org http.us.debian.org ftp.at.debian.org download.unesp.br ftp.debian.org.br
365 ftp.debian.org.br
#
上面表示ftp.debian.org.br最快 这里就可以把ftp.debian.org.br添加到source.list了
DEBIAN的所有映象可以在这里得到
http://www.debian.org/mirror/mirrors_full.

从0.3开始dselect包含了netselect-apt脚本 ,它可以使上面过和自动完成,只要把发行版本类型做为参数(没有输入则默认是stable),这时就会向当前目录下source.list里面自动添加最快的站点

CODE

    # ls sources.list
    ls: sources.list: File or directory not found
    # netselect-apt stable
    (...)
    # ls -l sources.list
    sources.list
    #

最后把当前目录下source.list内容添加到/etc/apt目录下同名文件就OK了


2.4 添加CDROM映象到source.list文件中
使用命令如下
# apt-cdrom add
运行后它会自动mount cdrom,查找包信息,并添加到APT的包数据库中
下面是一些可用参数,如果你CDROM与众不同就使用它们
CODE

    -h           - program help
    -d directory - CD-ROM mount point
    -r           - Rename a recognized CD-ROM
    -m           - No mounting
    -f           - Fast mode, don't check package files
    -a           - Thorough scan mode


# apt-cdrom -d /home/kov/mycdrom add
再如 只标识CDROM而不把它们添加到list中(自己运行看看)
# apt-cdrom ident
使用这个命令的条件是你的CDROM已在/etc/fstab中正确配置



2.1 The /etc/apt/sources.list file

As part of its operation, APT uses a file that lists the 'sources' from which packages can be obtained. This file is /etc/apt/sources.list.

The entries in this file normally follow this format:

deb http://site.http.org/debian distribution section1 section2 section3
deb-src http://site.http.org/debian distribution section1 section2 section3

Of course, the above entries are fictitious and should not be used. The first word on each line, deb or deb-src, indicates the type of archive: whether it contains binary packages (deb), that is, the pre-compiled packages that we normally use, or source packages (deb-src), which are the original program sources plus the Debian control file (.dsc) and the diff.gz containing the changes needed for `debianizing' the program.

We usually find the following in the default Debian sources.list:

# See sources.list(5) for more information, especialy
# Remember that you can only use http, ftp or file URIs
# CDROMs are managed through the apt-cdrom tool.
deb http://http.us.debian.org/debian stable main contrib non-free
deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
deb http://security.debian.org stable/updates main contrib non-free

# Uncomment if you want the apt-get source function to work
#deb-src http://http.us.debian.org/debian stable main contrib non-free
#deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free

These are the lines needed by a basic Debian install. The first deb line points to the official archive, the second to the non-US archive and the third to the archive of Debian security updates.

The two last lines are commented out (with a `#' in front), so apt-get will ignore them. These are deb-src lines, that is, they point to Debian source packages. If you often download program sources for testing or recompiling, uncomment them.

The /etc/apt/sources.list file can contain several types of lines. APT knows how to deal with archives of types http, ftp, file (local files, e.g., a directory containing a mounted ISO9660 filesystem) and ssh, that I know of.

Do not forget to run apt-get update after modifying the /etc/apt/sources.list file. You must do this to let APT obtain the package lists from the sources you specified.
2.2 How to use APT locally

Sometimes you have lots of packages .deb that you would like to use APT to install so that the dependencies would be automaticaly solved.

To do that create a directory and put the .debs you want to index in it . For example:

# mkdir /root/debs

You may modify the definitions set on the package's control file directly for your repository using an override file. Inside this file you may want to define some options to override the ones that come with the package. It looks like follows:

package priority section

package is the name of the package, priority is low, medium or high and section is the section to which it belongs. The file name does not matter, you'll have to pass it as an argument for dpkg-scanpackages later. If you do not want to write an override file, just use /dev/null. when calling dpkg-scanpackages.

Still in the /root directory do:

# dpkg-scanpackages debs file | gzip > debs/Packages.gz

In the above line, file is the override file, the command generates a file Packages.gz that contains various informations about the packages, which are used by APT. To use the packages, finally, add:

deb file:/root debs/

After that just use the APT commands as usual. You may also generate a sources repository. To do that use the same procedure, but remember that you need to have the files .orig.tar.gz, .dsc and .diff.gz in the directory and you have to use Sources.gz instead of Packages.gz. The program used is also different. It is dpkg-scansources. The command line will look like this:

# dpkg-scansources debs | gzip > debs/Sources.gz

Notice that dpkg-scansources doesn't need an override file. The sources.list's line is:

deb-src file:/root debs/

2.3 Deciding which mirror is the best to include in the sources.list file: netselect, netselect-apt

A very frequent doubt, mainly among the newest users is: "which Debian mirror to include in sources.list?". There are many ways to decide which mirror. The experts probably have a script that measures the ping time through the several mirrors. But there's a program that does this for us: netselect.

To install netselect, as usual:

# apt-get install netselect

Executing it without parameters shows the help. Executing it with a space-separated list of hosts (mirrors), it will return a score and one of the hosts. This score takes in consideration the estimated ping time and the hops (hosts by which a network query will pass by to reach the destination) number and is inversely proportional to the estimated download speed (so, the lower, the better). The returned host is the one that had the lowest score (the full list of scores can be seen adding the -vv option). See this example:

# netselect ftp.debian.org http.us.debian.org ftp.at.debian.org download.unesp.br ftp.debian.org.br
365 ftp.debian.org.br
#

This means that, from the mirrors included as parameters to netselect, ftp.debian.org.br was the best, with an score of 365. (Attention!! As it was done on my computer and the network topography is extremely different depending on the contact point, this value is not necessarily the right speed in other computers).

Now, just put the fastest mirror found by netselect in the /etc/apt/sources.list file (see The /etc/apt/sources.list file, Section 2.1) and follow the tips in Managing packages, Chapter 3.

Note: the list of mirrors may always be found in the file http://www.debian.org/mirror/mirrors_full.

Beginning with the 0.3 version, netselect package includes the netselect-apt script, which makes the process above automatic. Just enter the distribution tree as parameter (the default is stable) and the sources.list file will be generated with the best main and non-US mirrors and will be saved under the current directory. The following example generates a sources.list of the stable distribution:

# ls sources.list
ls: sources.list: File or directory not found
# netselect-apt stable
(...)
# ls -l sources.list
sources.list
#

Remember: the sources.list file is generated under the current directory, and must be moved to the /etc/apt directory.

Then, follow the tips in Managing packages, Chapter 3.
2.4 Adding a CD-ROM to the sources.list file

If you'd rather use your CD-ROM for installing packages or updating your system automatically with APT, you can put it in your sources.list. To do so, you can use the apt-cdrom program like this:

# apt-cdrom add

with the Debian CD-ROM in the drive. It will mount the CD-ROM, and if it's a valid Debian CD it will look for package information on the disk. If your CD-ROM configuration is a little unusual, you can also use the following options:

-h - program help
-d directory - CD-ROM mount point
-r - Rename a recognized CD-ROM
-m - No mounting
-f - Fast mode, don't check package files
-a - Thorough scan mode

For example:

# apt-cdrom -d /home/kov/mycdrom add

You can also identify a CD-ROM, without adding it to your list:

# apt-cdrom ident

Note that this program only works if your CD-ROM is properly configured in your system's /etc/fstab.





不要问我结果 我只研究过程与思路
无双客栈
顶部
无双
荣誉斑竹
Rank: 14Rank: 14Rank: 14Rank: 14
天才猪



UID 4
精华 84
积分 5863
帖子 11390
活跃指数 0
LU金币 4248 个
LU金条 0 个
阅读权限 200
注册 2003-9-16
来自 杭州
 
发表于 2003-10-26 14:32  资料  个人空间  主页 短消息  加为好友 
APT HOWTO
Chapter 3 - Managing packages

[/COLOR]
[COLOR=blue]3.1 更新系统中可用的包列表

包系统使用一个私有的数据库来保存包信息(哪个已安装那个没安装等),apt-get程序使用这个数据库来查找臬安装需要的包和哪些附加的包需要被安装(依赖性)
要更新这个列表,你可以使用
apt-get update
命令,它从/etc/apt/sources.list文件配置的嫌地源更新所有的包列表
这个命令很有用,可以保证系统中所有的包的信息是最新的,特别是安全更新中
(每天运行一下apt-get update;apt-get upgrade就可以升级自己系统 保证每天是最新的



3.2 安装软件包
先保证自己的包列表是最新的(使用apt-get update更新一下).想安装包只要使用下面这条命令:
# apt-get install xchat
APT装会从它的数据库中查找这个包的最新的版本,并从sources.list中指定的源中下载这个文件。如查这个包依赖其它包,APT会检查依赖性并安装需要的包,如
CODE

    # apt-get install nautilus
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following extra packages will be installed:
      bonobo libmedusa0 libnautilus0
    The following NEW packages will be installed:
      bonobo libmedusa0 libnautilus0 nautilus
    0 packages upgraded, 4 newly installed, 0 to remove and 1  not upgraded.
    Need to get 8329kB of archives. After unpacking 17.2MB will be used.
    Do you want to continue? [Y/n]

当apt需要安装没有在命令行中指明的包时它才会问你continue.
下面是一些有用参数
CODE

    -h  This help text.
    -d  Download only - do NOT install or unpack archives
    -f  Attempt to continue if the integrity check fails
    -s  No-act. Perform ordering simulation
    -y  Assume Yes to all queries and do not prompt
    -u  Show a list of upgraded packages as well

在一个命令行中可以安装多个包。这些包文件会先下到/var/cache/apt/archives然后再进行下一步的安装
同样可以在命令行中指定要删除的包 只是在包名后面添加一个-号
如下
CODE

    # apt-get install nautilus gnome-panel-      
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following extra packages will be installed:
      bonobo libmedusa0 libnautilus0
    The following packages will be REMOVED:
      gnome-applets gnome-panel gnome-panel-data gnome-session
    The following NEW packages will be installed:
      bonobo libmedusa0 libnautilus0 nautilus
    0 packages upgraded, 4 newly installed, 4 to remove and 1  not upgraded.
    Need to get 8329kB of archives. After unpacking 2594kB will be used.
    Do you want to continue? [Y/n]

下面有删除包的命令,(3。3节 使用--purge remove可以删除包和配置文件,使用remove不会删除配置文件 )

如果你误破坏了某个包,如误删除了某个包的几个重要文件,那么只要使用下面这个命令重安装包就可以了(--reinstall选项)
CODE

    # apt-get --reinstall install gdm
    Reading Package Lists... Done
    Building Dependency Tree... Done
    0 packages upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 1  not upgraded.
    Need to get 0B/182kB of archives. After unpacking 0B will be used.
    Do you want to continue? [Y/n]



删除包
如查不再使用一个包 那么使用下面命令来删除它(apt-get remove package,remove选项)
CODE

    # apt-get remove gnome-panel
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following packages will be REMOVED:
      gnome-applets gnome-panel gnome-panel-data gnome-session
    0 packages upgraded, 0 newly installed, 4 to remove and 1  not upgraded.
    Need to get 0B of archives. After unpacking 14.6MB will be freed.
    Do you want to continue? [Y/n]

上面可以看到被依赖的包同样会被删除,没有办法使用APT来删除包而不删除依赖它们的包
使用上面这个命令会删除包,但是它们的配置文件仍然保存在系统中,想完全删除的话使用下面这个命令(--purge选项)
CODE

    # apt-get --purge remove gnome-panel
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following packages will be REMOVED:
      gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
    0 packages upgraded, 0 newly installed, 4 to remove and 1  not upgraded.
    Need to get 0B of archives. After unpacking 14.6MB will be freed.
    Do you want to continue? [Y/n]

后面有*的表示它们的配置文件也会被删除
同样可以在remove命令中安装包 在包名后面使用+号可以了
CODE

    # apt-get --purge remove gnome-panel nautilus+
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following extra packages will be installed:
      bonobo libmedusa0 libnautilus0 nautilus
    The following packages will be REMOVED:
      gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
    The following NEW packages will be installed:
      bonobo libmedusa0 libnautilus0 nautilus
    0 packages upgraded, 4 newly installed, 4 to remove and 1  not upgraded.
    Need to get 8329kB of archives. After unpacking 2594kB will be used.
    Do you want to continue? [Y/n]


3.4 升级包
包升级功能是APT系统中一个相当成肪的功能,它可以就使用一条命令来执行:apt-get upgrade.你可以使用这条命令来升级同一个发布版的包(也就是如果是stable那么会升级stable版本的包 不会升级unstable版本的包)。想升级到不同的发布版本,应试使用apt-get dist-upgrade。下面3.5就会介绍

使用-u选项可以看到APT显示那些要被升级的包的完整列表,没有它你不知道哪些包会被升级(sid版本的不加也显示 无双),APT将会下载每个包的最新版本,然后以正确的次序以安装它们。注意,在运行这个命令时必须运行apt-get update。
CODE

    # apt-get -u upgrade
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following packages have been kept back
      cpp gcc lilo
    The following packages will be upgraded
      adduser ae apt autoconf debhelper dpkg-dev esound esound-common ftp indent
      ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0 libesd0-dev
      libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev liborbit0
      libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit procps psmisc
    29 packages upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
    Need to get 5055B/5055kB of archives. After unpacking 1161kB will be used.
    Do you want to continue? [Y/n]

过和很简单,第一行中following packages have been kept back表示由于某些原因,这些包将不会被升级,最可能就是没有满足依赖性,需要依赖的包的新版本没有(不过再过几天,当新的包添加上云后就可以升级了,所以不要在意。),第二个就是这个包已经依赖新的包。
第一个原因没有很好的解决方法,第二个原因可以自己使用apt-get install 安装列出的包,这将会下载所依赖的包。更好的解决方法是使用dist-upgrade。看3.5


3.5 更新到新的发行版本
这处特征可以让你一次更新整个DEBIAN系统,通过INTERNET或是新的CD。
这同时可以用来解决包的依赖性,当使用apt-get upgrade时这些包没有升级

如你现在使用版本0的debian,但是又买了一个版本3的,可以使用apt-get从新CD中更新你的系统。先使用apt-cdrom添加CD到你的/etc/apt/sources.list,然后使用apt-get dist-upgrade

需要注意的是APT总是查找最新可用的包版本,如果你的/etc/apt/sources.list里面的源有更新的包,司长经它会从那里使而不是你的CD。APT会从那里而不是从CD中下载包。
例子
CODE

    # apt-get -u dist-upgrade
    Reading Package Lists... Done
    Building Dependency Tree... Done
    Calculating Upgrade... Done
    The following NEW packages will be installed:
      cpp-2.95 cron exim gcc-2.95 libident libopenldap-runtime libopenldap1
      libpcre2 logrotate mailx
    The following packages have been kept back
      lilo
    The following packages will be upgraded
      adduser ae apt autoconf cpp debhelper dpkg-dev esound esound-common ftp gcc
      indent ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0
      libesd0-dev libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev
      liborbit0 libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit
      procps psmisc
    31 packages upgraded, 10 newly installed, 0 to remove and 1 not upgraded.
    Need to get 0B/7098kB of archives. After unpacking 3118kB will be used.
    Do you want to continue? [Y/n]

可以看到已有的包会被升级,而新包也会被安装(因为依赖而要安装的包),而lilo仍然被keep back.什么原因呢
CODE

    # apt-get -u install lilo
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following extra packages will be installed:
      cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
      logrotate mailx
    The following packages will be REMOVED:
      debconf-tiny
    The following NEW packages will be installed:
      cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
      logrotate mailx
    The following packages will be upgraded
      lilo
    1 packages upgraded, 9 newly installed, 1 to remove and 31 not upgraded.
    Need to get 225kB/1179kB of archives. After unpacking 2659kB will be used.
    Do you want to continue? [Y/n]

原来是因为与debconf-tiny排斥
想知道哪些包会被安装或是删除可以使用下面这条命令
CODE

    # apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
    Reading Package Lists... Done
    Building Dependency Tree... Done
    Calculating Upgrade... Starting
    Starting 2
    Investigating python1.5
    Package python1.5 has broken dep on python1.5-base
      Considering python1.5-base 0 as a solution to python1.5 0
      Holding Back python1.5 rather than change python1.5-base
    Investigating python1.5-dev
    Package python1.5-dev has broken dep on python1.5
      Considering python1.5 0 as a solution to python1.5-dev 0
      Holding Back python1.5-dev rather than change python1.5
     Try to Re-Instate python1.5-dev
    Done
    Done
    The following packages have been kept back
      gs python1.5-dev
    0 packages upgraded, 0 newly installed, 0 to remove and 2  not upgraded.



3.6 删除不用的包文件
安装包是APT会先把文件下到/var/cache/apt/archives/再开始安装,所以本地仓库会增加很快并使用大量的空间,所以APT提供了管理本地仓库的工具:apt-get's clean and autoclean methods.
apt-get clean删除除了锁文件(/var/cache/apt/archives/和/var/cache/apt/archives/partial/)然的其它文件,所以如果想再安装一个包,APT将会重下载它
apt-get autoclean 只删除那些不再可下载的包文件
CODE

    # ls /var/cache/apt/archives/logrotate* /var/cache/apt/archives/gpm*
    logrotate_3.5.9-7_i386.deb
    logrotate_3.5.9-8_i386.deb
    gpm_1.19.6-11_i386.deb
In /var/cache/apt/archives there are two files for the package logrotate and one for the package gpm.

    # apt-show-versions -p logrotate
    logrotate/stable uptodate 3.5.9-8
    # apt-show-versions -p gpm
    gpm/stable upgradeable from 1.19.6-11 to 1.19.6-12

可以看到被清除的只是没有用的旧版本
CODE

    # apt-get autoclean
    Reading Package Lists... Done
    Building Dependency Tree... Done
    Del gpm 1.19.6-11 [145kB]
    Del logrotate 3.5.9-7 [26.5kB]


3.7 通过dselect使用APT
dselect是帮助DEBIAN用户管理DEBIAN包的工具
dselect的一个特点就是知道使用DEBIAN包中的“建议”与“推荐”("recommending" and "suggesting" )其它包的功能。
使用dselect要在root下运行,选择apt做为你的访问方法(access method 菜单上第一个)
想知道dselect用法 可以在 http://www.debian.org/doc/ddp.查找到它的帮助文档
这里的文档比较老,还是我把dselect用法说一下吧 无双
CODE

1 access 访问方法,选择apt
2 update 更新包列表,使用apt-get update后,运行dselect前应该选择一下它
3 select 选择要安装的包,(INSERT)表示选择(CDELETE)表示删除 回车表示确认
4 install 安装你已经选择的包,安装过和中会配置 最后问你要不要清除下盏的包
 config  配置,看4 顼上没有用了
 remove 删除安装时下苗的包  看install 含上里面了
quit 不说了

CODE

After making your selections with dselect, use:

    # apt-get -u dselect-upgrade

as in the example below:

    # apt-get -u dselect-upgrade
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following packages will be REMOVED:
      lbxproxy
    The following NEW packages will be installed:
      bonobo console-tools-libs cpp-3.0 enscript expat fingerd gcc-3.0
      gcc-3.0-base icepref klogd libdigest-md5-perl libfnlib0 libft-perl
      libgc5-dev libgcc300 libhtml-clean-perl libltdl0-dev libsasl-modules
      libstdc++3.0 metamail nethack proftpd-doc psfontmgr python-newt talk tidy
      util-linux-locales vacation xbill xplanet-images
    The following packages will be upgraded
      debian-policy
    1 packages upgraded, 30 newly installed, 1 to remove and 0  not upgraded.
    Need to get 7140kB of archives. After unpacking 16.3MB will be used.
    Do you want to continue? [Y/n]

Compare with what we see when running apt-get dist-upgrade on the same system:

    # apt-get -u dist-upgrade  
    Reading Package Lists... Done
    Building Dependency Tree... Done
    Calculating Upgrade... Done
    The following packages will be upgraded
      debian-policy
    1 packages upgraded, 0 newly installed, 0 to remove and 0  not upgraded.
    Need to get 421kB of archives. After unpacking 25.6kB will be freed.
    Do you want to continue? [Y/n]

Note that many of the packages from above are being installed because other packages "suggested" or "recommended" them. Others are being installed or removed (in the case of lbxproxy, for example) per the choices we made while navigating through dselect's package listing. Dselect can be a powerful tool when used in conjunction with APT.



3.8 臬使用一个混和的系统
有的需要使用一个DEBIAN版本做主系统发布版,然后使用使用其它分支来使用更多包
设置你的主版本是修改以下这行
CODE

/etc/apt/apt.conf

    APT::Default-Release "version";

这里 version 是你想使用的主发布版本,可以是stable, testing 和 unstable.
想安装其它版本的包 你必须用下面这种方式来使用APT
# apt-get -t distribution install package
要想让它工作,你必须在/etc/apt/sources.list里面写明发布版本(distribution)并且在它的源里有那个文件
同样可以安装某个包的特殊版本如下
CODE

    # apt-get install package=version
For example, the line below will install version 2.2.4-1 of the nautilus package.:
    # apt-get install nautilus=2.2.4-1

警告
unstable 版是所有最新的DEBIAN包的集合,这些新包可能会影响整个系统,所以旭呆你不是高手的话 或是你的系统很重要的话还是不安装了(我不是高手 也安装了 没有问题 这只是说可能会有问题)
testing 是介于stable 与unstable之间的 包相对稳定 但是没有UNSTABLE那么新
IMPORTANT: the `unstable' version of Debian is the version to which the newest versions of Debian packages are uploaded first. This distribution sees all of the changes that packages go through, both small ones and more drastic ones which affect many packages or the whole system. For this reason, this version of the distribution should not be used by inexperienced users or by those who need proven stability.

The `testing' distribution is not necessarily best than `unstable', because it does not receive security updates quickly. For servers and other production systems stable should always be used.


3.9 臬从debian的某个特殊版本升级包


apt-show-versions为使用混合系统的用户提供一个安全升级它们系统的方法,不让他们得到不稳定的系统。下面是充放你升级已安装了的unstable包
apt-show-versions provides a safe way for users of mixed distributions to upgrade their systems without getting more of the less-stable distribution than they had in mind. For instance, it is possible to upgrade just your unstable packages by running after having installed the apt-show-versions package:

# apt-get install `apt-show-versions -u -b | grep unstable`


3.10 怎样保持某个特殊版本的包
人可以已修改了某个包的一些内容,并且没有时间或不想把这些改变写到新版本中去,或已升级到了3。0 但仍然想使用一些2.2的包 ,你可以“钉住”你不想升级的包

编辑下面这个文件
/etc/apt/preferences.

格式如下
CODE

    Package: <package>
    Pin: <pin definition>
    Pin-Priority: <pin's priority>

如保持sylpheed在0.4.99,添加如下行
CODE

    Package: sylpheed
    Pin: version 0.4.99*

后面的*号表示通配符,就是保留所有以0.4.99开始的字符串的包。
Pin-Priority字段是可选的,如查没有指定,默认是989。Priority<0表示这个包永远不会被安装 0-100表示不会安装并没有可用的版本,这样就不会在版本选择进和中显示,100是给一个已安装的包,包的安装版本被一个不同的版本代替,代替的必须大于100

Priority<>100表示一个包应该安装,而且包的安装版本的改变只能被升级。任何100< Priority<=1000表示这个行为是明显的,一个属性在这区间的包装不会隆级到一个低版本号的可用版本。如我安装了sylpheed0.5.3, 并定义了ylpheed 0.4.99 with priority 999,包0.4.99将不会安装来适应这个pin。想要让一个包可以隆级来适应这个pin(钉子) 要priority>1000

A pin can be specified on a package's version, release or origin.
下面是原文
CODE

Let's take a look at how pin priorities work. A priority lower than 0 indicates that the package should never be installed. Priorities 0 to 100 denote packages that are not installed and that have no available versions. These won't come into the version-choosing process. Priority 100 is the priority assigned to an installed package - for the installed version of a package to be replaced by a different version, the replacement must have a priority greater than 100.

Priorities above 100 indicate that a package should be installed. Typically, the installed version of a package is changed only to upgrade it to a newer version. Any priority between 100 and 1000 (inclusive) indicates this typical behavior. A package with such a priority will not downgrade to an available version with a lower version number. For instance, if I have sylpheed 0.5.3 installed and define a pin on sylpheed 0.4.99 with priority 999, package 0.4.99 will not be installed to satisfy the pin. To make a package "downgradable", to satisfy the pin, it needs possess a priority greater than 1000.

A pin can be specified on a package's version, release or origin.

Pinning on a version, as we have seen, supports literal version numbers as well as wildcards to specify several versions at one time.

Option release depends on the Release file from an APT repository or from a CD. This option may be of no use at all if you're using package repositories that don't provide this file. You may see the contents of the Release files that you have on /var/lib/apt/lists/. The parameters for a release are: a (archive), c (components), v (version), o (origin) and l (label).

An example:

    Package: *
    Pin: release v=2.2*,a=stable,c=main,o=Debian,l=Debian
    Pin-Priority: 1001

In this example, we chose version 2.2* of Debian (which can be 2.2r2, 2.2r3 -- this accomodates "point releases" that typically include security fixes and other very important updates), the stable repository, section main (as opposed to contrib or non-free) and origin and label Debian. Origin (o=) defines who produced that Release file, the label (l=) defines the name of the distribution: Debian for Debian itself and Progeny for Progeny, for example. A sample Release file:

    $ cat /var/lib/apt/lists/ftp.debian.org.br_debian_dists_potato_main_binary-i386_Release
    Archive: stable
    Version: 2.2r3
    Component: main
    Origin: Debian
    Label: Debian
    Architecture: i386









3.1 Updating the list of available packages

The packaging system uses a private database to keep track of which packages are installed, which are not installed and which are available for installation. The apt-get program uses this database to find out how to install packages requested by the user and to find out which additional packages are needed in order for a selected package to work properly.

To update this list, you would use the command apt-get update. This command looks for the package lists in the archives found in /etc/apt/sources.list; see The /etc/apt/sources.list file, Section 2.1 for more information about this file.

It's a good idea to run this command regularly to keep yourself and your system informed about possible package updates, particularly security updates.
3.2 Installing packages

Finally, the process you've all been waiting for! With your sources.list ready and your list of available packages up to date, all you have to do is run apt-get to get your desired package installed. For example, you can run:

# apt-get install xchat

APT will search it's database for the most recent version of this package and will retrieve it from the corresponding archive as specified in sources.list. In the event that this package depends on another -- as is the case here -- APT will check the dependencies and install the needed packages. See this example:

# apt-get install nautilus
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
bonobo libmedusa0 libnautilus0
The following NEW packages will be installed:
bonobo libmedusa0 libnautilus0 nautilus
0 packages upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
Need to get 8329kB of archives. After unpacking 17.2MB will be used.
Do you want to continue? [Y/n]

The package nautilus depends on the shared libraries cited, therefore APT will get them from the archive. If you had specified the names of these libraries on the apt-get command line, APT would not have asked if you wanted to continue; it would automatically accept that you wanted to install all of those packages.

This means that APT only asks for confirmation when it needs to install packages which weren't specified on the command line.

The following options to apt-get may be useful:

-h This help text.
-d Download only - do NOT install or unpack archives
-f Attempt to continue if the integrity check fails
-s No-act. Perform ordering simulation
-y Assume Yes to all queries and do not prompt
-u Show a list of upgraded packages as well

Multiple packages may be selected for installation in one line. Files downloaded from the network are placed in the directory /var/cache/apt/archives for later installation.

You can specify packages to be removed on the same command line, as well. Just put a '-' immediately after the name of the package to be removed, like this:

# apt-get install nautilus gnome-panel-
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
bonobo libmedusa0 libnautilus0
The following packages will be REMOVED:
gnome-applets gnome-panel gnome-panel-data gnome-session
The following NEW packages will be installed:
bonobo libmedusa0 libnautilus0 nautilus
0 packages upgraded, 4 newly installed, 4 to remove and 1 not upgraded.
Need to get 8329kB of archives. After unpacking 2594kB will be used.
Do you want to continue? [Y/n]

See section Removing packages, Section 3.3 for more details on package removal.

If you somehow damage an installed package, or simply want the files of a package to be reinstalled with the newest version that is available, you can use the --reinstall option like so:

# apt-get --reinstall install gdm
Reading Package Lists... Done
Building Dependency Tree... Done
0 packages upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 1 not upgraded.
Need to get 0B/182kB of archives. After unpacking 0B will be used.
Do you want to continue? [Y/n]

3.3 Removing packages

If you no longer want to use a package, you can remove it from your system using APT. To do this just type: apt-get remove package. For example:

# apt-get remove gnome-panel
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be REMOVED:
gnome-applets gnome-panel gnome-panel-data gnome-session
0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
Need to get 0B of archives. After unpacking 14.6MB will be freed.
Do you want to continue? [Y/n]

As you can see in the above example, APT also takes care of removing packages which depend on the package you have asked to remove. There is no way to remove a package using APT without also removing those packages that depend on it.

Running apt-get as above will cause the packages to be removed but their configuration files, if any, will remain intact on the system. For a complete removal of the package, run:

# apt-get --purge remove gnome-panel
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be REMOVED:
gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
Need to get 0B of archives. After unpacking 14.6MB will be freed.
Do you want to continue? [Y/n]

Note the '*' after the names. This indicates that the configuration files for each of these packages will also be removed.

Just as in the case of the install method, you can use a symbol with remove to invert the meaning for a particular package. In the case of removing, if you add a '+' right after the package name, the package will be installed instead of being removed.

# apt-get --purge remove gnome-panel nautilus+
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
bonobo libmedusa0 libnautilus0 nautilus
The following packages will be REMOVED:
gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
The following NEW packages will be installed:
bonobo libmedusa0 libnautilus0 nautilus
0 packages upgraded, 4 newly installed, 4 to remove and 1 not upgraded.
Need to get 8329kB of archives. After unpacking 2594kB will be used.
Do you want to continue? [Y/n]

Note that apt-get lists the extra packages which will be installed (that is, the packages whose installation is needed for the proper functioning of the package whose installation has been requested), those which will be removed, and those which will be installed (including the extra packages again).
3.4 Upgrading packages

Package upgrades are a great success of the APT system. They can be achieved with a single command: apt-get upgrade. You can use this command to upgrade packages within the same distribution, as well as to upgrade to a new distribution, although for the latter the command apt-get dist-upgrade is preferred; see section Upgrading to a new release, Section 3.5 for more details.

It's useful to run this command with the -u option. This option causes APT to show the complete list of packages which will be upgraded. Without it, you'll be upgrading blindly. APT will download the latest versions of each package and will install them in the proper order. It's important to always run apt-get update before you try this. See section Updating the list of available packages, Section 3.1. Look at this example:

# apt-get -u upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages have been kept back
cpp gcc lilo
The following packages will be upgraded
adduser ae apt autoconf debhelper dpkg-dev esound esound-common ftp indent
ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0 libesd0-dev
libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev liborbit0
libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit procps psmisc
29 packages upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 5055B/5055kB of archives. After unpacking 1161kB will be used.
Do you want to continue? [Y/n]

The process is very simple. Note that in the first few lines, apt-get says that some packages were kept back. This means that there are new versions of these packages which will not be installed for some reason. Possible reasons are broken dependencies (a package on which it depends doesn't have a version available for download) or new dependencies (the package has come to depend on new packages since the last version).

There's no clean solution for this first case. For the second case, it's sufficient to run apt-get install for the specific package in question, as this will download the dependencies. An even cleaner solution is to use dist-upgrade. See section Upgrading to a new release, Section 3.5.
3.5 Upgrading to a new release

This feature of APT allows you to upgrade an entire Debian system at once, either through the Internet or from a new CD (purchased or downloaded as an ISO image).

It is also used when changes are made to the relationships between installed packages. With apt-get upgrade, these packages would be kept untouched (kept back).

For example, suppose that you're using revision 0 of the stable version of Debian and you buy a CD with revision 3. You can use APT to upgrade your system from this new CD. To do this, use apt-cdrom (see section Adding a CD-ROM to the sources.list file, Section 2.4) to add the CD to your /etc/apt/sources.list and run apt-get dist-upgrade.

It's important to note that APT always looks for the most recent versions of packages. Therefore, if your /etc/apt/sources.list were to list an archive that had a more recent version of a package than the version on the CD, APT would download the package from there.

In the example shown in section Upgrading packages, Section 3.4, we saw that some packages were kept back. We'll solve this problem now with the dist-upgrade method:

# apt-get -u dist-upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
Calculating Upgrade... Done
The following NEW packages will be installed:
cpp-2.95 cron exim gcc-2.95 libident libopenldap-runtime libopenldap1
libpcre2 logrotate mailx
The following packages have been kept back
lilo
The following packages will be upgraded
adduser ae apt autoconf cpp debhelper dpkg-dev esound esound-common ftp gcc
indent ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0
libesd0-dev libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev
liborbit0 libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit
procps psmisc
31 packages upgraded, 10 newly installed, 0 to remove and 1 not upgraded.
Need to get 0B/7098kB of archives. After unpacking 3118kB will be used.
Do you want to continue? [Y/n]

Note now that the packages will be upgraded, and new packages will also be installed (the new dependencies of the packages). Note too that lilo is still being kept back. It probably has a more serious problem than a new dependency. We can find out by running:

# apt-get -u install lilo
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
logrotate mailx
The following packages will be REMOVED:
debconf-tiny
The following NEW packages will be installed:
cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
logrotate mailx
The following packages will be upgraded
lilo
1 packages upgraded, 9 newly installed, 1 to remove and 31 not upgraded.
Need to get 225kB/1179kB of archives. After unpacking 2659kB will be used.
Do you want to continue? [Y/n]

As noted in the above, lilo has a new conflict with the package debconf-tiny, which means it couldn't be installed (or upgraded) without removing debconf-tiny.

To know what's keeping or removing a package you may use:

# apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
Calculating Upgrade... Starting
Starting 2
Investigating python1.5
Package python1.5 has broken dep on python1.5-base
Considering python1.5-base 0 as a solution to python1.5 0
Holding Back python1.5 rather than change python1.5-base
Investigating python1.5-dev
Package python1.5-dev has broken dep on python1.5
Considering python1.5 0 as a solution to python1.5-dev 0
Holding Back python1.5-dev rather than change python1.5
Try to Re-Instate python1.5-dev
Done
Done
The following packages have been kept back
gs python1.5-dev
0 packages upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

This way, it's easy to notice that the python1.5-dev package cannot be installed because of an unsatisfied dependency: python1.5.
3.6 Removing unused package files: apt-get clean and autoclean

When you install a package APT retrieves the needed files from the hosts listed in /etc/apt/sources.list, stores them in a local repository (/var/cache/apt/archives/), and then proceeds with installation, see Installing packages, Section 3.2.

In time the local repository can grow and occupy a lot of disk space. Fortunately, APT provides tools for managing its local repository: apt-get's clean and autoclean methods.

apt-get clean removes everything except lock files from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. Thus, if you need to reinstall a package APT should retrieve it again.

apt-get autoclean removes only package files that can no longer be downloaded.

The following example show how apt-get autoclean works:

# ls /var/cache/apt/archives/logrotate* /var/cache/apt/archives/gpm*
logrotate_3.5.9-7_i386.deb
logrotate_3.5.9-8_i386.deb
gpm_1.19.6-11_i386.deb

In /var/cache/apt/archives there are two files for the package logrotate and one for the package gpm.

# apt-show-versions -p logrotate
logrotate/stable uptodate 3.5.9-8
# apt-show-versions -p gpm
gpm/stable upgradeable from 1.19.6-11 to 1.19.6-12

apt-show-versions shows that logrotate_3.5.9-8_i386.deb provides the up to date version of logrotate, so logrotate_3.5.9-7_i386.deb is useless. Also gpm_1.19.6-11_i386.deb is useless because a more recent version of the package can be retrieved.

# apt-get autoclean
Reading Package Lists... Done
Building Dependency Tree... Done
Del gpm 1.19.6-11 [145kB]
Del logrotate 3.5.9-7 [26.5kB]

Finally, apt-get autoclean removes only the old files. See How to upgrade packages from specific versions of Debian, Section 3.9 for more information on apt-show-versions.
3.7 Using APT with dselect

dselect is a program that helps users select Debian packages for installation. It's considered somewhat complicated and rather boring, but with practice you can get the hang of its console-based ncurses interface.

One feature of dselect is that it knows how to make use of the capacity Debian packages have for "recommending" and "suggesting" other packages for installation. To use the program, run `dselect' as root. Choose 'apt' as your access method. This isn't truly necessary, but if you're not using a CD ROM and you want to download packages from the Internet, it's the best way to use dselect.

To gain a better understanding of dselect's usage, read the dselect documentation found on the Debian page http://www.debian.org/doc/ddp.

After making your selections with dselect, use:

# apt-get -u dselect-upgrade

as in the example below:

# apt-get -u dselect-upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be REMOVED:
lbxproxy
The following NEW packages will be installed:
bonobo console-tools-libs cpp-3.0 enscript expat fingerd gcc-3.0
gcc-3.0-base icepref klogd libdigest-md5-perl libfnlib0 libft-perl
libgc5-dev libgcc300 libhtml-clean-perl libltdl0-dev libsasl-modules
libstdc++3.0 metamail nethack proftpd-doc psfontmgr python-newt talk tidy
util-linux-locales vacation xbill xplanet-images
The following packages will be upgraded
debian-policy
1 packages upgraded, 30 newly installed, 1 to remove and 0 not upgraded.
Need to get 7140kB of archives. After unpacking 16.3MB will be used.
Do you want to continue? [Y/n]

Compare with what we see when running apt-get dist-upgrade on the same system:

# apt-get -u dist-upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
Calculating Upgrade... Done
The following packages will be upgraded
debian-policy
1 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 421kB of archives. After unpacking 25.6kB will be freed.
Do you want to continue? [Y/n]

Note that many of the packages from above are being installed because other packages "suggested" or "recommended" them. Others are being installed or removed (in the case of lbxproxy, for example) per the choices we made while navigating through dselect's package listing. Dselect can be a powerful tool when used in conjunction with APT.
3.8 How to keep a mixed system

People are sometimes interested in using one of the Debian versions as its main system distribution and one or more packages from another branch.

To set up what is your main version of Debian you should edit the /etc/apt/apt.conf to contain the following line:

APT::Default-Release "version";

Where version is the version of Debian you want to use as the main distribution. The versions you can use are stable, testing and unstable. To install packages from another version, then, you must you APT in the following way:

# apt-get -t distribution install package

For that to work, though, you need at least one APT source line in your /etc/apt/sources.list for the distribution you want the package from, and the package must exist on that source.

You can also request a specific version of a package using the following sintax:

# apt-get install package=version

For example, the line below will install version 2.2.4-1 of the nautilus package.:

# apt-get install nautilus=2.2.4-1

IMPORTANT: the `unstable' version of Debian is the version to which the newest versions of Debian packages are uploaded first. This distribution sees all of the changes that packages go through, both small ones and more drastic ones which affect many packages or the whole system. For this reason, this version of the distribution should not be used by inexperienced users or by those who need proven stability.

The `testing' distribution is not necessarily best than `unstable', because it does not receive security updates quickly. For servers and other production systems stable should always be used.
3.9 How to upgrade packages from specific versions of Debian

apt-show-versions provides a safe way for users of mixed distributions to upgrade their systems without getting more of the less-stable distribution than they had in mind. For instance, it is possible to upgrade just your unstable packages by running after having installed the apt-show-versions package:

# apt-get install `apt-show-versions -u -b | grep unstable`

3.10 How to keep specific versions of packages installed (complex)

You may have occasion to modify something in a package and don't have time or don't want to port those changes to a new version of the program. Or, for instance, you may have just upgraded your Debian distribution to 3.0, but want to continue with the version of a certain package from Debian 2.2. You can "pin" the version you have installed so that it will not be upgraded.

Using this resource is simple. You just need to edit the file /etc/apt/preferences.

The format is simple:

Package: <package>
Pin: <pin definition>
Pin-Priority: <pin's priority>

For example, to keep package sylpheed that I have modified to use "reply-to-list" at version 0.4.99, I add:

Package: sylpheed
Pin: version 0.4.99*

Note that I used an * (asterisk). This is a "wildcard"; it say that I want that this "pin" to be valid for all versions beginning with 0.4.99. This is because Debian versions its packages with a "Debian revision" and I don't want to avoid the installation of these revisions. So, for instance, versions 0.4.99-1 and 0.4.99-10 will be installed as soon as they are made available. Note that if you modified the package you won't want to do things this way.

The Pin-Priority field is optional; if not specified, it defaults to 989.

Let's take a look at how pin priorities work. A priority lower than 0 indicates that the package should never be installed. Priorities 0 to 100 denote packages that are not installed and that have no available versions. These won't come into the version-choosing process. Priority 100 is the priority assigned to an installed package - for the installed version of a package to be replaced by a different version, the replacement must have a priority greater than 100.

Priorities above 100 indicate that a package should be installed. Typically, the installed version of a package is changed only to upgrade it to a newer version. Any priority between 100 and 1000 (inclusive) indicates this typical behavior. A package with such a priority will not downgrade to an available version with a lower version number. For instance, if I have sylpheed 0.5.3 installed and define a pin on sylpheed 0.4.99 with priority 999, package 0.4.99 will not be installed to satisfy the pin. To make a package "downgradable", to satisfy the pin, it needs possess a priority greater than 1000.

A pin can be specified on a package's version, release or origin.

Pinning on a version, as we have seen, supports literal version numbers as well as wildcards to specify several versions at one time.

Option release depends on the Release file from an APT repository or from a CD. This option may be of no use at all if you're using package repositories that don't provide this file. You may see the contents of the Release files that you have on /var/lib/apt/lists/. The parameters for a release are: a (archive), c (components), v (version), o (origin) and l (label).

An example:

Package: *
Pin: release v=2.2*,a=stable,c=main,o=Debian,l=Debian
Pin-Priority: 1001

In this example, we chose version 2.2* of Debian (which can be 2.2r2, 2.2r3 -- this accomodates "point releases" that typically include security fixes and other very important updates), the stable repository, section main (as opposed to contrib or non-free) and origin and label Debian. Origin (o=) defines who produced that Release file, the label (l=) defines the name of the distribution: Debian for Debian itself and Progeny for Progeny, for example. A sample Release file:

$ cat /var/lib/apt/lists/ftp.debian.org.br_debian_dists_potato_main_binary-i386_Release
Archive: stable
Version: 2.2r3
Component: main
Origin: Debian
Label: Debian
Architecture: i386





不要问我结果 我只研究过程与思路
无双客栈
顶部
 



当前时区 GMT+8, 现在时间是 2008-10-13 10:48
乐悠LoveUnix论坛-京ICP备05005823号

Thanks to Discuz!  © 2001-2007    Power by LoveUnix.net
Processed in 0.094144 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - 乐悠LoveUnix - Archiver