如何在Debian 9上配置sources.list

转载来源:https://linoxide.com/debian/configure-sources-list-debian-9/

这是关于如何在Debian 9上配置sources.list文件的简要指南,代号为stretch。Debian是最受欢迎的Linux发行版之一,它的大部分优势来自Debian软件包管理的核心 - apt。Debian中的所有内容,无论是应用程序还是任何其他组件,都内置于一个软件包中,然后该软件包将安装到您的系统上(由安装程序或您自己安装)。

了解APT和sources.list

Debian及其衍生产品的软件包经理很贴切。代表Advanced Package Tool的APT是一套用于管理Debian软件包的工具,因此也是Debian系统上安装的应用程序。APT可以:

  • 安装应用程序
  • 删除应用程序
  • 更新应用程序
  • 修复损坏的包等

另请参阅如何脱机安装Debian软件包

APT能够解决依赖性问题并从指定的包存储库中检索所请求的包。它将实际安装和删除软件包委托给dpkg。APT主要由命令行工具使用,但您可以使用GUI工具。

Debian使用Debian 文件/etc/apt/sources.list 作为其操作的一部分。此文件包含可从中获取包的“源”列表。此文件中的条目通常遵循此格式。

deb http://site.example.com/debian distribution component1 component2 component3
deb-src http://site.example.com/debian distribution component1 component2 component3

上面显示的条目是虚构的,不应使用,这个只是个示例配置。

 

档案类型:

每行的第一个条目 -   deb  或  deb-src 表示存档的类型。

扫描二维码关注公众号,回复: 8490702 查看本文章
  • deb 表示提供的URL包含预编译的包。这些是在使用apt-get或aptitude等包管理器时默认安装的包。
  • deb-src 表示带有Debian控制文件(.dsc)的源包和包含打包程序所需更改的diff.gz。

存储库URL:

该行的下一个条目是指向将从中下载包的存储库的URL。您可以从Debian Worldwide sources.list镜像中找到Debian存储库软件包的主要列表。

分配:

'distribution'可以分别是发布代码名称/别名(jessie,stretch,buster,sid)或发布类(旧稳定,稳定,测试,不稳定)。如果您要跟踪版本类,则使用类名,如果要跟踪Debian版本,请使用代码名称。

组件

通常有三个组件可以在Debian上使用,即:

  • main - 这包含作为Debian发行版的一部分的包。这些软件包符合DFSG标准。
  • contrib - 这里的软件包符合DFSG,但包含不在主存储库中的软件包。
  • non-free - 包含不符合DFSG的软件包。

Debian 9上的完整sources.list文件如下所示:

deb http://deb.debian.org/debian stretch main
deb-src http://deb.debian.org/debian stretch main

deb http://deb.debian.org/debian stretch-updates main
deb-src http://deb.debian.org/debian stretch-updates main

deb http://security.debian.org/debian-security/ stretch / updates main
deb-src http://security.debian.org/debian-security/ stretch / updates main

然后要有contrib和非free组件,在main之后添加contrib non-free,如下所示:

deb http://deb.debian.org/debian stretch main contrib non-free
deb-src http://deb.debian.org/debian stretch main contrib non-free

deb http://deb.debian.org/debian stretch-updates main contrib non-free
deb-src http://deb.debian.org/debian stretch-updates main contrib non-free

deb http://security.debian.org/debian-security/ stretch / updates main contrib non-free
deb-src http://security.debian.org/debian-security/ stretch / updates main contrib non-free

对sources.list文件进行更改后,必须运行以下命令:

$ sudo apt-get update

这将确保您的apt索引同步。然后,您可以从存储库安装新包。

 

添加自定义存储库

并不总是建议在文件/etc/apt/sources.list上添加自定义和第三方存储库  相反,您可以在/etc/apt/sources.list.d目录下创建一个文件。例如,要从Debice 9的上游存储库安装docker,您将执行以下操作:

$ sudo vim /etc/apt/sources.list

添加内容:

deb https://apt.dockerproject.org/repo debian-stretch main

然后,您可以继续更新apt-cache并从中安装docker软件包。这是添加任何其他第三方存储库的推荐方法。

 

导入apt键

使用apt和sources.list存储库时,在某些时候您需要导入gpg密钥。这通常使用命令apt-key完成,其语法为。

#apt-key adv --keyserver <server-address>  -  recv-keys <key-id>

例如,要下载docker存储库gpg密钥,您将运行:

#apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

然后

#apt-get update && apt-get install docker-engine

通常,使用sources.list文件相对容易。你唯一需要注意的是正确分配。如果在稳定安装中添加了包含不稳定包的sid存储库,则最终可能会破坏系统或遇到许多未解析的依赖项。

发布了153 篇原创文章 · 获赞 803 · 访问量 38万+

猜你喜欢

转载自blog.csdn.net/Aria_Miazzy/article/details/84845040