Debian8 更新源配置

Debian 8 jessie安装完成后,需要配置更新源。推荐163源。

1.  安装apt-spy,自动选择最快的更新源

sudo apt-get install apt-spy
apt-spy -d stable -a asia -t 5	

注释:

 

    -d 选项指定发行版本,可选项为"stable、testing、unstable”。unstable为非稳定版,stable为稳定版,建议选择stable。

    -a选项指定debian安装源服务器的区域,如asia、Europe、North-America。asia为亚洲,建议选择此项。

    -t为超时阈值。设置较小的值可以忽略较慢的服务器。为了选择较小的服务器,可以选择一个比较小的值。

执行完毕后,apt-spy自动创建/etc/apt/sources.list.d文件夹,并在该文件夹里面创建apt-spy.list文件。其中内容就是自动选择后的最快的源。将内容复制到sources.list文件中即可。

可以通过添加contrib和non-free的方式增加软件源的范围。

2.  增加testing和sid源。

 

<span style="color:#cc33cc">apt-spy -d testing -a asia -t 5
apt-spy -d sid -a asia -t 5
</span>

 

分别将两个命令执行后的apt-spy.list内容复制到sources.list文件中。

这里将我执行后的sources.list文件内容粘贴在这里:

<span style="color:#cc33cc">#163 stable
deb http://mirrors.163.com/debian/ stable main contrib non-free
deb-src http://mirrors.163.com/debian/ stable main contrib non-free
deb http://security.debian.org/ stable/updates main
		
#163 testing
deb http://mirrors.163.com/debian/ testing main contrib non-free
deb-src http://mirrors.163.com/debian/ testing main contrib non-free
deb http://security.debian.org/ testing/updates main
		
#163 sid
deb ftp://ftp.cn.debian.org/debian/ sid main contrib non-free
deb-src ftp://ftp.cn.debian.org/debian/ sid main contrib non-free
</span>

3.  设置软件更新选择源的优先级

在加了测试/不稳定的repo之后,当你更新系统的时候所有安装过并且可用的软件就会立马更新,而后你的系统就被你玩火自焚了。

所以需要设置一些规则,以便选定的软件包在正常的更新时不会被更新到一个不稳定的测试版本。

我们需要告诉apt系统,除了我们希望使用测试版或不稳定版的特定软件包之外,其它的总是使用稳定版的软件包来更新。

可以通过如下两个文件之一来设置APT源选择的优先级。

/etc/apt/preferences
/etc/apt/preferences.d/my_preferences

打开这两个文件之一,没有的话创建一个。

粘贴如下内容:

 

Package: *
Pin: release a=stable
Pin-Priority: 700
     
Package: *
Pin: release a=testing
Pin-Priority: 650
     
Package: *
Pin: release a=sid
Pin-Priority: 600

 

这里说一下,稳定版指的是你当前的debian版本,测试版是下一个,而不稳定版则是更远的将来发行版,对应stable/testing/sid。上面的设置中最主要的是优先级(Pin-Priority)。当前的稳定版应该有最高的优先级,这就是说,正常的apt-get操作只会从当前的稳定版的软件库(现在是jessie)里面安装软件。

更新包缓存:

sudo apt-get update		

确认优先级设置正确。使用apt-cache的policy参数来检查

 

apt-cache policy apache2
	apache2:
	Installed: (none)
	Candidate: 2.2.22-13
	Version table:
            2.4.7-1 0
		600 http://http.us.debian.org/debian/ unstable/main amd64 Packages
	    2.4.6-3 0
		650 http://http.us.debian.org/debian/ testing/main amd64 Packages
	    2.2.22-13 0
		700 http://http.us.debian.org/debian/ wheezy/main amd64 Packages

这里检查没问题。

 

4.  选择源进行安装软件。

方式一:

 

 
 
 
 
 
sudo apt-get install apache2/testing

 

上述命令会从测试版软件库中安装apache2,并从稳定办软件库中安装其他依赖包(稳定版通过apt规则确定)。这个命令在某些情况下会失败,比如安装的软件包(apache2)所需的依赖包在稳定版软件库中没有更新到可以支持该软件时。

方式二:

<span style="color:#cc33cc">apt-get -t testing install apache2</span>

上述命令会从测试版软件库中安装apache2,并从测试版软件库中安装其依赖包。这要比上面的命令工作的更好。

所以,要安装较新的软件包,直接从测试版/不稳定版的软件库中安装就行了。注意,优先级号码不只是一个数字而已,还有其特定意义。可以查看 apt_preferences的man页面了解更多:

<span style="color:#cc33cc">man 5 apt_preferences</span>

测试版/不稳定版的软件库是一个获取较新版本软件包的一个好办法,不过其实并不推荐使用它们。如果弄错了,可能会从也许不兼容的分支上下载软件包,这会把你的系统搞乱。

一个更好的方式是,使用向后移植的软件库来安装更新的包。它从测试版和不稳定版的软件库中获取较新版本的软件包,但是为当前的稳定版软件库而编译。所以,对于 debian jessie来说,你可以使用jessie-backports 软件库。访问http://backports.debian.org/ 了解更多。

jessie backports软件源:

deb http://ftp.cn.debian.org/debian jessie-backports main contrib  non-free

参考文章:https://linux.cn/article-3288-1.html

 

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
linux-debian软件安装包sources.list 路径 /etc/apt # deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official amd64 CD Binary-1 20150906-11:13]/ jessie main # deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official amd64 CD Binary-1 20150906-11:13]/ jessie main # deb http://ftp.debian.org/debian/ experimental main deb http://mirrors.ustc.edu.cn/debian/ jessie main contrib non-free deb-src http://mirrors.ustc.edu.cn/debian/ jessie main contrib non-free deb http://mirrors.ustc.edu.cn/debian/ jessie-proposed-updates main contrib non-free deb-src http://mirrors.ustc.edu.cn/debian/ jessie-proposed-updates main contrib non-free deb http://mirrors.ustc.edu.cn/debian/ jessie-updates main contrib non-free deb-src http://mirrors.ustc.edu.cn/debian/ jessie-updates main contrib non-free # deb http://mirrors.163.com/debian/ jessie main non-free contrib # deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib # deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib # deb-src http://mirrors.163.com/debian/ jessie main non-free contrib # deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib # deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib # deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib # deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib # deb http://cs3.swfu.edu.cn/debian/ jessie main contrib non-free # Line commented out by installer because it failed to verify: # deb http://security.debian.org/ jessie/updates main # Line commented out by installer because it failed to verify: # deb-src http://security.debian.org/ jessie/updates main # jessie-updates, previously known as 'volatile' # A network mirror was not selected during install. The following entries # are provided as examples, but you should amend them as appropriate # for your mirror of choice. # deb http://ftp.debian.org/debian/ jessie-updates main # deb-

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT研究僧大师兄

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值