|
|
虽系鄙人拙文,但转载请注明作者与出处。
摘要:本文简述如何设置 apt 使得在 testing 系统的基础上混合使用 testing 和 unstable 的软件仓库。目标读者为使用 testing 但需要某些 unstable 组件的用户,比如新版本的开发库,桌面系统,办公系统等。
关键词: testing, unstable, 混合, apt, 优先级
正文:
Debian 是一个追求稳定的系统,而稳定的同时也不得不保持保守。对于大部分用户来说,如果追求软件的极端前卫, Debian 不是很合适的系统,因为大部分软件即使进入 unstable 也要经过很严格的审核。相信大部分 Debian 用户是以稳定为重,但桌面用户似乎也不太适合去使用 stable 版本,因为它大概2年左右才会有软件版本上的更新(准确的说是无法确定什么时候会更新,因为 Debian 的政策是"release when ready"(准备好了再更新));同时 unstable 也不合适,因为整个 unstable 会在旦夕之间崩溃(大家应该记得 mkinitrd/yaird 这些 initrd 工具如何使得所有的内核都 panic 而无法启动)。因此, testing 是很中庸的选择。但是有时候我们需要考虑 unstable,比如:
1. unstable 中新软件可能解决了很多易用性方面的问题,比如 gnome 和 openoffice.org ;
2. 或者一些 testing 软件工作不正常,但 unstable 中的该软件在某些架构下编译失败,导致暂时无法进入 testing ,比如现在 amd64 上的 gdb ;
3. 有些软件还没有进入 testing ,但我们希望能够使用,比如现在的 bitstormlite。
因此出现了:基于 testing 系统来安装 unstable 的软件,从而达到稳定的基础上尽量使用新软件。下面详细介绍下如何来做:
注意:请不要混合使用 stable 和其他仓库,因为 stable 软件的基础工具链不会更新, testing 和 unstable 的软件很有可能无法在 stable 上正常工作。如果需要较新的软件,请使用 backport (请参考 http://www.backports.org/dokuwiki/doku.php ),或者自己编译。
1. 软件如何进入 testing
搞清楚软件如何从 unstable 进入 testing 是有用的,明白如何运作能够帮助我们明白混合系统的可行性。
粗略的说,testing 软件的软件都是在 unstable 中的软件经过一定时间的检验后,当该软件的源代码可以在 debian 支持的所有架构上编译通过,确认不会产生依赖性问题,而且没有严重的bug,才会进入 testing。
你不用搞明白所有的细节,只需要知道: testing 的软件实际上就是 unstable 的软件经过比较严格的检验后进入 testing 的。既然 testing 的软件实际上就是几天前的 unstable 软件,那么混合使用 testing 和 unstable 也是可行的。同时也可以看出为什么 stable 是不能这样用的,因为 stable 只进行安全更新,而不按照这个流程更新。
2. 设置 apt 同时使用 testing 和 unstable
下面是 /etc/apt/sources.list 的例子, 以官方仓库 http://ftp.debian.org/ 为例,使用镜像请自行添加,可以参考本版置顶贴 http://www.linuxsir.cn/bbs/showthread.php?t=218212 。请注意,要保证 testing 的仓库在 unstable 的前面:
- # sources.list begin
- # testing goes first
- deb http://ftp.debian.org/ testing main contrib non-free
- deb-src http://ftp.debian.org/ testing main contrib non-free
- # and testing update
- deb http://security.debian.org/ testing/updates main contrib non-free
- deb-src http://security.debian.org/ testing/updates main contrib non-free
- # then unstable
- deb http://ftp.debian.org/ unstable main contrib non-free
- deb-src http://ftp.debian.org/ unstable main contrib non-free
- # sources.list end
复制代码 其他仓库,如 http://www.debian-multimedia.org 也要遵循 testing 在前的原则。
3. apt 如何控制软件仓库优先集
首先,我们需要修改 /etc/apt/apt.conf (没有的话可以手动建立一个),确定目标发行为 testing:
- APT::Default-Release "testing";
复制代码
当 apt 设置了多个仓库时,apt 通过优先级(Priority)来控制仓库中软件的优先级,其中有如下关系(摘录自 man apt_preferences):
- P > 1000
- causes a version to be installed even if this constitutes a
- downgrade of the package
- 进行软件安装,即使需要降级
- 990 < P <=1000
- causes a version to be installed even if it does not come from the
- target release, unless the installed version is more recent
- 进行软件安装,即使该软件不来自目标发行,除非已安装的软件版本较新
- 500 < P <=990
- causes a version to be installed unless there is a version available
- belonging to the target release or the installed version is more
- recent
- 进行软件安装,除非目标发行中有该软件,或者已安装的软件版本较新
- 100 < P <=500
- causes a version to be installed unless there is a version available
- belonging to some other distribution or the installed version is
- more recent
- 进行软件安装,除非别的发行中有该软件,或者已安装的软件版本较新
- 0 < P <=100
- causes a version to be installed only if there is no installed
- version of the package
- 仅当该软件没有被安装的时候才安装
- P < 0
- prevents the version from being installed
- 防止该软件被安装
复制代码 优先级设置在 /etc/apt/preferences 文件中:- Package: *
- Pin: release o=Debian,a=testing
- Pin-Priority: 900
- Package: *
- Pin: release o=Debian,a=unstable
- Pin-Priority: 800
复制代码 这里把 unstable 的优先级设置的高于 500 是为了让 unstable 软件能得到升级。后面会说明为什么。如果不希望 unstable 软件跟着升级,则可以改为低于500,如300.
到这里大家可以正常先升级一下:
# apt-get update
# apt-get upgrade
如果你之前在使用 testing 的话,这时系统应该没有任何变化。
4. 具体如何操作
这种设置在默认情况下,会先寻找 testing 仓库,如果存在该软件,默认安装 testing 中的版本。如果不存在该软件,则会寻找 unstable 仓库,找到后会安装 unstable 中的版本。
如果需要安装 unstable 中某软件更高的版本时,则可以通过 -t 来指定 unstable,如:- # apt-get -t unstable install openoffice.org
复制代码 注意:这样做以后,当 unstable 中有新版本时, apt-get upgrade 会继续升级到 unstable 中的版本,直到该版本进入 testing ,即 testing 版本与 unstable 一致后,才会以 testing 为优先。但我建议大家允许这样升级,因为 unstable 中软件会有很多问题, unstable 中的更新实际上也是在解决问题,直到通过检验进入 testing ,而且前文也说明了 testing 中的软件就是这么来的。这在一定程度上也可以保证软件得到修正。
如果发现手动改变仓库安装的软件存在依赖性问题时,请使用 testing 中的版本吧,我们不直接使用 unstable 就是为了避免这类问题。
5. 注意
混合 testing 和 unstable 的目的是为了在稳定的基础上尽量使用较新的软件。而为了保证稳定,大家应该保证某些软件不要升级到 unstable 版本(下面的升级指升级到 unstable 中的版本):
(1) 基础工具链不要升级,即 gcc, glibc, binutils。实际上正是基础工具链决定了3个发行的不同。擅自升级它们会导致你不得不升级到 unstable ,从而超出了本文的范围。
(2) 导致工具链升级的软件不要升级。由于 unstable 更新比较频繁,基础工具链的组件也在不时更新,因此很有可能 unstable 中的软件依赖于更高版本的基础工具链。这种情况下还是请你主动放弃升级,毕竟这种付出是不值得的。当然这种情况也很少见。
(3) 内核及其相关工具尽量不要升级。一则它们的不稳定是致命的(kernel panic...),二则因为很多驱动可能跟不上内核的升级,比如 fglrx, nvidia 等等。当然你可以同时安装多个内核,但请保留 testing 版本中的内核,因为至少它能保证正常工作。
另外,桌面升级时有几个问题需要考虑到:除了上述两点,有可能 unstable 的桌面所依赖的某些组件的版本要求并不严格,进而在升级时会安装 testing 中的版本而工作不正常。实际上 unstable 中组件版本才能工作正常,这时候需要手动升级该组件的版本。如果遇到依赖性问题请放弃升级。
后记:
总之,能够安于 testing 的现状是最好的,但能够最大限度的保证新版本和稳定的平衡也是很好的。希望大家如果有意采取本文所说的混合方法,并且小心行事,定会达到理想的效果!
参考资料
http://forums.debian.net/viewtopic.php?t=15612 by rickh @ debian user forum
man apt_preferences |
|